]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/customize.php
WordPress 4.5
[autoinstalls/wordpress.git] / wp-admin / customize.php
1 <?php
2 /**
3  * Theme Customize Screen.
4  *
5  * @package WordPress
6  * @subpackage Customize
7  * @since 3.4.0
8  */
9
10 define( 'IFRAME_REQUEST', true );
11
12 /** Load WordPress Administration Bootstrap */
13 require_once( dirname( __FILE__ ) . '/admin.php' );
14
15 if ( ! current_user_can( 'customize' ) ) {
16         wp_die(
17                 '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
18                 '<p>' . __( 'You are not allowed to customize the appearance of this site.' ) . '</p>',
19                 403
20         );
21 }
22
23 wp_reset_vars( array( 'url', 'return', 'autofocus' ) );
24 if ( ! empty( $url ) ) {
25         $wp_customize->set_preview_url( wp_unslash( $url ) );
26 }
27 if ( ! empty( $return ) ) {
28         $wp_customize->set_return_url( wp_unslash( $return ) );
29 }
30 if ( ! empty( $autofocus ) && is_array( $autofocus ) ) {
31         $wp_customize->set_autofocus( wp_unslash( $autofocus ) );
32 }
33
34 /**
35  * @global WP_Scripts           $wp_scripts
36  * @global WP_Customize_Manager $wp_customize
37  */
38 global $wp_scripts, $wp_customize;
39
40 $registered = $wp_scripts->registered;
41 $wp_scripts = new WP_Scripts;
42 $wp_scripts->registered = $registered;
43
44 add_action( 'customize_controls_print_scripts',        'print_head_scripts', 20 );
45 add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts'     );
46 add_action( 'customize_controls_print_styles',         'print_admin_styles', 20 );
47
48 /**
49  * Fires when Customizer controls are initialized, before scripts are enqueued.
50  *
51  * @since 3.4.0
52  */
53 do_action( 'customize_controls_init' );
54
55 wp_enqueue_script( 'customize-controls' );
56 wp_enqueue_style( 'customize-controls' );
57
58 /**
59  * Enqueue Customizer control scripts.
60  *
61  * @since 3.4.0
62  */
63 do_action( 'customize_controls_enqueue_scripts' );
64
65 // Let's roll.
66 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
67
68 wp_user_settings();
69 _wp_admin_html_begin();
70
71 $body_class = 'wp-core-ui wp-customizer js';
72
73 if ( wp_is_mobile() ) :
74         $body_class .= ' mobile';
75
76         ?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=1.2" /><?php
77 endif;
78
79 if ( $wp_customize->is_ios() ) {
80         $body_class .= ' ios';
81 }
82
83 if ( is_rtl() ) {
84         $body_class .= ' rtl';
85 }
86 $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
87
88 $admin_title = sprintf( $wp_customize->get_document_title_template(), __( 'Loading&hellip;' ) );
89
90 ?><title><?php echo $admin_title; ?></title>
91
92 <script type="text/javascript">
93 var ajaxurl = <?php echo wp_json_encode( admin_url( 'admin-ajax.php', 'relative' ) ); ?>;
94 </script>
95
96 <?php
97 /**
98  * Fires when Customizer control styles are printed.
99  *
100  * @since 3.4.0
101  */
102 do_action( 'customize_controls_print_styles' );
103
104 /**
105  * Fires when Customizer control scripts are printed.
106  *
107  * @since 3.4.0
108  */
109 do_action( 'customize_controls_print_scripts' );
110 ?>
111 </head>
112 <body class="<?php echo esc_attr( $body_class ); ?>">
113 <div class="wp-full-overlay expanded">
114         <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
115                 <div id="customize-header-actions" class="wp-full-overlay-header">
116                         <?php
117                         $save_text = $wp_customize->is_theme_active() ? __( 'Save &amp; Publish' ) : __( 'Save &amp; Activate' );
118                         submit_button( $save_text, 'primary save', 'save', false );
119                         ?>
120                         <span class="spinner"></span>
121                         <a class="customize-controls-preview-toggle" href="#">
122                                 <span class="controls"><?php _e( 'Customize' ); ?></span>
123                                 <span class="preview"><?php _e( 'Preview' ); ?></span>
124                         </a>
125                         <a class="customize-controls-close" href="<?php echo esc_url( $wp_customize->get_return_url() ); ?>">
126                                 <span class="screen-reader-text"><?php _e( 'Cancel' ); ?></span>
127                         </a>
128                 </div>
129
130                 <div id="widgets-right" class="wp-clearfix"><!-- For Widget Customizer, many widgets try to look for instances under div#widgets-right, so we have to add that ID to a container div in the Customizer for compat -->
131                 <div class="wp-full-overlay-sidebar-content" tabindex="-1">
132                         <div id="customize-info" class="accordion-section customize-info">
133                                 <div class="accordion-section-title">
134                                         <span class="preview-notice"><?php
135                                                 echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title site-title">' . get_bloginfo( 'name' ) . '</strong>' );
136                                         ?></span>
137                                         <button class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button>
138                                 </div>
139                                 <div class="customize-panel-description"><?php
140                                         _e( 'The Customizer allows you to preview changes to your site before publishing them. You can also navigate to different pages on your site to preview them.' );
141                                 ?></div>
142                         </div>
143
144                         <div id="customize-theme-controls">
145                                 <ul><?php // Panels and sections are managed here via JavaScript ?></ul>
146                         </div>
147                 </div>
148                 </div>
149
150                 <div id="customize-footer-actions" class="wp-full-overlay-footer">
151                         <?php $previewable_devices = $wp_customize->get_previewable_devices(); ?>
152                         <?php if ( ! empty( $previewable_devices ) ) : ?>
153                         <div class="devices">
154                                 <?php foreach ( (array) $previewable_devices as $device => $settings ) : ?>
155                                         <?php
156                                         if ( empty( $settings['label'] ) ) {
157                                                 continue;
158                                         }
159                                         $active = ! empty( $settings['default'] );
160                                         $class = 'preview-' . $device;
161                                         if ( $active ) {
162                                                 $class .= ' active';
163                                         }
164                                         ?>
165                                         <button type="button" class="<?php echo esc_attr( $class ); ?>" aria-pressed="<?php echo esc_attr( $active ) ?>" data-device="<?php echo esc_attr( $device ); ?>">
166                                                 <span class="screen-reader-text"><?php echo esc_html( $settings['label'] ); ?></span>
167                                         </button>
168                                 <?php endforeach; ?>
169                         </div>
170                         <?php endif; ?>
171                         <button type="button" class="collapse-sidebar button-secondary" aria-expanded="true" aria-label="<?php esc_attr_e( 'Collapse Sidebar' ); ?>">
172                                 <span class="collapse-sidebar-arrow"></span>
173                                 <span class="collapse-sidebar-label"><?php _e( 'Collapse' ); ?></span>
174                         </button>
175                 </div>
176         </form>
177         <div id="customize-preview" class="wp-full-overlay-main"></div>
178         <?php
179
180         /**
181          * Print templates, control scripts, and settings in the footer.
182          *
183          * @since 3.4.0
184          */
185         do_action( 'customize_controls_print_footer_scripts' );
186         ?>
187 </div>
188 </body>
189 </html>