Make WordPress Core

Ticket #19131: 19131.4.diff

File 19131.4.diff, 4.8 KB (added by nacin, 13 years ago)
  • wp-admin/includes/class-wp-posts-list-table.php

     
    4848        function __construct() {
    4949                global $post_type_object, $wpdb;
    5050
    51                 if ( !isset( $_REQUEST['post_type'] ) )
    52                         $post_type = 'post';
    53                 elseif ( in_array( $_REQUEST['post_type'], get_post_types( array( 'show_ui' => true ) ) ) )
    54                         $post_type = $_REQUEST['post_type'];
    55                 else
    56                         wp_die( __( 'Invalid post type' ) );
    57                 $_REQUEST['post_type'] = $post_type;
    58 
     51                $post_type = get_current_screen()->post_type;
    5952                $post_type_object = get_post_type_object( $post_type );
    6053
    6154                if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) {
  • wp-admin/includes/template.php

     
    13921392        },
    13931393        ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',
    13941394        pagenow = '<?php echo $current_screen->id; ?>',
    1395         typenow = '<?php if ( isset($current_screen->post_type) ) echo $current_screen->post_type; ?>',
     1395        typenow = '<?php echo $current_screen->post_type; ?>',
    13961396        adminpage = '<?php echo $admin_body_class; ?>',
    13971397        thousandsSeparator = '<?php echo addslashes( $wp_locale->number_format['thousands_sep'] ); ?>',
    13981398        decimalPoint = '<?php echo addslashes( $wp_locale->number_format['decimal_point'] ); ?>',
  • wp-admin/includes/screen.php

     
    399399                if ( is_a( $hook_name, 'WP_Screen' ) )
    400400                        return $hook_name;
    401401
    402                 $action = $post_type = $taxonomy = '';
     402                $action = $post_type = $taxonomy = null;
    403403                $is_network = $is_user = false;
    404404
    405405                if ( $hook_name )
     
    447447
    448448                // If this is the current screen, see if we can be more accurate for post types and taxonomies.
    449449                if ( ! $hook_name ) {
    450                         if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) )
    451                                 $post_type = $_REQUEST['post_type'];
    452                         if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) )
    453                                 $taxonomy = $_REQUEST['taxonomy'];
     450                        if ( isset( $_REQUEST['post_type'] ) )
     451                                $post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false;
     452                        if ( isset( $_REQUEST['taxonomy'] ) )
     453                                $taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false;
    454454
    455455                        switch ( $base ) {
    456456                                case 'post' :
     
    468468                                        }
    469469                                        break;
    470470                                case 'edit-tags' :
    471                                         if ( ! $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) )
     471                                        if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) )
    472472                                                $post_type = 'post';
    473473                                        break;
    474474                        }
     
    476476
    477477                switch ( $base ) {
    478478                        case 'post' :
    479                                 if ( ! $post_type )
     479                                if ( null === $post_type )
    480480                                        $post_type = 'post';
    481481                                $id = $post_type;
    482482                                break;
    483483                        case 'edit' :
    484                                 if ( ! $post_type )
     484                                if ( null === $post_type )
    485485                                        $post_type = 'post';
    486486                                $id .= '-' . $post_type;
    487487                                break;
    488488                        case 'edit-tags' :
    489                                 if ( ! $taxonomy )
     489                                if ( null === $taxonomy )
    490490                                        $taxonomy = 'post_tag';
    491491                                $id = 'edit-' . $taxonomy;
    492492                                break;
     
    511511
    512512                $screen->base       = $base;
    513513                $screen->action     = $action;
    514                 $screen->post_type  = $post_type;
    515                 $screen->taxonomy   = $taxonomy;
     514                $screen->post_type  = (string) $post_type;
     515                $screen->taxonomy   = (string) $taxonomy;
    516516                $screen->is_user    = $is_user;
    517517                $screen->is_network = $is_network;
    518518
  • wp-admin/edit.php

     
    99/** WordPress Administration Bootstrap */
    1010require_once( './admin.php' );
    1111
    12 if ( !isset($_GET['post_type']) )
    13         $post_type = 'post';
    14 elseif ( in_array( $_GET['post_type'], get_post_types( array('show_ui' => true ) ) ) )
    15         $post_type = $_GET['post_type'];
    16 else
    17         wp_die( __('Invalid post type') );
     12if ( ! $taxnow )
     13        wp_die( __( 'Invalid post type' ) );
    1814
    19 $_GET['post_type'] = $post_type;
    20 
     15$post_type = $typenow;
    2116$post_type_object = get_post_type_object( $post_type );
    2217
    23 if ( !current_user_can($post_type_object->cap->edit_posts) )
    24         wp_die(__('Cheatin&#8217; uh?'));
     18if ( ! $post_type_object )
     19        wp_die( __( 'Invalid post type' ) );
    2520
     21if ( ! current_user_can( $post_type_object->cap->edit_posts ) )
     22        wp_die( __( 'Cheatin&#8217; uh?' ) );
     23
    2624$wp_list_table = _get_list_table('WP_Posts_List_Table');
    2725$pagenum = $wp_list_table->get_pagenum();
    2826