Make WordPress Core

Opened 6 years ago

Last modified 6 years ago

#44343 new feature request

Add filter hook for parent dropdown arguments

Reported by: obiplabon's profile obiplabon Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch 2nd-opinion
Focuses: administration Cc:

Description

We can easily control parent dropdown arguments on taxonomy screen and post edit screen (1). But on post edit screen it's not possible to control the parent dropdown arguments for ajax call (2). So we need a filter hook for that.

http://pix.toile-libre.org/upload/original/1528614160.png

Attachments (2)

44343.diff (1.2 KB) - added by obiplabon 6 years ago.
Patch for this feature
1528614160.png (20.0 KB) - added by birgire 6 years ago.

Download all attachments as: .zip

Change History (7)

@obiplabon
6 years ago

Patch for this feature

#1 @obiplabon
6 years ago

  • Keywords has-patch added; needs-patch removed

@birgire
6 years ago

#2 follow-up: @birgire
6 years ago

  • Version trunk deleted

Thanks for the ticket and the patch @obiplabon.

That seems to make sense to have it easily filterable too, though I think one could use the get_terms_args filter, with a doing_action()/did_action() check for the corresponding ajax action hook, as a workaround.

Some notes regarding 44343.diff:

  • Missing @since in the filter's docblock.
  • It would be nice to have the description for the input @param.
  • It would be nice to have the default elements of the $args input documented.
  • Would we ever need to only change the ajax output of wp_dropdown_categories()? What about using the existing post_edit_category_parent_dropdown_args filter, for the ajax wp_dropdown_categories() arguments, as well, since those two outputs are so related? In that case, we can refer to the existing inline filter documentation. Here I'm assuming the ajax callback is only used for the post edit screen (we might have to verify that). Thoughts?

I attached the screenshot 1528614160.png, just in case the external link goes down or changes.

#3 in reply to: ↑ 2 @obiplabon
6 years ago

Hi birgire

Thanks for your valuable review. It's my first patch that's why I was a bit confused about what to add and what to not. I'll add those stuffs from now on.

Thanks for the workaround. I didn't even think about that, somehow slipped my mind.

post_edit_category_parent_dropdown_args works only when the page reloads, this filter hook doesn't work for ajax call. And yes, the ajax callback is only used for the post edit screen.

When we add hierarchical terms from post edit screen the dropdown changes and there's no convenient filter hook to change the wp_dropdown_categories() arguments. It'd be better if there's a easy filter hook.

What do you think? Should I upload an updated patch?

Thanks

#4 @birgire
6 years ago

  • Keywords 2nd-opinion added

It might be good to have a second opinion regarding reusing the post_edit_category_parent_dropdown_args filter in ajax, before writing the patch.

At the moment I would favor reusing that filter for ajax too, instead of introducing a new one.

So I tag the question for that.

#5 @obiplabon
6 years ago

@birgire Thanks, liked your second opinion idea.

Let's hear what other people say.

Note: See TracTickets for help on using tickets.