Answer the question
In order to leave comments, you need to log in
How to allow only paragraph tag in TinyMCE WP?
Tell me how to remove all tags except <p> in the WP visual editor.
I tried this, but in the end it turns out messy.
add_filter('init', 'tinymce_init');
function tinymce_init() {
add_filter( 'mce_external_plugins', 'tinymce_plugin' );
}
function tinymce_plugin($init) {
$init['keyup_event'] = ....../event.js';
return $init;
}
jQuery(document).ready(function($) {
tinymce.PluginManager.add('keyup_event', function(editor, url) {
editor.on('keyup', function(e) {
content = tinymce.activeEditor.getContent({format : 'raw'});
content = content.replace(/<!--[\s\S]*?--!?>/g, "").replace(/<(?!p)\/?[a-z][^>]*(>|$)/gi, "");
tinymce.activeEditor.setContent(content);
});
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question