Allow is_network and is_user to work for all screen instances. see #18785.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19132 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8454367edf
commit
9741ce2773
|
@ -55,10 +55,7 @@ case 'fetch-list' :
|
||||||
$list_class = $_GET['list_args']['class'];
|
$list_class = $_GET['list_args']['class'];
|
||||||
check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' );
|
check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' );
|
||||||
|
|
||||||
$current_screen = (object) $_GET['list_args']['screen'];
|
$current_screen = convert_to_screen( $_GET['list_args']['screen']['id'] );
|
||||||
//TODO fix this in a better way see #15336
|
|
||||||
$current_screen->is_network = 'false' === $current_screen->is_network ? false : true;
|
|
||||||
$current_screen->is_user = 'false' === $current_screen->is_user ? false : true;
|
|
||||||
|
|
||||||
define( 'WP_NETWORK_ADMIN', $current_screen->is_network );
|
define( 'WP_NETWORK_ADMIN', $current_screen->is_network );
|
||||||
define( 'WP_USER_ADMIN', $current_screen->is_user );
|
define( 'WP_USER_ADMIN', $current_screen->is_user );
|
||||||
|
|
|
@ -400,6 +400,7 @@ final class WP_Screen {
|
||||||
return $hook_name;
|
return $hook_name;
|
||||||
|
|
||||||
$action = $post_type = $taxonomy = '';
|
$action = $post_type = $taxonomy = '';
|
||||||
|
$is_network = $is_user = false;
|
||||||
|
|
||||||
if ( $hook_name )
|
if ( $hook_name )
|
||||||
$id = $hook_name;
|
$id = $hook_name;
|
||||||
|
@ -412,10 +413,13 @@ final class WP_Screen {
|
||||||
$id = str_replace( array( '-new', '-add' ), '', $id );
|
$id = str_replace( array( '-new', '-add' ), '', $id );
|
||||||
|
|
||||||
if ( $hook_name ) {
|
if ( $hook_name ) {
|
||||||
if ( '-network' == substr( $id, -8 ) )
|
if ( '-network' == substr( $id, -8 ) ) {
|
||||||
$id = str_replace( '-network', '', $id );
|
$id = str_replace( '-network', '', $id );
|
||||||
elseif ( '-user' == substr( $id, -5 ) )
|
$is_network = true;
|
||||||
|
} elseif ( '-user' == substr( $id, -5 ) ) {
|
||||||
$id = str_replace( '-user', '', $id );
|
$id = str_replace( '-user', '', $id );
|
||||||
|
$is_user = true;
|
||||||
|
}
|
||||||
|
|
||||||
$id = sanitize_key( $id );
|
$id = sanitize_key( $id );
|
||||||
if ( post_type_exists( $id ) ) {
|
if ( post_type_exists( $id ) ) {
|
||||||
|
@ -431,6 +435,9 @@ final class WP_Screen {
|
||||||
$post_type = $second;
|
$post_type = $second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$is_network = is_network_admin();
|
||||||
|
$is_user = is_user_admin();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'index' == $id )
|
if ( 'index' == $id )
|
||||||
|
@ -485,10 +492,10 @@ final class WP_Screen {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_network_admin() ) {
|
if ( $is_network ) {
|
||||||
$id .= '-network';
|
$id .= '-network';
|
||||||
$base .= '-network';
|
$base .= '-network';
|
||||||
} elseif ( is_user_admin() ) {
|
} elseif ( $is_user ) {
|
||||||
$id .= '-user';
|
$id .= '-user';
|
||||||
$base .= '-user';
|
$base .= '-user';
|
||||||
}
|
}
|
||||||
|
@ -506,8 +513,8 @@ final class WP_Screen {
|
||||||
$screen->action = $action;
|
$screen->action = $action;
|
||||||
$screen->post_type = $post_type;
|
$screen->post_type = $post_type;
|
||||||
$screen->taxonomy = $taxonomy;
|
$screen->taxonomy = $taxonomy;
|
||||||
$screen->is_user = is_user_admin();
|
$screen->is_user = $is_user;
|
||||||
$screen->is_network = is_network_admin();
|
$screen->is_network = $is_network;
|
||||||
|
|
||||||
self::$_registry[ $id ] = $screen;
|
self::$_registry[ $id ] = $screen;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue