wordpress snippets last updated   : July 14, 2014
we now have 634 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 →
jqsnipp.com | we just launched jquery snippets website