Easy way to inject js in tinymce iframe?

WordPress injects its own external script files in the TinyMCE editor iframe, see for example the wp-includes/js/tinymce/plugins/wpembed/plugin.js file: (function ( tinymce ) { ‘use strict’; tinymce.PluginManager.add( ‘wpembed’, function ( editor, url ) { editor.on( ‘init’, function () { var scriptId = editor.dom.uniqueId(); var scriptElm = editor.dom.create( ‘script’, { id: scriptId, type: ‘text/javascript’, src: url + … Read more

tinyMCE duplicates previous block element when pressing return (visual editor)

I’m currently having the same problem. Here’s my work-around. add_filter( ‘tiny_mce_before_init’, ‘workaround’ ); public function workaround( $in ) { $in[‘force_br_newlines’] = true; $in[‘force_p_newlines’] = false; $in[‘forced_root_block’] = ”; return $in; } tiny_mce_before_init gives you access to the TinyMCE settings that WordPress’ editor uses. See also: TinyMCEConfiguration The downside to this is instead of “return” resulting … Read more

wordpress with many custom styled static pages

You can make each one into a custom Page Template, and either add the style block directly in the template, or conditionally load a stylesheet based on which template is in use. This will let you still use the editor to change the content of the page, but involves a lot of “one-off” page management. … Read more

How to Add TinyMCE’s plugin in wordpress?

You can register TinyMCE plugins using mce_external_plugins filter: add_filter(‘mce_external_plugins’, ‘my_tinymce_plugins’); function my_tinymce_plugins() { $plugins_array = array( ‘my-tinymce-plugin-name’ => ‘tinymce-plugin-url-of-js-file’ ); return $plugins_array; } You can add that code to functions.php file of your theme, or better in a WordPress plugin to make it theme independent. Also, I recommend to not upload externa tinymce plugins to … Read more

Excluding post type from WordPress link builder

Versions <= 3.6.1 It looks like the function wp_link_query() is used to display the internal posts/pages when you press the Or link to existing content in the “link builder”: wp_link_query() is defined in /wp-includes/class-wp-editor.php. It is queried via the wp_ajax_wp_link_ajax(), defined in the file /wp-admin/includes/ajax-actions.php. These functions don’t have any explicit filters to change the … Read more

Remove ‘Visual’ tab from TinyMCE editor

I can think of three way you can do this Log in to the Admin Control Panel and go to: Users -> All Users Find your username and click on Edit. Check “Disable the visual editor when writing” Add this code in the themes function.php file add_filter( ‘user_can_richedit’ , ‘__return_false’, 50 ); Install a plugin … Read more