[wp-trac] [WordPress Trac] #25238: Ensure parity between JS and PHP calculation of theem customizer control IDs

WordPress Trac noreply at wordpress.org
Fri Sep 6 07:28:44 UTC 2013


#25238: Ensure parity between JS and PHP calculation of theem customizer control
IDs
--------------------------+-----------------------------
 Reporter:  westonruter   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Themes        |    Version:  3.5
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Do global search/replace for customize control selector

 In `WP_Customize_Conrol::render()`, the `$id` for a control is constructed
 via:

 {{{#!php
       $id    = 'customize-control-' . str_replace( '[', '-', str_replace(
 ']', '', $this->id ) );
 }}}

 The PHP `str_replace` function does a '''''global''''' replacement. In
 JavaScript, however, if you call the `string.replace()` with a string as
 the pattern argument instead of a RegExp, it will do a '''''single'''''
 replacement instead of a global one. Therefore, RegExp literals with the
 `g` flag must be supplied to ensure that the ID calculated in JS matches
 the ID calculated in PHP.

 If a setting is registered for a multidimensional array, for example
 `myplugin[foo][bar][baz]`, then the field in the Customizer will fail to
 pick up changes because it is not able to find the control's container
 element via the selector.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25238>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list