Before WP 3.9 i had the following two filters applied in the functions.php:
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
add_filter('mce_buttons_2', 'my_mce_buttons_2');
function mce_mod( $init ) {
$init['theme_advanced_blockformats'] = 'p,h3,h4';
$init['theme_advanced_styles'] = "Header gross=mus-bi news-single-bighead; Header klein=mus-bi news-single-smallhead; Link=news-single-link; List Items=news-single-list";
return $init;
}
add_filter('tiny_mce_before_init', 'mce_mod');
so that the paragraph formats dropdown only shows p, h3 and h4 while the custom styles dropdown shows "Header gross", "Header klein" and so on. But unfortunately wp and tinymce don't bother anymore since wp 3.9, i only see the standard paragraph formats dropdown now
as well as the standard styles format dropdown:
So far i haven't found any docs about if any hooks have changed with the update to tinymce 4. Anyone knows? Best regards Ralf
Update: Ok based on a little more research and the comments beneath i guess i've figured things out:
//Creating the style selector stayed the same
function my_mce_buttons( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
add_filter('mce_buttons', 'my_mce_buttons');
function mce_mod( $init ) {
//theme_advanced_blockformats seems deprecated - instead the hook from Helgas post did the trick
$init['block_formats'] = "Paragraph=p; Heading 3=h3; Heading 4=h4";
//$init['style_formats'] doesn't work - instead you have to use tinymce style selectors
$style_formats = array(
array(
'title' => 'Header 3',
'classes' => 'mus-bi news-single-bighead'
),
array(
'title' => 'Header 4',
'classes' => 'mus-bi news-single-smallhead'
),
array(
'title' => 'Link',
'block' => 'a',
'classes' => 'news-single-link',
'wrapper' => true
)
);
$init['style_formats'] = json_encode( $style_formats );
return $init;
}
add_filter('tiny_mce_before_init', 'mce_mod');
style_select
and add a "Classes" menu to it. wordpress.stackexchange.com/questions/143689/…