Created
June 26, 2014 03:44
-
-
Save tkc49/9574cd1fb3c171d69ffb to your computer and use it in GitHub Desktop.
WordPressのビジュアルエディターに独自スタイルのボタンを追加するコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function mytheme_tinymce_settings($settings) | |
{ | |
$style_formats = array( | |
array( | |
'title' => 'タイトルにする', | |
'selector' => 'h1', | |
'classes' => 'title-headding' | |
), | |
array( | |
'title' => '画像のリンクを黄色する', | |
'selector' => 'a', | |
'classes' => 'img-highlight', | |
), | |
); | |
$settings['style_formats'] = json_encode( $style_formats ); | |
return $settings; | |
} | |
add_filter('tiny_mce_before_init','mytheme_tinymce_settings'); | |
function myplugin_tinymce_buttons($buttons) | |
{ | |
//Add style selector to the beginning of the toolbar | |
array_unshift($buttons, 'styleselect'); | |
return $buttons; | |
} | |
add_filter('mce_buttons_2','myplugin_tinymce_buttons'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment