[wp-trac] [WordPress Trac] #30737: JS templates for Customizer Panels and Sections

WordPress Trac noreply at wordpress.org
Wed Jan 21 00:43:53 UTC 2015


#30737: JS templates for Customizer Panels and Sections
------------------------------+------------------
 Reporter:  celloexpressions  |       Owner:
     Type:  enhancement       |      Status:  new
 Priority:  high              |   Milestone:  4.2
Component:  Customize         |     Version:  4.1
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |     Focuses:
------------------------------+------------------

Comment (by westonruter):

 What about adding to the QUnit tests to check that the new methods work as
 expected?

 Nevermind that we currently don't have any PHPUnit tests at all for
 `WP_Customize_Manager` or `WP_Customize_Control` ;-P

 Also, in the case where a panel/section/control's `check_capabilities()`
 returns `false` resulting in the `json()` method returning `null`, how
 will this affect `_wpCustomizeSettings` in `customize.php` which is passed
 into the JS boot logic? There will be panels/sections/controls in that are
 `null`.

 From looking at `customize-controls.js`, it seems it would try to pass
 `null` into the constructor, and it would even throw a `Null is not an
 object` error when attempting `api.panelConstructor[ data.type ]`. See
 https://github.com/xwp/wordpress-
 develop/blob/2b4099c6bd5faa4b99436ab404279699ffc442f9/src/wp-admin/js
 /customize-controls.js#L2023-L2055


 Should the logic instead be moved to `customize.php`, for instance:

 {{{
         // Prepare Customize Control objects to pass to JavaScript.
         foreach ( $wp_customize->controls() as $id => $control ) {
                 if ( $control->check_capabilities() ) { // this
 conditional added
                         $settings['controls'][ $id ] = $control->json();
                 }
         }
 }}}

 Really, however, that whole blob of logic in `customize.php` should be
 moved to a new method on `WP_Customize_Manager`, like
 `WP_Customize_Manager::get_configuration()`

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


More information about the wp-trac mailing list