3

I've been searching the codex, and I'm probably overlooking something somewhere, but could someone tell if it would be possible to remove a button/quicktag from the WordPress html editor?

2 Answers 2

5

With the quicktag_settings filter:

function wpa_47010( $qtInit ) {
    $qtInit['buttons'] = 'strong,em,link,block,del,img,ul,ol,li,code,more,spell,close,fullscreen';
    return $qtInit;
}
add_filter('quicktags_settings', 'wpa_47010');

The default is:

$qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close';

Though 'fullscreen' usually gets added too at the end. So I just deleted the 'ins' button.

Edit to add:

If you wish to create a custom button the following tutorial might help.

3
  • Thanks @helgatheviking! I'm sure I've read that article. Don't know how I might have misinterpret that one though.
    – Charlie
    Mar 27, 2012 at 18:16
  • welcome! i think in the article they advocate disabling buttons via filtering $qtInit['disable_buttons']. but i didn't see that in the source code anywhere. adambrown.info/p/wp_hooks/hook/… Mar 27, 2012 at 18:28
  • 1
    fullscreen is now called dfw (for distraction-free writing.) Jun 7, 2018 at 13:44
3

I'm late to this party I know, but might I add that it's better to be agnostic about the default buttons provided by Wordpress. So instead of typing the buttons you want, I choose to remove the buttons I don't want:

function nmt_quicktags_buttons( $qt_init) {
    $del_buttons = array('del','ins','img','code');
    $qt_init['buttons'] = implode(',', array_diff(explode(',',$qt_init['buttons']), $del_buttons));
    return $qt_init;
}

Now if anyone at Wordpress decides the quicktags-toolbar gets a new button, it will show up in your editor without a code change of your plugin/function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.