]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/customize.php
WordPress 3.6.1
[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 define( 'IFRAME_REQUEST', true );
11
12 require_once( './admin.php' );
13 if ( ! current_user_can( 'edit_theme_options' ) )
14         wp_die( __( 'Cheatin&#8217; uh?' ) );
15
16 wp_reset_vars( array( 'url', 'return' ) );
17 $url = urldecode( $url );
18 $url = wp_validate_redirect( $url, home_url( '/' ) );
19 if ( $return )
20         $return = wp_validate_redirect( urldecode( $return ) );
21 if ( ! $return )
22         $return = $url;
23
24 global $wp_scripts, $wp_customize;
25
26 $registered = $wp_scripts->registered;
27 $wp_scripts = new WP_Scripts;
28 $wp_scripts->registered = $registered;
29
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 );
33
34 do_action( 'customize_controls_init' );
35
36 wp_enqueue_script( 'customize-controls' );
37 wp_enqueue_style( 'customize-controls' );
38
39 wp_enqueue_script( 'accordion' );
40
41 do_action( 'customize_controls_enqueue_scripts' );
42
43 // Let's roll.
44 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
45
46 wp_user_settings();
47 _wp_admin_html_begin();
48
49 $body_class = 'wp-core-ui js';
50
51 if ( wp_is_mobile() ) :
52         $body_class .= ' mobile';
53
54         ?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=0.8, minimum-scale=0.5, maximum-scale=1.2"><?php
55 endif;
56
57 $is_ios = wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] );
58
59 if ( $is_ios )
60         $body_class .= ' ios';
61
62 if ( is_rtl() )
63         $body_class .=  ' rtl';
64 $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
65
66 $admin_title = sprintf( __( '%1$s &#8212; WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $wp_customize->theme()->display('Name') ) ) );
67 ?><title><?php echo $admin_title; ?></title><?php
68
69 do_action( 'customize_controls_print_styles' );
70 do_action( 'customize_controls_print_scripts' );
71 ?>
72 </head>
73 <body class="<?php echo esc_attr( $body_class ); ?>">
74 <div class="wp-full-overlay expanded">
75         <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
76
77                 <div id="customize-header-actions" class="wp-full-overlay-header">
78                         <?php
79                                 $save_text = $wp_customize->is_theme_active() ? __( 'Save &amp; Publish' ) : __( 'Save &amp; Activate' );
80                                 submit_button( $save_text, 'primary save', 'save', false );
81                         ?>
82                         <span class="spinner"></span>
83                         <a class="back button" href="<?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?>">
84                                 <?php _e( 'Cancel' ); ?>
85                         </a>
86                 </div>
87
88                 <?php
89                         $screenshot = $wp_customize->theme()->get_screenshot();
90                         $cannot_expand = ! ( $screenshot || $wp_customize->theme()->get('Description') );
91                 ?>
92
93                 <div class="wp-full-overlay-sidebar-content accordion-container" tabindex="-1">
94                         <div id="customize-info" class="accordion-section <?php if ( $cannot_expand ) echo ' cannot-expand'; ?>">
95                                 <div class="accordion-section-title" aria-label="<?php esc_attr_e( 'Theme Customizer Options' ); ?>" tabindex="0">
96                                         <span class="preview-notice"><?php
97                                                 /* translators: %s is the theme name in the Customize/Live Preview pane */
98                                                 echo sprintf( __( 'You are previewing %s' ), '<strong class="theme-name">' . $wp_customize->theme()->display('Name') . '</strong>' );
99                                         ?></span>
100                                 </div>
101                                 <?php if ( ! $cannot_expand ) : ?>
102                                 <div class="accordion-section-content">
103                                         <?php if ( $screenshot ) : ?>
104                                                 <img class="theme-screenshot" src="<?php echo esc_url( $screenshot ); ?>" />
105                                         <?php endif; ?>
106
107                                         <?php if ( $wp_customize->theme()->get('Description') ): ?>
108                                                 <div class="theme-description"><?php echo $wp_customize->theme()->display('Description'); ?></div>
109                                         <?php endif; ?>
110                                 </div>
111                                 <?php endif; ?>
112                         </div>
113
114                         <div id="customize-theme-controls"><ul>
115                                 <?php
116                                 foreach ( $wp_customize->sections() as $section )
117                                         $section->maybe_render();
118                                 ?>
119                         </ul></div>
120                 </div>
121
122                 <div id="customize-footer-actions" class="wp-full-overlay-footer">
123                         <a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
124                                 <span class="collapse-sidebar-arrow"></span>
125                                 <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
126                         </a>
127                 </div>
128         </form>
129         <div id="customize-preview" class="wp-full-overlay-main"></div>
130         <?php
131
132         do_action( 'customize_controls_print_footer_scripts' );
133
134         // If the frontend and the admin are served from the same domain, load the
135         // preview over ssl if the customizer is being loaded over ssl. This avoids
136         // insecure content warnings. This is not attempted if the admin and frontend
137         // are on different domains to avoid the case where the frontend doesn't have
138         // ssl certs. Domain mapping plugins can allow other urls in these conditions
139         // using the customize_allowed_urls filter.
140
141         $allowed_urls = array( home_url('/') );
142         $admin_origin = parse_url( admin_url() );
143         $home_origin  = parse_url( home_url() );
144         $cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) );
145
146         if ( is_ssl() && ! $cross_domain )
147                 $allowed_urls[] = home_url( '/', 'https' );
148
149         $allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) );
150
151         $fallback_url = add_query_arg( array(
152                 'preview'        => 1,
153                 'template'       => $wp_customize->get_template(),
154                 'stylesheet'     => $wp_customize->get_stylesheet(),
155                 'preview_iframe' => true,
156                 'TB_iframe'      => 'true'
157         ), home_url( '/' ) );
158
159         $login_url = add_query_arg( array(
160                 'interim-login' => 1,
161                 'customize-login' => 1
162         ), wp_login_url() );
163
164         $settings = array(
165                 'theme'    => array(
166                         'stylesheet' => $wp_customize->get_stylesheet(),
167                         'active'     => $wp_customize->is_theme_active(),
168                 ),
169                 'url'      => array(
170                         'preview'       => esc_url( $url ? $url : home_url( '/' ) ),
171                         'parent'        => esc_url( admin_url() ),
172                         'activated'     => admin_url( 'themes.php?activated=true&previewed' ),
173                         'ajax'          => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
174                         'allowed'       => array_map( 'esc_url', $allowed_urls ),
175                         'isCrossDomain' => $cross_domain,
176                         'fallback'      => $fallback_url,
177                         'home'          => esc_url( home_url( '/' ) ),
178                         'login'         => $login_url,
179                 ),
180                 'browser'  => array(
181                         'mobile' => wp_is_mobile(),
182                         'ios'    => $is_ios,
183                 ),
184                 'settings' => array(),
185                 'controls' => array(),
186                 'nonce'    => array(
187                         'save'    => wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() ),
188                         'preview' => wp_create_nonce( 'preview-customize_' . $wp_customize->get_stylesheet() )
189                 ),
190         );
191
192         foreach ( $wp_customize->settings() as $id => $setting ) {
193                 $settings['settings'][ $id ] = array(
194                         'value'     => $setting->js_value(),
195                         'transport' => $setting->transport,
196                 );
197         }
198
199         foreach ( $wp_customize->controls() as $id => $control ) {
200                 $control->to_json();
201                 $settings['controls'][ $id ] = $control->json;
202         }
203
204         ?>
205         <script type="text/javascript">
206                 var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;
207         </script>
208 </div>
209 </body>
210 </html>