Skip to content

Instantly share code, notes, and snippets.

@drinkmaker
Created July 20, 2016 08:51
Show Gist options
  • Save drinkmaker/bf96fb285be46119f47b573a255d4aae to your computer and use it in GitHub Desktop.
Save drinkmaker/bf96fb285be46119f47b573a255d4aae to your computer and use it in GitHub Desktop.
stop wp removing some html tags in editor (So stupid feature)
<?php
// stop wp removing some html tags in editor (So stupid feature)
function esta_tinymce_fix($init) {
// html elements being stripped
$init['extended_valid_elements'] = 'div[*], article[*], span[*], strong[*], pre[*], h1[*], h2[*], h3[*], h4[*], h5[*], h6[*], b[*], i[*], tt[*], em[*], font[*], a[*], p[*], br[*], blockquote[*], dt[*], dd[*], ol[*], li[*], ul[*], li[*], img[*], hr[*], form[*], select[*], option[*], textarea[*] input[*], table[*], tr[*], td[*], th[*]';
// don't remove line breaks
$init['remove_linebreaks'] = false;
// don't remove redundant BR
$init['remove_redundant_brs'] = false;
// pass back to wordpress
return $init;
}
add_filter('tiny_mce_before_init', 'esta_tinymce_fix');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment