Crayon Syntax Highlighter broken on WordPress on PHP 7.3

Crayon Syntax Highlighter broken on WordPress on PHP 7.3

When I came to post the previous post on my blog, I found that my host’s recent upgrade to PHP 7.3 broke what seemed like everything. Turns out it’s just one plugin – Crayon Syntax Highlighter, which is really useful for styling code in posts.

Unfortunately, the developer hasn’t updated his plugin in three years or so, and it seems to be changes to how regex is used that has broken it. You may get the same error I did: “PHP Warning: preg_replace(): Compilation failed: invalid range in character class”.

The quick fix is bin the plugin, but obviously I’d still like to use it. Thankfully, some other people have taken it upon themselves to release a fixed version, which you can get from here: https://github.com/Crunchify/crayon-syntax-highlighter/releases

Deactivate the current Crayon plugin (don’t delete it as you’ll have to configure everything again!), install this one (manually – upload the zip from that link to your site), and enable it. Once confirmed working, you can delete the old version of the plugin.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.