wordpress snippets last updated   : August 18, 2014
we now have 638 snippets

Automatically close HTML in WYSIWYG

wordpress snippet

Adding this PHP code to the functions.php of your wordpress theme will automatically close any missing tags when using the WYSIWYG editor.

snippet :  PHPcopy
function clean_bad_content($bPrint = false) {
    global $post;
    $szPostContent  = $post->post_content;
    $szRemoveFilter = array("~<p[^>]*>\s?</p>~", "~<a[^>]*>\s?</a>~", "~<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;
   }
source →

Did you like this post? If so please share it with your friends. Thanks!

jqsnipp.com | we just launched jquery snippets website