From 57592ef97685e466f7561b2bfaff4182c7517e26 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 21 Aug 2015 01:27:15 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@33682 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/meta-boxes.php | 39 +++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/meta-boxes.php b/src/wp-admin/includes/meta-boxes.php index 59e9fc3f7a..5efa971aff 100644 --- a/src/wp-admin/includes/meta-boxes.php +++ b/src/wp-admin/includes/meta-boxes.php @@ -510,7 +510,44 @@ function post_categories_meta_box( $post, $box ) { - $tax_name, 'hide_empty' => 0, 'name' => 'new' . $tax_name . '_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —' ) ); ?> + $tax_name, + 'hide_empty' => 0, + 'name' => 'new' . $tax_name . '_parent', + 'orderby' => 'name', + 'hierarchical' => 1, + 'show_option_none' => '— ' . $taxonomy->labels->parent_item . ' —', + ); + + /** + * Filters the arguments for the taxonomy parent dropdown on the Post Edit page. + * + * @since 4.4.0 + * + * @param array $parent_dropdown_args { + * Optional. Array of arguments to generate parent dropdown. + * + * @type string $taxonomy Name of the taxonomy to retrieve. + * @type bool $hide_if_empty True to skip generating markup if no + * categories are found. Default 0. + * @type string $name Value for the 'name' attribute + * of the select element. + * Default "new{$tax_name}_parent". + * @type string $orderby Which column to use for ordering + * terms. Default 'name'. + * @type bool|int $hierarchical Whether to traverse the taxonomy + * hierarchy. Default 1. + * @type string $show_option_none Text to display for the "none" option. + * Default "— {$parent} —", + * where `$parent` is 'parent_item' + * taxonomy label. + * } + * + */ + $parent_dropdown_args = apply_filters( 'post_edit_category_parent_dropdown_args', $parent_dropdown_args ); + wp_dropdown_categories( $parent_dropdown_args ); + ?>