Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing ?ver= from css/js breaks wpseo admin pages #17025

Open
2 tasks done
Grezvany13 opened this issue May 12, 2021 · 1 comment
Open
2 tasks done

Removing ?ver= from css/js breaks wpseo admin pages #17025

Grezvany13 opened this issue May 12, 2021 · 1 comment

Comments

@Grezvany13
Copy link

Grezvany13 commented May 12, 2021

  • I've read and understood the contribution guidelines.
  • I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened.

Admin page of plugin breaks when the ?ver= tag is removed from styles and scripts globally (see reproduction).
Both CSS and JS files from the plugin are not loaded anymore, causing the styling and some functionalities to break.

Console returns the error:

admin.php?page=wpseo_dashboard:278
Uncaught TypeError: window.wpseoHelpScoutBeaconConsent is not a function

Please describe what you expected to happen and why.

It should be possible, for security reasons, to remove the version tag from loaded files without breaking anything. By default does WordPress add its own version number, which is a security risk.

How can we reproduce this behavior?

  1. Add the following code in functions.php of the active theme, or through a plugin like Code Snippets:
// remove version number from loaded CSS and JS
function jd_remove_src_version($src) {
	if (strpos($src, '?ver=')) {
		$src = remove_query_arg('ver', $src);
		return $src;
	}
}
add_filter('script_loader_src', 'jd_remove_src_version');
add_filter('style_loader_src', 'jd_remove_src_version');
  1. Go to /wp-admin/admin.php?page=wpseo_dashboard
  2. Notice the styling being missing and an error in the console.

Technical info

Used versions

  • WordPress version: 5.7.1
  • Yoast SEO version: 16.2
@Djennez
Copy link
Member

Djennez commented May 14, 2021

Looks like that is limited to the select2 components (at least for the General page of Yoast).

I am not sure if this is expected to work, so I am also not sure if this is something that'll be considered to change. So I would advise not to do this for our plugin files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants