Make WordPress Core

Ticket #36152: 36152.3.diff

File 36152.3.diff, 2.3 KB (added by swissspidy, 9 years ago)
  • src/wp-admin/includes/class-wp-posts-list-table.php

    diff --git src/wp-admin/includes/class-wp-posts-list-table.php src/wp-admin/includes/class-wp-posts-list-table.php
    index d6f4d9c..fe8808b 100644
    class WP_Posts_List_Table extends WP_List_Table { 
    412412        }
    413413
    414414        /**
    415          * @global int $cat
     415         * Displays a categories drop-down for filtering on the Posts list table.
     416         *
     417         * @since 4.6.0
     418         * @access protected
     419         *
     420         * @global int $cat Currently selected category.
     421         *
     422         * @param string $post_type The Post Type.
     423         */
     424        protected function categories_dropdown( $post_type ) {
     425                global $cat;
     426
     427                /**
     428                 * Filters whether to remove the 'Categories' drop-down from the post list table.
     429                 *
     430                 * @since 4.6.0
     431                 *
     432                 * @param bool   $disable   Whether to disable the categories drop-down. Default false.
     433                 * @param string $post_type The post type.
     434                 */
     435                if ( false !== apply_filters( 'disable_categories_dropdown', false, $post_type ) ) {
     436                        return;
     437                }
     438
     439                if ( is_object_in_taxonomy( $post_type, 'category' ) ) {
     440                        $dropdown_options = array(
     441                                'show_option_all' => get_taxonomy( 'category' )->labels->all_items,
     442                                'hide_empty' => 0,
     443                                'hierarchical' => 1,
     444                                'show_count' => 0,
     445                                'orderby' => 'name',
     446                                'selected' => $cat
     447                        );
     448
     449                        echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>';
     450                        wp_dropdown_categories( $dropdown_options );
     451                }
     452        }
     453
     454        /**
    416455         * @param string $which
    417456         */
    418457        protected function extra_tablenav( $which ) {
    419                 global $cat;
    420458?>
    421459                <div class="alignleft actions">
    422460<?php
    423461                if ( 'top' === $which && !is_singular() ) {
    424462
    425463                        $this->months_dropdown( $this->screen->post_type );
    426 
    427                         if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) {
    428                                 $dropdown_options = array(
    429                                         'show_option_all' => get_taxonomy( 'category' )->labels->all_items,
    430                                         'hide_empty' => 0,
    431                                         'hierarchical' => 1,
    432                                         'show_count' => 0,
    433                                         'orderby' => 'name',
    434                                         'selected' => $cat
    435                                 );
    436 
    437                                 echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>';
    438                                 wp_dropdown_categories( $dropdown_options );
    439                         }
     464                        $this->categories_dropdown( $this->screen->post_type );
    440465
    441466                        /**
    442467                         * Fires before the Filter button on the Posts and Pages list tables.