Ticket #21742: 21742.2.diff
File 21742.2.diff, 3.8 KB (added by , 12 years ago) |
---|
-
wp-includes/load.php
583 583 * @return bool True if inside WordPress administration pages. 584 584 */ 585 585 function 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' ) ) 587 589 return WP_ADMIN; 590 588 591 return false; 589 592 } 590 593 … … 599 602 * @return bool True if inside WordPress network administration pages. 600 603 */ 601 604 function 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' ) ) 603 608 return WP_BLOG_ADMIN; 609 604 610 return false; 605 611 } 606 612 … … 615 621 * @return bool True if inside WordPress network administration pages. 616 622 */ 617 623 function 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' ) ) 619 627 return WP_NETWORK_ADMIN; 628 620 629 return false; 621 630 } 622 631 … … 631 640 * @return bool True if inside WordPress user administration pages. 632 641 */ 633 642 function 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' ) ) 635 646 return WP_USER_ADMIN; 647 636 648 return false; 637 649 } 638 650 -
wp-admin/includes/screen.php
244 244 public $id; 245 245 246 246 /** 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 /** 247 269 * Whether the screen is in the network admin. 248 270 * 271 * This property is read-only. Do not write to this property. 272 * 249 273 * @since 3.3.0 250 274 * @var bool 251 275 * @access public … … 255 279 /** 256 280 * Whether the screen is in the user admin. 257 281 * 282 * This property is read-only. Do not write to this property. 283 * 258 284 * @since 3.3.0 259 285 * @var bool 260 286 * @access public … … 377 403 return $hook_name; 378 404 379 405 $post_type = $taxonomy = null; 380 $is_network = $is_user = false;406 $is_network = $is_user = $is_blog = $is_admin = false; 381 407 $action = ''; 382 408 383 409 if ( $hook_name ) … … 402 428 if ( ! $post_type && $hook_name ) { 403 429 if ( '-network' == substr( $id, -8 ) ) { 404 430 $id = substr( $id, 0, -8 ); 405 $is_network = true;431 $is_network = $is_admin = true; 406 432 } elseif ( '-user' == substr( $id, -5 ) ) { 407 433 $id = substr( $id, 0, -5 ); 408 $is_user = true;434 $is_user = $is_admin = true; 409 435 } 410 436 411 437 $id = sanitize_key( $id ); … … 419 445 $post_type = $maybe; 420 446 } 421 447 } 448 449 if ( ! $is_network && ! $is_user ) 450 $is_blog = $is_admin = true; 422 451 } 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; 425 456 } 426 457 427 458 if ( 'index' == $id ) … … 499 530 $screen->taxonomy = (string) $taxonomy; 500 531 $screen->is_user = $is_user; 501 532 $screen->is_network = $is_network; 533 $screen->is_blog = $is_blog; 534 $screen->is_admin = $is_admin; 502 535 503 536 self::$_registry[ $id ] = $screen; 504 537