Crayon Syntax Highlighter WordPress Plugin and PHP 7.3 Problem

So after trying to upgrade this blog to PHP 7.3, I found that the blog wasnt displaying properly. I was getting an “This site is experiencing technical issues” error message instead of my blog post appearing.

The reason I was trying to update to PHP 7.3, was because I wanted to use the Google Native Lazyload plugin that is supposed to help with sites performance when it comes to images. But this plugin requires PHP 7.0 as a minimum.

So I went into my hosting account, and switched from PHP 5 to PHP 7.3, and boom the website stopped working. Assuming that WordPress itself wouldnt have any issues with the latest version of PHP, it had to be either the theme I was running or one of the plugins. So I first tried switching themes to see if that helped. No good of course. So then I switched off most of my plugins to see if that helped, and thats when I found that the site worked. Switching them back on one by one narrowed it down to Crayon Syntax Highlighter.

Doing a Google search, thats when I discovered that Crayon Syntax Highlighter hasnt been updated in about 3 years. But it seems like most devs really like it as a lot of people have continued using it. So searching around for Crayon Syntax Highlighter and PHP 7.3 issues I came across this post on

They have 3 fixes they have made to the code for Crayon Syntax Highlighter. The first one that I tried worked so ill list that below.

In order to fix this you need to make changes to the plugin code in crayon_langs.class.php

Replace line 340, change from

return preg_replace('/[^\w-+#]/msi', '', $id);


return preg_replace('/[^\w\-+#]/msi', '', $id);

The change is very subtle, but if you look theres an extra slash after the w. So its obviously some sort of issue with the regular expression. Im guessing php has changed the way that it processes regular expressions or maybe fixed some sort of bug that changed the behaviour.

Anyway this simple change got Crayon Syntax Highlighter working properly again, and my site displaying as normal. So alls well that ends well. Its a shame this plugin isnt being maintained by anyone, as it seems to be very good and I like the way it displays the code on the blog.

Leave a Comment

Your email address will not be published. Required fields are marked *