Creating a custom MCE view for your shortcodes [closed]

I had a lot of trouble finding information and examples of this, so here you go: https://github.com/dtbaker/wordpress-mce-view-and-shortcode-editor This converts a [shortcode] into a nice custom view to match the frontend, and adds an edit button for easy shortcode editing. <?php /** * Class dtbaker_Shortcode_Banner * handles the creation of [boutique_banner] shortcode * adds a button … Read more

Remove “Are You Sure” dialogue when leaving editor

You can use the method described here. Add the following to your functions.php <?php function wpse35898_admin_head() { ?> <script type=”text/javascript”> window.onbeforeunload = function() {}; </script> <?php } add_action( ‘admin_head’ , ‘wpse35898_admin_head’ ); ?>

HTML5, WordPress and Tiny MCE issue – wrapping anchor tag around div results in funky output

[*] You need to modify the TinyMCE settings, specifically the valid_children setting. To accomplish this in WordPress, use the tiny_mce_before_init filter reference. Something like this (untested): add_filter(‘tiny_mce_before_init’, ‘modify_valid_children’); function modify_valid_children($settings){ $settings[‘valid_children’]=”+a[div|p|ul|ol|li|h1|h2|h3|h4|h5|h5|h6]”; return $settings; } You may be able to use +a[*] to capture all elements, but you’ll want to take care to avoid nested anchor … Read more

Cite-Tag for blockquotes

The TinyMCE Custom Styles Codex Page should get you through this. There are code snippets on that page, but, as an overview, the process requires two steps: Add the TinyMCE “styleselect” element to the first or second row of icons. Add one or more elements to that styleselect menu. If this were me, I would … Read more

How to keep   non-breaking spaces in the visual editor?

This seems to do it: function allow_nbsp_in_tinymce( $mceInit ) { $mceInit[‘entities’] = ‘160,nbsp,38,amp,60,lt,62,gt’; $mceInit[‘entity_encoding’] = ‘named’; return $mceInit; } add_filter( ‘tiny_mce_before_init’, ‘allow_nbsp_in_tinymce’ ); Also see: https://www.tinymce.com/docs/configure/content-filtering/#entities Any improvement suggestions?