function add_style_select_button($buttons) {
array_unshift($buttons, 'styleselect');
return $buttons;
}
add_filter('mce_buttons_2', 'add_style_select_button');
function my_mce_before_init_insert_formats( $init_array ) {
$style_formats = array(
// These are the custom styles
array(
'title' => 'line 2',
'block' => 'span',
'classes' => 'line20',
'wrapper' => true,
),
array(
'title' => 'line 3',
'inline' => 'span',
'classes' => 'line30',
'wrapper' => true,
),
);
// Insert the array, JSON ENCODED, into 'style_formats'
$init_array['style_formats'] = json_encode( $style_formats );
return $init_array;
}
// Attach callback to 'tiny_mce_before_init'
add_filter( 'tiny_mce_before_init', 'my_mce_before_init_insert_formats' );
css
/* custom css */
.line20 {
line-height: 2em;
}
.line30 {
line-height: 3em;
}