Improve/introduce Customizer JavaScript models for Controls, Sections, and Panels.
* Introduce models for panels and sections. * Introduce API to expand and focus a control, section or panel. * Allow deep-linking to panels, sections, and controls inside of the Customizer. * Clean up `accordion.js`, removing all Customizer-specific logic. * Add initial unit tests for `wp.customize.Class` in `customize-base.js`. https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/ provides an overview of how to use the JavaScript API. props westonruter, celloexpressions, ryankienstra. see #28032, #28579, #28580, #28650, #28709, #29758. fixes #29529. Built from https://develop.svn.wordpress.org/trunk@30102 git-svn-id: http://core.svn.wordpress.org/trunk@30102 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -498,6 +498,8 @@ final class WP_Customize_Manager {
|
||||
$settings = array(
|
||||
'values' => array(),
|
||||
'channel' => wp_unslash( $_POST['customize_messenger_channel'] ),
|
||||
'activePanels' => array(),
|
||||
'activeSections' => array(),
|
||||
'activeControls' => array(),
|
||||
);
|
||||
|
||||
@@ -511,6 +513,12 @@ final class WP_Customize_Manager {
|
||||
foreach ( $this->settings as $id => $setting ) {
|
||||
$settings['values'][ $id ] = $setting->js_value();
|
||||
}
|
||||
foreach ( $this->panels as $id => $panel ) {
|
||||
$settings['activePanels'][ $id ] = $panel->active();
|
||||
}
|
||||
foreach ( $this->sections as $id => $section ) {
|
||||
$settings['activeSections'][ $id ] = $section->active();
|
||||
}
|
||||
foreach ( $this->controls as $id => $control ) {
|
||||
$settings['activeControls'][ $id ] = $control->active();
|
||||
}
|
||||
@@ -911,11 +919,11 @@ final class WP_Customize_Manager {
|
||||
|
||||
if ( ! $section->panel ) {
|
||||
// Top-level section.
|
||||
$sections[] = $section;
|
||||
$sections[ $section->id ] = $section;
|
||||
} else {
|
||||
// This section belongs to a panel.
|
||||
if ( isset( $this->panels [ $section->panel ] ) ) {
|
||||
$this->panels[ $section->panel ]->sections[] = $section;
|
||||
$this->panels[ $section->panel ]->sections[ $section->id ] = $section;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -932,8 +940,8 @@ final class WP_Customize_Manager {
|
||||
continue;
|
||||
}
|
||||
|
||||
usort( $panel->sections, array( $this, '_cmp_priority' ) );
|
||||
$panels[] = $panel;
|
||||
uasort( $panel->sections, array( $this, '_cmp_priority' ) );
|
||||
$panels[ $panel->id ] = $panel;
|
||||
}
|
||||
$this->panels = $panels;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user