WordPress. SyntaxHighlighter replaces <> with &lt &gt

I noticed on the new block built-in editor that when adding code to the SyntaxHighlighter block, some characters are displayed incorrectly, for example, characters:

>
<

That is, if you add an example of a cron job to the SyntaxHighlighter block, it will not be displayed correctly on the site:

0 0 * * * /home/ixnfo/script.sh >/dev/null 2>&1

To display the characters as they are, open the file /wp-content/plugins/syntaxhighlighter/syntaxhighlighter.php in a text editor and find approximately on line 516:

$code = str_replace( '&lt ;', '<', $code );

And replace with:

$code = htmlspecialchars_decode( $code );

Note that after automatically updating WordPress, the syntaxhighlighter.php file will be overwritten and the changes will need to be made again. You can run a script that will inform you by email when the file changes, for example, as I described in the article:
File Integrity Check Script

At the same time, you can search for corrupted characters in site posts (for example, I had a case when the old classic WordPress editor in some posts replaced these characters when editing a post, but I did not notice this):

SELECT * FROM `wp_posts` WHERE post_type='post' AND post_status='publish' AND post_content LIKE '%&gt%';
SELECT * FROM `wp_posts` WHERE post_type='post' AND post_status='publish' AND post_content LIKE '%&lt%';

Leave a comment

Leave a Reply