02 May 2021

Remove icons from the visual text editor in wordpress


/**
* Removes buttons from the second row (kitchen sink) of the tiny mce editor
*
* @link http://thestizmedia.com/remove-buttons-items-wordpress-tinymce-editor/
*
* @param array $buttons The default array of buttons in the kitchen sink
* @return array The updated array of buttons that exludes some items
*/
add_filter('mce_buttons_2', 'jivedig_remove_tiny_mce_buttons_from_kitchen_sink');
function jivedig_remove_tiny_mce_buttons_from_kitchen_sink($buttons)
{

$remove_buttons = array(
// 'formatselect',
// 'underline',
// 'alignjustify',
'forecolor',
// 'pastetext',
// 'removeformat',
// 'charmap',
// 'outdent',
// 'indent',
// 'undo',
// 'redo',
// 'wp_help',
);
foreach ($buttons as $button_key => $button_value) {
if (in_array($button_value, $remove_buttons)) {
unset($buttons[$button_key]);
}
}
return $buttons;
}