WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#35252 closed enhancement (fixed)

Add a `{$taxonomy}_term_edit_form_top` action (similar to the post editing form)

Reported by: flixos90 Owned by: boonebgorges
Milestone: 4.5 Priority: normal
Severity: normal Version: 4.4
Component: Taxonomy Keywords: has-patch
Focuses: administration Cc:
PR Number:

Description

I'm proposing to add a new action hook {$taxonomy}_term_edit_form_top to the term editing form that works similar to the edit_form_top action on the post editing form. This will allow developers to insert additional content on top of the edit form, just like when editing posts. Currently there is only a {$taxonomy}_pre_edit_form action which however is executed before the page's wrapper element, so it shouldn't be used to print content.

Concerning the new action, I'm not so much thinking about adding the actual meta fields there (since the term name, slug and description are probably more important and should stay on top), but rather any custom content - in my case for example, I would like to be able to show a custom message to the user if he/she entered a weird value for one of my term meta fields.

I'm gonna upload a patch with my proposed change.

Attachments (2)

35252.diff (1.0 KB) - added by flixos90 4 years ago.
added the new action
35252.2.diff (1.0 KB) - added by boonebgorges 4 years ago.

Download all attachments as: .zip

Change History (8)

@flixos90
4 years ago

added the new action

#1 @flixos90
4 years ago

  • Keywords has-patch added

#2 @boonebgorges
4 years ago

  • Milestone changed from Awaiting Review to 4.5
  • Owner set to boonebgorges
  • Status changed from new to assigned

Sure, this seems reasonable.

#3 follow-up: @boonebgorges
4 years ago

Is there a reason why the action has to be dynamic? If we're passing a taxonomy to it, then the dynamic filter name is redundant. See 35252.2.diff.

@boonebgorges
4 years ago

#4 in reply to: ↑ 3 ; follow-up: @flixos90
4 years ago

Replying to boonebgorges:

Is there a reason why the action has to be dynamic? If we're passing a taxonomy to it, then the dynamic filter name is redundant. See 35252.2.diff.

Not specifically, I was just looking at the other actions within the form most of which are dynamic, so I applied the same pattern to this new one. But your version is perfectly fine too.

In general however, I wonder which way is preferable. If you want to add something to only specific taxonomies, the dynamic approach is better I think because then you only add the filter where you actually need it - but if you want to add to every one, the way you did it would be easier.

#5 in reply to: ↑ 4 @boonebgorges
4 years ago

Replying to flixos90:

Replying to boonebgorges:

Is there a reason why the action has to be dynamic? If we're passing a taxonomy to it, then the dynamic filter name is redundant. See 35252.2.diff.

Not specifically, I was just looking at the other actions within the form most of which are dynamic, so I applied the same pattern to this new one. But your version is perfectly fine too.

In general however, I wonder which way is preferable. If you want to add something to only specific taxonomies, the dynamic approach is better I think because then you only add the filter where you actually need it - but if you want to add to every one, the way you did it would be easier.

True. I guess all the other actions in this form use the taxonomy name. I'm not a very big fan - it's more confusing to document, and passing the $taxonomy as an argument rather than as part of the action name gives you lots more flexibility, but I guess we should just go with the flow.

#6 @boonebgorges
4 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 36526:

Introduce {$taxonomy}_term_edit_form_top action to edit-tag-form.php.

This new action gives developers a place to output content at the beginning
of the form element on edit-tags.php.

Props flixos90.
Fixes #35252.

Note: See TracTickets for help on using tickets.