Site icon Hip-Hop Website Design and Development

Add Button to TinyMCE Customized Menu

I’ve added a brand new button with a menu to the TinyMCE visible editor utilizing this tremendously useful tutorial however would now like so as to add additional gadgets to this menu relying on whether or not varied submit varieties are lively in my theme. I believe I am heading in the right direction with addMenuItem and ‘context’ however cannot determine the right way to set this up within the right order.

My plugin code:

add_action('admin_head', 'nto_add_shortcode_button');

perform nto_add_shortcode_button() {
    international $typenow;

    // test consumer permissions
    if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) {
        return;
    }

    // confirm the submit kind
    if( ! in_array( $typenow, array( 'submit', 'web page' ) ) )
        return;

    // test if WYSIWYG is enabled
    if ( get_user_option('rich_editing') == 'true') {
        add_filter("mce_external_plugins", "nto_add_tinymce_plugin");
        add_filter('mce_buttons', 'nto_register_my_tc_button');
    }
}

perform nto_add_tinymce_plugin($plugin_array) {
    $plugin_array['nto_shortcode_button1'] = plugins_url( '/text-button.js', __FILE__ );
    return $plugin_array;
}

perform nto_register_my_tc_button($buttons) {
    array_push($buttons, "nto_shortcode_button1");
    return $buttons;
}

Then, when initiating my submit kind:

perform nto_features_scripts() {
    wp_enqueue_script( 'options',  plugins_url( '/options.js', __FILE__ ), array(), 'false', true );
}
add_action( 'admin_head', 'nto_features_scripts', 100 );

Then lastly, in options.js:

tinymce.init({
    selector: "textarea",
    toolbar: "mybutton",
    setup: perform(editor) {
        editor.addMenuItem('myitem', {
            textual content: 'My menu merchandise',
            context: 'nto_shortcode_button1',
            onclick: perform() {
                editor.insertContent('Some content material');
            }
        });
    }
});

Returns:

Uncaught ReferenceError: tinymce will not be outlined

Q: How can I appropriately provoke this addition to my customized button?