报错描述
安装完Crayon Syntax Highlighter,在wordpress后台报错
Compilation failed: invalid range in character class at offset 4
报错原因
这是php7.3以后语法高亮插件Crayon Syntax Highlighter安装后出现的问题,定位到插件目录下crayon_langs.class.php文件中这一行。
return preg_replace('/[^\w-+#]/msi', '', $id);
重写后代码如下:
// Override function clean_id($id) { $id = CrayonUtil::space_to_hyphen( strtolower(trim($id)) ); // PARSED_ERRORS //return preg_replace('/[^\w-+#]/msi', '', $id); // So return preg_replace('/[^\w\-+#]/msi', '', $id); }
参考自:
https://crunchify.com/fix-for-crayon-syntax-highlighter-wordpress-plugin-and-php-7-3-fatal-error/