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

Customising the WordPress TinyMce editor and it’s buttons

I think theme_advanced_buttons1, theme_advanced_buttons2 etc were part of the TinyMCE advanced theme which is no longer available in TinyMCE 4. WordPress 4.9.7 is using TinyMCE version 4.7.11. The two rows of controls are now referred to with: mce_buttons mce_buttons_2 Here is a good example, taken from https://www.kevinleary.net/customizing-tinymce-wysiwyg-editor-wordpress/ which allows easy customisation of the buttons on … 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

TinyMCE Autoresize

Here’s a solution. There’s a slight problem as it does not recognize when images are added to the editor. 1: Create a folder with the name tinymce-autoresize in the plugins folder. 2. Create a file in tinymce-autoresize named tinymce_autoresize.php with this content: function intialize_autoresize_plugin() { // Check user permission if ( ! current_user_can(‘edit_posts’) && ! … Read more

Using post ID in custom tinyMCE button

You would need to place a globally namespaced javascript variable in your php code where you enqueue the script to be loaded for the editor pages. So, this code will enqueue a script function to be added to the “edit post/page” screens: add_action(‘admin_head’,’my_add_styles_admin’); function my_add_styles_admin() { global $current_screen; $type = $current_screen->post_type; if (is_admin() && $type … Read more

Registering custom TinyMCE buttons, for admin area, to work with custom instances of wp_editor

I copied your code into my functions.php, and added a simple admin panel (‘Foo’) to display the editor. Then I created a new directory inside my current theme for the editor button, and put the editor button JS into the relevant file: /wp-content/themes/[my-theme-dir]/tinymce_buttons/pH/editor_plugin.js. Result: when I went to Dashboard > Foo (the panel I’d created), … Read more

How can the tinyMCE dom be manipulated (offical API does not seem to work)?

Hope You can use fallowing // Sets class attribute on all paragraphs in the active editor tinymce.activeEditor.dom.setAttrib(tinymce.activeEditor.dom.select(‘p’), ‘class’, ‘myclass’); // Sets class attribute on a specific element in the current page tinymce.dom.setAttrib(‘mydiv’, ‘class’, ‘myclass’); or You can add Id by jquery like this $(‘div’).find(‘p’).attr(‘id’, ‘myid’);