WordPress.org

Ready to get started?Download WordPress

Forums

TinyMCE (with plugin) (3 posts)

  1. martin_vl87
    Member
    Posted 3 years ago #

    I had made a plugin for TinyMCE and insert the plugin manualy in the TinyMCE folder, but I want to do it with a wp-plugin. There for I have write the following code:

    /********************************************************/
    /*	Function:	dam_add_button							*/
    /********************************************************/
    function dam_add_button() {
       // Don't bother doing this stuff if the current user lacks permissions
       if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
         return;
    
       // Add only in Rich Editor mode
       if ( get_user_option('rich_editing') == 'true') {
         add_filter('mce_external_plugins', 'dam_insert_plugin');
         add_filter('mce_buttons', 'dam_register_button');
       }
    }
    
    /********************************************************/
    /*	Function:	dam_register_button							*/
    /********************************************************/
    function dam_register_button($buttons) {
       array_push($buttons, 'separator', 'dam');
       return $buttons;
    }
    
    /********************************************************/
    /*	Function:	dam_insert_plugin							*/
    /********************************************************/
    function dam_insert_plugin($plugin_array) {
       $plugin_array['dam'] = WP_PLUGIN_URL.'dam/editor_plugin.js';
       return $plugin_array;
    }
    
    /********************************************************/
    /*	decalaration of the WordPress action/filter hooks:	*/
    /********************************************************/
    add_action('init', 'dam_add_button');

    But when I run this code as a plugin I don't see a button at all. Can someone help me with this problem?

    (I have the TinyMCE plugin placed in the plugin folder: "wp-content/plugins/dambord/dam/editor_plugin.js")

    Martin

  2. Matthew Denton
    Member
    Posted 3 years ago #

    Martin:

    I compared your above code against my plugins code for including it's custom tinyMCE control and it looks correct. When I first created my plugin I had the same issue and to correct it I needed to sync my tinyMCE's command name to match the value used in the insert/register functions.

    For example:

    ed.addCommand('dam', function(ui, val) {
    ...
    });
    tinymce.PluginManager.add('dam', tinymce.plugins.dam);
  3. martin_vl87
    Member
    Posted 3 years ago #

    Thanks a lot. I have change the different commands to the same name. Now the icon of the plugin is showing in the icon bar.

    Now I only need to migrate my TinyCME plugin to 3.0, but that isn't a wordpress problem ;).

    Tanks again.

Topic Closed

This topic has been closed to new replies.

About this Topic