/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Escape HTML Entities in Comments * tell your commentators to wrap their code snippets in <code> tags * http://konstruktors.com/blog/wordpress/1850-automatically-escape-html-entities-of-code-fragments-in-comments/ * **/ function myfunction_encode_code_in_comment($source) { create_function('$matches', '$matches[1] = preg_replace(array("/^[\r|\n]+/i", "/[\r|\n]+$/i"), "", $matches[1]); return "<code>" . htmlentities($matches[1]) . "</"."code>";'), $source); if ($encoded) return $encoded; else return $source; } add_filter('pre_comment_content', 'myfunction_encode_code_in_comment');