[wp-trac] [WordPress Trac] #8640: 2 new functions for Plugin API.

WordPress Trac wp-trac at lists.automattic.com
Tue Dec 16 21:42:47 GMT 2008


#8640: 2 new functions for Plugin API.
---------------------------+------------------------------------------------
 Reporter:  momo360modena  |       Owner:  anonymous
     Type:  enhancement    |      Status:  new      
 Priority:  normal         |   Milestone:  2.8      
Component:  General        |     Version:           
 Severity:  normal         |    Keywords:           
---------------------------+------------------------------------------------
 With my plugins, i use often the same action for differents Hooks.

 The code is:

 {{{
 add_action('save_post', 'example');
 add_action('publish_post', 'example');
 add_action('post_syndicated_item', 'example');
 }}}

 Why not to create add_actions() and add_filters() ?

 The result will be:
 {{{
 add_actions( array('save_post', 'publish_post', 'post_syndicated_item'),
 'example' );
 }}}

 Props functions:
 {{{
 function add_filters($tags, $function_to_add, $priority = 10,
 $accepted_args = 1) {
         if ( is_array($tags) ) {
                 foreach ( (array) $tags as $tag ) {
                         add_filter($tag, $function_to_add, $priority,
 $accepted_args);
                 }
                 return true;
         } else {
                 return add_filter($tags, $function_to_add, $priority,
 $accepted_args);
         }
 }

 function add_actions($tags, $function_to_add, $priority = 10,
 $accepted_args = 1) {
         return add_filters($tags, $function_to_add, $priority,
 $accepted_args);
 }
 }}}

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


More information about the wp-trac mailing list