Skip to content

Instantly share code, notes, and snippets.

@benklocek
Created November 12, 2012 22:30
Show Gist options
  • Save benklocek/4062437 to your computer and use it in GitHub Desktop.
Save benklocek/4062437 to your computer and use it in GitHub Desktop.
Wordpress Functions: Add Style Dropdown to TinyMCE
// Add the Style Dropdown Menu to the second row of visual editor buttons
function bracia_mce_buttons_2($buttons){
array_unshift($buttons, 'styleselect');
return $buttons;
}
add_filter('mce_buttons_2', 'bracia_mce_buttons_2');
function bracia_tiny_mce_before_init( $settings ) {
$style_formats = array(
// array(
// 'title' => 'Download Link',
// 'selector' => 'a',
// 'classes' => 'download'
// ),
// array(
// 'title' => 'Testimonial',
// 'selector' => 'p',
// 'classes' => 'testimonial',
// ),
array(
'title' => 'Special Div',
'block' => 'div',
'classes' => 'special',
'wrapper' => true
)
);
$settings['style_formats'] = json_encode( $style_formats );
return $settings;
}
add_filter( 'tiny_mce_before_init', 'bracia_tiny_mce_before_init' );
add_editor_style();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment