• Hi everyone,

    For the past two days I have been trying to extend the functionality of TinyMCE with the Template Plugin in WordPress. I don’t want to use a WordPress plugin to do this. However, I couldn’t find any examples or discussions on the internet, so any help will be appreciated

    What I’ve managed to do so far is find the following information:

    – A link for the plugin.

    – What the Codex says – mce_external_plugins – This filter may be useful for loading any of the TinyMCE core plugins, many of which are not included by default in WordPress.

    – And the list of installation instructions from the TinyMCE website:
    – Add plugin to TinyMCE plugin option list example: plugins : “template”.
    – Add the template button name to button list, example: theme_advanced_buttons3_add : “template”.
    – Setup your template files
    – Setup your template options

    I have no idea how to continue as I have never modified the TinyMCE editor before and I only found instructions but no examples on what to do. Again thank you for the help.

Viewing 1 replies (of 1 total)
  • Thread Starter SoulOnFire

    (@soulonfire)

    Okay, I have managed to go so far using the information from the Codex:
    1) I have added the plugin and the button

    <?php
    /*
    Plugin Name: TinyMCE Template Plugin
    */
    
    /* Add the TinyMCE Template Plugin */
    add_filter('mce_external_plugins', 'my_custom_plugins');
    
    function my_custom_plugins () {
         $plugins = array('template'); //Add any more plugins you want to load here
         $plugins_array = array();
    
         //Build the response - the key is the plugin name, value is the URL to the plugin JS
         foreach ($plugins as $plugin ) {
              $plugins_array[ $plugin ] = plugins_url('tinymce/plugins/', __FILE__) . $plugin . '/plugin.min.js';
         }
         return $plugins_array;
    }
    
    function myplugin_tinymce_buttons($buttons)
     {
          //Add style selector to the beginning of the toolbar
          array_unshift($buttons, 'template');
    
          return $buttons;
     }
    add_filter('mce_buttons','myplugin_tinymce_buttons');
    ?>

    2) I have set up a template file and the following code:

    tinymce.init({
        plugins: "template",
        toolbar: "template",
        templates : "/templates/templates.php"
    });

    However, now I have the following error with the plugin.min.js file:
    ‘TypeError: e.notificationManager is undefined’

    I am going out of my mind with this and I have no idea what I am doing wrong. Am I missing something? Any help will be appreciated.

Viewing 1 replies (of 1 total)
  • The topic ‘How to extend TinyMCE with the Template Plugin’ is closed to new replies.