Remove quicktag buttons but not Visual / Text editor and tabs

I wish to remove the quick-tag buttons in the text (html) editor in TinyMCE but not the html editor itself nor the tabs for choosing between the editors.

When I use

   $settings = array('quicktags' => false);
   wp_editor($input, 'editor_name', $settings);

WordPress removes the entire text editor and the Visual / Text tabs for choosing between the editors (as stated in the codex). I have tried

   $settings = array('quicktags' => array());

But all buttons remain. Looking through the source code I cannot see a new native remove button code, just add. For backwards compatibility there is listed a edRemoveTag = function(){}, but I cannot find the actual function itself.

I have only found this related thread for quicktags in WP4.0 but it does not seem to cover this issue.

1 Answer
1

As you noted, setting quicktags to false removes the “visual” and “text” tabs. So, to leave the tabs you need to set quicktags to true and remove the buttons:

$settings = array(
    'quicktags' => array(
                       'buttons' => ','
                    )
);
wp_editor($input, 'editor_name', $settings);

To have this in all quicktags instances you can use quicktags_settings filter:

add_filter('quicktags_settings', 'cyb_quicktags_settings');
function cyb_quicktags_settings( $qtInit  ) {
    //Set to emtpy string, empty array or false won't work. It must be set to ","
    $qtInit['buttons'] = ',';
    return $qtInit;
}

If you are using a plugin that add custom quicktags, you may to set a high priority argument to the filter (later execution):

add_filter('quicktags_settings', 'cyb_quicktags_settings', 100);

Leave a Comment