strip only specific tags (like ), but keep other tags (like )

You’d better never disable those actions (what you say). Instead, insert add_filter(‘the_content’, ‘MyFilter’, 88 ); and create such function: function MyFilter($content){ $tags = array( ‘p’, ‘span’); /////////////////////////////////////////////////// ///////// HERE INSERT ANY OF BELOW CODE ////////// /////////////////////////////////////////////////// return $content; } ======== METHOD 1 ========= $content= preg_replace( ‘#<(‘ . implode( ‘|’, $tags) . ‘)(.*|)?>#si’, ”, $content); $content= … Read more

Removing buttons from the html editor

With the quicktag_settings filter: function wpa_47010( $qtInit ) { $qtInit[‘buttons’] = ‘strong,em,link,block,del,img,ul,ol,li,code,more,spell,close,fullscreen’; return $qtInit; } add_filter(‘quicktags_settings’, ‘wpa_47010’); The default is: $qtInit[‘buttons’] = ‘strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close’; Though ‘fullscreen’ usually gets added too at the end. So I just deleted the ‘ins’ button. Edit to add: If you wish to create a custom button the following tutorial might help.

serialize_blocks breaking html tags in content

This happens in serialize_block_attributes, the docblock explains why: /** … * The serialized result is a JSON-encoded string, with unicode escape sequence * substitution for characters which might otherwise interfere with embedding * the result in an HTML comment. … */ So this is done as an encoding measure to avoid attributes accidentally closing a … Read more

How to to stop html editor from addig tags to shortcodes, images, etc

1. Filtering the content Here’s a one-function content filter to meet the above four requirements: add_filter( ‘the_content’, ‘strip_some_paragraphs’, 20 ); function strip_some_paragraphs( $content ) { $content = preg_replace( ‘/<p>(([\s]*)|[\s]*(<img[^>]*>|\[[^\]]*\])[\s]*)<\/p>/’, ‘$3’, $content ); return $content; } 2. Resources for Regular Expressions regular-expressions.info – Manual, Basic & Advanced Tutorials regexpal.com – on the fly regex tester, very … Read more

Enable / Add Custom Keyboard Shortcuts To Work With WordPress’ HTML Editor

The toolbar / editor used on Stack Exchange websites (and in my plug-in WP-MarkDown) is PageDown. This comes with three JavaScript files: One that handles MarkDown to HTML conversion One that handles sanitization One that handles the editor (the toolbar and previewer) Included in the latter are the MarkDown keyboard shortcuts you mentioned. The following … Read more

Disable the Code View in the content editor?

You can do it in JavaScript, though the downside is you have to do it block by block. You’ll need webpack set up with lodash installed: function removeHtmlEditing( settings, name ) { return lodash.assign( {}, settings, { supports: lodash.assign( {}, settings.supports, { html: false } ), } ); } wp.hooks.addFilter( ‘blocks.registerBlockType’, ‘core/paragraph’, removeHtmlEditing ); There’s … Read more