Make WordPress Core


Ignore:
Timestamp:
08/31/2012 05:16:46 PM (14 years ago)
Author:
ryan
Message:

Introduce WP_Screen::in_admin() for determining which admin the screen is in.
Change is_*_admin() to reference in_admin() with fallback to the WP_*_ADMIN constants during early bootstrap. This allows unit tests and ajax handlers to set the admin context.

fixes #21742

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/load.php

    r21559 r21687  
    584584 */
    585585function is_admin() {
    586         if ( defined( 'WP_ADMIN' ) )
     586        if ( isset( $GLOBALS['current_screen'] ) )
     587                return $GLOBALS['current_screen']->in_admin();
     588        elseif ( defined( 'WP_ADMIN' ) )
    587589                return WP_ADMIN;
     590
    588591        return false;
    589592}
    … …  
    600603 */
    601604function is_blog_admin() {
    602         if ( defined( 'WP_BLOG_ADMIN' ) )
     605        if ( isset( $GLOBALS['current_screen'] ) )
     606                return $GLOBALS['current_screen']->in_admin( 'blog' );
     607        elseif ( defined( 'WP_BLOG_ADMIN' ) )
    603608                return WP_BLOG_ADMIN;
     609
    604610        return false;
    605611}
    … …  
    616622 */
    617623function is_network_admin() {
    618         if ( defined( 'WP_NETWORK_ADMIN' ) )
     624        if ( isset( $GLOBALS['current_screen'] ) )
     625                return $GLOBALS['current_screen']->in_admin( 'network' );
     626        elseif ( defined( 'WP_NETWORK_ADMIN' ) )
    619627                return WP_NETWORK_ADMIN;
     628
    620629        return false;
    621630}
    … …  
    632641 */
    633642function is_user_admin() {
    634         if ( defined( 'WP_USER_ADMIN' ) )
     643        if ( isset( $GLOBALS['current_screen'] ) )
     644                return $GLOBALS['current_screen']->in_admin( 'user' );
     645        elseif ( defined( 'WP_USER_ADMIN' ) )
    635646                return WP_USER_ADMIN;
     647
    636648        return false;
    637649}
Note: See TracChangeset for help on using the changeset viewer.