Opened 22 months ago

Last modified 17 months ago

#18166 new enhancement

Be able to amend the parent dropdown on the edit taxonomy term page

Reported by: leewillis77 Owned by:
Priority: normal Milestone: Awaiting Review
Component: Taxonomy Version: 3.2.1
Severity: normal Keywords: has-patch
Cc:

Description

It would be useful to filter the parent dropdown on the edit taxonomy term page (/wp-admin/edit-tags.php?taxonomy=foo&post_type=bar).

See attached patch (The filter probably needs a better name, but you get the point).

Attachments (2)

filter.diff (1.1 KB) - added by leewillis77 22 months ago.
Example filter
filter2.diff (1.1 KB) - added by leewillis77 22 months ago.
Revised patch, reverses arguments passed to filter, and svn diff from root.

Download all attachments as: .zip

Change History (9)

Example filter

  • Summary changed from Would be nice to be able to amend the parent dropdown on the edit taxonomy term page to Be able to amend the parent dropdown on the edit taxonomy term page

apply_filters() only returns one value, so you need to pass the entire array in the first argument for it to be returned.

comment:2 follow-up: ↓ 3   leewillis7722 months ago

Actually - the patch is exactly what I need, I think perhaps the description I used is misleading.

I want to be able to amend the arguments passed to wp_dropdown_categories. In the use case that led to me reporting this I'm amending the depth parameter so that the end result is that the dropdown list only contains top-level items.

So while my use-case is to cause the contents of the drop-down to be amended, I'm not actually looking to filter the output directly ...

comment:3 in reply to: ↑ 2   kawauso22 months ago

Replying to leewillis77:

Actually - the patch is exactly what I need, I think perhaps the description I used is misleading.

I want to be able to amend the arguments passed to wp_dropdown_categories. In the use case that led to me reporting this I'm amending the depth parameter so that the end result is that the dropdown list only contains top-level items.

So while my use-case is to cause the contents of the drop-down to be amended, I'm not actually looking to filter the output directly ...

Slightly bad wording on my part, the issue is that with your patch the only value eventually passed to wp_dropdown_categories() is $taxonomy (after filtering) since the first value passed to apply_filters() is the one being filtered. You need to be passing the entire arguments array as the first parameter. Also please make patches relative to the root directory.

Ah, right OK. The value returned is up to the filter function itself. In my working example I was doing:

function ($a, $b) {

modify_b();
return $b;

}

But you're right - as a matter of style I guess the arguments should be the other way around, so that the first variable passed is the one that is "filtered". Re-worked patch attached.

Revised patch, reverses arguments passed to filter, and svn diff from root.

But you're right - as a matter of style I guess the arguments should be the other way around, so that the first variable passed is the one that is "filtered".

It's not just a matter of style, In the event there's nothing hooked to the filter, the first arg would be returned. So if nothing was using the filter in the original patch, $taxonomy would've been passed to wp_dropdown_categories() instead of the array.

  • Keywords has-patch added

I'm still having to work-around (Bodge) the lack of this filter - is there anything else I can to hasten its inclusion? The patch still applies cleanly to trunk for info.

Note: See TracTickets for help on using tickets.