Skip to content

Instantly share code, notes, and snippets.

@BaskSerg
Created April 13, 2017 03:29
Show Gist options
  • Save BaskSerg/8bd0b04dcf9bf4dfaa4653e73d788150 to your computer and use it in GitHub Desktop.
Save BaskSerg/8bd0b04dcf9bf4dfaa4653e73d788150 to your computer and use it in GitHub Desktop.
Remove buttons from the WordPress TinyMCE editor
<?php
/**
* Removes buttons from the first row of the tiny mce editor
*
*/
function remove_first_row_buttons($buttons) {
$remove = array(
'bold',
'italic',
'bullist',
'numlist',
'link',
'formatselect',
'blockquote',
'aligncenter',
'alignleft',
'alignright',
'wp_more',
'wp_adv',
'unlink',
'dfw'
);
return array_diff($buttons, $remove);
}
add_filter('mce_buttons', 'remove_first_row_buttons');
/**
* Removes buttons from the second row of the tiny mce editor
*
*/
function remove_second_row_buttons( $buttons ) {
$remove = array(
'hr',
'strikethrough',
'forecolor',
'sub',
'sup',
'wp_help',
'redo',
'undo',
'indent',
'outdent',
'charmap',
'removeformat',
'pasteword',
'pastetext',
'forecolor',
'justifyfull',
'underline'
);
return array_diff( $buttons, $remove );
}
add_filter( 'mce_buttons_2', 'remove_second_row_buttons' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment