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 | |
/** | |
* Add "Styles" drop-down to TinyMCE | |
* | |
* @since 1.0.0 | |
* @link http://wp.tutsplus.com/tutorials/theme-development/adding-custom-styles-in-wordpress-tinymce-editor/ | |
* @param array $buttons | |
* @return array | |
*/ | |
function ja_mce_editor_buttons( $buttons ) { | |
array_unshift( $buttons, 'styleselect' ); | |
return $buttons; | |
} | |
add_filter( 'mce_buttons_2', 'ja_mce_editor_buttons' ); | |
/** | |
* Add styles/classes to the TinyMCE "Styles" drop-down | |
* | |
* @since 1.0.0 | |
* @link http://wp.tutsplus.com/tutorials/theme-development/adding-custom-styles-in-wordpress-tinymce-editor/ | |
* @param array $settings | |
* @return array | |
*/ | |
function ja_mce_before_init( $settings ) { | |
$style_formats = array( | |
array( | |
'title' => 'Paragraph Large', | |
'selector' => 'p', | |
'classes' => 'large', | |
), | |
); | |
$settings['style_formats'] = json_encode( $style_formats ); | |
return $settings; | |
} | |
add_filter( 'tiny_mce_before_init', 'ja_mce_before_init' ); |
Questions, comments, or suggestion for improvement? Leave a comment on the GitHub Gist page.