WordPress 3.9和TinyMCE 4.0自定义按钮插件修复

时间:2014-04-25 22:37:05

标签: wordpress button tinymce

作为Google Fonts Manager plugin的作者,我也遇到了这个问题。自定义字体下拉列表不再出现,TinyMCE文档根本没有帮助。该插件使用以下函数:theme_advanced_buttons1_add_before,theme_advanced_fonts和tiny_mce_before_init来添加字体选项。它已经不再适用了,到目前为止,我对如何解决这个问题感到困惑。任何想法??

这是当前的代码:

//add font selection to TinyMCE
function wp_googlefontmgr_formatTinyMCE($init) {

//get option settings
$myfontlist = "";
$mycsslist = "";
$editorfonts = get_option("wp_googlefontmgr_editorfonts", 1);
$websafefonts = get_option("wp_googlefontmgr_safefonts", 1);

if($editorfonts) {
    if($websafefonts) {  
        //get websafefont list
        $safefontlist = 'Arial=Arial,Helvetica,sans-serif,Arial Black=Arial Black,Gadget,sans-serif,Comic Sans=Comic Sans MS,Comic Sans MS,cursive,Courier New=Courier New,Courier New,Courier,monospace,Georgia=Georgia,Georgia,serif,';
        $safefontlist .= 'Impact=Impact,Charcoal,sans-serif,Lucida Console=Lucida Console,Monaco,monospace,Lucida Sans Unicode=Lucida Sans Unicode,Lucida Grande,sans-serif,Palatino Linotype=Palatino Linotype,Book Antiqua,Palatino,serif,';
        $safefontlist .= 'Tahoma=Tahoma,Geneva,sans-serif,Times New Roman=Times New Roman,Times,serif,Trebuchet MS=Trebuchet MS,Helvetica,sans-serif,Verdana=Verdana,Geneva,sans-serif,Gill Sans=Gill Sans,Geneva,sans-serif,';
    }
    $fontdata = get_option("wp_googlefontmgr_fonts");
    //get the google font list
    if($fontdata) {
        //load fonts for use in plugin
        $array = explode(",", $fontdata);
        foreach($array as $value) {
            $myfontlist .=sprintf(_('%s=%s,'), $value, $value);
            $mycsslist .= "http://fonts.googleapis.com/css?family=" .urlencode($value). ",";
        }
    }
    //check if websafe fonts are to be loaded
    if($websafefonts){
        $myfontlist = $myfontlist. $safefontlist;
    }
    $init['content_css']=get_template_directory_uri() . "/editor-style.css";
    $init['content_css']=rtrim($mycsslist,',');
    $init['theme_advanced_buttons1_add_before'] = 'formatselect,fontselect';
    $init['theme_advanced_fonts'] = rtrim($myfontlist,',');

    return $init;
}
}

1 个答案:

答案 0 :(得分:1)

theme_advanced_fonts替换为font_formats