문제

I have code for php file as under

class TinyMCE_Buttons {
function __construct() {
    add_action( 'init', array(&$this,'init') );
}
function init() {
    if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') )
        return;     
    if ( get_user_option('rich_editing') == 'true' ) {  
        add_filter( 'mce_external_plugins', array(&$this, 'add_plugin') );  
        add_filter( 'mce_buttons', array(&$this,'register_button') ); 

    }  
}  
function add_plugin($plugin_array) {  
   $plugin_array['shortcodes'] = SHORTCODES_PLUGIN_URL.'/js/tinymce.js';
   return $plugin_array; 
}
function register_button($buttons) {  
   array_push($buttons, "shortcodes_button");
   return $buttons; 
}   
}
$shortcode = new TinyMCE_Buttons;

this is my .js file

(function() {   
tinymce.create('tinymce.plugins.ShortcodeMce', {
    init : function(ed, url){
        tinymce.plugins.ShortcodeMce.theurl = url;
    },
    createControl : function(btn, e) {
        if ( btn == "shortcodes_button" ) {
            var a = this;   
            var btn = e.createSplitButton('symple_button', {
                title: "Insert Shortcode",
                image: tinymce.plugins.ShortcodeMce.theurl +"/shortcodes.png",
                icons: false,
            });
            btn.onRenderMenu.add(function (c, b) {

                b.add({title : 'Shortcodes', 'class' : 'mceMenuItemTitle'}).setDisabled(1);

                // Columns
                c = b.addMenu({title:"Columns"});
// add more menu and cloase file

Its not worked in tinymce4.x version also not gives any error. any solution accepted.

도움이 되었습니까?

해결책

The init and createControl callbacks are no longer called for the Plugin object.

Secondly, you need to call the addButton function on the Editor object.

A proposed solution could work like this (taking code from your post above):

(function() {   
tinymce.create('tinymce.plugins.ShortcodeMce', function (editor, url) {
    tinymce.plugins.ShortcodeMce.theurl = url;

    var btn = editor.addButton('symple_button', {
        type: "splitbutton",
        title: "Insert Shortcode",
        image: tinymce.plugins.ShortcodeMce.theurl +"/shortcodes.png",
        icons: false,
        menu: [
            { title: "Shortcodes", classes: "mceMenuItemTitle", disabled: true }
        ]
    });

Here's the reference of the Button interface in TinyMCE API 4.x: http://www.tinymce.com/wiki.php/api4:class.tinymce.ui.Button

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top