Make WordPress Core

Changeset 33682


Ignore:
Timestamp:
08/21/2015 01:27:15 AM (9 years ago)
Author:
boonebgorges
Message:

Filter the arguments passed to wp_dropdown_categories() in the Categories post edit metabox.

The new 'post_edit_category_parent_dropdown_args' provides parity with other
places in wp-admin where wp_dropdown_categories() args are filtered, such as
'taxonomy_parent_dropdown_args'.

Props theMikeD.
Fixes #33026.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/meta-boxes.php

    r33666 r33682  
    511511                        <?php echo $taxonomy->labels->parent_item_colon; ?>
    512512                    </label>
    513                     <?php wp_dropdown_categories( array( 'taxonomy' => $tax_name, 'hide_empty' => 0, 'name' => 'new' . $tax_name . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '&mdash; ' . $taxonomy->labels->parent_item . ' &mdash;' ) ); ?>
     513                    <?php
     514                    $parent_dropdown_args = array(
     515                        'taxonomy'         => $tax_name,
     516                        'hide_empty'       => 0,
     517                        'name'             => 'new' . $tax_name . '_parent',
     518                        'orderby'          => 'name',
     519                        'hierarchical'     => 1,
     520                        'show_option_none' => '&mdash; ' . $taxonomy->labels->parent_item . ' &mdash;',
     521                    );
     522
     523                    /**
     524                     * Filters the arguments for the taxonomy parent dropdown on the Post Edit page.
     525                     *
     526                     * @since 4.4.0
     527                     *
     528                     * @param array $parent_dropdown_args {
     529                     *     Optional. Array of arguments to generate parent dropdown.
     530                     *
     531                     *     @type string   $taxonomy         Name of the taxonomy to retrieve.
     532                     *     @type bool     $hide_if_empty    True to skip generating markup if no
     533                     *                                      categories are found. Default 0.
     534                     *     @type string   $name             Value for the 'name' attribute
     535                     *                                      of the select element.
     536                     *                                      Default "new{$tax_name}_parent".
     537                     *     @type string   $orderby          Which column to use for ordering
     538                     *                                      terms. Default 'name'.
     539                     *     @type bool|int $hierarchical     Whether to traverse the taxonomy
     540                     *                                      hierarchy. Default 1.
     541                     *     @type string   $show_option_none Text to display for the "none" option.
     542                     *                                      Default "&mdash; {$parent} &mdash;",
     543                     *                                      where `$parent` is 'parent_item'
     544                     *                                      taxonomy label.
     545                     * }
     546                     *
     547                     */
     548                    $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args );
     549                    wp_dropdown_categories( $parent_dropdown_args );
     550                    ?>
    514551                    <input type="button" id="<?php echo $tax_name; ?>-add-submit" data-wp-lists="add:<?php echo $tax_name; ?>checklist:<?php echo $tax_name; ?>-add" class="button category-add-submit" value="<?php echo esc_attr( $taxonomy->labels->add_new_item ); ?>" />
    515552                    <?php wp_nonce_field( 'add-' . $tax_name, '_ajax_nonce-add-' . $tax_name, false ); ?>
Note: See TracChangeset for help on using the changeset viewer.