wordpress js for tinymce not working

Here is my plugin code:

<?php

class myplugin{

    function __construct(){

        //stuff


        add_action( 'admin_head', array(&$this, 'fb_add_tinymce') );

    }

    function fb_add_tinymce() {
        global $typenow;

        // only on Post Type: post and page
        if( ! in_array( $typenow, array( 'post', 'page' ) ) )
            return ;

        add_filter( 'mce_external_plugins', array(&$this,'fb_add_tinymce_plugin' ));
        // Add to line 1 form WP TinyMCE
        add_filter( 'mce_buttons', array(&$this,'fb_add_tinymce_button' ));
    }

    // inlcude the js for tinymce
    function fb_add_tinymce_plugin( $plugin_array ) {

        $plugin_array['fb_test'] = plugins_url( 'lib/js/mce-buttons.js', __FILE__ );
        // Print all plugin js path
        var_dump( $plugin_array );
        return $plugin_array;
    }

    // Add the button key for address via JS
    function fb_add_tinymce_button( $buttons ) {

        array_push( $buttons, 'fb_test_button_key' );
        // Print all buttons
        //var_dump( $buttons );
        return $buttons;
    }

}

$plg = new myplugin();

?>

mce-buttons.js file:

Read More
(function($) {

    console.log(1);

    alert('test');

})(jQuery);

The plugin is enabled but when i go to add a new post i cannot see the alert box popping up or the console log outputting the number 1 just to make sure it works.

Related posts

2 comments

Comments are closed.