2

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.

  • The plugin AddQuicktag give you this possibility with help a settings page, see github.com/bueltge/AddQuicktag – bueltge Jan 6 '15 at 22:15
  • 1
    Sorry, I pressed enter to early on my mobile. You find also the example, the solution for doing this inside this class of the plugin f custom source, see github.com/bueltge/AddQuicktag/blob/master/inc/… – bueltge Jan 6 '15 at 22:16
  • Thanks but I'm trying to eliminate the need for plugins – myol Jan 7 '15 at 10:12
  • Yes, I have understand this. But in the class of my second comment can you find the hooks and functions to remove the quicktags. – bueltge Jan 7 '15 at 12:15
4

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);
  • Well done spotting that out (+1), I was just going to start looking through the Javascript code. I'm just curious, where did you find the condition responsible for this, that the comma escapes through the "eye of the needle" ? – birgire Jan 6 '15 at 19:24
  • I already checked that one out, but couldn't see the comma solution from that. So that's why I started to look at the javascript. – birgire Jan 6 '15 at 19:31
  • 1
    Yes, it should work. I've tested in the settings argument of wp_editor() and also work. See edited answer. – cybmeta Jan 6 '15 at 19:56
  • 1
    Ah, that comma thing is a bug in "wp-includes/js/quicktags.js", line 263 if ( settings.buttons ) { should be if ( typeof settings.buttons === 'string' ) {, otherwise a blank qtInit buttons setting gets ignored. – bonger Jan 6 '15 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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