Make WordPress Core

Ticket #18722: 18722.no-global.2.diff

File 18722.no-global.2.diff, 2.9 KB (added by coffee2code, 13 years ago)

Patch to help screen figure out its post_type

  • wp-admin/includes/class-wp-terms-list-table.php

     
    283283        }
    284284
    285285        function column_posts( $tag ) {
    286                 global $taxonomy, $post_type;
     286                global $taxonomy;
    287287
    288288                $count = number_format_i18n( $tag->count );
    289289
    290290                $tax = get_taxonomy( $taxonomy );
    291291
     292                $post_type = get_current_screen()->post_type;
    292293                $ptype_object = get_post_type_object( $post_type );
     294
    293295                if ( ! $ptype_object->show_ui )
    294296                        return $count;
    295297
  • wp-admin/includes/screen.php

     
    445445
    446446                $base = $id;
    447447
    448                 // If this is the current screen, see if we can be more accurate for post types and taxonomies.
    449                 if ( ! $hook_name ) {
    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;
     448                // If post_type or taxonomy haven't been determined yet, check further.
     449                if ( ! $post_type && isset( $_REQUEST['post_type'] ) )
     450                        $post_type = post_type_exists( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : false;
     451                if ( ! $taxonomy && isset( $_REQUEST['taxonomy'] ) )
     452                        $taxonomy = taxonomy_exists( $_REQUEST['taxonomy'] ) ? $_REQUEST['taxonomy'] : false;
    454453
    455                         switch ( $base ) {
    456                                 case 'post' :
    457                                         if ( isset( $_GET['post'] ) )
    458                                                 $post_id = (int) $_GET['post'];
    459                                         elseif ( isset( $_POST['post_ID'] ) )
    460                                                 $post_id = (int) $_POST['post_ID'];
    461                                         else
    462                                                 $post_id = 0;
    463 
    464                                         if ( $post_id ) {
    465                                                 $post = get_post( $post_id );
    466                                                 if ( $post )
    467                                                         $post_type = $post->post_type;
    468                                         }
    469                                         break;
    470                                 case 'edit-tags' :
    471                                         if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) )
    472                                                 $post_type = 'post';
    473                                         break;
    474                         }
    475                 }
    476 
    477454                switch ( $base ) {
    478455                        case 'post' :
     456                                if ( isset( $_GET['post'] ) )
     457                                        $post_id = (int) $_GET['post'];
     458                                elseif ( isset( $_POST['post_ID'] ) )
     459                                        $post_id = (int) $_POST['post_ID'];
     460                                else
     461                                        $post_id = 0;
     462
     463                                if ( $post_id ) {
     464                                        $post = get_post( $post_id );
     465                                        if ( $post )
     466                                                $post_type = $post->post_type;
     467                                }
    479468                                if ( null === $post_type )
    480469                                        $post_type = 'post';
    481470                                $id = $post_type;
     
    488477                        case 'edit-tags' :
    489478                                if ( null === $taxonomy )
    490479                                        $taxonomy = 'post_tag';
     480                                if ( null === $post_type && is_object_in_taxonomy( 'post', $taxonomy ? $taxonomy : 'post_tag' ) )
     481                                        $post_type = 'post';
    491482                                $id = 'edit-' . $taxonomy;
    492483                                break;
    493484                        case 'upload' :