]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/screen.php
Wordpress 3.5
[autoinstalls/wordpress.git] / wp-admin / includes / screen.php
index 2fe318d9a6305702a7555859acedcec549371534..4a409e8c68b4297b831469ccf2c43801708cd0a4 100644 (file)
@@ -96,7 +96,7 @@ function get_hidden_meta_boxes( $screen ) {
        if ( $use_defaults ) {
                $hidden = array();
                if ( 'post' == $screen->base ) {
        if ( $use_defaults ) {
                $hidden = array();
                if ( 'post' == $screen->base ) {
-                       if ( 'post' == $screen->post_type || 'page' == $screen->post_type )
+                       if ( 'post' == $screen->post_type || 'page' == $screen->post_type || 'attachment' == $screen->post_type )
                                $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv');
                        else
                                $hidden = array( 'slugdiv' );
                                $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv');
                        else
                                $hidden = array( 'slugdiv' );
@@ -243,10 +243,22 @@ final class WP_Screen {
         */
        public $id;
 
         */
        public $id;
 
+       /**
+        * Which admin the screen is in. network | user | site | false
+        *
+        * @since 3.5.0
+        * @var string
+        * @access protected
+        */
+       protected $in_admin;
+
        /**
         * Whether the screen is in the network admin.
         *
        /**
         * Whether the screen is in the network admin.
         *
+        * Deprecated. Use in_admin() instead.
+        *
         * @since 3.3.0
         * @since 3.3.0
+        * @deprecated 3.5.0
         * @var bool
         * @access public
         */
         * @var bool
         * @access public
         */
@@ -255,7 +267,10 @@ final class WP_Screen {
        /**
         * Whether the screen is in the user admin.
         *
        /**
         * Whether the screen is in the user admin.
         *
+        * Deprecated. Use in_admin() instead.
+        *
         * @since 3.3.0
         * @since 3.3.0
+        * @deprecated 3.5.0
         * @var bool
         * @access public
         */
         * @var bool
         * @access public
         */
@@ -377,7 +392,7 @@ final class WP_Screen {
                        return $hook_name;
 
                $post_type = $taxonomy = null;
                        return $hook_name;
 
                $post_type = $taxonomy = null;
-               $is_network = $is_user = false;
+               $in_admin = false;
                $action = '';
 
                if ( $hook_name )
                $action = '';
 
                if ( $hook_name )
@@ -402,10 +417,10 @@ final class WP_Screen {
                if ( ! $post_type && $hook_name ) {
                        if ( '-network' == substr( $id, -8 ) ) {
                                $id = substr( $id, 0, -8 );
                if ( ! $post_type && $hook_name ) {
                        if ( '-network' == substr( $id, -8 ) ) {
                                $id = substr( $id, 0, -8 );
-                               $is_network = true;
+                               $in_admin = 'network';
                        } elseif ( '-user' == substr( $id, -5 ) ) {
                                $id = substr( $id, 0, -5 );
                        } elseif ( '-user' == substr( $id, -5 ) ) {
                                $id = substr( $id, 0, -5 );
-                               $is_user = true;
+                               $in_admin = 'user';
                        }
 
                        $id = sanitize_key( $id );
                        }
 
                        $id = sanitize_key( $id );
@@ -419,13 +434,22 @@ final class WP_Screen {
                                        $post_type = $maybe;
                                }
                        }
                                        $post_type = $maybe;
                                }
                        }
+
+                       if ( ! $in_admin )
+                               $in_admin = 'site';
                } else {
                } else {
-                       $is_network = is_network_admin();
-                       $is_user = is_user_admin();
+                       if ( defined( 'WP_NETWORK_ADMIN' ) && WP_NETWORK_ADMIN )
+                               $in_admin = 'network';
+                       elseif ( defined( 'WP_USER_ADMIN' ) && WP_USER_ADMIN )
+                               $in_admin = 'user';
+                       else
+                               $in_admin = 'site';
                }
 
                if ( 'index' == $id )
                        $id = 'dashboard';
                }
 
                if ( 'index' == $id )
                        $id = 'dashboard';
+               elseif ( 'front' == $id )
+                       $in_admin = false;
 
                $base = $id;
 
 
                $base = $id;
 
@@ -472,14 +496,21 @@ final class WP_Screen {
                        case 'edit-tags' :
                                if ( null === $taxonomy )
                                        $taxonomy = 'post_tag';
                        case 'edit-tags' :
                                if ( null === $taxonomy )
                                        $taxonomy = 'post_tag';
+                               // The edit-tags ID does not contain the post type. Look for it in the request.
+                               if ( null === $post_type ) {
+                                       $post_type = 'post';
+                                       if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) )
+                                               $post_type = $_REQUEST['post_type'];
+                               }
+
                                $id = 'edit-' . $taxonomy;
                                break;
                }
 
                                $id = 'edit-' . $taxonomy;
                                break;
                }
 
-               if ( $is_network ) {
+               if ( 'network' == $in_admin ) {
                        $id   .= '-network';
                        $base .= '-network';
                        $id   .= '-network';
                        $base .= '-network';
-               } elseif ( $is_user ) {
+               } elseif ( 'user' == $in_admin ) {
                        $id   .= '-user';
                        $base .= '-user';
                }
                        $id   .= '-user';
                        $base .= '-user';
                }
@@ -497,8 +528,9 @@ final class WP_Screen {
                $screen->action     = $action;
                $screen->post_type  = (string) $post_type;
                $screen->taxonomy   = (string) $taxonomy;
                $screen->action     = $action;
                $screen->post_type  = (string) $post_type;
                $screen->taxonomy   = (string) $taxonomy;
-               $screen->is_user    = $is_user;
-               $screen->is_network = $is_network;
+               $screen->is_user    = ( 'user' == $in_admin );
+               $screen->is_network = ( 'network' == $in_admin );
+               $screen->in_admin   = $in_admin;
 
                self::$_registry[ $id ] = $screen;
 
 
                self::$_registry[ $id ] = $screen;
 
@@ -527,6 +559,23 @@ final class WP_Screen {
         */
        private function __construct() {}
 
         */
        private function __construct() {}
 
+       /**
+        * Indicates whether the screen is in a particular admin
+        *
+        * @since 3.5.0
+        *
+        * @param string $admin The admin to check against (network | user | site).
+        * If empty any of the three admins will result in true.
+        * @return boolean True if the screen is in the indicated admin, false otherwise.
+        *
+        */
+       public function in_admin( $admin = null ) {
+               if ( empty( $admin ) )
+                       return (bool) $this->in_admin;
+
+               return ( $admin == $this->in_admin );
+       }
+
        /**
         * Sets the old string-based contextual help for the screen.
         *
        /**
         * Sets the old string-based contextual help for the screen.
         *
@@ -744,7 +793,7 @@ final class WP_Screen {
                ?>
                <div id="screen-meta" class="metabox-prefs">
 
                ?>
                <div id="screen-meta" class="metabox-prefs">
 
-                       <div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>">
+                       <div id="contextual-help-wrap" class="<?php echo esc_attr( $help_class ); ?>" tabindex="-1" aria-label="<?php esc_attr_e('Contextual Help Tab'); ?>">
                                <div id="contextual-help-back"></div>
                                <div id="contextual-help-columns">
                                        <div class="contextual-help-tabs">
                                <div id="contextual-help-back"></div>
                                <div id="contextual-help-columns">
                                        <div class="contextual-help-tabs">
@@ -757,7 +806,7 @@ final class WP_Screen {
                                                        ?>
 
                                                        <li id="<?php echo esc_attr( $link_id ); ?>"<?php echo $class; ?>>
                                                        ?>
 
                                                        <li id="<?php echo esc_attr( $link_id ); ?>"<?php echo $class; ?>>
-                                                               <a href="<?php echo esc_url( "#$panel_id" ); ?>">
+                                                               <a href="<?php echo esc_url( "#$panel_id" ); ?>" aria-controls="<?php echo esc_attr( $panel_id ); ?>">
                                                                        <?php echo esc_html( $tab['title'] ); ?>
                                                                </a>
                                                        </li>
                                                                        <?php echo esc_html( $tab['title'] ); ?>
                                                                </a>
                                                        </li>
@@ -827,12 +876,12 @@ final class WP_Screen {
                <div id="screen-meta-links">
                <?php if ( $this->get_help_tabs() ) : ?>
                        <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
                <div id="screen-meta-links">
                <?php if ( $this->get_help_tabs() ) : ?>
                        <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle">
-                       <a href="#contextual-help-wrap" id="contextual-help-link" class="show-settings"><?php _e( 'Help' ); ?></a>
+                       <a href="#contextual-help-wrap" id="contextual-help-link" class="show-settings" aria-controls="contextual-help-wrap" aria-expanded="false"><?php _e( 'Help' ); ?></a>
                        </div>
                <?php endif;
                if ( $this->show_screen_options() ) : ?>
                        <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
                        </div>
                <?php endif;
                if ( $this->show_screen_options() ) : ?>
                        <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
-                       <a href="#screen-options-wrap" id="show-settings-link" class="show-settings"><?php _e( 'Screen Options' ); ?></a>
+                       <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>
                        </div>
                <?php endif; ?>
                </div>
                        </div>
                <?php endif; ?>
                </div>
@@ -876,7 +925,7 @@ final class WP_Screen {
                $hidden  = get_hidden_columns( $this );
 
                ?>
                $hidden  = get_hidden_columns( $this );
 
                ?>
-               <div id="screen-options-wrap" class="hidden">
+               <div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="<?php esc_attr_e('Screen Options Tab'); ?>">
                <form id="adv-settings" action="" method="post">
                <?php if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page' ) || ( $columns && empty( $columns['_title'] ) ) ) : ?>
                        <h5><?php _e( 'Show on screen' ); ?></h5>
                <form id="adv-settings" action="" method="post">
                <?php if ( isset( $wp_meta_boxes[ $this->id ] ) || $this->get_option( 'per_page' ) || ( $columns && empty( $columns['_title'] ) ) ) : ?>
                        <h5><?php _e( 'Show on screen' ); ?></h5>
@@ -888,7 +937,7 @@ final class WP_Screen {
                                <?php
                                        meta_box_prefs( $this );
 
                                <?php
                                        meta_box_prefs( $this );
 
-                                       if ( 'dashboard' === $this->id && current_user_can( 'edit_theme_options' ) ) {
+                                       if ( 'dashboard' === $this->id && has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) {
                                                if ( isset( $_GET['welcome'] ) ) {
                                                        $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
                                                        update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );
                                                if ( isset( $_GET['welcome'] ) ) {
                                                        $welcome_checked = empty( $_GET['welcome'] ) ? 0 : 1;
                                                        update_user_meta( get_current_user_id(), 'show_welcome_panel', $welcome_checked );