6 * @subpackage Customize
10 require_once( './admin.php' );
11 if ( ! current_user_can( 'edit_theme_options' ) )
12 wp_die( __( 'Cheatin’ uh?' ) );
14 wp_reset_vars( array( 'url', 'return' ) );
15 $url = urldecode( $url );
16 $url = wp_validate_redirect( $url, home_url( '/' ) );
18 $return = wp_validate_redirect( urldecode( $return ) );
22 global $wp_scripts, $wp_customize;
24 $registered = $wp_scripts->registered;
25 $wp_scripts = new WP_Scripts;
26 $wp_scripts->registered = $registered;
28 add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 );
29 add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' );
30 add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 );
32 do_action( 'customize_controls_init' );
34 wp_enqueue_script( 'customize-controls' );
35 wp_enqueue_style( 'customize-controls' );
37 do_action( 'customize_controls_enqueue_scripts' );
40 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
43 _wp_admin_html_begin();
47 if ( wp_is_mobile() ) :
48 $body_class .= ' mobile';
50 ?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=0.8, minimum-scale=0.5, maximum-scale=1.2"><?php
53 $is_ios = wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] );
56 $body_class .= ' ios';
58 $admin_title = sprintf( __( '%1$s — WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $wp_customize->theme()->display('Name') ) ) );
59 ?><title><?php echo $admin_title; ?></title><?php
61 do_action( 'customize_controls_print_styles' );
62 do_action( 'customize_controls_print_scripts' );
65 <body class="<?php echo esc_attr( $body_class ); ?>">
66 <div class="wp-full-overlay expanded">
67 <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
68 <?php wp_nonce_field( 'customize_controls-' . $wp_customize->get_stylesheet() ); ?>
69 <div id="customize-header-actions" class="wp-full-overlay-header">
71 $save_text = $wp_customize->is_theme_active() ? __( 'Save & Publish' ) : __( 'Save & Activate' );
72 submit_button( $save_text, 'primary', 'save', false );
74 <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
75 <a class="back button" href="<?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?>">
76 <?php _e( 'Cancel' ); ?>
81 $screenshot = $wp_customize->theme()->get_screenshot();
82 $cannot_expand = ! ( $screenshot || $wp_customize->theme()->get('Description') );
85 <div class="wp-full-overlay-sidebar-content">
86 <div id="customize-info" class="customize-section<?php if ( $cannot_expand ) echo ' cannot-expand'; ?>">
87 <div class="customize-section-title">
88 <span class="preview-notice"><?php
89 /* translators: %s is the theme name in the Customize/Live Preview pane */
90 echo sprintf( __( 'You are previewing %s' ), '<strong class="theme-name">' . $wp_customize->theme()->display('Name') . '</strong>' );
93 <?php if ( ! $cannot_expand ) : ?>
94 <div class="customize-section-content">
95 <?php if ( $screenshot ) : ?>
96 <img class="theme-screenshot" src="<?php echo esc_url( $screenshot ); ?>" />
99 <?php if ( $wp_customize->theme()->get('Description') ): ?>
100 <div class="theme-description"><?php echo $wp_customize->theme()->display('Description'); ?></div>
106 <div id="customize-theme-controls"><ul>
108 foreach ( $wp_customize->sections() as $section )
109 $section->maybe_render();
114 <div id="customize-footer-actions" class="wp-full-overlay-footer">
115 <a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
116 <span class="collapse-sidebar-arrow"></span>
117 <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
121 <div id="customize-preview" class="wp-full-overlay-main"></div>
124 do_action( 'customize_controls_print_footer_scripts' );
126 // If the frontend and the admin are served from the same domain, load the
127 // preview over ssl if the customizer is being loaded over ssl. This avoids
128 // insecure content warnings. This is not attempted if the admin and frontend
129 // are on different domains to avoid the case where the frontend doesn't have
130 // ssl certs. Domain mapping plugins can allow other urls in these conditions
131 // using the customize_allowed_urls filter.
133 $allowed_urls = array( home_url('/') );
134 $admin_origin = parse_url( admin_url() );
135 $home_origin = parse_url( home_url() );
136 $cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) );
138 if ( is_ssl() && ! $cross_domain )
139 $allowed_urls[] = home_url( '/', 'https' );
141 $allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) );
143 $fallback_url = add_query_arg( array(
145 'template' => $wp_customize->get_template(),
146 'stylesheet' => $wp_customize->get_stylesheet(),
147 'preview_iframe' => true,
148 'TB_iframe' => 'true'
149 ), home_url( '/' ) );
151 $login_url = add_query_arg( array(
152 'interim-login' => 1,
153 'customize-login' => 1
158 'stylesheet' => $wp_customize->get_stylesheet(),
159 'active' => $wp_customize->is_theme_active(),
162 'preview' => esc_url( $url ? $url : home_url( '/' ) ),
163 'parent' => esc_url( admin_url() ),
164 'activated' => admin_url( 'themes.php?activated=true&previewed' ),
165 'ajax' => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
166 'allowed' => array_map( 'esc_url', $allowed_urls ),
167 'isCrossDomain' => $cross_domain,
168 'fallback' => $fallback_url,
169 'home' => esc_url( home_url( '/' ) ),
170 'login' => $login_url,
173 'mobile' => wp_is_mobile(),
176 'settings' => array(),
177 'controls' => array(),
180 foreach ( $wp_customize->settings() as $id => $setting ) {
181 $settings['settings'][ $id ] = array(
182 'value' => $setting->js_value(),
183 'transport' => $setting->transport,
187 foreach ( $wp_customize->controls() as $id => $control ) {
189 $settings['controls'][ $id ] = $control->json;
193 <script type="text/javascript">
194 var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;