Return to Snippet

Revision: 47343
at June 6, 2011 01:06 by alp

Initial Code
 * Escape HTML Entities in Comments
 * tell your commentators to wrap their code snippets in <code> tags
function myfunction_encode_code_in_comment($source) {
	$encoded = preg_replace_callback('/<code>(.*?)<\/code>/ims',
	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;
		return $source;
add_filter('pre_comment_content', 'myfunction_encode_code_in_comment');

Initial URL

Initial Description

Initial Title
Wordpress: Escape HTML Entities in Comments

Initial Tags
wordpress, code

Initial Language