Opened 12 years ago
Closed 12 years ago
#25238 closed defect (bug) (fixed)
Ensure parity between JS and PHP calculation of theme customizer control IDs
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.7 | Priority: | normal |
Severity: | normal | Version: | 3.5 |
Component: | Customize | Keywords: | has-patch |
Focuses: | Cc: |
Description
Do global search/replace for customize control selector
In WP_Customize_Conrol::render()
, the $id
for a control is constructed via:
$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.
Attachments (1)
Change History (7)
#1
@
12 years ago
- Component changed from Themes to Appearance
- Summary changed from Ensure parity between JS and PHP calculation of theem customizer control IDs to Ensure parity between JS and PHP calculation of theme customizer control IDs
#3
@
12 years ago
Just wanted to mention that the patch for this bug is a dependency for the new Widget Customizer plugin: https://github.com/x-team/wp-widget-customizer
Use RegExp with global flag instead of strings for replacement patterns