[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
       
    Wed Jan  7 16:48:16 UTC 2015
    
    
  
#30942: In quicktags settings, setting buttons to zero-length string doesn't give
empty toolbar.
--------------------------+-----------------------------
 Reporter:  gitlost       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Editor        |    Version:  4.1
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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.
                         }
 }}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30942>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
    
    
More information about the wp-trac
mailing list