Codex tools: Log in
Contents |
The mce_buttons group of filters can be used by developers to add or remove buttons/features from the WordPress's TinyMCE toolbar(s).
This filter is passed an array of button ids which determine which buttons are displayed or removed.
Four filter hooks are available:
The following will add a "Styles" dropdown to the advanced toolbar.
function myplugin_tinymce_buttons($buttons)
{
//Add style selector to the beginning of the toolbar
array_unshift($buttons, 'styleselect');
return $buttons;
}
add_filter('mce_buttons_2','myplugin_tinymce_buttons');
The following will remove the text color selector from the advanced toolbar.
function myplugin_tinymce_buttons($buttons)
{
//Remove the text color selector
$remove = 'forecolor';
//Find the array key and then unset
if ( ( $key = array_search($remove,$buttons) ) !== false )
unset($buttons[$key]);
return $buttons;
}
add_filter('mce_buttons_2','myplugin_tinymce_buttons');
Or, if you want to remove more buttons at the same time:
function myplugin_tinymce_buttons($buttons)
{
//Remove the format dropdown select and text color selector
$remove = array('formatselect','forecolor');
return array_diff($buttons,$remove);
}
add_filter('mce_buttons_2','myplugin_tinymce_buttons');