[wp-trac] [WordPress Trac] #11212: Add filter to wp_parse_args()

WordPress Trac wp-trac at lists.automattic.com
Sat Nov 21 05:26:36 UTC 2009


#11212: Add filter to wp_parse_args()
--------------------------+-------------------------------------------------
 Reporter:  Viper007Bond  |       Owner:           
     Type:  enhancement   |      Status:  new      
 Priority:  lowest        |   Milestone:  2.9      
Component:  General       |     Version:  2.9      
 Severity:  normal        |    Keywords:  has-patch
--------------------------+-------------------------------------------------

Comment(by Viper007Bond):

 Example of the awesomeness of this filter:

 I want to control the `max_depth` value of `wp_list_comments()`, so here's
 a function that'll do it:

 {{{
 add_filter( 'wp_parse_args', 'viper_thread_comments_depth', 10, 3 );

 function viper_thread_comments_depth( $args, $passed, $defaults ) {
         $wp_list_comments_defaults = array(
                 'walker' => null, 'max_depth' => '', 'style' => 'ul',
 'callback' => null, 'end-callback' => null, 'type' => 'all',
                 'page' => '', 'per_page' => '', 'avatar_size' => 32,
 'reverse_top_level' => null, 'reverse_children' => ''
         );

         if ( $wp_list_comments_defaults === $defaults )
                 $args['max_depth'] = 1;

         return $args;
 }
 }}}

 Obviously that's not 100% reliable for all functions (due to defaults
 collisions), but there's a ton of cases where it is reliable. :)

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/11212#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list