Created
May 23, 2012 13:27
-
-
Save roborourke/2775231 to your computer and use it in GitHub Desktop.
Code by @alisothegeek to enable a styles dropdown in the WP tinymce editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Custom styles for tiny mce | |
* HT: http://alisothegeek.com/2011/05/tinymce-styles-dropdown-wordpress-visual-editor/ | |
*/ | |
add_filter( 'mce_buttons_2', 'my_mce_buttons_2' ); | |
function my_mce_buttons_2( $buttons ) { | |
array_unshift( $buttons, 'styleselect' ); | |
return $buttons; | |
} | |
add_filter( 'tiny_mce_before_init', 'my_mce_before_init' ); | |
function my_mce_before_init( $settings ) { | |
$style_formats = array( | |
array( | |
'title' => 'Button', | |
'selector' => 'a', | |
'classes' => 'button' | |
), | |
array( | |
'title' => 'Intro paragraph', | |
'selector' => 'p', | |
'classes' => 'intro' | |
), | |
array( | |
'title' => 'Callout', | |
'selector' => 'p', | |
'classes' => 'callout' | |
) | |
); | |
$settings[ 'style_formats' ] = json_encode( $style_formats ); | |
return $settings; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment