0

I write this function in my wordpress theme.

// Custom raw code output
function sd_code_filter($content_text) {
    $content_text = preg_replace_callback('!(<pre.*?>)(.*?)</pre>!ise', " '$1' .  stripslashes( str_replace(array('<','>'),array('<','>'),'$2') )  . '</pre>' ", $content_text);
    return $content_text;
}

This function is giving me below warning on frontend.

Warning: preg_replace_callback(): Requires argument 2, ' '$1' . stripslashes( str_replace(array('<','>'),array('<','>'),'$2') ) . '</pre>' ', to be a valid callback in /home2/arzand/public_html/nccf-new/wp-content/themes/nccf/functions.php on line 380

Please help me how can i resolve this warning.

Toto
  • 89,455
  • 62
  • 89
  • 125
Suresh Patel
  • 15
  • 1
  • 8
  • First of all, take a look at [`preg_replace_callback`](http://php.net/manual/en/function.preg-replace-callback.php) documentation and practice on using it as efficiently as you can. – Junaid Sep 28 '17 at 06:12
  • I guess I should have said "learn to use it correctly" than "to use it efficiently" – Junaid Sep 28 '17 at 06:20
  • Junaid i am not a PHP developer previously theme is using preg_replace and now pref_replace is deprecated so that i replace preg_replace with preg_replace_callback – Suresh Patel Sep 28 '17 at 06:30
  • Possible duplicate of [How to use preg\_replace\_callback?](https://stackoverflow.com/questions/11174807/how-to-use-preg-replace-callback) – Toto Sep 28 '17 at 12:34

0 Answers0