How to fix content not being shown when using wordpress plugin : Prettify GC Syntax Highlighter ?

mohamad wael
1 min readSep 26, 2020

--

To fix the content now being shown when using the wordpress plugin : Prettify GC Syntax Highlighter, edit prettify-gc-syntax-highlighter.phpand replace :

return preg_replace(
"/<pre\\s*class\\s*=\\s*([\"'])\\s*prettyprint\\s*([^>]*?)\\s*>(.*?)<\/pre>/ise",
"'<pre class='.stripslashes('$1').'prettyprint '.stripslashes('$2').'>'.htmlentities(stripslashes('$3')).'</pre>'",
$text);

with

return preg_replace_callback(
"/<pre\\s*class\\s*=\\s*([\"'])\\s*prettyprint\\s*([^>]*?)\\s*>(.*?)<\/pre>/is",
function($matches){
return '<pre class=' . stripslashes($matches[1]) .'prettyprint ' . stripslashes($matches[2]). '>' . htmlentities($matches[3]) .'</pre>';
},
$text);

Also replace :

return preg_replace(
"/<pre\\s*class\\s*=([^>]*?)(\\blinenums\\b)([^>]*?)\\s*>/ise",
"'<pre class='.stripslashes('$1').stripslashes('$2').'trigger '.stripslashes('$2').stripslashes('$3').'>'",
$text);

with

return preg_replace_callback(
"/<pre\\s*class\\s*=([^>]*?)(\\blinenums\\b)([^>]*?)\\s*>/is",
function($matches){
return '<pre class=' . stripslashes($matches[1]) . stripslashes($matches[2]) . 'trigger ' . stripslashes($matches[2]) . stripslashes($matches[3]) . '>';
}
, $text);

This will fix the errors :

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in .../prettify-gc-syntax-highlighter.php on line 63Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in .../prettify-gc-syntax-highlighter/prettify-gc-syntax-highlighter.php on line 69

Originally published at https://twiserandom.com on September 26, 2020.

--

--

No responses yet