Make WordPress Core

Ticket #19080: 19080.3.diff

File 19080.3.diff, 3.3 KB (added by nacin, 12 years ago)

Per even more IRC conversations. Supplants 19080.diff and .2.diff.

  • wp-admin/includes/screen.php

     
    418418                                $id = str_replace( '-user', '', $id );
    419419
    420420                        $id = sanitize_key( $id );
    421                         if ( false !== strpos( $id, '-' ) ) {
     421                        if ( post_type_exists( $id ) ) {
     422                                $post_type = $id;
     423                                $id = 'post'; // changes later. ends up being $base.
     424                        } elseif ( false !== strpos( $id, '-' ) ) {
    422425                                list( $id, $second ) = explode( '-', $id, 2 );
    423426                                if ( taxonomy_exists( $second ) ) {
    424427                                        $id = 'edit-tags';
     
    438441
    439442                // If this is the current screen, see if we can be more accurate for post types and taxonomies.
    440443                if ( ! $hook_name ) {
     444                        if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) )
     445                                $post_type = $_REQUEST['post_type'];
     446                        if ( isset( $_REQUEST['taxonomy'] ) && post_type_exists( $_REQUEST['taxonomy'] ) )
     447                                $post_type = $_REQUEST['taxonomy'];
     448
    441449                        switch ( $base ) {
    442450                                case 'post' :
    443451                                        if ( isset( $_GET['post'] ) )
     
    451459                                                $post = get_post( $post_id );
    452460                                                if ( $post )
    453461                                                        $post_type = $post->post_type;
    454                                         } elseif ( isset( $_POST['post_type'] ) && post_type_exists( $_POST['post_type'] ) ) {
    455                                                 $post_type = $_POST['post_type'];
    456                                         } elseif ( $action == 'add' && isset( $_GET['post_type'] ) && post_type_exists( $_GET['post_type'] ) ) {
    457                                                 $post_type = $_GET['post_type'];
    458462                                        }
    459463                                        break;
    460                                 case 'edit' :
    461                                         if ( isset( $_GET['post_type'] ) && post_type_exists( $_GET['post_type'] ) )
    462                                                 $post_type = $_GET['post_type'];
    463                                         break;
    464464                                case 'edit-tags' :
    465                                         if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) )
    466                                                 $taxonomy = $_REQUEST['taxonomy'];
    467                                         if ( isset( $_REQUEST['post_type'] ) && post_type_exists( $_REQUEST['post_type'] ) )
    468                                                 $post_type = $_REQUEST['post_type'];
    469                                         else if ( is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) )
     465                                        if ( ! $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) )
    470466                                                $post_type = 'post';
    471467                                        break;
    472468                        }
     
    498494                        $base .= '-user';
    499495                }
    500496
    501                 if ( isset( self::$_registry[ $id ] ) )
    502                         return self::$_registry[ $id ];
     497                if ( isset( self::$_registry[ $id ] ) ) {
     498                        $screen = self::$_registry[ $id ];
     499                        if ( $screen === get_current_screen() )
     500                                return $screen;
     501                } else {
     502                        $screen = new WP_Screen();
     503                        $screen->id     = $id;
     504                }
    503505
    504                 $screen = new WP_Screen();
    505                 $screen->id         = $id;
    506506                $screen->base       = $base;
    507507                $screen->action     = $action;
    508508                $screen->post_type  = $post_type;
  • wp-admin/admin.php

     
    8888        $plugin_page = plugin_basename($plugin_page);
    8989}
    9090
    91 if ( isset($_GET['post_type']) )
    92         $typenow = sanitize_key($_GET['post_type']);
     91if ( isset( $_GET['post_type'] ) && post_type_exists( $_GET['post_type'] ) )
     92        $typenow = $_GET['post_type'];
    9393else
    9494        $typenow = '';
    9595
    96 if ( isset($_GET['taxonomy']) )
    97         $taxnow = sanitize_key($_GET['taxonomy']);
     96if ( isset( $_GET['taxonomy'] ) && taxonomy_exists( $_GET['taxonomy'] ) )
     97        $taxnow = $_GET['taxonomy'];
    9898else
    9999        $taxnow = '';
    100100