6 * @subpackage Customize
10 define( 'IFRAME_REQUEST', true );
12 require_once( './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 );
34 do_action( 'customize_controls_init' );
36 wp_enqueue_script( 'customize-controls' );
37 wp_enqueue_style( 'customize-controls' );
39 do_action( 'customize_controls_enqueue_scripts' );
42 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
45 _wp_admin_html_begin();
49 if ( wp_is_mobile() ) :
50 $body_class .= ' mobile';
52 ?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=0.8, minimum-scale=0.5, maximum-scale=1.2"><?php
55 $is_ios = wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] );
58 $body_class .= ' ios';
60 $admin_title = sprintf( __( '%1$s — WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $wp_customize->theme()->display('Name') ) ) );
61 ?><title><?php echo $admin_title; ?></title><?php
63 do_action( 'customize_controls_print_styles' );
64 do_action( 'customize_controls_print_scripts' );
67 <body class="<?php echo esc_attr( $body_class ); ?>">
68 <div class="wp-full-overlay expanded">
69 <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
70 <div id="customize-header-actions" class="wp-full-overlay-header">
72 $save_text = $wp_customize->is_theme_active() ? __( 'Save & Publish' ) : __( 'Save & Activate' );
73 submit_button( $save_text, 'primary', 'save', false );
75 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
76 <a class="back button" href="<?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?>">
77 <?php _e( 'Cancel' ); ?>
82 $screenshot = $wp_customize->theme()->get_screenshot();
83 $cannot_expand = ! ( $screenshot || $wp_customize->theme()->get('Description') );
86 <div class="wp-full-overlay-sidebar-content">
87 <div id="customize-info" class="customize-section<?php if ( $cannot_expand ) echo ' cannot-expand'; ?>">
88 <div class="customize-section-title">
89 <span class="preview-notice"><?php
90 /* translators: %s is the theme name in the Customize/Live Preview pane */
91 echo sprintf( __( 'You are previewing %s' ), '<strong class="theme-name">' . $wp_customize->theme()->display('Name') . '</strong>' );
94 <?php if ( ! $cannot_expand ) : ?>
95 <div class="customize-section-content">
96 <?php if ( $screenshot ) : ?>
97 <img class="theme-screenshot" src="<?php echo esc_url( $screenshot ); ?>" />
100 <?php if ( $wp_customize->theme()->get('Description') ): ?>
101 <div class="theme-description"><?php echo $wp_customize->theme()->display('Description'); ?></div>
107 <div id="customize-theme-controls"><ul>
109 foreach ( $wp_customize->sections() as $section )
110 $section->maybe_render();
115 <div id="customize-footer-actions" class="wp-full-overlay-footer">
116 <a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
117 <span class="collapse-sidebar-arrow"></span>
118 <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
122 <div id="customize-preview" class="wp-full-overlay-main"></div>
125 do_action( 'customize_controls_print_footer_scripts' );
127 // If the frontend and the admin are served from the same domain, load the
128 // preview over ssl if the customizer is being loaded over ssl. This avoids
129 // insecure content warnings. This is not attempted if the admin and frontend
130 // are on different domains to avoid the case where the frontend doesn't have
131 // ssl certs. Domain mapping plugins can allow other urls in these conditions
132 // using the customize_allowed_urls filter.
134 $allowed_urls = array( home_url('/') );
135 $admin_origin = parse_url( admin_url() );
136 $home_origin = parse_url( home_url() );
137 $cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) );
139 if ( is_ssl() && ! $cross_domain )
140 $allowed_urls[] = home_url( '/', 'https' );
142 $allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) );
144 $fallback_url = add_query_arg( array(
146 'template' => $wp_customize->get_template(),
147 'stylesheet' => $wp_customize->get_stylesheet(),
148 'preview_iframe' => true,
149 'TB_iframe' => 'true'
150 ), home_url( '/' ) );
152 $login_url = add_query_arg( array(
153 'interim-login' => 1,
154 'customize-login' => 1
159 'stylesheet' => $wp_customize->get_stylesheet(),
160 'active' => $wp_customize->is_theme_active(),
163 'preview' => esc_url( $url ? $url : home_url( '/' ) ),
164 'parent' => esc_url( admin_url() ),
165 'activated' => admin_url( 'themes.php?activated=true&previewed' ),
166 'ajax' => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
167 'allowed' => array_map( 'esc_url', $allowed_urls ),
168 'isCrossDomain' => $cross_domain,
169 'fallback' => $fallback_url,
170 'home' => esc_url( home_url( '/' ) ),
171 'login' => $login_url,
174 'mobile' => wp_is_mobile(),
177 'settings' => array(),
178 'controls' => array(),
180 'save' => wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() ),
181 'preview' => wp_create_nonce( 'preview-customize_' . $wp_customize->get_stylesheet() )
185 foreach ( $wp_customize->settings() as $id => $setting ) {
186 $settings['settings'][ $id ] = array(
187 'value' => $setting->js_value(),
188 'transport' => $setting->transport,
192 foreach ( $wp_customize->controls() as $id => $control ) {
194 $settings['controls'][ $id ] = $control->json;
198 <script type="text/javascript">
199 var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;