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 wp-customizer 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>
79 <script type="text/javascript">
80 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>';
85 * Print Customizer control styles.
89 do_action( 'customize_controls_print_styles' );
92 * Print Customizer control scripts.
96 do_action( 'customize_controls_print_scripts' );
99 <body class="<?php echo esc_attr( $body_class ); ?>">
100 <div class="wp-full-overlay expanded">
101 <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
103 <div id="customize-header-actions" class="wp-full-overlay-header">
105 $save_text = $wp_customize->is_theme_active() ? __( 'Save & Publish' ) : __( 'Save & Activate' );
106 submit_button( $save_text, 'primary save', 'save', false );
108 <span class="spinner"></span>
109 <a class="back button" href="<?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?>">
110 <?php _e( 'Cancel' ); ?>
115 $screenshot = $wp_customize->theme()->get_screenshot();
116 $cannot_expand = ! ( $screenshot || $wp_customize->theme()->get('Description') );
119 <div class="wp-full-overlay-sidebar-content accordion-container" tabindex="-1">
120 <div id="customize-info" class="accordion-section <?php if ( $cannot_expand ) echo ' cannot-expand'; ?>">
121 <div class="accordion-section-title" aria-label="<?php esc_attr_e( 'Theme Customizer Options' ); ?>" tabindex="0">
122 <span class="preview-notice"><?php
123 /* translators: %s is the theme name in the Customize/Live Preview pane */
124 echo sprintf( __( 'You are previewing %s' ), '<strong class="theme-name">' . $wp_customize->theme()->display('Name') . '</strong>' );
127 <?php if ( ! $cannot_expand ) : ?>
128 <div class="accordion-section-content">
129 <?php if ( $screenshot ) : ?>
130 <img class="theme-screenshot" src="<?php echo esc_url( $screenshot ); ?>" />
133 <?php if ( $wp_customize->theme()->get('Description') ): ?>
134 <div class="theme-description"><?php echo $wp_customize->theme()->display('Description'); ?></div>
140 <div id="customize-theme-controls"><ul>
142 foreach ( $wp_customize->sections() as $section )
143 $section->maybe_render();
148 <div id="customize-footer-actions" class="wp-full-overlay-footer">
149 <a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
150 <span class="collapse-sidebar-arrow"></span>
151 <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
155 <div id="customize-preview" class="wp-full-overlay-main"></div>
159 * Print Customizer control scripts in the footer.
163 do_action( 'customize_controls_print_footer_scripts' );
165 // If the frontend and the admin are served from the same domain, load the
166 // preview over ssl if the customizer is being loaded over ssl. This avoids
167 // insecure content warnings. This is not attempted if the admin and frontend
168 // are on different domains to avoid the case where the frontend doesn't have
169 // ssl certs. Domain mapping plugins can allow other urls in these conditions
170 // using the customize_allowed_urls filter.
172 $allowed_urls = array( home_url('/') );
173 $admin_origin = parse_url( admin_url() );
174 $home_origin = parse_url( home_url() );
175 $cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) );
177 if ( is_ssl() && ! $cross_domain )
178 $allowed_urls[] = home_url( '/', 'https' );
181 * Filter the list of URLs allowed to be clicked and followed in the Customizer preview.
185 * @param array $allowed_urls An array of allowed URLs.
187 $allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) );
189 $fallback_url = add_query_arg( array(
191 'template' => $wp_customize->get_template(),
192 'stylesheet' => $wp_customize->get_stylesheet(),
193 'preview_iframe' => true,
194 'TB_iframe' => 'true'
195 ), home_url( '/' ) );
197 $login_url = add_query_arg( array(
198 'interim-login' => 1,
199 'customize-login' => 1
204 'stylesheet' => $wp_customize->get_stylesheet(),
205 'active' => $wp_customize->is_theme_active(),
208 'preview' => esc_url( $url ? $url : home_url( '/' ) ),
209 'parent' => esc_url( admin_url() ),
210 'activated' => admin_url( 'themes.php?activated=true&previewed' ),
211 'ajax' => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
212 'allowed' => array_map( 'esc_url', $allowed_urls ),
213 'isCrossDomain' => $cross_domain,
214 'fallback' => $fallback_url,
215 'home' => esc_url( home_url( '/' ) ),
216 'login' => $login_url,
219 'mobile' => wp_is_mobile(),
222 'settings' => array(),
223 'controls' => array(),
225 'save' => wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() ),
226 'preview' => wp_create_nonce( 'preview-customize_' . $wp_customize->get_stylesheet() )
230 foreach ( $wp_customize->settings() as $id => $setting ) {
231 $settings['settings'][ $id ] = array(
232 'value' => $setting->js_value(),
233 'transport' => $setting->transport,
237 foreach ( $wp_customize->controls() as $id => $control ) {
239 $settings['controls'][ $id ] = $control->json;
243 <script type="text/javascript">
244 var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;