WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#12171 closed defect (bug) (fixed)

add_category_form_fields Action Fires Twice

Reported by: blepoxp Owned by: dd32
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

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)

12171.diff (445 bytes) - added by nacin 4 years ago.
12171.2.diff (776 bytes) - added by nacin 4 years ago.
Better patch.
12171.4.diff (2.5 KB) - added by dd32 4 years ago.
12171.3.diff (3.5 KB) - added by nacin 4 years ago.
Addresses some more collisions

Download all attachments as: .zip

Change History (16)

comment:1 blepoxp4 years ago

  • Cc glenn@… added

comment:2 nacin4 years ago

  • Keywords has-patch added; dev-feedback removed
  • Owner changed from filosofo to dd32
  • Status changed from new to assigned

nacin4 years ago

nacin4 years ago

Better patch.

comment:3 nacin4 years ago

Added a second patch to prevent add_tag_form_fields from firing twice in case a taxonomy called "tag" is registered.

comment:4 dd324 years ago

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.

comment:5 dd324 years ago

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)

comment:6 nacin4 years ago

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.

dd324 years ago

nacin4 years ago

Addresses some more collisions

comment:7 dd324 years ago

I've got a hybrid of mine and nacin's code running locally which i'll finish testing later today.

comment:8 automattor4 years ago

(In [13035]) Rename new taxonomy page hooks to prevent hook conflicts. See #12171

comment:9 dd324 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 dd324 years ago

  • Status changed from assigned to closed

comment:11 nacin4 years ago

  • Status changed from closed to reopened

comment:12 nacin4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.