WordPress 3.9 採用了新的 TinyMCE 4.0版本,這個版本根據 WordpPress 官方說明,擁有幾項特點:

  • New UI and UI API.
  • New theme.
  • Revamped events system/API.
  • Better code quality, readability and build process.
  • Lots of (inline) documentation.
  • And generally many improvements everywhere.

 

一般來說,使用 HTML WYSIWYG 編輯器,允許我們更改預設值,可以讓你自訂要放的按鈕、甚至自訂新的功能按鈕。在 WordPress 3.9 裡,因為好多種按鈕被隱藏起來,其實你也可以自由更改,做出一套你習慣的編輯按鈕區。以下我們用比較簡單的方式來介紹如何新增被隱藏的按鈕、或自訂按鈕順序。所有更改內容,請找你的布景(theme)裡面的 functions.php ,將程式碼加入即可。

方法一:新增被隱藏的按鈕

function my_mce_buttons_2($buttons) {
  $buttons[] = 'fontselect';
  $buttons[] = 'formatselect';
  return $buttons;
}
add_filter('mce_buttons_2', 'my_mce_buttons_2');

方法二:自訂按鈕順序(更改 tiny_mce_before_init 的預設值)

function myformatTinyMCE($in)
{
  $in['toolbar1']='bold,italic,underline,strikethrough,bullist,numlist,blockquote,hr,alignleft,aligncenter,alignright,link,unlink,wp_more,spellchecker,wp_fullscreen,wp_adv ';
  $in['toolbar2']='formatselect,fontselect,fontsizeselect,alignjustify,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help ';
  return $in;
}
add_filter('tiny_mce_before_init', 'myformatTinyMCE' );

參考資料:
1. http://codex.wordpress.org/TinyMCE_Custom_Buttons
2. http://www.wpexplorer.com/wordpress-tinymce-tweaks/
3. http://codex.wordpress.org/TinyMCE

你或許會想要看:

  • 暫無相關文章

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *