Disable HTML Rewriting in the WordPress Visual Editor

UPDATE:  With WordPress 5 and Gutenburg everything I have done will not work as they are using a completely different JavaScript text editor

I have just created an Ignore Code Wordpress plugin that came out of this post on trying to protect the insert_php shortcode from the wiles of the WordPress visual editor TinyMCE.

To use this plugin simply download it from the WordPress site (or search for it inside your admin on the Plugin page). Then wherever you have code you don’t want the visual editor to rewrite use the [[ignore_code]] shortcode.  This version also supports the [insert_php] and <?php tags, though for the PHP tag you will have to start the first line with  <?php // >   However with the latter two you will have to separately install plugins to get the dynamic PHP inserting functionality.

The disadvantage of this is anything inside the [[ignore_code]] tags will not show up in the visual editor at all.

Note that you can’t use the fix on the post and this plugin at the same time as tiny_mce_before_init can only be called once.  Also if you have a plugin that calls tiny_mce_before_init this may not work or it may make the other plugin not work (generally this will be called to modify something with the WordPress visual editor)

This was tested on WordPress 3.51 to 4.6, your mileage may vary for versions further from this.

Please Note: this is beta software, use at your own risk, I won’t be liable for crashing your site.  Make sure you have FTP access to your WordPress site so you can uninstall it manually if it messes your website up.

I Did The Digging So You Don't Have To

I Did The Digging So You Don't Have To

Where should I send my free Web Tools Booklet filled with resources to supercharge your web development workflow?

Your Web Tools Booklet is on its way.