Skip to content

Instantly share code, notes, and snippets.

@tkc49
Created June 26, 2014 03:44
Show Gist options
  • Save tkc49/9574cd1fb3c171d69ffb to your computer and use it in GitHub Desktop.
Save tkc49/9574cd1fb3c171d69ffb to your computer and use it in GitHub Desktop.
WordPressのビジュアルエディターに独自スタイルのボタンを追加するコード
<?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