Created
June 4, 2013 17:01
-
-
Save roborourke/5707639 to your computer and use it in GitHub Desktop.
Styles dropdown in WP
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' => 'Pull quote left', | |
'selector' => 'blockquote', | |
'classes' => 'alignleft' | |
), | |
array( | |
'title' => 'Pull quote right', | |
'selector' => 'blockquote', | |
'classes' => 'alignright' | |
) | |
); | |
$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