Make WordPress Core

Changeset 31307


Ignore:
Timestamp:
01/30/2015 07:17:51 PM (10 years ago)
Author:
boonebgorges
Message:

Introduce 'show_in_quick_edit' parameter for register_taxonomy().

Setting 'show_in_quick_edit' to false when registering a custom taxonomy will
hide the taxonomy when editing posts using Quick Edit.

The new 'quick_edit_show_taxonomy' filter allows this behavior to be filtered
on a finer scale, as when you want a given taxonomy to be hidden for one post
type but not for others.

Props hlashbrooke.
Fixes #26948.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r31220 r31307  
    945945        $flat_taxonomies = array();
    946946        foreach ( $taxonomy_names as $taxonomy_name ) {
     947
     948            /**
     949             * Filters whether the current taxonomy should be shown in the Quick Edit panel.
     950             *
     951             * @since 4.2.0
     952             *
     953             * @param bool   $show          Whether to show the current taxonomy in Quick Edit.
     954             *                              Default: true.
     955             * @param string $taxonomy_name Taxonomy name.
     956             * @param string $post_type     Post type of current Quick Edit post.
     957             */
     958            if ( ! apply_filters( 'quick_edit_show_taxonomy', true, $taxonomy_name, $screen->post_type ) ) {
     959                continue;
     960            }
     961
    947962            $taxonomy = get_taxonomy( $taxonomy_name );
    948963
    949             if ( !$taxonomy->show_ui )
     964            if ( ! $taxonomy->show_in_quick_edit ) {
    950965                continue;
     966            }
    951967
    952968            if ( $taxonomy->hierarchical )
  • trunk/src/wp-includes/taxonomy.php

    r31287 r31307  
    283283 * - show_tagcloud - Whether to list the taxonomy in the Tag Cloud Widget.
    284284 *     * If not set, the default is inherited from show_ui.
     285 * - show_in_quick_edit - Whether to show the taxonomy in the quick/bulk edit panel.
     286 *     * It not set, the default is inherited from show_ui.
    285287 * - show_admin_column - Whether to display a column for the taxonomy on its post type listing screens.
    286288 *     * Defaults to false.
     
    309311 *
    310312 * @since 2.3.0
     313 * @since 4.2.0 Introduced 'show_in_quick_edit' parameter.
    311314 * @uses $wp_taxonomies Inserts new taxonomy object into the list
    312315 * @uses $wp Adds query vars
     
    332335        'show_in_nav_menus'     => null,
    333336        'show_tagcloud'         => null,
     337        'show_in_quick_edit'    => null,
    334338        'show_admin_column'     => false,
    335339        'meta_box_cb'           => null,
     
    389393    if ( null === $args['show_tagcloud'] )
    390394        $args['show_tagcloud'] = $args['show_ui'];
     395
     396    // If not set, default to the setting for show_ui.
     397    if ( null === $args['show_in_quick_edit'] ) {
     398        $args['show_in_quick_edit'] = $args['show_ui'];
     399    }
    391400
    392401    $default_caps = array(
  • trunk/tests/phpunit/tests/taxonomy.php

    r30209 r31307  
    164164
    165165    /**
     166     * @ticket 26948
     167     */
     168    public function test_register_taxonomy_show_in_quick_edit_should_default_to_value_of_show_ui() {
     169        register_taxonomy( 'wptests_tax_1', 'post', array(
     170            'show_ui' => true,
     171        ) );
     172
     173        register_taxonomy( 'wptests_tax_2', 'post', array(
     174            'show_ui' => false,
     175        ) );
     176
     177        $tax_1 = get_taxonomy( 'wptests_tax_1' );
     178        $this->assertTrue( $tax_1->show_in_quick_edit );
     179
     180        $tax_2 = get_taxonomy( 'wptests_tax_2' );
     181        $this->assertFalse( $tax_2->show_in_quick_edit );
     182    }
     183
     184    /**
    166185     * @ticket 11058
    167186     */
Note: See TracChangeset for help on using the changeset viewer.