[wp-trac] [WordPress Trac] #30942: In quicktags settings, setting buttons to zero-length string doesn't give empty toolbar.

WordPress Trac noreply at wordpress.org
Fri Jan 4 10:51:45 UTC 2019


#30942: In quicktags settings, setting buttons to zero-length string doesn't give
empty toolbar.
--------------------------+----------------------
 Reporter:  gitlost       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Editor        |     Version:  4.1
 Severity:  normal        |  Resolution:  wontfix
 Keywords:  has-patch     |     Focuses:
--------------------------+----------------------
Changes (by iseulde):

 * status:  new => closed
 * resolution:   => wontfix
 * milestone:  Awaiting Review =>


Old description:

> This issue was raised on Wordpress stackexchange
> http://wordpress.stackexchange.com/a/174086/57034.
>
> If you set the buttons of the quicktags settings to a zero-length string,
> eg by using the `'quicktags_settings'` filter
> {{{
>         add_filter( 'quicktags_settings', function ( $qtInit ) {
>                 $qtInit['buttons'] = '';
>                 return $qtInit;
>         } );
> }}}
>
> which typically results in the following setting in `tinyMCEPreInit`
>
> {{{
> qtInit: {'content': id:"content",buttons:""},'replycontent':
> id:"replycontent",buttons:""}}
> }}}
>
> then quicktags just ignores it and uses the default buttons, due to this
> falsey test on line 263 of "wp-includes/js/quicktags.js"
> {{{
>                         if ( settings.buttons ) {
>                                 use = ','+settings.buttons+',';
>                         }
> }}}
>
> This can be worked around by using any non-falsey value in setting
> `$qtInit['buttons']` but that's somewhat non-intuitive. The proposed
> simple patch tests for string type so you can use `''` (and also tests
> for boolean `false` which is nice to have as well).
> {{{
>                         if ( typeof settings.buttons === 'string' ) {
>                                 use = ','+settings.buttons+',';
>                         } else if ( settings.buttons === false ) {
>                                 use = ' '; // Any old truthy string.
>                         }
>
> }}}

New description:

 This issue was raised on WordPress stackexchange
 http://wordpress.stackexchange.com/a/174086/57034.

 If you set the buttons of the quicktags settings to a zero-length string,
 eg by using the `'quicktags_settings'` filter
 {{{
         add_filter( 'quicktags_settings', function ( $qtInit ) {
                 $qtInit['buttons'] = '';
                 return $qtInit;
         } );
 }}}

 which typically results in the following setting in `tinyMCEPreInit`

 {{{
 qtInit: {'content': id:"content",buttons:""},'replycontent':
 id:"replycontent",buttons:""}}
 }}}

 then quicktags just ignores it and uses the default buttons, due to this
 falsey test on line 263 of "wp-includes/js/quicktags.js"
 {{{
                         if ( settings.buttons ) {
                                 use = ','+settings.buttons+',';
                         }
 }}}

 This can be worked around by using any non-falsey value in setting
 `$qtInit['buttons']` but that's somewhat non-intuitive. The proposed
 simple patch tests for string type so you can use `''` (and also tests for
 boolean `false` which is nice to have as well).
 {{{
                         if ( typeof settings.buttons === 'string' ) {
                                 use = ','+settings.buttons+',';
                         } else if ( settings.buttons === false ) {
                                 use = ' '; // Any old truthy string.
                         }

 }}}

--

Comment:

 This is no longer relevant after the merge of the block editor. Let's
 preserve the way it's currently built for the old editor.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/30942#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list