Automatically Remove Code Mistakes in Posts

functions

function clean_bad_content($bPrint = false) {
global $post;
$szPostContent = $post->post_content;
$szRemoveFilter = array(“~<p[^>]*>\s?</p>~”, “~<a[^>]*>\s?~”, “~<font[^>]*>~”, “~<\/font>~”, “~style\=\”[^\”]*\”~”, “~<span[^>]*>\s?</span>~”);
$szPostContent = preg_replace($szRemoveFilter, ”, $szPostContent);
$szPostContent = apply_filters(‘the_content’, $szPostContent);
if ($bPrint == false) return $szPostContent;
else echo $szPostContent;
}

template within loop

<?php if (function_exists(‘clean_bad_content’)) clean_bad_content(true); ?>


Remove Code Mistakes