]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/customize.php
WordPress 4.7.1
[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>' . __( 'Sorry, you are not allowed to customize this site.' ) . '</p>',
19                 403
20         );
21 }
22
23 /**
24  * @global WP_Scripts           $wp_scripts
25  * @global WP_Customize_Manager $wp_customize
26  */
27 global $wp_scripts, $wp_customize;
28
29 if ( $wp_customize->changeset_post_id() ) {
30         if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $wp_customize->changeset_post_id() ) ) {
31                 wp_die(
32                         '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
33                         '<p>' . __( 'Sorry, you are not allowed to edit this changeset.' ) . '</p>',
34                         403
35                 );
36         }
37         if ( in_array( get_post_status( $wp_customize->changeset_post_id() ), array( 'publish', 'trash' ), true ) ) {
38                 wp_die(
39                         '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
40                         '<p>' . __( 'This changeset has already been published and cannot be further modified.' ) . '</p>' .
41                         '<p><a href="' . esc_url( remove_query_arg( 'changeset_uuid' ) ) . '">' . __( 'Customize New Changes' ) . '</a></p>',
42                         403
43                 );
44         }
45 }
46
47
48 wp_reset_vars( array( 'url', 'return', 'autofocus' ) );
49 if ( ! empty( $url ) ) {
50         $wp_customize->set_preview_url( wp_unslash( $url ) );
51 }
52 if ( ! empty( $return ) ) {
53         $wp_customize->set_return_url( wp_unslash( $return ) );
54 }
55 if ( ! empty( $autofocus ) && is_array( $autofocus ) ) {
56         $wp_customize->set_autofocus( wp_unslash( $autofocus ) );
57 }
58
59 $registered = $wp_scripts->registered;
60 $wp_scripts = new WP_Scripts;
61 $wp_scripts->registered = $registered;
62
63 add_action( 'customize_controls_print_scripts',        'print_head_scripts', 20 );
64 add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts'     );
65 add_action( 'customize_controls_print_styles',         'print_admin_styles', 20 );
66
67 /**
68  * Fires when Customizer controls are initialized, before scripts are enqueued.
69  *
70  * @since 3.4.0
71  */
72 do_action( 'customize_controls_init' );
73
74 wp_enqueue_script( 'customize-controls' );
75 wp_enqueue_style( 'customize-controls' );
76
77 /**
78  * Enqueue Customizer control scripts.
79  *
80  * @since 3.4.0
81  */
82 do_action( 'customize_controls_enqueue_scripts' );
83
84 // Let's roll.
85 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
86
87 wp_user_settings();
88 _wp_admin_html_begin();
89
90 $body_class = 'wp-core-ui wp-customizer js';
91
92 if ( wp_is_mobile() ) :
93         $body_class .= ' mobile';
94
95         ?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=1.2" /><?php
96 endif;
97
98 if ( $wp_customize->is_ios() ) {
99         $body_class .= ' ios';
100 }
101
102 if ( is_rtl() ) {
103         $body_class .= ' rtl';
104 }
105 $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
106
107 $admin_title = sprintf( $wp_customize->get_document_title_template(), __( 'Loading&hellip;' ) );
108
109 ?><title><?php echo $admin_title; ?></title>
110
111 <script type="text/javascript">
112 var ajaxurl = <?php echo wp_json_encode( admin_url( 'admin-ajax.php', 'relative' ) ); ?>;
113 </script>
114
115 <?php
116 /**
117  * Fires when Customizer control styles are printed.
118  *
119  * @since 3.4.0
120  */
121 do_action( 'customize_controls_print_styles' );
122
123 /**
124  * Fires when Customizer control scripts are printed.
125  *
126  * @since 3.4.0
127  */
128 do_action( 'customize_controls_print_scripts' );
129 ?>
130 </head>
131 <body class="<?php echo esc_attr( $body_class ); ?>">
132 <div class="wp-full-overlay expanded">
133         <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
134                 <div id="customize-header-actions" class="wp-full-overlay-header">
135                         <?php
136                         $save_text = $wp_customize->is_theme_active() ? __( 'Save &amp; Publish' ) : __( 'Save &amp; Activate' );
137                         $save_attrs = array();
138                         if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->publish_posts ) ) {
139                                 $save_attrs['style'] = 'display: none';
140                         }
141                         submit_button( $save_text, 'primary save', 'save', false, $save_attrs );
142                         ?>
143                         <span class="spinner"></span>
144                         <button type="button" class="customize-controls-preview-toggle">
145                                 <span class="controls"><?php _e( 'Customize' ); ?></span>
146                                 <span class="preview"><?php _e( 'Preview' ); ?></span>
147                         </button>
148                         <a class="customize-controls-close" href="<?php echo esc_url( $wp_customize->get_return_url() ); ?>">
149                                 <span class="screen-reader-text"><?php _e( 'Close the Customizer and go back to the previous page' ); ?></span>
150                         </a>
151                 </div>
152
153                 <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 -->
154                 <div class="wp-full-overlay-sidebar-content" tabindex="-1">
155                         <div id="customize-info" class="accordion-section customize-info">
156                                 <div class="accordion-section-title">
157                                         <span class="preview-notice"><?php
158                                                 echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title site-title">' . get_bloginfo( 'name' ) . '</strong>' );
159                                         ?></span>
160                                         <button type="button" class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button>
161                                 </div>
162                                 <div class="customize-panel-description"><?php
163                                         _e( 'The Customizer allows you to preview changes to your site before publishing them. You can navigate to different pages on your site within the preview. Edit shortcuts are shown for some editable elements.' );
164                                 ?></div>
165                         </div>
166
167                         <div id="customize-theme-controls">
168                                 <ul class="customize-pane-parent"><?php // Panels and sections are managed here via JavaScript ?></ul>
169                         </div>
170                 </div>
171                 </div>
172
173                 <div id="customize-footer-actions" class="wp-full-overlay-footer">
174                         <?php $previewable_devices = $wp_customize->get_previewable_devices(); ?>
175                         <?php if ( ! empty( $previewable_devices ) ) : ?>
176                         <div class="devices">
177                                 <?php foreach ( (array) $previewable_devices as $device => $settings ) : ?>
178                                         <?php
179                                         if ( empty( $settings['label'] ) ) {
180                                                 continue;
181                                         }
182                                         $active = ! empty( $settings['default'] );
183                                         $class = 'preview-' . $device;
184                                         if ( $active ) {
185                                                 $class .= ' active';
186                                         }
187                                         ?>
188                                         <button type="button" class="<?php echo esc_attr( $class ); ?>" aria-pressed="<?php echo esc_attr( $active ) ?>" data-device="<?php echo esc_attr( $device ); ?>">
189                                                 <span class="screen-reader-text"><?php echo esc_html( $settings['label'] ); ?></span>
190                                         </button>
191                                 <?php endforeach; ?>
192                         </div>
193                         <?php endif; ?>
194                         <button type="button" class="collapse-sidebar button" aria-expanded="true" aria-label="<?php echo esc_attr( _x( 'Hide Controls', 'label for hide controls button without length constraints' ) ); ?>">
195                                 <span class="collapse-sidebar-arrow"></span>
196                                 <span class="collapse-sidebar-label"><?php _ex( 'Hide Controls', 'short (~12 characters) label for hide controls button' ); ?></span>
197                         </button>
198                 </div>
199         </form>
200         <div id="customize-preview" class="wp-full-overlay-main"></div>
201         <?php
202
203         /**
204          * Prints templates, control scripts, and settings in the footer.
205          *
206          * @since 3.4.0
207          */
208         do_action( 'customize_controls_print_footer_scripts' );
209         ?>
210 </div>
211 </body>
212 </html>