Last active
October 14, 2016 08:11
-
-
Save joemcgill/7171061 to your computer and use it in GitHub Desktop.
Set of functions for easily customizing the tinyMCE editor in WordPress. More references: Wes Bos – http://wesbos.com/custom-wordpress-tinymce-wysiwyg-classes/
TinyMCE Reference – http://www.tinymce.com/wiki.php/TinyMCE3x:Buttons/controls
This file contains hidden or 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
// add style selector drop down | |
function my_mce_buttons_2( $buttons ) { | |
array_unshift( $buttons, 'styleselect' ); | |
return $buttons; | |
} | |
add_filter( 'mce_buttons_2', 'my_mce_buttons_2' ); | |
// customize the MCE editor | |
function my_customize_mce( $init ) { | |
/* Only include these tags */ | |
$init['theme_advanced_blockformats'] = 'h2,h3,h4,p'; | |
/* Remove these buttons */ | |
$init['theme_advanced_disable'] = 'forecolor, underline, justifyfull, indent, outdent'; /* | |
/* Set up your custom style classes */ | |
$style_formats = array( | |
array( | |
'title' => 'Intro Paragraph', | |
'selector' => 'p', | |
'classes' => 'lead' | |
), | |
); | |
/* Only include your custom styles -- defined above -- in your style dropdown */ | |
$init['style_formats'] = json_encode( $style_formats ); | |
return $init; | |
} | |
add_filter('tiny_mce_before_init', 'my_customize_mce'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment