changeset 204 | 09a1c134465b |
parent 194 | 32102edaa81b |
203:f507feede89a | 204:09a1c134465b |
---|---|
94 |
94 |
95 // Hide slug boxes by default |
95 // Hide slug boxes by default |
96 if ( $use_defaults ) { |
96 if ( $use_defaults ) { |
97 $hidden = array(); |
97 $hidden = array(); |
98 if ( 'post' == $screen->base ) { |
98 if ( 'post' == $screen->base ) { |
99 if ( 'post' == $screen->post_type || 'page' == $screen->post_type ) |
99 if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type ) |
100 $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); |
100 $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv'); |
101 else |
101 else |
102 $hidden = array( 'slugdiv' ); |
102 $hidden = array( 'slugdiv' ); |
103 } |
103 } |
104 $hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen ); |
104 $hidden = apply_filters( 'default_hidden_meta_boxes', $hidden, $screen ); |
242 * @access public |
242 * @access public |
243 */ |
243 */ |
244 public $id; |
244 public $id; |
245 |
245 |
246 /** |
246 /** |
247 * Which admin the screen is in. network | user | site | false |
|
248 * |
|
249 * @since 3.5.0 |
|
250 * @var string |
|
251 * @access protected |
|
252 */ |
|
253 protected $in_admin; |
|
254 |
|
255 /** |
|
247 * Whether the screen is in the network admin. |
256 * Whether the screen is in the network admin. |
248 * |
257 * |
249 * @since 3.3.0 |
258 * Deprecated. Use in_admin() instead. |
259 * |
|
260 * @since 3.3.0 |
|
261 * @deprecated 3.5.0 |
|
250 * @var bool |
262 * @var bool |
251 * @access public |
263 * @access public |
252 */ |
264 */ |
253 public $is_network; |
265 public $is_network; |
254 |
266 |
255 /** |
267 /** |
256 * Whether the screen is in the user admin. |
268 * Whether the screen is in the user admin. |
257 * |
269 * |
258 * @since 3.3.0 |
270 * Deprecated. Use in_admin() instead. |
271 * |
|
272 * @since 3.3.0 |
|
273 * @deprecated 3.5.0 |
|
259 * @var bool |
274 * @var bool |
260 * @access public |
275 * @access public |
261 */ |
276 */ |
262 public $is_user; |
277 public $is_user; |
263 |
278 |
375 |
390 |
376 if ( is_a( $hook_name, 'WP_Screen' ) ) |
391 if ( is_a( $hook_name, 'WP_Screen' ) ) |
377 return $hook_name; |
392 return $hook_name; |
378 |
393 |
379 $post_type = $taxonomy = null; |
394 $post_type = $taxonomy = null; |
380 $is_network = $is_user = false; |
395 $in_admin = false; |
381 $action = ''; |
396 $action = ''; |
382 |
397 |
383 if ( $hook_name ) |
398 if ( $hook_name ) |
384 $id = $hook_name; |
399 $id = $hook_name; |
385 else |
400 else |
400 } |
415 } |
401 |
416 |
402 if ( ! $post_type && $hook_name ) { |
417 if ( ! $post_type && $hook_name ) { |
403 if ( '-network' == substr( $id, -8 ) ) { |
418 if ( '-network' == substr( $id, -8 ) ) { |
404 $id = substr( $id, 0, -8 ); |
419 $id = substr( $id, 0, -8 ); |
405 $is_network = true; |
420 $in_admin = 'network'; |
406 } elseif ( '-user' == substr( $id, -5 ) ) { |
421 } elseif ( '-user' == substr( $id, -5 ) ) { |
407 $id = substr( $id, 0, -5 ); |
422 $id = substr( $id, 0, -5 ); |
408 $is_user = true; |
423 $in_admin = 'user'; |
409 } |
424 } |
410 |
425 |
411 $id = sanitize_key( $id ); |
426 $id = sanitize_key( $id ); |
412 if ( 'edit-comments' != $id && 'edit-tags' != $id && 'edit-' == substr( $id, 0, 5 ) ) { |
427 if ( 'edit-comments' != $id && 'edit-tags' != $id && 'edit-' == substr( $id, 0, 5 ) ) { |
413 $maybe = substr( $id, 5 ); |
428 $maybe = substr( $id, 5 ); |
417 } elseif ( post_type_exists( $maybe ) ) { |
432 } elseif ( post_type_exists( $maybe ) ) { |
418 $id = 'edit'; |
433 $id = 'edit'; |
419 $post_type = $maybe; |
434 $post_type = $maybe; |
420 } |
435 } |
421 } |
436 } |
437 |
|
438 if ( ! $in_admin ) |
|
439 $in_admin = 'site'; |
|
422 } else { |
440 } else { |
423 $is_network = is_network_admin(); |
441 if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN ) |
424 $is_user = is_user_admin(); |
442 $in_admin = 'network'; |
443 elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN ) |
|
444 $in_admin = 'user'; |
|
445 else |
|
446 $in_admin = 'site'; |
|
425 } |
447 } |
426 |
448 |
427 if ( 'index' == $id ) |
449 if ( 'index' == $id ) |
428 $id = 'dashboard'; |
450 $id = 'dashboard'; |
451 elseif ( 'front' == $id ) |
|
452 $in_admin = false; |
|
429 |
453 |
430 $base = $id; |
454 $base = $id; |
431 |
455 |
432 // If this is the current screen, see if we can be more accurate for post types and taxonomies. |
456 // If this is the current screen, see if we can be more accurate for post types and taxonomies. |
433 if ( ! $hook_name ) { |
457 if ( ! $hook_name ) { |
470 $id .= '-' . $post_type; |
494 $id .= '-' . $post_type; |
471 break; |
495 break; |
472 case 'edit-tags' : |
496 case 'edit-tags' : |
473 if ( null === $taxonomy ) |
497 if ( null === $taxonomy ) |
474 $taxonomy = 'post_tag'; |
498 $taxonomy = 'post_tag'; |
499 // The edit-tags ID does not contain the post type. Look for it in the request. |
|
500 if ( null === $post_type ) { |
|
501 $post_type = 'post'; |
|
502 if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) |
|
503 $post_type = $_REQUEST['post_type']; |
|
504 } |
|
505 |
|
475 $id = 'edit-' . $taxonomy; |
506 $id = 'edit-' . $taxonomy; |
476 break; |
507 break; |
477 } |
508 } |
478 |
509 |
479 if ( $is_network ) { |
510 if ( 'network' == $in_admin ) { |
480 $id .= '-network'; |
511 $id .= '-network'; |
481 $base .= '-network'; |
512 $base .= '-network'; |
482 } elseif ( $is_user ) { |
513 } elseif ( 'user' == $in_admin ) { |
483 $id .= '-user'; |
514 $id .= '-user'; |
484 $base .= '-user'; |
515 $base .= '-user'; |
485 } |
516 } |
486 |
517 |
487 if ( isset( self::$_registry[ $id ] ) ) { |
518 if ( isset( self::$_registry[ $id ] ) ) { |
495 |
526 |
496 $screen->base = $base; |
527 $screen->base = $base; |
497 $screen->action = $action; |
528 $screen->action = $action; |
498 $screen->post_type = (string) $post_type; |
529 $screen->post_type = (string) $post_type; |
499 $screen->taxonomy = (string) $taxonomy; |
530 $screen->taxonomy = (string) $taxonomy; |
500 $screen->is_user = $is_user; |
531 $screen->is_user = ( 'user' == $in_admin ); |
501 $screen->is_network = $is_network; |
532 $screen->is_network = ( 'network' == $in_admin ); |
533 $screen->in_admin = $in_admin; |
|
502 |
534 |
503 self::$_registry[ $id ] = $screen; |
535 self::$_registry[ $id ] = $screen; |
504 |
536 |
505 return $screen; |
537 return $screen; |
506 } |
538 } |
524 * |
556 * |
525 * @since 3.3.0 |
557 * @since 3.3.0 |
526 * @access private |
558 * @access private |
527 */ |
559 */ |
528 private function __construct() {} |
560 private function __construct() {} |
561 |
|
562 /** |
|
563 * Indicates whether the screen is in a particular admin |
|
564 * |
|
565 * @since 3.5.0 |
|
566 * |
|
567 * @param string $admin The admin to check against (network | user | site). |
|
568 * If empty any of the three admins will result in true. |
|
569 * @return boolean True if the screen is in the indicated admin, false otherwise. |
|
570 * |
|
571 */ |
|
572 public function in_admin( $admin = null ) { |
|
573 if ( empty( $admin ) ) |
|
574 return (bool) $this->in_admin; |
|
575 |
|
576 return ( $admin == $this->in_admin ); |
|
577 } |
|
529 |
578 |
530 /** |
579 /** |
531 * Sets the old string-based contextual help for the screen. |
580 * Sets the old string-based contextual help for the screen. |
532 * |
581 * |
533 * For backwards compatibility. |
582 * For backwards compatibility. |
742 |
791 |
743 // Time to render! |
792 // Time to render! |
744 ?> |
793 ?> |
745 <div id="screen-meta" class="metabox-prefs"> |
794 <div id="screen-meta" class="metabox-prefs"> |
746 |
795 |
747 <div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>"> |
796 <div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e('Contextual Help Tab'); ?>"> |
748 <div id="contextual-help-back"></div> |
797 <div id="contextual-help-back"></div> |
749 <div id="contextual-help-columns"> |
798 <div id="contextual-help-columns"> |
750 <div class="contextual-help-tabs"> |
799 <div class="contextual-help-tabs"> |
751 <ul> |
800 <ul> |
752 <?php |
801 <?php |
755 $link_id = "tab-link-{$tab['id']}"; |
804 $link_id = "tab-link-{$tab['id']}"; |
756 $panel_id = "tab-panel-{$tab['id']}"; |
805 $panel_id = "tab-panel-{$tab['id']}"; |
757 ?> |
806 ?> |
758 |
807 |
759 <li id="<?php echo esc_attr( $link_id ); ?>"<?php echo $class; ?>> |
808 <li id="<?php echo esc_attr( $link_id ); ?>"<?php echo $class; ?>> |
760 <a href="<?php echo esc_url( "#$panel_id" ); ?>"> |
809 <a href="<?php echo esc_url( "#$panel_id" ); ?>" aria-controls="<?php echo esc_attr( $panel_id ); ?>"> |
761 <?php echo esc_html( $tab['title'] ); ?> |
810 <?php echo esc_html( $tab['title'] ); ?> |
762 </a> |
811 </a> |
763 </li> |
812 </li> |
764 <?php |
813 <?php |
765 $class = ''; |
814 $class = ''; |
825 return; |
874 return; |
826 ?> |
875 ?> |
827 <div id="screen-meta-links"> |
876 <div id="screen-meta-links"> |
828 <?php if ( $this->get_help_tabs() ) : ?> |
877 <?php if ( $this->get_help_tabs() ) : ?> |
829 <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
878 <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
830 <a href="#contextual-help-wrap" id="contextual-help-link" class="show-settings"><?php _e( 'Help' ); ?></a> |
879 <a href="#contextual-help-wrap" id="contextual-help-link" class="show-settings" aria-controls="contextual-help-wrap" aria-expanded="false"><?php _e( 'Help' ); ?></a> |
831 </div> |
880 </div> |
832 <?php endif; |
881 <?php endif; |
833 if ( $this->show_screen_options() ) : ?> |
882 if ( $this->show_screen_options() ) : ?> |
834 <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
883 <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle"> |
835 <a href="#screen-options-wrap" id="show-settings-link" class="show-settings"><?php _e( 'Screen Options' ); ?></a> |
884 <a href="#screen-options-wrap" id="show-settings-link" class="show-settings" aria-controls="screen-options-wrap" aria-expanded="false"><?php _e( 'Screen Options' ); ?></a> |
836 </div> |
885 </div> |
837 <?php endif; ?> |
886 <?php endif; ?> |
838 </div> |
887 </div> |
839 <?php |
888 <?php |
840 } |
889 } |
874 |
923 |
875 $columns = get_column_headers( $this ); |
924 $columns = get_column_headers( $this ); |
876 $hidden = get_hidden_columns( $this ); |
925 $hidden = get_hidden_columns( $this ); |
877 |
926 |
878 ?> |
927 ?> |
879 <div id="screen-options-wrap" class="hidden"> |
928 <div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="<?php esc_attr_e('Screen Options Tab'); ?>"> |
880 <form id="adv-settings" action="" method="post"> |
929 <form id="adv-settings" action="" method="post"> |
881 <?php if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page' ) || ( $columns && empty( $columns['_title'] ) ) ) : ?> |
930 <?php if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page' ) || ( $columns && empty( $columns['_title'] ) ) ) : ?> |
882 <h5><?php _e( 'Show on screen' ); ?></h5> |
931 <h5><?php _e( 'Show on screen' ); ?></h5> |
883 <?php |
932 <?php |
884 endif; |
933 endif; |
886 if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?> |
935 if ( isset( $wp_meta_boxes[ $this->id ] ) ) : ?> |
887 <div class="metabox-prefs"> |
936 <div class="metabox-prefs"> |
888 <?php |
937 <?php |
889 meta_box_prefs( $this ); |
938 meta_box_prefs( $this ); |
890 |
939 |
891 if ( 'dashboard' === $this->id && current_user_can( 'edit_theme_options' ) ) { |
940 if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) { |
892 if ( isset( $_GET['welcome'] ) ) { |
941 if ( isset( $_GET['welcome'] ) ) { |
893 $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1; |
942 $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1; |
894 update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); |
943 update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked ); |
895 } else { |
944 } else { |
896 $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); |
945 $welcome_checked = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); |