TinyMCE Keyup Function

// get tinymce instance of wp default editor var ed = tinyMCE.getInstanceById(‘content’); // add a callback to tinyMCE.onKeyUp event ed.onKeyUp.add(function(){ // format: text will strip html tags console.log( ed.getContent({ format: ‘text’ }) ).length; }) http://www.tinymce.com/wiki.php/api3:event.tinymce.editor.onkeyup

Should the WP post editor B (bold) button be inserting a tag instead of in HTML5?

Here’s what I came up with. So far it doesn’t seem to have broken anything: add_filter(‘tiny_mce_before_init’, ‘modify_formats’); function modify_formats($settings){ $formats = array( ‘bold’ => array(‘inline’ => ‘b’), ‘italic’ => array(‘inline’ => ‘i’) ); $settings[‘formats’] = json_encode( $formats ); return $settings; } One could easily have used plus a class here, but given the changes in … Read more

Add Item to Custom TinyMCE Menu

addMenuItem() adds to tinymce’s toolbar, which isn’t used by WP by default, and uses context to add to the particular (sub)menu. You’re adding a MenuButton, and you can access the button through the editor’s buttons array, keyed by the button name: add_action( ‘admin_print_footer_scripts’, function () { ?> <script type=”text/javascript”> jQuery(function ($) { tinymce.on(‘SetupEditor’, function (editor) … Read more

How do i disable/disallow and tags in TinyMCE?

Simple way, do not add content when logged in as admin user but only as author. If you want to go to somewhat extreme, remove the posting capabilities from the admin. Not sure where that will leave you with editing slugs so a proper check of permission will be needed. This answers your question as … Read more

Open link in a new tab checked by default when adding a new link in visual post editor

Add this function in your theme’s functions.php function my_enqueue($hook) { if (‘post.php’ != $hook ) { return; } wp_enqueue_script(‘my_custom_script’, get_template_directory_uri() . ‘/js/myscript.js’); } add_action(‘admin_enqueue_scripts’, ‘my_enqueue’);` In myscript.js place this code jQuery(document).ready(function(){ jQuery(‘#wp-link-target’).prop(“checked”, true); }) It worked for me.