mirror of
git://develop.git.wordpress.org/
synced 2025-02-27 10:02:43 +01:00
Don't fallback to default post type or taxonomy if given an invalid post type or taxonomy. Use typenow as the canonical post type. Props nacin. see #19131
git-svn-id: https://develop.svn.wordpress.org/trunk@19321 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
914a945108
commit
f626327800
@ -9,19 +9,17 @@
|
|||||||
/** WordPress Administration Bootstrap */
|
/** WordPress Administration Bootstrap */
|
||||||
require_once( './admin.php' );
|
require_once( './admin.php' );
|
||||||
|
|
||||||
if ( !isset($_GET['post_type']) )
|
if ( ! $typenow )
|
||||||
$post_type = 'post';
|
wp_die( __( 'Invalid post type' ) );
|
||||||
elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) )
|
|
||||||
$post_type = $_GET['post_type'];
|
|
||||||
else
|
|
||||||
wp_die( __('Invalid post type') );
|
|
||||||
|
|
||||||
$_GET['post_type'] = $post_type;
|
|
||||||
|
|
||||||
|
$post_type = $typenow;
|
||||||
$post_type_object = get_post_type_object( $post_type );
|
$post_type_object = get_post_type_object( $post_type );
|
||||||
|
|
||||||
if ( !current_user_can($post_type_object->cap->edit_posts) )
|
if ( ! $post_type_object )
|
||||||
wp_die(__('Cheatin’ uh?'));
|
wp_die( __( 'Invalid post type' ) );
|
||||||
|
|
||||||
|
if ( ! current_user_can( $post_type_object->cap->edit_posts ) )
|
||||||
|
wp_die( __( 'Cheatin’ uh?' ) );
|
||||||
|
|
||||||
$wp_list_table = _get_list_table('WP_Posts_List_Table');
|
$wp_list_table = _get_list_table('WP_Posts_List_Table');
|
||||||
$pagenum = $wp_list_table->get_pagenum();
|
$pagenum = $wp_list_table->get_pagenum();
|
||||||
|
@ -48,14 +48,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||||||
function __construct() {
|
function __construct() {
|
||||||
global $post_type_object, $wpdb;
|
global $post_type_object, $wpdb;
|
||||||
|
|
||||||
if ( !isset( $_REQUEST['post_type'] ) )
|
$post_type = get_current_screen()->post_type;
|
||||||
$post_type = 'post';
|
|
||||||
elseif ( in_array( $_REQUEST['post_type'], get_post_types( array( 'show_ui' => true ) ) ) )
|
|
||||||
$post_type = $_REQUEST['post_type'];
|
|
||||||
else
|
|
||||||
wp_die( __( 'Invalid post type' ) );
|
|
||||||
$_REQUEST['post_type'] = $post_type;
|
|
||||||
|
|
||||||
$post_type_object = get_post_type_object( $post_type );
|
$post_type_object = get_post_type_object( $post_type );
|
||||||
|
|
||||||
if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) {
|
if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) {
|
||||||
|
@ -399,7 +399,7 @@ final class WP_Screen {
|
|||||||
if ( is_a( $hook_name, 'WP_Screen' ) )
|
if ( is_a( $hook_name, 'WP_Screen' ) )
|
||||||
return $hook_name;
|
return $hook_name;
|
||||||
|
|
||||||
$action = $post_type = $taxonomy = '';
|
$action = $post_type = $taxonomy = null;
|
||||||
$is_network = $is_user = false;
|
$is_network = $is_user = false;
|
||||||
|
|
||||||
if ( $hook_name )
|
if ( $hook_name )
|
||||||
@ -447,10 +447,10 @@ final class WP_Screen {
|
|||||||
|
|
||||||
// If this is the current screen, see if we can be more accurate for post types and taxonomies.
|
// If this is the current screen, see if we can be more accurate for post types and taxonomies.
|
||||||
if ( ! $hook_name ) {
|
if ( ! $hook_name ) {
|
||||||
if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) )
|
if ( isset( $_REQUEST['post_type'] ) )
|
||||||
$post_type = $_REQUEST['post_type'];
|
$post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false;
|
||||||
if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) )
|
if ( isset( $_REQUEST['taxonomy'] ) )
|
||||||
$taxonomy = $_REQUEST['taxonomy'];
|
$taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false;
|
||||||
|
|
||||||
switch ( $base ) {
|
switch ( $base ) {
|
||||||
case 'post' :
|
case 'post' :
|
||||||
@ -468,7 +468,7 @@ final class WP_Screen {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'edit-tags' :
|
case 'edit-tags' :
|
||||||
if ( ! $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) )
|
if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) )
|
||||||
$post_type = 'post';
|
$post_type = 'post';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -476,17 +476,17 @@ final class WP_Screen {
|
|||||||
|
|
||||||
switch ( $base ) {
|
switch ( $base ) {
|
||||||
case 'post' :
|
case 'post' :
|
||||||
if ( ! $post_type )
|
if ( null === $post_type )
|
||||||
$post_type = 'post';
|
$post_type = 'post';
|
||||||
$id = $post_type;
|
$id = $post_type;
|
||||||
break;
|
break;
|
||||||
case 'edit' :
|
case 'edit' :
|
||||||
if ( ! $post_type )
|
if ( null === $post_type )
|
||||||
$post_type = 'post';
|
$post_type = 'post';
|
||||||
$id .= '-' . $post_type;
|
$id .= '-' . $post_type;
|
||||||
break;
|
break;
|
||||||
case 'edit-tags' :
|
case 'edit-tags' :
|
||||||
if ( ! $taxonomy )
|
if ( null === $taxonomy )
|
||||||
$taxonomy = 'post_tag';
|
$taxonomy = 'post_tag';
|
||||||
$id = 'edit-' . $taxonomy;
|
$id = 'edit-' . $taxonomy;
|
||||||
break;
|
break;
|
||||||
@ -511,8 +511,8 @@ final class WP_Screen {
|
|||||||
|
|
||||||
$screen->base = $base;
|
$screen->base = $base;
|
||||||
$screen->action = $action;
|
$screen->action = $action;
|
||||||
$screen->post_type = $post_type;
|
$screen->post_type = (string) $post_type;
|
||||||
$screen->taxonomy = $taxonomy;
|
$screen->taxonomy = (string) $taxonomy;
|
||||||
$screen->is_user = $is_user;
|
$screen->is_user = $is_user;
|
||||||
$screen->is_network = $is_network;
|
$screen->is_network = $is_network;
|
||||||
|
|
||||||
|
@ -1392,7 +1392,7 @@ var userSettings = {
|
|||||||
},
|
},
|
||||||
ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',
|
ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',
|
||||||
pagenow = '<?php echo $current_screen->id; ?>',
|
pagenow = '<?php echo $current_screen->id; ?>',
|
||||||
typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>',
|
typenow = '<?php echo $current_screen->post_type; ?>',
|
||||||
adminpage = '<?php echo $admin_body_class; ?>',
|
adminpage = '<?php echo $admin_body_class; ?>',
|
||||||
thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
|
thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
|
||||||
decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
|
decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user