Question

Nobody has touched wp-admin for this site in weeks. Suddenly, URLs are being sanitized in ways that break everything. The question marks of query parameters are being replaced with URL escape code %3F, which is obviously breaking nearly every script and stylesheet include that's affected. The result is content like this:

<script type='text/javascript' src='wp-content/plugins/woocommerce/assets/js/select2/select2.full.min.js%3Fver=4.0.3'></script>

<script type='text/javascript' src='wp-includes/js/wp-embed.min.js%3Fver=5.4.1'></script>

Some, but not all URLs in the document are affected. Scripts and some anchor elements are affected.

In addition to this URL madness, it seems like portions of the main site are being included in every single page - i.e., the homepage's markup is being embedded within wp-admin pages, etc.

The effect is that the site can essentially not be used - large dynamic portions of pages, especially the main landing page, simply fail to load or appear malformed due to missing scripts and stylesheets.

I should add that it's nearly impossible to navigate wp-admin given the absurd state that it's in at the moment, so I can't really find my way around to do regular diagnostics.

How do I even begin to fix something like this? If this wasn't a moneymaking site with plenty of content I haven't even touched ('the last guy' decided to install dozens of plugins whose purposes are difficult to decipher, are possibly redundant, and might break everything if removed) I would gladly just reinstall everything.

I have attempted:

  • Removing a "WP Fastest Cache" plugin which, according to some, 'breaks everything' as of this month. Edit: It looks like this plugin is parasitic. After deactivating it, clearing my local cache, etc., pages still contain a comment marking them as having been cached by it...

  • Visiting and re-saving permalink settings in wp-admin as suggested by a comment I found in a similar issue elsewhere.

  • -
Was it helpful?

Solution

It turns out that the folder wp-content/mu-plugins, for whatever reason, didn't contain plugins, but instead a dump of broken copies of most pages on the site, as well as an outdated copy of the entire public_html directory, with another plugins folder nested inside of it, etc! How that happened is beyond me, but simply removing the entire folder corrected all errors on the site and actually significantly improved its performance!

Note: If you are encountering a similar issue, DO NOT use this as your go-to solution unless you are absolutely sure it is a problem: mu-plugins should normally contain critical plugins.

OTHER TIPS

%3F is used for ? and can be a result of urlencode function. Some plugin may use the urlencode php function to encode instead of WordPress esc_url()

Troubleshoot Method

  • Open the complete website project in some editor which have find in files feature.
  • Find if any %3F is present in code files. There may be a possibility of manual entry by any plugin developer.
  • Find urlencode php function.
  • If you find some then check the where it is implemented. and replace that with ecs_url() or you can remove if its with in any unnecessary plugin.

In case nothing found:

  • Find the occurrence of select2.full.min.js
  • Check if its a plugin instead of woocommerce tried to load in any problematic way.

Implement the site in your local host and check by removing the plugins one by one. Of course the site will break but just look after the %3F encoding problem and which plugin is causing that. After that you can take alternate solution to that plugin or you can change the code of that plugin.
This is just a procedure to find the cause of the problem. If you wish you could specify the site url or can reply me on comments for further help.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top