Opened 3 years ago
Closed 3 years ago
#12171 closed defect (bug) (fixed)
add_category_form_fields Action Fires Twice
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | Taxonomy | Version: | 3.0 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | glenn@… |
Description
The add_category_form_fields action fires twice in /wp-admin/edit-tags.php on line 341 - 345 in trunk with r. 13020.
This seems to happen because add_category_form_fields gets called and then 'add_' . $taxonomy . '_form' gets called.
I can submit a patch once I know which do_action needs to be removed.
if ( 'category' == $taxonomy )
do_action('edit_category_form', (object)array('parent' => 0) );
else
do_action('add_tag_form', $taxonomy);
do_action('add_' . $taxonomy . '_form', $taxonomy);
Attachments (4)
Change History (16)
- Keywords has-patch added; dev-feedback removed
- Owner changed from filosofo to dd32
- Status changed from new to assigned
Added a second patch to prevent add_tag_form_fields from firing twice in case a taxonomy called "tag" is registered.
A few things can be done here, However, I'm wondering if it'd be best to rename the new hook to avoid the conflict instead.
Eg, Change it from do_action('add_' . $taxonomy . '_form_pre', $taxonomy); to do_action($taxonomy . '_add_form_pre', $taxonomy);
This'd allow for the new generic hook to apply to categories, whilst also having the backwards compat for the old category actions args the same.
The reasoning for the renaming, is to allow for the current category hooks to continue to operate, however provide a exact and known hook for all future plugin developers to rely on (without having to add a special function to handle the category hook)
Correct, I'm going through and running into problems at the hooks starting at L 292, which are the ones included above (though not the action referred to in the ticket summary).
Throwing up the third patch to address the other code blocks. I agree with renaming so I'll include that as well.
I've got a hybrid of mine and nacin's code running locally which i'll finish testing later today.
comment:8
automattor — 3 years ago
Give that a whirl, and see if it provides a good enough support. All previous hooks should be working the same as they were before.
comment:10
dd32 — 3 years ago
- Status changed from assigned to closed
comment:11
nacin — 3 years ago
- Status changed from closed to reopened
comment:12
nacin — 3 years ago
- Resolution set to fixed
- Status changed from reopened to closed

Better patch.