Skip to content

Instantly share code, notes, and snippets.

@sidonaldson
Created October 30, 2015 11:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidonaldson/67268666c5501f06289d to your computer and use it in GitHub Desktop.
Save sidonaldson/67268666c5501f06289d to your computer and use it in GitHub Desktop.
This snippet will tame TinyMCE within Wordpress and prevent it trying to clean up the code and reformat it. Specifically helps to prevent wordpress strip p tags and line-breaks and stops it from inserting nbsp etc
function mce_mod( $init ) {
$init['forced_root_block'] = 'p';
$init['apply_source_formatting'] = false;
$init['preformatted'] = true;
$init['force_br_newlines'] = true;
$init['wpautop'] = false;
return $init;
}
add_filter('tiny_mce_before_init', 'mce_mod', 99);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment