_wp_customize_loader_settings

Adds settings for the customize-loader script.

Description

_wp_customize_loader_settings(); 

Usage

  1. if ( !function_exists( '_wp_customize_loader_settings' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = _wp_customize_loader_settings(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/theme.php  
  1. function _wp_customize_loader_settings() { 
  2. $admin_origin = parse_url( admin_url() ); 
  3. $home_origin = parse_url( home_url() ); 
  4. $cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) ); 
  5.  
  6. $browser = array( 
  7. 'mobile' => wp_is_mobile(),  
  8. 'ios' => wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] ),  
  9. ); 
  10.  
  11. $settings = array( 
  12. 'url' => esc_url( admin_url( 'customize.php' ) ),  
  13. 'isCrossDomain' => $cross_domain,  
  14. 'browser' => $browser,  
  15. 'l10n' => array( 
  16. 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),  
  17. 'mainIframeTitle' => __( 'Customizer' ),  
  18. ),  
  19. ); 
  20.  
  21. $script = 'var _wpCustomizeLoaderSettings = ' . wp_json_encode( $settings ) . ';'; 
  22.  
  23. $wp_scripts =wp_scripts); 
  24. $data = $wp_scripts->get_data( 'customize-loader', 'data' ); 
  25. if ( $data ) 
  26. $script = "$data\n$script"; 
  27.  
  28. $wp_scripts->add_data( 'customize-loader', 'data', $script );