_wp_customize_loader_settings() WordPress Function

The wp_customize_loader_settings() function allows you to customize the settings for the WordPress Customizer Loader. This function is useful for developers who want to override the default Customizer settings.

_wp_customize_loader_settings() #

Adds settings for the customize-loader script.


Source

File: wp-includes/theme.php

3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
function _wp_customize_loader_settings() {
    $admin_origin = parse_url( admin_url() );
    $home_origin  = parse_url( home_url() );
    $cross_domain = ( strtolower( $admin_origin['host'] ) != strtolower( $home_origin['host'] ) );
 
    $browser = array(
        'mobile' => wp_is_mobile(),
        'ios'    => wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] ),
    );
 
    $settings = array(
        'url'           => esc_url( admin_url( 'customize.php' ) ),
        'isCrossDomain' => $cross_domain,
        'browser'       => $browser,
        'l10n'          => array(
            'saveAlert'       => __( 'The changes you made will be lost if you navigate away from this page.' ),
            'mainIframeTitle' => __( 'Customizer' ),
        ),
    );
 
    $script = 'var _wpCustomizeLoaderSettings = ' . wp_json_encode( $settings ) . ';';
 
    $wp_scripts = wp_scripts();
    $data       = $wp_scripts->get_data( 'customize-loader', 'data' );
    if ( $data ) {
        $script = "$data\n$script";
    }
 
    $wp_scripts->add_data( 'customize-loader', 'data', $script );
}


Top ↑

Changelog

Changelog
VersionDescription
3.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.