[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
Tue Nov 24 06:10:52 UTC 2020


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

 * keywords:  has-patch => has-patch needs-refresh


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:

 Patch no longer applies cleanly.

-- 
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