+ $settings['controls'][ $id ] = $control->json();
+ }
+
+ // Prepare Customize Section objects to pass to JavaScript.
+ foreach ( $wp_customize->sections() as $id => $section ) {
+ $settings['sections'][ $id ] = $section->json();
+ }
+
+ // Prepare Customize Panel objects to pass to JavaScript.
+ foreach ( $wp_customize->panels() as $id => $panel ) {
+ $settings['panels'][ $id ] = $panel->json();
+ foreach ( $panel->sections as $section_id => $section ) {
+ $settings['sections'][ $section_id ] = $section->json();
+ }
+ }
+
+ // Pass to frontend the Customizer construct being deeplinked
+ if ( isset( $_GET['autofocus'] ) ) {
+ $autofocus = wp_unslash( $_GET['autofocus'] );
+ if ( is_array( $autofocus ) ) {
+ foreach ( $autofocus as $type => $id ) {
+ if ( isset( $settings[ $type . 's' ][ $id ] ) ) {
+ $settings['autofocus'][ $type ] = $id;
+ }
+ }
+ }