TinyMCE Styles Dropdown not adding html tags other than span
Question
I am trying to add h1,h2 .. in the TinyMCE Styles Dropdown with my other html elements. I have tried the following code, but the problem is it only adds styles if I use span
as ‘block’ value. If I use div, h3, h4, the code doesn’t add anything
I have searched a lot for the solution but haven’t found anything helpful.
Could you please tell me how to fix this problem?
FYI: I am using wordpress 3.5.1
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
// Register our callback to the appropriate filter
add_filter('mce_buttons_2', 'my_mce_buttons_2');
// Callback function to filter the MCE settings
function my_mce_before_init_insert_formats( $init_array ) {
// Define the style_formats array
$style_formats = array(
// Each array child is a format with it's own settings
array(
'title' => 'Head',
'block' => 'h4',
'classes' => 'headings',
'wrapper' => true,
),
array(
'title' => 'Sub Heading',
'block' => 'span',
'classes' => 'subheadlines2',
'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' );
0
plugin-development, plugins, tinymce
9 years
2013-10-01T08:04:33-05:00
2013-10-01T08:04:33-05:00 0 Answers
89 views
0
Leave an answer