Skip to content

Instantly share code, notes, and snippets.

@coderaaron
Forked from joemcgill/Customize TinyMCE in WP
Created October 26, 2013 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderaaron/7172138 to your computer and use it in GitHub Desktop.
Save coderaaron/7172138 to your computer and use it in GitHub Desktop.
// 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 aah_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', 'aah_customize_mce');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment