[wp-trac] [WordPress Trac] #22250: Useful helper function, add_action_with_args()
WordPress Trac
noreply at wordpress.org
Mon Oct 22 18:39:46 UTC 2012
#22250: Useful helper function, add_action_with_args()
-------------------------+----------------------
Reporter: rzen | Owner:
Type: enhancement | Status: closed
Priority: normal | Milestone:
Component: General | Version:
Severity: normal | Resolution: wontfix
Keywords: close |
-------------------------+----------------------
Comment (by scribu):
Oh, and if you find yourself doing something like this:
{{{
foreach ( get_option( 'footer_sidebars' ) as $sidebar_id ) {
add_action( 'wp_footer', function() use ( $sidebar_id ) {
get_sidebar( 'footer' );
} );
}
}}}
you should consider refactoring your code so that it looks more like this:
{{{
add_action( 'wp_footer', function() {
foreach ( get_option( 'footer_sidebars' ) as $sidebar_id ) {
get_sidebar( $sidebar_id );
}
} );
}}}
Callbacks are not free.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22250#comment:13>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list