如何让定制的tinyMCE按钮在太长时切换到下一行

时间:2012-09-20 作者:Derek

这里可能缺少一个非常简单的解决方案,但我在Wordpress的tinyMCE编辑器中添加了多个自定义按钮,我的问题是按钮行太长(它们都在同一行-它们自己的行),因此,由于我正在连接mce\\U buttons\\U 3,我有很多按钮,是否有任何方法可以将其分解,以便如果行太长而无法分解默认WP布局,那么我可以在另一行上添加其他按钮?下面是我正在使用的示例:

add_action(\'init\', \'add_button\');  
function add_button() {  
   if ( current_user_can(\'edit_posts\') &&  current_user_can(\'edit_pages\') )  
   {  
     add_filter(\'mce_external_plugins\', \'add_plugin\');  
     add_filter(\'mce_buttons_3\', \'register_button\');  
   }  
} 

function register_button($buttons) {  
   array_push($buttons, "quote", "one-fourth", "one-fourth-last", "one-third", "one-third-last", "one-half", "one-half-last", "two-third", "two-third-last", "three-fourth", "three-fourth-last", "custom-list-1", "custom-list-2", "custom-list-3", "custom-list-4", "message-box-info", "message-box-success", "message-box-warning", "message-box-erroneous", "message-box-simple", "message-box-custom", "recent-posts", "custom-frame-left", "custom-frame-center", "custom-frame-right", "custom-table", "accordion", "accordion-toggle", "tabs", "tabs-content", "toggle-content", "dropcap", "pull-quote", "clear", "divider", "divider-top", "custom-button", "round-button", "small-button", "button", "read-more" );  
   return $buttons;  
} 

1 个回复
SO网友:Paul

问题是你有太多的按钮。。。

我创建的插件也有同样的问题,但我只有21个按钮,而你有41个按钮。。。

解决方案是将它们分成两部分:将前20个按钮添加到第三行(mce\\U buttons\\U 3),然后将21个按钮添加到第四行(mce\\U buttons\\U 4)

您需要为每一行创建一个函数。。。

代码如下所示:

add_action(\'init\', \'add_button\');  
add_action(\'init\', \'add_button2\'); 

function add_button() {  
   if ( current_user_can(\'edit_posts\') &&  current_user_can(\'edit_pages\') )  
   {  
     add_filter(\'mce_external_plugins\', \'add_plugin\');  
     add_filter(\'mce_buttons_3\', \'register_button\');  
   }  
}

function add_button2() {  
   if ( current_user_can(\'edit_posts\') &&  current_user_can(\'edit_pages\') )  
   {  
     add_filter(\'mce_external_plugins\', \'add_plugin2\');  
     add_filter(\'mce_buttons_4\', \'register_button2\');  
   }  
}

function register_button($buttons) {  
   array_push($buttons, "quote", "one-fourth", "one-fourth-last", "one-third", "one-third-last", "one-half", "one-half-last", "two-third", "two-third-last", "three-fourth", "three-fourth-last", "custom-list-1", "custom-list-2", "custom-list-3", "custom-list-4", "message-box-info", "message-box-success", "message-box-warning", "message-box-erroneous", "message-box-simple" );  
   return $buttons;  
}

function register_button2($buttons) {  
   array_push($buttons, "message-box-custom", "recent-posts", "custom-frame-left", "custom-frame-center", "custom-frame-right", "custom-table", "accordion", "accordion-toggle", "tabs", "tabs-content", "toggle-content", "dropcap", "pull-quote", "clear", "divider", "divider-top", "custom-button", "round-button", "small-button", "button", "read-more" );  
   return $buttons;  
}
当然,您还必须创建“add\\u plugin”和“add\\u plugin2”函数。。。

我希望这有助于。。。

结束

相关推荐

TinyMCE Plugin Parameter

有人能告诉我,如果有任何地方我可以找到这些TinyMCE插件的用途吗?$in[\'plugins\']=\'inlinepopups,tabfocus,paste,media,fullscreen,wordpress,wpeditimage,wpgallery,wplink,wpdialogs,wpfullscreen\'; 我想知道如果我删除wordpress 编辑将停止删除我的<p> 标签,但我也丢失了html 编辑器视图。