WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#7216 closed enhancement (fixed)

remove_filter should allow all callback functions for a tag to be removed

Reported by: filosofo Owned by: jacobsantos
Milestone: 2.7 Priority: normal
Severity: normal Version: 2.6
Component: General Keywords: has-patch remove_filter dev-feedback
Focuses: Cc:

Description

Sometimes you want to remove lambda callback functions, and sometimes you want to remove all callback functions for a given action or filter hook, but currently you can't.

My patch allows you to remove all callback functions for a given tag, by specifying "all" as the function name: remove_filter('tag_name', 'all');

Attachments (2)

remove_filter.diff (720 bytes) - added by filosofo 7 years ago.
7216.r8534.diff (1.4 KB) - added by santosj 7 years ago.
remove_all_filters() and remove_all_actions() based off of r8534

Download all attachments as: .zip

Change History (11)

@filosofo7 years ago

comment:1 @jacobsantos7 years ago

Suggestion: Create a new function for handling this behavior.

comment:2 @jacobsantos7 years ago

  • Owner changed from anonymous to jacobsantos

comment:3 @jacobsantos7 years ago

  • Status changed from new to assigned

comment:4 @filosofo7 years ago

Why a new function? apply_filters lets you pass "all" as the "tag," so this is parallel behavior. Performance reasons should not be a factor, because remove_filter is not called enough to make a difference, and the check on that block should be pretty quick anyways.

Another function is just something else to have to remember.

comment:5 @jacobsantos7 years ago

Branches are something to be avoided as much as possible. The CPU still has to decide: Well, do I go into the branch and start loading that code or should I skip it and load the code after.

Having its own separate function, would be a short body and be pretty sweet.

@santosj7 years ago

remove_all_filters() and remove_all_actions() based off of r8534

comment:6 @santosj7 years ago

  • Keywords all removed

comment:7 @santosj7 years ago

  • Keywords dev-feedback added
  • Milestone changed from 2.9 to 2.7

Can this get in to 2.7?

comment:8 @santosj7 years ago

Is the patch acceptable for 2.7?

comment:9 @westi7 years ago

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

(In [8660]) remove_all_{actions|filters}. Fixes #7216 props filosofo and santosj.

Note: See TracTickets for help on using tickets.