Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
// 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