Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#21591 closed enhancement (duplicate)

Allow passing array of hook names to add_filter and add_action

Reported by: joehoyle's profile joehoyle Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Plugins Keywords:
Focuses: Cc:


One thing I wish I was able to do is pass multiple hooks to add_action() and add_filter(), so I could do stuff like this:

add_action( ["admin_print_styles-post.php", "admin_print_styles-post-new.php"], function() {
    echo 'Two in one!';
} );

Currently If you want to use a closure you have to do something like

add_action( "admin_print_styles-post.php", $hook = function() {
    echo 'Two in one!';
} );
add_action( "admin_print_styles-post-new.php", $hook );

Change History (1)

#1 @scribu
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.