WordPress預設編輯器為TinyMCE,使用起來功能感覺簡陋但又不想使用其它增強類的插件。
其實預設編輯器TinyMCE有部分功能按鈕被隱藏了,增加code可以為TinyMCE編輯器增加額外按鈕
比如:顯示分隔線、字體選擇、上下標等,可以滿足不需要過於複雜的功能。
TinyMCE增加額外按鈕
下面code添加到你的主題functions.php模版文件中。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
function enable_more_buttons($buttons) { $buttons[] = 'hr'; $buttons[] = 'del'; $buttons[] = 'sub'; $buttons[] = 'sup'; $buttons[] = 'fontselect'; $buttons[] = 'fontsizeselect'; $buttons[] = 'cleanup'; $buttons[] = 'styleselect'; $buttons[] = 'wp_page'; $buttons[] = 'anchor'; $buttons[] = 'backcolor'; return $buttons; } add_filter("mce_buttons_1", "enable_more_buttons"); |
增加額外按鈕預設是加到編輯器工具欄的第一行,也可以加到第二行
添加到第二行:
1 |
add_filter("mce_buttons_2", "enable_more_buttons"); |
添加到第三行:
1 |
add_filter("mce_buttons_3", "enable_more_buttons"); |
TinyMCE增加中文字體
1 2 3 4 5 |
function custum_fontfamily($initArray){ $initArray['font_formats'] = "微軟雅黑='微軟雅黑';宋體='宋體';黑體='黑體';仿宋='仿宋';楷體='楷體';隸書='隸書';幼圓='幼圓';"; return $initArray; } add_filter('tiny_mce_before_init', 'custum_fontfamily'); |
wordpress編輯器按鈕使用的Key
1.剪下(cut)複製(copy)貼上(paste)上一步(undo)重做(redo)置中(justifycenter)
2.加粗(bold)斜體(italic)靠左對齊(justifyleft)靠右對齊(justfyright)
3.兩端對齊(justfyfull)插入超鏈接(link)取消超鏈接(unlink)插入圖片(image)
4.清除格式(removeformat)下劃線(underline)刪除線(strikethrough)
5.錨文件(anchor)新建文件(newdocument)
6.字體顏色(forecolor)字體背景色(backcolor)
7.格式選擇(formmatselect)字型選擇(fontselect)字型大小選擇(fontsizeselect)
8.樣式選擇(styleselect)無序列表(bullist)編號列表(numlist)
9.減少縮排(outdent)縮排(indent)幫助(wp_help)
10.打開HTML代碼編輯器(code)水平線(hr)清除代碼(cleanup)
11.上標(sub)下標(sup)特殊符號(charmap)插入more標籤(wp_more)
12.插入分頁標籤(wp_page)
13.隱藏按鈕顯示開關(wp_adv)
14.隱藏按鈕區起始部分(wp_adv_start)
15.隱藏按鈕區結束部分(wp_adv_end)
16.拼寫檢查(spellchecker)