[wp-trac] [WordPress Trac] #21591: Allow passing array of hook names to add_filter and add_action

WordPress Trac wp-trac at lists.automattic.com
Wed Aug 15 13:26:32 UTC 2012


#21591: Allow passing array of hook names to add_filter and add_action
-------------------------+-----------------------------
 Reporter:  joehoyle     |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Plugins      |    Version:
 Severity:  normal       |   Keywords:
-------------------------+-----------------------------
 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 );
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21591>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list