From be55326e50e6c7e15a5ff6e915d2efd2ef832fdd Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 23 Dec 2008 12:52:37 +0000 Subject: [PATCH] Allow overriding cat walker. Props AaronCampbell. fixes #8682 for trunk git-svn-id: https://develop.svn.wordpress.org/trunk@10246 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/includes/template.php | 6 ++++-- wp-includes/category-template.php | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 74d25ea2ae..1c9203ac45 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -439,8 +439,10 @@ class Walker_Category_Checklist extends Walker { * @param unknown_type $selected_cats * @param unknown_type $popular_cats */ -function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false ) { - $walker = new Walker_Category_Checklist; +function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null ) { + if ( empty($walker) || !is_a($walker, 'Walker') ) + $walker = new Walker_Category_Checklist; + $descendants_and_self = (int) $descendants_and_self; $args = array(); diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index e3c1b466b3..fb8e45def4 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -719,8 +719,13 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { * @see Walker_Category::walk() for parameters and return description. */ function walk_category_tree() { - $walker = new Walker_Category; $args = func_get_args(); + // the user's options are the third parameter + if ( empty($args[2]['walker']) || !is_a($args[2]['walker'], 'Walker') ) + $walker = new Walker_Category; + else + $walker = $args[2]['walker']; + return call_user_func_array(array( &$walker, 'walk' ), $args ); } @@ -732,8 +737,13 @@ function walk_category_tree() { * @see Walker_CategoryDropdown::walk() for parameters and return description. */ function walk_category_dropdown_tree() { - $walker = new Walker_CategoryDropdown; $args = func_get_args(); + // the user's options are the third parameter + if ( empty($args[2]['walker']) || !is_a($args[2]['walker'], 'Walker') ) + $walker = new Walker_CategoryDropdown; + else + $walker = $args[2]['walker']; + return call_user_func_array(array( &$walker, 'walk' ), $args ); }