diff --git a/wp-admin/admin.php b/wp-admin/admin.php index bf64a1a67..46e45e34d 100644 --- a/wp-admin/admin.php +++ b/wp-admin/admin.php @@ -88,13 +88,13 @@ if ( isset($_GET['page']) ) { $plugin_page = plugin_basename($plugin_page); } -if ( isset($_GET['post_type']) ) - $typenow = sanitize_key($_GET['post_type']); +if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) + $typenow = $_REQUEST['post_type']; else $typenow = ''; -if ( isset($_GET['taxonomy']) ) - $taxnow = sanitize_key($_GET['taxonomy']); +if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) + $taxnow = $_REQUEST['taxonomy']; else $taxnow = ''; diff --git a/wp-admin/includes/screen.php b/wp-admin/includes/screen.php index 239a593a6..8e02a9306 100644 --- a/wp-admin/includes/screen.php +++ b/wp-admin/includes/screen.php @@ -418,7 +418,10 @@ final class WP_Screen { $id = str_replace( '-user', '', $id ); $id = sanitize_key( $id ); - if ( false !== strpos( $id, '-' ) ) { + if ( post_type_exists( $id ) ) { + $post_type = $id; + $id = 'post'; // changes later. ends up being $base. + } elseif ( false !== strpos( $id, '-' ) ) { list( $id, $second ) = explode( '-', $id, 2 ); if ( taxonomy_exists( $second ) ) { $id = 'edit-tags'; @@ -438,6 +441,11 @@ final class WP_Screen { // If this is the current screen, see if we can be more accurate for post types and taxonomies. if ( ! $hook_name ) { + if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) + $post_type = $_REQUEST['post_type']; + if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) + $taxonomy = $_REQUEST['taxonomy']; + switch ( $base ) { case 'post' : if ( isset( $_GET['post'] ) ) @@ -451,22 +459,10 @@ final class WP_Screen { $post = get_post( $post_id ); if ( $post ) $post_type = $post->post_type; - } elseif ( isset( $_POST['post_type'] ) && post_type_exists( $_POST['post_type'] ) ) { - $post_type = $_POST['post_type']; - } elseif ( $action == 'add' && isset( $_GET['post_type'] ) && post_type_exists( $_GET['post_type'] ) ) { - $post_type = $_GET['post_type']; } break; - case 'edit' : - if ( isset( $_GET['post_type'] ) && post_type_exists( $_GET['post_type'] ) ) - $post_type = $_GET['post_type']; - break; case 'edit-tags' : - if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) ) - $taxonomy = $_REQUEST['taxonomy']; - if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) ) - $post_type = $_REQUEST['post_type']; - else if ( is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) + if ( ! $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) ) $post_type = 'post'; break; } @@ -498,11 +494,15 @@ final class WP_Screen { $base .= '-user'; } - if ( isset( self::$_registry[ $id ] ) ) - return self::$_registry[ $id ]; + if ( isset( self::$_registry[ $id ] ) ) { + $screen = self::$_registry[ $id ]; + if ( $screen === get_current_screen() ) + return $screen; + } else { + $screen = new WP_Screen(); + $screen->id = $id; + } - $screen = new WP_Screen(); - $screen->id = $id; $screen->base = $base; $screen->action = $action; $screen->post_type = $post_type;