180 * @var string |
177 * @var string |
181 */ |
178 */ |
182 private $_screen_settings; |
179 private $_screen_settings; |
183 |
180 |
184 /** |
181 /** |
|
182 * Whether the screen is using the block editor. |
|
183 * |
|
184 * @since 5.0.0 |
|
185 * @var bool |
|
186 */ |
|
187 public $is_block_editor = false; |
|
188 |
|
189 /** |
185 * Fetches a screen object. |
190 * Fetches a screen object. |
186 * |
191 * |
187 * @since 3.3.0 |
192 * @since 3.3.0 |
188 * |
193 * |
189 * @static |
|
190 * |
|
191 * @global string $hook_suffix |
194 * @global string $hook_suffix |
192 * |
195 * |
193 * @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen. |
196 * @param string|WP_Screen $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen. |
194 * Defaults to the current $hook_suffix global. |
197 * Defaults to the current $hook_suffix global. |
195 * @return WP_Screen Screen object. |
198 * @return WP_Screen Screen object. |
196 */ |
199 */ |
197 public static function get( $hook_name = '' ) { |
200 public static function get( $hook_name = '' ) { |
198 if ( $hook_name instanceof WP_Screen ) { |
201 if ( $hook_name instanceof WP_Screen ) { |
199 return $hook_name; |
202 return $hook_name; |
200 } |
203 } |
201 |
204 |
202 $post_type = $taxonomy = null; |
205 $post_type = $taxonomy = null; |
203 $in_admin = false; |
206 $in_admin = false; |
204 $action = ''; |
207 $action = ''; |
205 |
208 $is_block_editor = false; |
206 if ( $hook_name ) |
209 |
|
210 if ( $hook_name ) { |
207 $id = $hook_name; |
211 $id = $hook_name; |
208 else |
212 } else { |
209 $id = $GLOBALS['hook_suffix']; |
213 $id = $GLOBALS['hook_suffix']; |
|
214 } |
210 |
215 |
211 // For those pesky meta boxes. |
216 // For those pesky meta boxes. |
212 if ( $hook_name && post_type_exists( $hook_name ) ) { |
217 if ( $hook_name && post_type_exists( $hook_name ) ) { |
213 $post_type = $id; |
218 $post_type = $id; |
214 $id = 'post'; // changes later. ends up being $base. |
219 $id = 'post'; // changes later. ends up being $base. |
215 } else { |
220 } else { |
216 if ( '.php' == substr( $id, -4 ) ) |
221 if ( '.php' == substr( $id, -4 ) ) { |
217 $id = substr( $id, 0, -4 ); |
222 $id = substr( $id, 0, -4 ); |
|
223 } |
218 |
224 |
219 if ( 'post-new' == $id || 'link-add' == $id || 'media-new' == $id || 'user-new' == $id ) { |
225 if ( 'post-new' == $id || 'link-add' == $id || 'media-new' == $id || 'user-new' == $id ) { |
220 $id = substr( $id, 0, -4 ); |
226 $id = substr( $id, 0, -4 ); |
221 $action = 'add'; |
227 $action = 'add'; |
222 } |
228 } |
223 } |
229 } |
224 |
230 |
225 if ( ! $post_type && $hook_name ) { |
231 if ( ! $post_type && $hook_name ) { |
226 if ( '-network' == substr( $id, -8 ) ) { |
232 if ( '-network' == substr( $id, -8 ) ) { |
227 $id = substr( $id, 0, -8 ); |
233 $id = substr( $id, 0, -8 ); |
228 $in_admin = 'network'; |
234 $in_admin = 'network'; |
229 } elseif ( '-user' == substr( $id, -5 ) ) { |
235 } elseif ( '-user' == substr( $id, -5 ) ) { |
230 $id = substr( $id, 0, -5 ); |
236 $id = substr( $id, 0, -5 ); |
231 $in_admin = 'user'; |
237 $in_admin = 'user'; |
232 } |
238 } |
233 |
239 |
234 $id = sanitize_key( $id ); |
240 $id = sanitize_key( $id ); |
235 if ( 'edit-comments' != $id && 'edit-tags' != $id && 'edit-' == substr( $id, 0, 5 ) ) { |
241 if ( 'edit-comments' != $id && 'edit-tags' != $id && 'edit-' == substr( $id, 0, 5 ) ) { |
236 $maybe = substr( $id, 5 ); |
242 $maybe = substr( $id, 5 ); |
237 if ( taxonomy_exists( $maybe ) ) { |
243 if ( taxonomy_exists( $maybe ) ) { |
238 $id = 'edit-tags'; |
244 $id = 'edit-tags'; |
239 $taxonomy = $maybe; |
245 $taxonomy = $maybe; |
240 } elseif ( post_type_exists( $maybe ) ) { |
246 } elseif ( post_type_exists( $maybe ) ) { |
241 $id = 'edit'; |
247 $id = 'edit'; |
242 $post_type = $maybe; |
248 $post_type = $maybe; |
243 } |
249 } |
244 } |
250 } |
245 |
251 |
246 if ( ! $in_admin ) |
252 if ( ! $in_admin ) { |
247 $in_admin = 'site'; |
253 $in_admin = 'site'; |
|
254 } |
248 } else { |
255 } else { |
249 if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) |
256 if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) { |
250 $in_admin = 'network'; |
257 $in_admin = 'network'; |
251 elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN ) |
258 } elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN ) { |
252 $in_admin = 'user'; |
259 $in_admin = 'user'; |
253 else |
260 } else { |
254 $in_admin = 'site'; |
261 $in_admin = 'site'; |
255 } |
262 } |
256 |
263 } |
257 if ( 'index' == $id ) |
264 |
|
265 if ( 'index' == $id ) { |
258 $id = 'dashboard'; |
266 $id = 'dashboard'; |
259 elseif ( 'front' == $id ) |
267 } elseif ( 'front' == $id ) { |
260 $in_admin = false; |
268 $in_admin = false; |
|
269 } |
261 |
270 |
262 $base = $id; |
271 $base = $id; |
263 |
272 |
264 // If this is the current screen, see if we can be more accurate for post types and taxonomies. |
273 // If this is the current screen, see if we can be more accurate for post types and taxonomies. |
265 if ( ! $hook_name ) { |
274 if ( ! $hook_name ) { |
266 if ( isset( $_REQUEST['post_type'] ) ) |
275 if ( isset( $_REQUEST['post_type'] ) ) { |
267 $post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false; |
276 $post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false; |
268 if ( isset( $_REQUEST['taxonomy'] ) ) |
277 } |
|
278 if ( isset( $_REQUEST['taxonomy'] ) ) { |
269 $taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false; |
279 $taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false; |
|
280 } |
270 |
281 |
271 switch ( $base ) { |
282 switch ( $base ) { |
272 case 'post' : |
283 case 'post': |
273 if ( isset( $_GET['post'] ) ) |
284 if ( isset( $_GET['post'] ) && isset( $_POST['post_ID'] ) && (int) $_GET['post'] !== (int) $_POST['post_ID'] ) { |
|
285 wp_die( __( 'A post ID mismatch has been detected.' ), __( 'Sorry, you are not allowed to edit this item.' ), 400 ); |
|
286 } elseif ( isset( $_GET['post'] ) ) { |
274 $post_id = (int) $_GET['post']; |
287 $post_id = (int) $_GET['post']; |
275 elseif ( isset( $_POST['post_ID'] ) ) |
288 } elseif ( isset( $_POST['post_ID'] ) ) { |
276 $post_id = (int) $_POST['post_ID']; |
289 $post_id = (int) $_POST['post_ID']; |
277 else |
290 } else { |
278 $post_id = 0; |
291 $post_id = 0; |
|
292 } |
279 |
293 |
280 if ( $post_id ) { |
294 if ( $post_id ) { |
281 $post = get_post( $post_id ); |
295 $post = get_post( $post_id ); |
282 if ( $post ) |
296 if ( $post ) { |
283 $post_type = $post->post_type; |
297 $post_type = $post->post_type; |
|
298 |
|
299 /** This filter is documented in wp-admin/post.php */ |
|
300 $replace_editor = apply_filters( 'replace_editor', false, $post ); |
|
301 |
|
302 if ( ! $replace_editor ) { |
|
303 $is_block_editor = use_block_editor_for_post( $post ); |
|
304 } |
|
305 } |
284 } |
306 } |
285 break; |
307 break; |
286 case 'edit-tags' : |
308 case 'edit-tags': |
287 case 'term' : |
309 case 'term': |
288 if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) |
310 if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) { |
289 $post_type = 'post'; |
311 $post_type = 'post'; |
|
312 } |
290 break; |
313 break; |
291 case 'upload': |
314 case 'upload': |
292 $post_type = 'attachment'; |
315 $post_type = 'attachment'; |
293 break; |
316 break; |
294 } |
317 } |
295 } |
318 } |
296 |
319 |
297 switch ( $base ) { |
320 switch ( $base ) { |
298 case 'post' : |
321 case 'post': |
299 if ( null === $post_type ) |
322 if ( null === $post_type ) { |
300 $post_type = 'post'; |
323 $post_type = 'post'; |
|
324 } |
|
325 |
|
326 // When creating a new post, use the default block editor support value for the post type. |
|
327 if ( empty( $post_id ) ) { |
|
328 $is_block_editor = use_block_editor_for_post_type( $post_type ); |
|
329 } |
|
330 |
301 $id = $post_type; |
331 $id = $post_type; |
302 break; |
332 break; |
303 case 'edit' : |
333 case 'edit': |
304 if ( null === $post_type ) |
334 if ( null === $post_type ) { |
305 $post_type = 'post'; |
335 $post_type = 'post'; |
|
336 } |
306 $id .= '-' . $post_type; |
337 $id .= '-' . $post_type; |
307 break; |
338 break; |
308 case 'edit-tags' : |
339 case 'edit-tags': |
309 case 'term' : |
340 case 'term': |
310 if ( null === $taxonomy ) |
341 if ( null === $taxonomy ) { |
311 $taxonomy = 'post_tag'; |
342 $taxonomy = 'post_tag'; |
|
343 } |
312 // The edit-tags ID does not contain the post type. Look for it in the request. |
344 // The edit-tags ID does not contain the post type. Look for it in the request. |
313 if ( null === $post_type ) { |
345 if ( null === $post_type ) { |
314 $post_type = 'post'; |
346 $post_type = 'post'; |
315 if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) |
347 if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) { |
316 $post_type = $_REQUEST['post_type']; |
348 $post_type = $_REQUEST['post_type']; |
|
349 } |
317 } |
350 } |
318 |
351 |
319 $id = 'edit-' . $taxonomy; |
352 $id = 'edit-' . $taxonomy; |
320 break; |
353 break; |
321 } |
354 } |
391 * @param string $admin The admin to check against (network | user | site). |
426 * @param string $admin The admin to check against (network | user | site). |
392 * If empty any of the three admins will result in true. |
427 * If empty any of the three admins will result in true. |
393 * @return bool True if the screen is in the indicated admin, false otherwise. |
428 * @return bool True if the screen is in the indicated admin, false otherwise. |
394 */ |
429 */ |
395 public function in_admin( $admin = null ) { |
430 public function in_admin( $admin = null ) { |
396 if ( empty( $admin ) ) |
431 if ( empty( $admin ) ) { |
397 return (bool) $this->in_admin; |
432 return (bool) $this->in_admin; |
|
433 } |
398 |
434 |
399 return ( $admin == $this->in_admin ); |
435 return ( $admin == $this->in_admin ); |
400 } |
436 } |
401 |
437 |
402 /** |
438 /** |
|
439 * Sets or returns whether the block editor is loading on the current screen. |
|
440 * |
|
441 * @since 5.0.0 |
|
442 * |
|
443 * @param bool $set Optional. Sets whether the block editor is loading on the current screen or not. |
|
444 * @return bool True if the block editor is being loaded, false otherwise. |
|
445 */ |
|
446 public function is_block_editor( $set = null ) { |
|
447 if ( $set !== null ) { |
|
448 $this->is_block_editor = (bool) $set; |
|
449 } |
|
450 |
|
451 return $this->is_block_editor; |
|
452 } |
|
453 |
|
454 /** |
403 * Sets the old string-based contextual help for the screen for backward compatibility. |
455 * Sets the old string-based contextual help for the screen for backward compatibility. |
404 * |
456 * |
405 * @since 3.3.0 |
457 * @since 3.3.0 |
406 * |
|
407 * @static |
|
408 * |
458 * |
409 * @param WP_Screen $screen A screen object. |
459 * @param WP_Screen $screen A screen object. |
410 * @param string $help Help text. |
460 * @param string $help Help text. |
411 */ |
461 */ |
412 public static function add_old_compat_help( $screen, $help ) { |
462 public static function add_old_compat_help( $screen, $help ) { |
749 * get_current_screen()->remove_help_tab() instead. |
802 * get_current_screen()->remove_help_tab() instead. |
750 * |
803 * |
751 * @param string $old_help_default Default contextual help text. |
804 * @param string $old_help_default Default contextual help text. |
752 */ |
805 */ |
753 $default_help = apply_filters( 'default_contextual_help', '' ); |
806 $default_help = apply_filters( 'default_contextual_help', '' ); |
754 if ( $default_help ) |
807 if ( $default_help ) { |
755 $old_help = '<p>' . $default_help . '</p>'; |
808 $old_help = '<p>' . $default_help . '</p>'; |
|
809 } |
756 } |
810 } |
757 |
811 |
758 if ( $old_help ) { |
812 if ( $old_help ) { |
759 $this->add_help_tab( array( |
813 $this->add_help_tab( |
760 'id' => 'old-contextual-help', |
814 array( |
761 'title' => __('Overview'), |
815 'id' => 'old-contextual-help', |
762 'content' => $old_help, |
816 'title' => __( 'Overview' ), |
763 ) ); |
817 'content' => $old_help, |
|
818 ) |
|
819 ); |
764 } |
820 } |
765 |
821 |
766 $help_sidebar = $this->get_help_sidebar(); |
822 $help_sidebar = $this->get_help_sidebar(); |
767 |
823 |
768 $help_class = 'hidden'; |
824 $help_class = 'hidden'; |
769 if ( ! $help_sidebar ) |
825 if ( ! $help_sidebar ) { |
770 $help_class .= ' no-sidebar'; |
826 $help_class .= ' no-sidebar'; |
|
827 } |
771 |
828 |
772 // Time to render! |
829 // Time to render! |
773 ?> |
830 ?> |
774 <div id="screen-meta" class="metabox-prefs"> |
831 <div id="screen-meta" class="metabox-prefs"> |
775 |
832 |
776 <div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e('Contextual Help Tab'); ?>"> |
833 <div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e( 'Contextual Help Tab' ); ?>"> |
777 <div id="contextual-help-back"></div> |
834 <div id="contextual-help-back"></div> |
778 <div id="contextual-help-columns"> |
835 <div id="contextual-help-columns"> |
779 <div class="contextual-help-tabs"> |
836 <div class="contextual-help-tabs"> |
780 <ul> |
837 <ul> |
781 <?php |
838 <?php |
842 * @param string $screen_id Screen ID. |
900 * @param string $screen_id Screen ID. |
843 * @param WP_Screen $this Current WP_Screen instance. |
901 * @param WP_Screen $this Current WP_Screen instance. |
844 */ |
902 */ |
845 $columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this ); |
903 $columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this ); |
846 |
904 |
847 if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) |
905 if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) ) { |
848 $this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) ); |
906 $this->add_option( 'layout_columns', array( 'max' => $columns[ $this->id ] ) ); |
|
907 } |
849 |
908 |
850 if ( $this->get_option( 'layout_columns' ) ) { |
909 if ( $this->get_option( 'layout_columns' ) ) { |
851 $this->columns = (int) get_user_option("screen_layout_$this->id"); |
910 $this->columns = (int) get_user_option( "screen_layout_$this->id" ); |
852 |
911 |
853 if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) ) |
912 if ( ! $this->columns && $this->get_option( 'layout_columns', 'default' ) ) { |
854 $this->columns = $this->get_option( 'layout_columns', 'default' ); |
913 $this->columns = $this->get_option( 'layout_columns', 'default' ); |
855 } |
914 } |
856 $GLOBALS[ 'screen_layout_columns' ] = $this->columns; // Set the global for back-compat. |
915 } |
|
916 $GLOBALS['screen_layout_columns'] = $this->columns; // Set the global for back-compat. |
857 |
917 |
858 // Add screen options |
918 // Add screen options |
859 if ( $this->show_screen_options() ) |
919 if ( $this->show_screen_options() ) { |
860 $this->render_screen_options(); |
920 $this->render_screen_options(); |
|
921 } |
861 ?> |
922 ?> |
862 </div> |
923 </div> |
863 <?php |
924 <?php |
864 if ( ! $this->get_help_tabs() && ! $this->show_screen_options() ) |
925 if ( ! $this->get_help_tabs() && ! $this->show_screen_options() ) { |
865 return; |
926 return; |
|
927 } |
866 ?> |
928 ?> |
867 <div id="screen-meta-links"> |
929 <div id="screen-meta-links"> |
868 <?php if ( $this->get_help_tabs() ) : ?> |
930 <?php if ( $this->show_screen_options() ) : ?> |
|
931 <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
|
932 <button type="button" id="show-settings-link" class="button show-settings" aria-controls="screen-options-wrap" aria-expanded="false"><?php _e( 'Screen Options' ); ?></button> |
|
933 </div> |
|
934 <?php |
|
935 endif; |
|
936 if ( $this->get_help_tabs() ) : |
|
937 ?> |
869 <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
938 <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
870 <button type="button" id="contextual-help-link" class="button show-settings" aria-controls="contextual-help-wrap" aria-expanded="false"><?php _e( 'Help' ); ?></button> |
939 <button type="button" id="contextual-help-link" class="button show-settings" aria-controls="contextual-help-wrap" aria-expanded="false"><?php _e( 'Help' ); ?></button> |
871 </div> |
|
872 <?php endif; |
|
873 if ( $this->show_screen_options() ) : ?> |
|
874 <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
|
875 <button type="button" id="show-settings-link" class="button show-settings" aria-controls="screen-options-wrap" aria-expanded="false"><?php _e( 'Screen Options' ); ?></button> |
|
876 </div> |
940 </div> |
877 <?php endif; ?> |
941 <?php endif; ?> |
878 </div> |
942 </div> |
879 <?php |
943 <?php |
880 } |
944 } |
881 |
945 |
882 /** |
946 /** |
883 * |
|
884 * @global array $wp_meta_boxes |
947 * @global array $wp_meta_boxes |
885 * |
948 * |
886 * @return bool |
949 * @return bool |
887 */ |
950 */ |
888 public function show_screen_options() { |
951 public function show_screen_options() { |
889 global $wp_meta_boxes; |
952 global $wp_meta_boxes; |
890 |
953 |
891 if ( is_bool( $this->_show_screen_options ) ) |
954 if ( is_bool( $this->_show_screen_options ) ) { |
892 return $this->_show_screen_options; |
955 return $this->_show_screen_options; |
|
956 } |
893 |
957 |
894 $columns = get_column_headers( $this ); |
958 $columns = get_column_headers( $this ); |
895 |
959 |
896 $show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' ); |
960 $show_screen = ! empty( $wp_meta_boxes[ $this->id ] ) || $columns || $this->get_option( 'per_page' ); |
897 |
961 |
898 switch ( $this->base ) { |
962 $this->_screen_settings = ''; |
899 case 'widgets': |
963 |
900 $nonce = wp_create_nonce( 'widgets-access' ); |
964 if ( 'post' === $this->base ) { |
901 $this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on&_wpnonce=' . urlencode( $nonce ) . '">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off&_wpnonce=' . urlencode( $nonce ) . '">' . __('Disable accessibility mode') . "</a></p>\n"; |
965 $expand = '<fieldset class="editor-expand hidden"><legend>' . __( 'Additional settings' ) . '</legend><label for="editor-expand-toggle">'; |
902 break; |
966 $expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />'; |
903 case 'post' : |
967 $expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></fieldset>'; |
904 $expand = '<fieldset class="editor-expand hidden"><legend>' . __( 'Additional settings' ) . '</legend><label for="editor-expand-toggle">'; |
968 $this->_screen_settings = $expand; |
905 $expand .= '<input type="checkbox" id="editor-expand-toggle"' . checked( get_user_setting( 'editor_expand', 'on' ), 'on', false ) . ' />'; |
|
906 $expand .= __( 'Enable full-height editor and distraction-free functionality.' ) . '</label></fieldset>'; |
|
907 $this->_screen_settings = $expand; |
|
908 break; |
|
909 default: |
|
910 $this->_screen_settings = ''; |
|
911 break; |
|
912 } |
969 } |
913 |
970 |
914 /** |
971 /** |
915 * Filters the screen settings text displayed in the Screen Options tab. |
972 * Filters the screen settings text displayed in the Screen Options tab. |
916 * |
973 * |
948 * @param array $options { |
1006 * @param array $options { |
949 * @type bool $wrap Whether the screen-options-wrap div will be included. Defaults to true. |
1007 * @type bool $wrap Whether the screen-options-wrap div will be included. Defaults to true. |
950 * } |
1008 * } |
951 */ |
1009 */ |
952 public function render_screen_options( $options = array() ) { |
1010 public function render_screen_options( $options = array() ) { |
953 $options = wp_parse_args( $options, array( |
1011 $options = wp_parse_args( |
954 'wrap' => true, |
1012 $options, |
955 ) ); |
1013 array( |
|
1014 'wrap' => true, |
|
1015 ) |
|
1016 ); |
956 |
1017 |
957 $wrapper_start = $wrapper_end = $form_start = $form_end = ''; |
1018 $wrapper_start = $wrapper_end = $form_start = $form_end = ''; |
958 |
1019 |
959 // Output optional wrapper. |
1020 // Output optional wrapper. |
960 if ( $options['wrap'] ) { |
1021 if ( $options['wrap'] ) { |
961 $wrapper_start = '<div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="' . esc_attr__( 'Screen Options Tab' ) . '">'; |
1022 $wrapper_start = '<div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="' . esc_attr__( 'Screen Options Tab' ) . '">'; |
962 $wrapper_end = '</div>'; |
1023 $wrapper_end = '</div>'; |
963 } |
1024 } |
964 |
1025 |
965 // Don't output the form and nonce for the widgets accessibility mode links. |
1026 // Don't output the form and nonce for the widgets accessibility mode links. |
966 if ( 'widgets' !== $this->base ) { |
1027 if ( 'widgets' !== $this->base ) { |
967 $form_start = "\n<form id='adv-settings' method='post'>\n"; |
1028 $form_start = "\n<form id='adv-settings' method='post'>\n"; |
968 $form_end = "\n" . wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false, false ) . "\n</form>\n"; |
1029 $form_end = "\n" . wp_nonce_field( 'screen-options-nonce', 'screenoptionnonce', false, false ) . "\n</form>\n"; |
969 } |
1030 } |
970 |
1031 |
971 echo $wrapper_start . $form_start; |
1032 echo $wrapper_start . $form_start; |
972 |
1033 |
973 $this->render_meta_boxes_preferences(); |
1034 $this->render_meta_boxes_preferences(); |
1012 <fieldset class="metabox-prefs"> |
1073 <fieldset class="metabox-prefs"> |
1013 <legend><?php _e( 'Boxes' ); ?></legend> |
1074 <legend><?php _e( 'Boxes' ); ?></legend> |
1014 <?php |
1075 <?php |
1015 meta_box_prefs( $this ); |
1076 meta_box_prefs( $this ); |
1016 |
1077 |
1017 if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) { |
1078 if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) { |
1018 if ( isset( $_GET['welcome'] ) ) { |
1079 if ( isset( $_GET['welcome'] ) ) { |
1019 $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1; |
1080 $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1; |
1020 update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); |
1081 update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); |
1021 } else { |
1082 } else { |
1022 $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); |
1083 $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); |
1023 if ( '' === $welcome_checked ) { |
1084 if ( 2 == $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) { |
1024 $welcome_checked = '1'; |
1085 $welcome_checked = false; |
1025 } |
|
1026 if ( '2' === $welcome_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) { |
|
1027 $welcome_checked = false; |
|
1028 } |
|
1029 } |
1086 } |
1030 echo '<label for="wp_welcome_panel-hide">'; |
1087 } |
1031 echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />'; |
1088 echo '<label for="wp_welcome_panel-hide">'; |
1032 echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n"; |
1089 echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked( (bool) $welcome_checked, true, false ) . ' />'; |
1033 } |
1090 echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n"; |
1034 |
1091 } |
1035 if ( 'dashboard' === $this->id && has_action( 'try_gutenberg_panel' ) ) { |
|
1036 if ( isset( $_GET['try_gutenberg'] ) ) { |
|
1037 $try_gutenberg_checked = empty( $_GET['try_gutenberg'] ) ? 0 : 1; |
|
1038 update_user_meta( get_current_user_id(), 'show_try_gutenberg_panel', $try_gutenberg_checked ); |
|
1039 } else { |
|
1040 $try_gutenberg_checked = get_user_meta( get_current_user_id(), 'show_try_gutenberg_panel', true ); |
|
1041 if ( '' === $try_gutenberg_checked ) { |
|
1042 $try_gutenberg_checked = '1'; |
|
1043 } |
|
1044 if ( '2' === $try_gutenberg_checked && wp_get_current_user()->user_email != get_option( 'admin_email' ) ) { |
|
1045 $try_gutenberg_checked = false; |
|
1046 } |
|
1047 } |
|
1048 echo '<label for="wp_try_gutenberg_panel-hide">'; |
|
1049 echo '<input type="checkbox" id="wp_try_gutenberg_panel-hide"' . checked( (bool) $try_gutenberg_checked, true, false ) . ' />'; |
|
1050 echo __( 'New Editor' ) . "</label>\n"; |
|
1051 } |
|
1052 ?> |
1092 ?> |
1053 </fieldset> |
1093 </fieldset> |
1054 <?php |
1094 <?php |
1055 } |
1095 } |
1056 |
1096 |