Skip to content

Instantly share code, notes, and snippets.

@gatespace
Last active October 11, 2015 17:07
Show Gist options
  • Save gatespace/3891254 to your computer and use it in GitHub Desktop.
Save gatespace/3891254 to your computer and use it in GitHub Desktop.
WordPressのTinyMCEにボタンを追加
<?php
/**
* TinyMCEにボタンを追加
* 参照: http://www.411.co.jp/article/2010/12/wordpress-vediter/
*/
function lf_mce_buttons($buttons){
array_push($buttons, "wp_page");
return $buttons;
}
add_filter("mce_buttons", "lf_mce_buttons");
// TMAより後に実行されるように、10000番ぐらいにフック登録
add_filter('tiny_mce_before_init', 'litleflag_my_tinymce', 10000);
function litleflag_my_tinymce($initArray) {
//選択できるブロック要素を変更
$initArray['theme_advanced_blockformats'] = 'p,h2,h3,h4,h5,div,pre';
//ボタン追加
$initArray['theme_advanced_buttons1'] .= ',hr';
$initArray['theme_advanced_buttons2'] .= ',sub, sup';
return $initArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment