]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/customize.php
WordPress 3.4
[autoinstalls/wordpress.git] / wp-admin / customize.php
1 <?php
2 /**
3  * Customize Controls
4  *
5  * @package WordPress
6  * @subpackage Customize
7  * @since 3.4.0
8  */
9
10 require_once( './admin.php' );
11 if ( ! current_user_can( 'edit_theme_options' ) )
12         wp_die( __( 'Cheatin&#8217; uh?' ) );
13
14 wp_reset_vars( array( 'url', 'return' ) );
15 $url = urldecode( $url );
16 $url = wp_validate_redirect( $url, home_url( '/' ) );
17 if ( $return )
18         $return = wp_validate_redirect( urldecode( $return ) );
19 if ( ! $return )
20         $return = $url;
21
22 global $wp_scripts, $wp_customize;
23
24 $registered = $wp_scripts->registered;
25 $wp_scripts = new WP_Scripts;
26 $wp_scripts->registered = $registered;
27
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 );
31
32 do_action( 'customize_controls_init' );
33
34 wp_enqueue_script( 'customize-controls' );
35 wp_enqueue_style( 'customize-controls' );
36
37 do_action( 'customize_controls_enqueue_scripts' );
38
39 // Let's roll.
40 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
41
42 wp_user_settings();
43 _wp_admin_html_begin();
44
45 $body_class = '';
46
47 if ( wp_is_mobile() ) :
48         $body_class .= ' mobile';
49
50         ?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=0.8, minimum-scale=0.5, maximum-scale=1.2"><?php
51 endif;
52
53 $is_ios = wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] );
54
55 if ( $is_ios )
56         $body_class .= ' ios';
57
58 $admin_title = sprintf( __( '%1$s &#8212; WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $wp_customize->theme()->display('Name') ) ) );
59 ?><title><?php echo $admin_title; ?></title><?php
60
61 do_action( 'customize_controls_print_styles' );
62 do_action( 'customize_controls_print_scripts' );
63 ?>
64 </head>
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">
70                         <?php
71                                 $save_text = $wp_customize->is_theme_active() ? __( 'Save &amp; Publish' ) : __( 'Save &amp; Activate' );
72                                 submit_button( $save_text, 'primary', 'save', false );
73                         ?>
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' ); ?>
77                         </a>
78                 </div>
79
80                 <?php
81                         $screenshot = $wp_customize->theme()->get_screenshot();
82                         $cannot_expand = ! ( $screenshot || $wp_customize->theme()->get('Description') );
83                 ?>
84
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>' );
91                                         ?></span>
92                                 </div>
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 ); ?>" />
97                                         <?php endif; ?>
98
99                                         <?php if ( $wp_customize->theme()->get('Description') ): ?>
100                                                 <div class="theme-description"><?php echo $wp_customize->theme()->display('Description'); ?></div>
101                                         <?php endif; ?>
102                                 </div>
103                                 <?php endif; ?>
104                         </div>
105
106                         <div id="customize-theme-controls"><ul>
107                                 <?php
108                                 foreach ( $wp_customize->sections() as $section )
109                                         $section->maybe_render();
110                                 ?>
111                         </ul></div>
112                 </div>
113
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>
118                         </a>
119                 </div>
120         </form>
121         <div id="customize-preview" class="wp-full-overlay-main"></div>
122         <?php
123
124         do_action( 'customize_controls_print_footer_scripts' );
125
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.
132
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' ] ) );
137
138         if ( is_ssl() && ! $cross_domain )
139                 $allowed_urls[] = home_url( '/', 'https' );
140
141         $allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) );
142
143         $fallback_url = add_query_arg( array(
144                 'preview'        => 1,
145                 'template'       => $wp_customize->get_template(),
146                 'stylesheet'     => $wp_customize->get_stylesheet(),
147                 'preview_iframe' => true,
148                 'TB_iframe'      => 'true'
149         ), home_url( '/' ) );
150
151         $login_url = add_query_arg( array(
152                 'interim-login' => 1,
153                 'customize-login' => 1
154         ), wp_login_url() );
155
156         $settings = array(
157                 'theme'    => array(
158                         'stylesheet' => $wp_customize->get_stylesheet(),
159                         'active'     => $wp_customize->is_theme_active(),
160                 ),
161                 'url'      => array(
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,
171                 ),
172                 'browser'  => array(
173                         'mobile' => wp_is_mobile(),
174                         'ios'    => $is_ios,
175                 ),
176                 'settings' => array(),
177                 'controls' => array(),
178         );
179
180         foreach ( $wp_customize->settings() as $id => $setting ) {
181                 $settings['settings'][ $id ] = array(
182                         'value'     => $setting->js_value(),
183                         'transport' => $setting->transport,
184                 );
185         }
186
187         foreach ( $wp_customize->controls() as $id => $control ) {
188                 $control->to_json();
189                 $settings['controls'][ $id ] = $control->json;
190         }
191
192         ?>
193         <script type="text/javascript">
194                 var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;
195         </script>
196 </div>
197 </body>
198 </html>