Make WordPress Core

Ticket #21742: 21742.2.diff

File 21742.2.diff, 3.8 KB (added by ryan, 12 years ago)
  • wp-includes/load.php

     
    583583 * @return bool True if inside WordPress administration pages.
    584584 */
    585585function is_admin() {
    586         if ( defined( 'WP_ADMIN' ) )
     586        if ( isset( $GLOBALS['current_screen'] ) )
     587                return $GLOBALS['current_screen']->is_admin;
     588        elseif ( defined( 'WP_ADMIN' ) )
    587589                return WP_ADMIN;
     590
    588591        return false;
    589592}
    590593
     
    599602 * @return bool True if inside WordPress network administration pages.
    600603 */
    601604function is_blog_admin() {
    602         if ( defined( 'WP_BLOG_ADMIN' ) )
     605        if ( isset( $GLOBALS['current_screen'] ) )
     606                return $GLOBALS['current_screen']->is_blog;
     607        elseif ( defined( 'WP_BLOG_ADMIN' ) )
    603608                return WP_BLOG_ADMIN;
     609
    604610        return false;
    605611}
    606612
     
    615621 * @return bool True if inside WordPress network administration pages.
    616622 */
    617623function is_network_admin() {
    618         if ( defined( 'WP_NETWORK_ADMIN' ) )
     624        if ( isset( $GLOBALS['current_screen'] ) )
     625                return $GLOBALS['current_screen']->is_network;
     626        elseif ( defined( 'WP_NETWORK_ADMIN' ) )
    619627                return WP_NETWORK_ADMIN;
     628
    620629        return false;
    621630}
    622631
     
    631640 * @return bool True if inside WordPress user administration pages.
    632641 */
    633642function is_user_admin() {
    634         if ( defined( 'WP_USER_ADMIN' ) )
     643        if ( isset( $GLOBALS['current_screen'] ) )
     644                return $GLOBALS['current_screen']->is_user;
     645        elseif ( defined( 'WP_USER_ADMIN' ) )
    635646                return WP_USER_ADMIN;
     647
    636648        return false;
    637649}
    638650
  • wp-admin/includes/screen.php

     
    244244        public $id;
    245245
    246246        /**
     247         * Whether the screen is in the admin.
     248         *
     249         * This property is read-only. Do not write to this property.
     250         *
     251         * @since 3.5.0
     252         * @var bool
     253         * @access public
     254         */
     255        public $is_admin;
     256
     257        /**
     258         * Whether the screen is in the blog admin.
     259         *
     260         * This property is read-only. Do not write to this property.
     261         *
     262         * @since 3.5.0
     263         * @var bool
     264         * @access public
     265         */
     266        public $is_blog;
     267
     268        /**
    247269         * Whether the screen is in the network admin.
    248270         *
     271         * This property is read-only. Do not write to this property.
     272         *
    249273         * @since 3.3.0
    250274         * @var bool
    251275         * @access public
     
    255279        /**
    256280         * Whether the screen is in the user admin.
    257281         *
     282         * This property is read-only. Do not write to this property.
     283         *
    258284         * @since 3.3.0
    259285         * @var bool
    260286         * @access public
     
    377403                        return $hook_name;
    378404
    379405                $post_type = $taxonomy = null;
    380                 $is_network = $is_user = false;
     406                $is_network = $is_user = $is_blog = $is_admin = false;
    381407                $action = '';
    382408
    383409                if ( $hook_name )
     
    402428                if ( ! $post_type && $hook_name ) {
    403429                        if ( '-network' == substr( $id, -8 ) ) {
    404430                                $id = substr( $id, 0, -8 );
    405                                 $is_network = true;
     431                                $is_network = $is_admin = true;
    406432                        } elseif ( '-user' == substr( $id, -5 ) ) {
    407433                                $id = substr( $id, 0, -5 );
    408                                 $is_user = true;
     434                                $is_user = $is_admin = true;
    409435                        }
    410436
    411437                        $id = sanitize_key( $id );
     
    419445                                        $post_type = $maybe;
    420446                                }
    421447                        }
     448
     449                        if ( ! $is_network && ! $is_user )
     450                                $is_blog = $is_admin = true;
    422451                } else {
    423                         $is_network = is_network_admin();
    424                         $is_user = is_user_admin();
     452                        $is_network = defined( 'WP_NETWORK_ADMIN' ) ? WP_NETWORK_ADMIN : false;
     453                        $is_user = defined( 'WP_USER_ADMIN' ) ? WP_USER_ADMIN : false;
     454                        $is_blog = defined( 'WP_BLOG_ADMIN' ) ? WP_BLOG_ADMIN : false;
     455                        $is_admin = defined( 'WP_ADMIN' ) ? WP_ADMIN : false;
    425456                }
    426457
    427458                if ( 'index' == $id )
     
    499530                $screen->taxonomy   = (string) $taxonomy;
    500531                $screen->is_user    = $is_user;
    501532                $screen->is_network = $is_network;
     533                $screen->is_blog    = $is_blog;
     534                $screen->is_admin   = $is_admin;
    502535
    503536                self::$_registry[ $id ] = $screen;
    504537