49 * argument, settings cannot be reliably saved. Some logic short-circuits if the current value is the |
49 * argument, settings cannot be reliably saved. Some logic short-circuits if the current value is the |
50 * same as the value being saved. This is particularly true for options via `update_option()`. |
50 * same as the value being saved. This is particularly true for options via `update_option()`. |
51 * |
51 * |
52 * By opening an Ajax request, this is avoided and the changeset is published. See #39221. |
52 * By opening an Ajax request, this is avoided and the changeset is published. See #39221. |
53 */ |
53 */ |
54 $nonces = $wp_customize->get_nonces(); |
54 $nonces = $wp_customize->get_nonces(); |
55 $request_args = array( |
55 $request_args = array( |
56 'nonce' => $nonces['save'], |
56 'nonce' => $nonces['save'], |
57 'customize_changeset_uuid' => $wp_customize->changeset_uuid(), |
57 'customize_changeset_uuid' => $wp_customize->changeset_uuid(), |
58 'wp_customize' => 'on', |
58 'wp_customize' => 'on', |
59 'customize_changeset_status' => 'publish', |
59 'customize_changeset_status' => 'publish', |
60 ); |
60 ); |
61 ob_start(); |
61 ob_start(); |
62 ?> |
62 ?> |
63 <?php wp_print_scripts( array( 'wp-util' ) ); ?> |
63 <?php wp_print_scripts( array( 'wp-util' ) ); ?> |
94 } |
94 } |
95 if ( ! empty( $autofocus ) && is_array( $autofocus ) ) { |
95 if ( ! empty( $autofocus ) && is_array( $autofocus ) ) { |
96 $wp_customize->set_autofocus( wp_unslash( $autofocus ) ); |
96 $wp_customize->set_autofocus( wp_unslash( $autofocus ) ); |
97 } |
97 } |
98 |
98 |
99 $registered = $wp_scripts->registered; |
99 $registered = $wp_scripts->registered; |
100 $wp_scripts = new WP_Scripts; |
100 $wp_scripts = new WP_Scripts; |
101 $wp_scripts->registered = $registered; |
101 $wp_scripts->registered = $registered; |
102 |
102 |
103 add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 ); |
103 add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 ); |
104 add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' ); |
104 add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' ); |
105 add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 ); |
105 add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 ); |
106 |
106 |
107 /** |
107 /** |
108 * Fires when Customizer controls are initialized, before scripts are enqueued. |
108 * Fires when Customizer controls are initialized, before scripts are enqueued. |
109 * |
109 * |
110 * @since 3.4.0 |
110 * @since 3.4.0 |
121 * @since 3.4.0 |
121 * @since 3.4.0 |
122 */ |
122 */ |
123 do_action( 'customize_controls_enqueue_scripts' ); |
123 do_action( 'customize_controls_enqueue_scripts' ); |
124 |
124 |
125 // Let's roll. |
125 // Let's roll. |
126 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); |
126 @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); |
127 |
127 |
128 wp_user_settings(); |
128 wp_user_settings(); |
129 _wp_admin_html_begin(); |
129 _wp_admin_html_begin(); |
130 |
130 |
131 $body_class = 'wp-core-ui wp-customizer js'; |
131 $body_class = 'wp-core-ui wp-customizer js'; |
132 |
132 |
133 if ( wp_is_mobile() ) : |
133 if ( wp_is_mobile() ) : |
134 $body_class .= ' mobile'; |
134 $body_class .= ' mobile'; |
135 |
135 |
136 ?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=1.2" /><?php |
136 ?> |
|
137 <meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=1.2" /> |
|
138 <?php |
137 endif; |
139 endif; |
138 |
140 |
139 if ( $wp_customize->is_ios() ) { |
141 if ( $wp_customize->is_ios() ) { |
140 $body_class .= ' ios'; |
142 $body_class .= ' ios'; |
141 } |
143 } |
145 } |
147 } |
146 $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) ); |
148 $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) ); |
147 |
149 |
148 $admin_title = sprintf( $wp_customize->get_document_title_template(), __( 'Loading…' ) ); |
150 $admin_title = sprintf( $wp_customize->get_document_title_template(), __( 'Loading…' ) ); |
149 |
151 |
150 ?><title><?php echo $admin_title; ?></title> |
152 ?> |
|
153 <title><?php echo $admin_title; ?></title> |
151 |
154 |
152 <script type="text/javascript"> |
155 <script type="text/javascript"> |
153 var ajaxurl = <?php echo wp_json_encode( admin_url( 'admin-ajax.php', 'relative' ) ); ?>, |
156 var ajaxurl = <?php echo wp_json_encode( admin_url( 'admin-ajax.php', 'relative' ) ); ?>, |
154 pagenow = 'customize'; |
157 pagenow = 'customize'; |
155 </script> |
158 </script> |
200 <ul></ul> |
203 <ul></ul> |
201 </div> |
204 </div> |
202 <div class="wp-full-overlay-sidebar-content" tabindex="-1"> |
205 <div class="wp-full-overlay-sidebar-content" tabindex="-1"> |
203 <div id="customize-info" class="accordion-section customize-info"> |
206 <div id="customize-info" class="accordion-section customize-info"> |
204 <div class="accordion-section-title"> |
207 <div class="accordion-section-title"> |
205 <span class="preview-notice"><?php |
208 <span class="preview-notice"> |
|
209 <?php |
206 echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title site-title">' . get_bloginfo( 'name', 'display' ) . '</strong>' ); |
210 echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title site-title">' . get_bloginfo( 'name', 'display' ) . '</strong>' ); |
207 ?></span> |
211 ?> |
|
212 </span> |
208 <button type="button" class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button> |
213 <button type="button" class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button> |
209 </div> |
214 </div> |
210 <div class="customize-panel-description"><?php |
215 <div class="customize-panel-description"> |
|
216 <?php |
211 _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.' ); |
217 _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.' ); |
212 ?></div> |
218 ?> |
|
219 </div> |
213 </div> |
220 </div> |
214 |
221 |
215 <div id="customize-theme-controls"> |
222 <div id="customize-theme-controls"> |
216 <ul class="customize-pane-parent"><?php // Panels and sections are managed here via JavaScript ?></ul> |
223 <ul class="customize-pane-parent"><?php // Panels and sections are managed here via JavaScript ?></ul> |
217 </div> |
224 </div> |
231 <?php |
238 <?php |
232 if ( empty( $settings['label'] ) ) { |
239 if ( empty( $settings['label'] ) ) { |
233 continue; |
240 continue; |
234 } |
241 } |
235 $active = ! empty( $settings['default'] ); |
242 $active = ! empty( $settings['default'] ); |
236 $class = 'preview-' . $device; |
243 $class = 'preview-' . $device; |
237 if ( $active ) { |
244 if ( $active ) { |
238 $class .= ' active'; |
245 $class .= ' active'; |
239 } |
246 } |
240 ?> |
247 ?> |
241 <button type="button" class="<?php echo esc_attr( $class ); ?>" aria-pressed="<?php echo esc_attr( $active ) ?>" data-device="<?php echo esc_attr( $device ); ?>"> |
248 <button type="button" class="<?php echo esc_attr( $class ); ?>" aria-pressed="<?php echo esc_attr( $active ); ?>" data-device="<?php echo esc_attr( $device ); ?>"> |
242 <span class="screen-reader-text"><?php echo esc_html( $settings['label'] ); ?></span> |
249 <span class="screen-reader-text"><?php echo esc_html( $settings['label'] ); ?></span> |
243 </button> |
250 </button> |
244 <?php endforeach; ?> |
251 <?php endforeach; ?> |
245 </div> |
252 </div> |
246 </div> |
253 </div> |