diff --git src/wp-admin/customize.php src/wp-admin/customize.php
index 425af6f..20c95aa 100644
|
|
|
do_action( 'customize_controls_print_scripts' ); |
| 235 | 235 | 'mobile' => wp_is_mobile(), |
| 236 | 236 | 'ios' => $is_ios, |
| 237 | 237 | ), |
| 238 | | 'settings' => array(), |
| 239 | | 'controls' => array(), |
| 240 | 238 | 'panels' => array(), |
| 241 | 239 | 'sections' => array(), |
| 242 | 240 | 'nonce' => array( |
| … |
… |
do_action( 'customize_controls_print_scripts' ); |
| 247 | 245 | 'documentTitleTmpl' => $document_title_tmpl, |
| 248 | 246 | ); |
| 249 | 247 | |
| 250 | | // Prepare Customize Setting objects to pass to JavaScript. |
| 251 | | foreach ( $wp_customize->settings() as $id => $setting ) { |
| 252 | | if ( $setting->check_capabilities() ) { |
| 253 | | $settings['settings'][ $id ] = array( |
| 254 | | 'value' => $setting->js_value(), |
| 255 | | 'transport' => $setting->transport, |
| 256 | | 'dirty' => $setting->dirty, |
| 257 | | ); |
| 258 | | } |
| 259 | | } |
| 260 | | |
| 261 | | // Prepare Customize Control objects to pass to JavaScript. |
| 262 | | foreach ( $wp_customize->controls() as $id => $control ) { |
| 263 | | if ( $control->check_capabilities() ) { |
| 264 | | $settings['controls'][ $id ] = $control->json(); |
| 265 | | } |
| 266 | | } |
| 267 | | |
| 268 | 248 | // Prepare Customize Section objects to pass to JavaScript. |
| 269 | 249 | foreach ( $wp_customize->sections() as $id => $section ) { |
| 270 | 250 | if ( $section->check_capabilities() ) { |
| … |
… |
do_action( 'customize_controls_print_scripts' ); |
| 289 | 269 | $autofocus = wp_unslash( $_GET['autofocus'] ); |
| 290 | 270 | if ( is_array( $autofocus ) ) { |
| 291 | 271 | foreach ( $autofocus as $type => $id ) { |
| 292 | | if ( isset( $settings[ $type . 's' ][ $id ] ) ) { |
| | 272 | $can_autofocus = ( |
| | 273 | ( 'control' === $type && $wp_customize->get_control( $id ) && $wp_customize->get_control( $id )->check_capabilities() ) |
| | 274 | || |
| | 275 | ( 'section' === $type && $wp_customize->get_section( $id ) && $wp_customize->get_section( $id )->check_capabilities() ) |
| | 276 | || |
| | 277 | ( 'panel' === $type && $wp_customize->get_panel( $id ) && $wp_customize->get_panel( $id )->check_capabilities() ) |
| | 278 | ); |
| | 279 | if ( $can_autofocus ) { |
| 293 | 280 | $settings['autofocus'][ $type ] = $id; |
| 294 | 281 | } |
| 295 | 282 | } |
| … |
… |
do_action( 'customize_controls_print_scripts' ); |
| 299 | 286 | ?> |
| 300 | 287 | <script type="text/javascript"> |
| 301 | 288 | var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>; |
| | 289 | _wpCustomizeSettings.controls = {}; |
| | 290 | _wpCustomizeSettings.settings = {}; |
| | 291 | <?php |
| | 292 | |
| | 293 | // Serialize settings one by one to improve memory usage. |
| | 294 | echo "(function ( s ){\n"; |
| | 295 | foreach ( $wp_customize->settings() as $setting ) { |
| | 296 | if ( $setting->check_capabilities() ) { |
| | 297 | printf( |
| | 298 | "s[%s] = %s;\n", |
| | 299 | wp_json_encode( $setting->id ), |
| | 300 | wp_json_encode( array( |
| | 301 | 'value' => $setting->js_value(), |
| | 302 | 'transport' => $setting->transport, |
| | 303 | 'dirty' => $setting->dirty, |
| | 304 | ) ) |
| | 305 | ); |
| | 306 | } |
| | 307 | } |
| | 308 | echo "})( _wpCustomizeSettings.settings );\n"; |
| | 309 | |
| | 310 | // Serialize controls one by one to improve memory usage. |
| | 311 | echo "(function ( c ){\n"; |
| | 312 | foreach ( $wp_customize->controls() as $control ) { |
| | 313 | if ( $control->check_capabilities() ) { |
| | 314 | printf( |
| | 315 | "c[%s] = %s;\n", |
| | 316 | wp_json_encode( $control->id ), |
| | 317 | wp_json_encode( $control->json() ) |
| | 318 | ); |
| | 319 | } |
| | 320 | } |
| | 321 | echo "})( _wpCustomizeSettings.controls );\n"; |
| | 322 | ?> |
| 302 | 323 | </script> |
| 303 | 324 | </div> |
| 304 | 325 | </body> |