Apply 'taxonomy_parent_dropdown_args' filter when editing terms.

Added in WP 3.7 [25123], the 'taxonomy_parent_dropdown_args' filter affected
only the term creation interface. This changeset introduces parity by ensuring
that it is applied when editing terms as well.

The new `$context` parameter indicates whether the filter is being applied in
a 'new' or 'edit' context.

Props TimothyBlynJacobs, DrewAPicture.
Fixes #29853.
Built from https://develop.svn.wordpress.org/trunk@30998


git-svn-id: http://core.svn.wordpress.org/trunk@30980 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2014-12-29 15:27:22 +00:00
parent 5ccb434f15
commit 25e625b9b0
2 changed files with 19 additions and 2 deletions

View File

@ -106,7 +106,22 @@ do_action( "{$taxonomy}_term_edit_form_tag" );
<tr class="form-field term-parent-wrap">
<th scope="row"><label for="parent"><?php _ex( 'Parent', 'term parent' ); ?></label></th>
<td>
<?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'name' => 'parent', 'orderby' => 'name', 'taxonomy' => $taxonomy, 'selected' => $tag->parent, 'exclude_tree' => $tag->term_id, 'hierarchical' => true, 'show_option_none' => __('None'))); ?>
<?php
$dropdown_args = array(
'hide_empty' => 0,
'hide_if_empty' => false,
'taxonomy' => $taxonomy,
'name' => 'parent',
'orderby' => 'name',
'selected' => $tag->parent,
'exclude_tree' => $tag->term_id,
'hierarchical' => true,
'show_option_none' => __( 'None' ),
);
/** This filter is documented in wp-admin/edit-tags.php */
$dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'edit' );
wp_dropdown_categories( $dropdown_args ); ?>
<?php if ( 'category' == $taxonomy ) : ?>
<p class="description"><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p>
<?php endif; ?>

View File

@ -478,6 +478,7 @@ do_action( "{$taxonomy}_term_new_form_tag" );
* Filter the taxonomy parent drop-down on the Edit Term page.
*
* @since 3.7.0
* @since 4.1.0 Added $context parameter.
*
* @param array $dropdown_args {
* An array of taxonomy parent drop-down arguments.
@ -492,8 +493,9 @@ do_action( "{$taxonomy}_term_new_form_tag" );
* @type string $show_option_none Label to display if there are no terms. Default 'None'.
* }
* @param string $taxonomy The taxonomy slug.
* @param string $context Filter context. Accepts 'new' or 'edit'.
*/
$dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy );
$dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'new' );
wp_dropdown_categories( $dropdown_args );
?>
<?php if ( 'category' == $taxonomy ) : // @todo: Generic text for hierarchical taxonomies ?>