Skip to content

Instantly share code, notes, and snippets.

@daltonrooney
Last active April 7, 2016 22:15
Show Gist options
  • Save daltonrooney/3261d31aa2c1b322e20f04f9e81890c7 to your computer and use it in GitHub Desktop.
Save daltonrooney/3261d31aa2c1b322e20f04f9e81890c7 to your computer and use it in GitHub Desktop.
Simplify WordPress TinyMCE
<?php
/* Simplify the default tiny MCE */
add_filter( 'mce_buttons', 'wpcustom_mce_buttons_1' );
function wpcustom_mce_buttons_1( $buttons ) {
$buttons = array( 'styleselect','bold', 'italic', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'link', 'unlink', 'pastetext', 'removeformat', 'undo', 'redo');
return $buttons;
}
add_filter( 'mce_buttons_2', 'wpcustom_mce_buttons_2' );
function wpcustom_mce_buttons_2( $buttons ) {
$buttons = array();
return $buttons;
}
/*
* Add new styles to the TinyMCE "formats" menu dropdown. These should match your editor-styles.css and front-end stylesheet.
*/
add_filter( 'tiny_mce_before_init', 'wpcustom_styles_dropdown' );
function wpcustom_styles_dropdown( $settings ) {
unset($settings['preview_styles']);
$new_styles = array(
array(
'title' => 'Headings',
'items' => array(
array(
'title' => 'H3',
'block' => 'h3'
),
),
),
array(
'title' => 'Paragraphs',
'items' => array(
array(
'title' => 'Paragraph',
'block' => 'p'
),
array(
'title' => 'Callout',
'block' => 'p',
'attributes' => array('class' => 'callout')
),
),
),
);
// Don't merge
$settings['style_formats_merge'] = false;
$settings['style_formats'] = json_encode( $new_styles );
return $settings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment