WPIntell

Source evidence

"Deprecated" warning

WP Code Highlight · support · 2016-02-04T15:54:00+00:00

complaintsentiment
mediumseverity
0.86relevance
5replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

1 / 15 rows with source links

6.7% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

14 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
Salvatore unresolved
Using newest version of WordPress, I can see in debug mode this warning: Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /Applications/AMPPS/www/mysitetest/wp-content/plugins/wp-code-highlight/wp-code-highlight.php on line 68 Hope it could be useful https://wordpress.org/plugins/wp-code-highlight/ Hi, you could fix that warning editing wp-code-highlight.php files located in wp-content/plugins/wp-code-highlight/wp-code-highlight.php Comment line 67-68 and add this line: //return preg_replace("/<pre(.*?)>(.*?)<\/pre>/ise", // "'<pre class=\"wp-code-highlight prettyprint$line_numbers\">'.wch_stripslashes('$2').'</pre>'", $content); return preg_replace_callback("/<pre(.*?)>(.*?)<\/pre>/is",function($m) { return '<pre class=\"wp-code-highlight prettyprint$line_numbers\">'.wch_stripslashes('$m[2]').'</pre>'; },$content); Hi, Just updated my PHP version from 5.4 to 7 and I was getting that error too. Your solution, @simone-camporeale, didn’t completely worked for me. I was getting literally this in each pre: $m[2] So I have modified simone.camporeale solution, and got this one that is working for me: return preg_replace_callback("/<pre(.*?)>(.*?)<\/pre>/is",function($m) { return '<pre class="wp-code-highlight prettyprint'.$line_numbers.'">'.wch_stripslashes($m[2]).''; },$content); Note it’s almost the same, but modifying a little bit the pre tag’s class and removing the apostrophes in the wch_strpslashes() parameter. EDIT: sorry for editing a lot. First time posting here and I was trying to figure out how to correctly put code in the code blocks. EDIT2: btw, I had to check all my code snippets since, on some, some symbols like & or > were automatically changed to the HTML name (& amp; and & gt; respectively) Hi @pauguillamon , noticed that your snippet is missing the closing element in case others are using your patch. return preg_replace_callback("/<pre(.*?)>(.*?)<\/pre>/is",function($m) { return '<pre class="wp-code-highlight prettyprint'.$line_numbers.'">'.wch_stripslashes($m[2]).''; },$content); @michael Visser: Sorry, but you also forgot the closing pre tag. Here’s the code that works for me ATM. // return preg_replace("/<pre(.*?)>(.*?)<\/pre>/ise", // "'<pre class=\"wp-code-highlight prettyprint$line_numbers\">'.wch_stripslashes('$2').'</pre>'", $content); return preg_replace_callback("/<pre(.*?)>(.*?)<\/pre>/is",function($m) { return '<pre class="wp-code-highlight prettyprint'.$line_numbers.'">'.wch_stripslashes($m[2]).'</pre>'; },$content); *headsmack* Thanks @hoelli , we’ll get there on the third attempt (or more) 😉

Comments

5 shown
simone.camporeale 2016-02-12T18:14:00+00:00

Hi, you could fix that warning editing wp-code-highlight.php files located in wp-content/plugins/wp-code-highlight/wp-code-highlight.php Comment line 67-68 and add this line: //return preg_replace("/<pre(.*?)>(.*?)<\/pre>/ise", // "'<pre class=\"wp-code-highlight prettyprint$line_numbers\">'.wch_stripslashes('$2').'</pre>'", $content); return preg_replace_callback("/<pre(.*?)>(.*?)<\/pre>/is",function($m) { return '<pre class=\"wp-code-highlight prettyprint$line_numbers\">'.wch_stripslashes('$m[2]').'</pre>'; },$content);

pauguillamon 2016-02-14T10:16:00+00:00

Hi, Just updated my PHP version from 5.4 to 7 and I was getting that error too. Your solution, @simone-camporeale, didn’t completely worked for me. I was getting literally this in each pre: $m[2] So I have modified simone.camporeale solution, and got this one that is working for me: return preg_replace_callback("/<pre(.*?)>(.*?)<\/pre>/is",function($m) { return '<pre class="wp-code-highlight prettyprint'.$line_numbers.'">'.wch_stripslashes($m[2]).''; },$content); Note it’s almost the same, but modifying a little bit the pre tag’s class and removing the apostrophes in the wch_strpslashes() parameter. EDIT: sorry for editing a lot. First time posting here and I was trying to figure out how to correctly put code in the code blocks. EDIT2: btw, I had to check all my code snippets since, on some, some symbols like & or > were automatically changed to the HTML name (& amp; and & gt; respectively)

Michael Visser 2016-09-15T09:58:00+00:00

Hi @pauguillamon , noticed that your snippet is missing the closing element in case others are using your patch. return preg_replace_callback("/<pre(.*?)>(.*?)<\/pre>/is",function($m) { return '<pre class="wp-code-highlight prettyprint'.$line_numbers.'">'.wch_stripslashes($m[2]).''; },$content);

hoelli 2017-01-17T20:44:00+00:00

@michael Visser: Sorry, but you also forgot the closing pre tag. Here’s the code that works for me ATM. // return preg_replace("/<pre(.*?)>(.*?)<\/pre>/ise", // "'<pre class=\"wp-code-highlight prettyprint$line_numbers\">'.wch_stripslashes('$2').'</pre>'", $content); return preg_replace_callback("/<pre(.*?)>(.*?)<\/pre>/is",function($m) { return '<pre class="wp-code-highlight prettyprint'.$line_numbers.'">'.wch_stripslashes($m[2]).'</pre>'; },$content);

Michael Visser 2017-01-18T09:19:00+00:00

*headsmack* Thanks @hoelli , we’ll get there on the third attempt (or more) 😉