WordPress Tinymce创建分裂按钮

时间:2013-12-24 09:31:25

标签: php tinymce wordpress

我需要帮助在WordPress TinyMCE中创建分割按钮

(function() {
    tinymce.create('tinymce.plugins.Wptuts', {
        init : function(ed, url) {
            ed.addButton('dropcap', {
                title : 'DropCap',
                cmd : 'dropcap',
                image : url + '/dropcap.jpg'
            });

            ed.addButton('showrecent', {
                title : 'Add recent posts shortcode',
                cmd : 'showrecent',
                image : url + '/recent.jpg'
            });

            ed.addCommand('dropcap', function() {
                var selected_text = ed.selection.getContent();
                var return_text = '';
                return_text = '<span class="dropcap">' + selected_text + '</span>';
                ed.execCommand('mceInsertContent', 0, return_text);
            });

            ed.addCommand('showrecent', function() {
                var number = prompt("How many posts you want to show ? "),
                    shortcode;
                if (number !== null) {
                    number = parseInt(number);
                    if (number > 0 && number <= 20) {
                        shortcode = '[recent-post number="' + number + '"/]';
                        ed.execCommand('mceInsertContent', 0, shortcode);
                    }
                    else {
                        alert("The number value is invalid. It should be from 0 to 20.");
                    }
                }
            });
        },
        // ... Hidden code
    });
    // Register plugin
    tinymce.PluginManager.add( 'wptuts', tinymce.plugins.Wptuts );
})();

我可以为Wordpress TinyMCE Editor创建简单的按钮 但我不知道如何创建一个拆分按钮。我真的遇到了麻烦。我已经在Google上搜索了但我找不到创建split button的好例子,有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

试试这个

ed.createSplitButton('splitbutton', {
   title : 'Splitbutton',
   image : url + '/splitbutton.jpg'
});