wp_editor disable after reaching character count limit

I guess the keyup event is too late. If you use the keypress event instead of keyup, then this seems to work: ed.on( ‘keypress’, function(e) { var content = ed.getContent().replace( /(<[a-zA-Z\/][^<>]*>|\[([^\]]+)\])|(\s+)/ig, ” ); var max = 20; var len = content.length; var diff = max – len; if ( diff < 1 ) tinymce.dom.Event.cancel(e); document.getElementById(“character_count”).innerHTML … Read more

WordPress 3.2 has broken my TinyMCE code

I found some info on changes in 3.2 that might be relevant: Aparrently, wp_tiny_mce_preload_dialogs() no longer exists from WP3.2 on. It got replaced by wp_preload_dialogs() which is now being called from wp_quicktags(). wp_quicktags, on his turn, is being called from the_editor() function. So, if you’re using the_editor() you no longer need to manually call the … Read more

Custom Tiny MCE button to bring up a custom php popup

This works: tinymce.create(‘tinymce.plugins.tinyplugin’, { init : function(ed, url){ ed.addButton(‘tinyplugin’, { title : ‘map’, onclick : function() { tb_show(“”, “../wp-content/plugins/myplugin/test.php?”); tinymce.DOM.setStyle([“TB_overlay”, “TB_window”, “TB_load”], “z-index”, “999999”) }, image: url + “/icon.png”, }); } }); The ? after the test.php is important or else the link will be broken.

Possible to stop WordPress from adding p1, p2… classes to p tags in TinyMCE?

I figured out how to strip those classes using TinyMCE’s paste_preprocess option. In your functions.php: add_filter(‘tiny_mce_before_init’, ‘customize_tinymce’); function customize_tinymce($in) { $in[‘paste_preprocess’] = “function(pl,o){ o.content = o.content.replace(/p class=\”p[0-9]+\”/g,’p’); o.content = o.content.replace(/span class=\”s[0-9]+\”/g,’span’); }”; return $in; } The value passed to paste_preprocess is a JavaScript function which will be executed whenever content is pasted into TinyMCE. The … Read more

TinyMCE in customizer

SwAt.Be, your own answer helped me a bunch and I’ve nailed the problem of printing admin scripts after the last rendition of wp_editor. Also see how I pass JS setup function as tinymce option to sync the editor changes with WP customizer to make it work properly. if (class_exists(‘WP_Customize_Control’)) { class WP_Customize_Teeny_Control extends WP_Customize_Control { … Read more

TinyMCE format dropdown no longer showing style previews

Ok, this was driving me nuts too as it seems to be completely undocumented However, fear not for it is surprisingly easy to fix! 😀 In your tiny_mce_before_init hook function right before the return statement simply add the line: unset($init[‘preview_styles’]); This will make wordpress function as it did before the 3.6 update (the updated added … Read more

Unable to add “code” button to TinyMCE toolbar

That is a very good question. I just tested your code locally and see the same result. A little digging reveals a twp-part problem. wp-includes/class-wp-editor.php is a good read for TinyMCE customizations WordPress 3.9 did update to TinyMCE 4.0 and the TinyMCE docs imply that the superscript button is now called “superscript” and not just … Read more

How to replace the content of tinyMCE editor in both text and visual mode using jQuery?

The first thing to do is to select the active editor. Here we select the editor using its id, which is content. var activeEditor = tinyMCE.get(‘content’); Then we use tinyMCE’s setContent: var activeEditor = tinyMCE.get(‘content’); var content=”HTML or plain text content here…”; activeEditor.setContent(content); However, if the editor is in text mode to begin with, after … Read more

Replace Taxomony Description Field with Visual/WYSIWYG Editor

You can use a {$taxonomy}_edit_form_fields action hook to add html to the term edit table. In that HTML you can remove description textarea and add tinymce editor add_action(“{$taxonomy}_edit_form_fields”, ‘add_form_fields_example’, 10, 2); function add_form_fields_example($term, $taxonomy){ ?> <tr valign=”top”> <th scope=”row”>Description</th> <td> <?php wp_editor(html_entity_decode($term->description), ‘description’, array(‘media_buttons’ => false)); ?> <script> jQuery(window).ready(function(){ jQuery(‘label[for=description]’).parent().parent().remove(); }); </script> </td> </tr> <?php … Read more