HTML Entities displaying improperly as malformed escaped code

I'm having a strange issue that I've never seen before. I moved a WordPress site from Siteground over to GoDaddy a few days ago, and now the site appears to have problems displaying HTML entities in certain cases. For example, on the 404 page, the title prints to the source code as:

h1 class="page-title"Oops! That page canamp;rsquo;t be found./h1

Causing it to display on the page as "Oops! That page canrsquo;t be found."

As you can see, for some reason the ampersand that is part of the HTML entity rsquo; is being encoded first, breaking the actual HTML entity. This also seems to happen in my custom taxonomy's terms, where it prints ampersands like amp;amp;amp; and even in the WordPress admin interface where it prints things like larr; instead of the left facing arrow ().

I tried editing the text in the taxonomy terms that were experiencing issues and the issue persisted. When I hit update again leaving the malformed amp;amp;amp; in place, it added three more amp;amp;amp;s to the end of the chain.

I looked in the PHP logs and found this little gem, over and over which I think is related:

PHP Warning:  in_array() expects parameter 2 to be array, null given in ...wp-includes/kses.php on line 1417

But it's really not a very helpful or specific error.

Even stranger, the problems aren't happening everywhere. When I made a new post and put some HTML entities into the content, they displayed the proper characters as expected.

Has anyone seen something like this before? Most of my searches have just brought up examples of it happening on sites with PHP error display turned on. The stuff I've run across seems to suggest that it could be an issue with the encoding, but I don't really know. I don't think it's a problem with the theme or any of the plugins, because this problem isn't happening on the site at all on the Siteground server which has the exact same code and database.

Any suggestions towards fixing this issue or at least troubleshooting it would be much appreciated. Thanks!

Edit: The entity code appears to all users in the front end, and the issue with the extra amp;s being added on to taxonomy terms are happening when I edit the terms as an administrator.

Topic wp-kses htmlspecialchars-decode html Wordpress encoding

Category Web


Turns out that this specific issue was caused by someone on the IT team who wasn't very experienced with WordPress adding some code that they found on a poorly written WordPress blog that literally starts out with an unmarked example of what not to do.

According to the IT team, this line added to wp-config.php was apparently the cause of the issue:

define( 'CUSTOM_TAGS', true );

There are two morals to this story:

  1. Always read WordPress blogs critically and verify that what you are doing is really the BEST solution, not just a solution.
  2. Never assume that others will be careful about trusting random things they read on the internet. This includes WordPress blogs.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.