Viewing 5 replies - 1 through 5 (of 5 total)
  • 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

    (@pauguillamon)

    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) ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘"Deprecated" warning’ is closed to new replies.