Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Last active July 22, 2017 08:20
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/86e4f040bcc641a86f59 to your computer and use it in GitHub Desktop.
Save tommcfarlin/86e4f040bcc641a86f59 to your computer and use it in GitHub Desktop.
[WordPress] Remove buttons from the TinyMCE editor
<?php
add_filter( 'mce_buttons_2', 'acme_remove_firm_kitchen_sink');
/**
* Removes the all but the formatting button from the post editor.
*
* @since 1.0.0
*
* @param array $buttons The current array buttons including the kitchen sink.
* @return array The updated array of buttons that exludes the kitchen sink.
*/
function acme_remove_firm_kitchen_sink( $buttons ) {
$invalid_buttons = array(
'underline',
'justifyfull',
'forecolor',
'|',
'pastetext',
'pasteword',
'removeformat',
'charmap',
'outdent',
'indent',
'undo',
'redo',
'wp_help'
);
foreach ( $buttons as $button_key => $button_value ) {
if ( in_array( $button_value, $invalid_buttons ) ) {
unset( $buttons[ $button_key ] );
}
}
return $buttons;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment