6 * @subpackage Customize
10 define( 'IFRAME_REQUEST', true );
12 require_once( dirname( __FILE__ ) . '/admin.php' );
13 if ( ! current_user_can( 'edit_theme_options' ) )
14 wp_die( __( 'Cheatin’ uh?' ) );
16 wp_reset_vars( array( 'url', 'return' ) );
17 $url = urldecode( $url );
18 $url = wp_validate_redirect( $url, home_url( '/' ) );
20 $return = wp_validate_redirect( urldecode( $return ) );
24 global $wp_scripts, $wp_customize;
26 $registered = $wp_scripts->registered;
27 $wp_scripts = new WP_Scripts;
28 $wp_scripts->registered = $registered;
30 add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 );
31 add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' );
32 add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 );
35 * Fires when Customizer controls are initialized, before scripts are enqueued.
39 do_action( 'customize_controls_init' );
41 wp_enqueue_script( 'customize-controls' );
42 wp_enqueue_style( 'customize-controls' );
44 wp_enqueue_script( 'accordion' );
47 * Enqueue Customizer control scripts.
51 do_action( 'customize_controls_enqueue_scripts' );
54 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
57 _wp_admin_html_begin();
59 $body_class = 'wp-core-ui js';
61 if ( wp_is_mobile() ) :
62 $body_class .= ' mobile';
64 ?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=0.8, minimum-scale=0.5, maximum-scale=1.2"><?php
67 $is_ios = wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] );
70 $body_class .= ' ios';
73 $body_class .= ' rtl';
74 $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
76 $admin_title = sprintf( __( '%1$s — WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $wp_customize->theme()->display('Name') ) ) );
77 ?><title><?php echo $admin_title; ?></title><?php
80 * Print Customizer control styles.
84 do_action( 'customize_controls_print_styles' );
87 * Print Customizer control scripts.
91 do_action( 'customize_controls_print_scripts' );
94 <body class="<?php echo esc_attr( $body_class ); ?>">
95 <div class="wp-full-overlay expanded">
96 <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
98 <div id="customize-header-actions" class="wp-full-overlay-header">
100 $save_text = $wp_customize->is_theme_active() ? __( 'Save & Publish' ) : __( 'Save & Activate' );
101 submit_button( $save_text, 'primary save', 'save', false );
103 <span class="spinner"></span>
104 <a class="back button" href="<?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?>">
105 <?php _e( 'Cancel' ); ?>
110 $screenshot = $wp_customize->theme()->get_screenshot();
111 $cannot_expand = ! ( $screenshot || $wp_customize->theme()->get('Description') );
114 <div class="wp-full-overlay-sidebar-content accordion-container" tabindex="-1">
115 <div id="customize-info" class="accordion-section <?php if ( $cannot_expand ) echo ' cannot-expand'; ?>">
116 <div class="accordion-section-title" aria-label="<?php esc_attr_e( 'Theme Customizer Options' ); ?>" tabindex="0">
117 <span class="preview-notice"><?php
118 /* translators: %s is the theme name in the Customize/Live Preview pane */
119 echo sprintf( __( 'You are previewing %s' ), '<strong class="theme-name">' . $wp_customize->theme()->display('Name') . '</strong>' );
122 <?php if ( ! $cannot_expand ) : ?>
123 <div class="accordion-section-content">
124 <?php if ( $screenshot ) : ?>
125 <img class="theme-screenshot" src="<?php echo esc_url( $screenshot ); ?>" />
128 <?php if ( $wp_customize->theme()->get('Description') ): ?>
129 <div class="theme-description"><?php echo $wp_customize->theme()->display('Description'); ?></div>
135 <div id="customize-theme-controls"><ul>
137 foreach ( $wp_customize->sections() as $section )
138 $section->maybe_render();
143 <div id="customize-footer-actions" class="wp-full-overlay-footer">
144 <a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
145 <span class="collapse-sidebar-arrow"></span>
146 <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
150 <div id="customize-preview" class="wp-full-overlay-main"></div>
154 * Print Customizer control scripts in the footer.
158 do_action( 'customize_controls_print_footer_scripts' );
160 // If the frontend and the admin are served from the same domain, load the
161 // preview over ssl if the customizer is being loaded over ssl. This avoids
162 // insecure content warnings. This is not attempted if the admin and frontend
163 // are on different domains to avoid the case where the frontend doesn't have
164 // ssl certs. Domain mapping plugins can allow other urls in these conditions
165 // using the customize_allowed_urls filter.
167 $allowed_urls = array( home_url('/') );
168 $admin_origin = parse_url( admin_url() );
169 $home_origin = parse_url( home_url() );
170 $cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) );
172 if ( is_ssl() && ! $cross_domain )
173 $allowed_urls[] = home_url( '/', 'https' );
176 * Filter the list of URLs allowed to be clicked and followed in the Customizer preview.
180 * @param array $allowed_urls An array of allowed URLs.
182 $allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) );
184 $fallback_url = add_query_arg( array(
186 'template' => $wp_customize->get_template(),
187 'stylesheet' => $wp_customize->get_stylesheet(),
188 'preview_iframe' => true,
189 'TB_iframe' => 'true'
190 ), home_url( '/' ) );
192 $login_url = add_query_arg( array(
193 'interim-login' => 1,
194 'customize-login' => 1
199 'stylesheet' => $wp_customize->get_stylesheet(),
200 'active' => $wp_customize->is_theme_active(),
203 'preview' => esc_url( $url ? $url : home_url( '/' ) ),
204 'parent' => esc_url( admin_url() ),
205 'activated' => admin_url( 'themes.php?activated=true&previewed' ),
206 'ajax' => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
207 'allowed' => array_map( 'esc_url', $allowed_urls ),
208 'isCrossDomain' => $cross_domain,
209 'fallback' => $fallback_url,
210 'home' => esc_url( home_url( '/' ) ),
211 'login' => $login_url,
214 'mobile' => wp_is_mobile(),
217 'settings' => array(),
218 'controls' => array(),
220 'save' => wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() ),
221 'preview' => wp_create_nonce( 'preview-customize_' . $wp_customize->get_stylesheet() )
225 foreach ( $wp_customize->settings() as $id => $setting ) {
226 $settings['settings'][ $id ] = array(
227 'value' => $setting->js_value(),
228 'transport' => $setting->transport,
232 foreach ( $wp_customize->controls() as $id => $control ) {
234 $settings['controls'][ $id ] = $control->json;
238 <script type="text/javascript">
239 var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;