Javascript 向WordPress添加多个TinyMCE按钮

Javascript 向WordPress添加多个TinyMCE按钮,javascript,php,wordpress,tinymce,Javascript,Php,Wordpress,Tinymce,我可以在WordPress中添加一个额外的自定义TinyMCE按钮,但不能添加两个,尽管下面的示例(以及复制和粘贴完整代码)来自相同的问题,以及 我添加了一个带有JS代码的按钮: (function() { tinymce.PluginManager.add('wdm_mce_button', function( editor, url ) { editor.addButton('wdm_mce_button', { text: '[bu

我可以在WordPress中添加一个额外的自定义TinyMCE按钮,但不能添加两个,尽管下面的示例(以及复制和粘贴完整代码)来自相同的问题,以及

我添加了一个带有JS代码的按钮:

(function() {
   tinymce.PluginManager.add('wdm_mce_button', function( editor, url ) {
       editor.addButton('wdm_mce_button', {
                   text: '[button]',
                   icon: false,
                   onclick: function() {
                     // change the shortcode as per your requirement
                      editor.insertContent('[button url=" " text=" " size="normal"]<br/>');
                  }
         });
   }); 
})();
到目前为止,一切都很顺利。一切都表明,我可以通过将第二个函数更改为:

function foo_register_mce_button( $buttons ) {
        array_push( $buttons, 'wdm_mce_button', 'wdm_mce_button2' );
        return $buttons;    
}
(function() {
tinymce.PluginManager.add('wdm_mce_button', function( editor, url ) {
   editor.addButton('wdm_mce_button', {
               text: '[button]',
               icon: false,
               onclick: function() {
                 // change the shortcode as per your requirement
                  editor.insertContent('[button url=" " text=" " size="normal"]<br/>');
              });
   editor.addButton('wdm_mce_button2', {
               text: '[button]',
               icon: false,
               onclick: function() {
                 // change the shortcode as per your requirement
                  editor.insertContent('[button url=" " text=" " size="normal"]<br/>');
              }

     });    
   });  
})();
并将JS函数更改为:

function foo_register_mce_button( $buttons ) {
        array_push( $buttons, 'wdm_mce_button', 'wdm_mce_button2' );
        return $buttons;    
}
(function() {
tinymce.PluginManager.add('wdm_mce_button', function( editor, url ) {
   editor.addButton('wdm_mce_button', {
               text: '[button]',
               icon: false,
               onclick: function() {
                 // change the shortcode as per your requirement
                  editor.insertContent('[button url=" " text=" " size="normal"]<br/>');
              });
   editor.addButton('wdm_mce_button2', {
               text: '[button]',
               icon: false,
               onclick: function() {
                 // change the shortcode as per your requirement
                  editor.insertContent('[button url=" " text=" " size="normal"]<br/>');
              }

     });    
   });  
})();
(函数(){
tinymce.PluginManager.add('wdm_mce_按钮',函数(编辑器,url){
editor.addButton(‘wdm_mce_按钮’{
文本:“[按钮]”,
图标:false,
onclick:function(){
//根据您的要求更改短代码
编辑器.insertContent(“[button url=”“text=”“size=“normal”]
”); }); editor.addButton('wdm_mce_button2'{ 文本:“[按钮]”, 图标:false, onclick:function(){ //根据您的要求更改短代码 编辑器.insertContent(“[button url=”“text=”“size=“normal”]
”); } }); }); })();
但这不起作用——坦率地说,我不明白为什么它会起作用:例如,在要显示“wdm_mce_button2”的数组中,如果我将其重命名为“wdm_mce_button3”,第一个按钮就不起作用

我做错了什么-我如何才能添加一个额外的自定义按钮