diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index 9cb93257dc..e21b74c3dc 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -411,4 +411,22 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde return wp_list_cats($query); } +function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc', + $show_last_update = 0, $show_counts = 0, $hide_empty = 1, $optionnone = FALSE, + $selected = 0, $exclude = 0) { + + $show_option_all = ''; + if ( $optionall ) + $show_option_all = $all; + + $show_option_none = ''; + if ( $optionnone ) + $show_option_none = __('None'); + + $vars = compact('show_option_all', 'show_option_none', 'orderby', 'order', + 'show_last_update', 'show_counts', 'hide_empty', 'selected', 'exclude'); + $query = add_query_arg($vars, ''); + return wp_dropdown_categories($query); +} + ?> diff --git a/wp-includes/template-functions-category.php b/wp-includes/template-functions-category.php index 8de01ec1c9..113c296ea3 100644 --- a/wp-includes/template-functions-category.php +++ b/wp-includes/template-functions-category.php @@ -149,62 +149,100 @@ function category_description($category = 0) { return apply_filters('category_description', $category->category_description, $category->cat_ID); } -// out of the WordPress loop -function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', - $optiondates = 0, $optioncount = 0, $hide_empty = 1, $optionnone=FALSE, - $selected=0, $hide=0) { - global $wpdb; - if ( ($file == 'blah') || ($file == '') ) - $file = get_settings('home') . '/'; - if ( !$selected ) - $selected=$cat; - $sort_column = 'cat_'.$sort_column; +function wp_dropdown_categories($args = '') { + parse_str($args, $r); + if ( !isset($r['show_option_all'])) + $r['show_option_all'] = ''; + if ( !isset($r['show_option_none'])) + $r['show_option_none'] = ''; + if ( !isset($r['orderby']) ) + $r['orderby'] = 'ID'; + if ( !isset($r['order']) ) + $r['order'] = 'ASC'; + if ( !isset($r['show_last_update']) ) + $r['show_last_update'] = 0; + if ( !isset($r['show_counts']) ) + $r['show_counts'] = 0; + if ( !isset($r['hide_empty']) ) + $r['hide_empty'] = 1; + if ( !isset($r['child_of']) ) + $r['child_of'] = 0; + if ( !isset($r['exclude']) ) + $r['exclude'] = ''; + if ( !isset($r['echo']) ) + $r['echo'] = 1; + if ( !isset($r['selected']) ) + $r['selected'] = 0; + if ( !isset($r['hierarchical']) ) + $r['hierarchical'] = 0; + if ( !isset($r['name']) ) + $r['name'] = 'cat'; + if ( !isset($r['class']) ) + $r['class'] = 'postform'; - $query = " - SELECT cat_ID, cat_name, category_nicename,category_parent, - COUNT($wpdb->post2cat.post_id) AS cat_count, - DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth - FROM $wpdb->categories LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id) - LEFT JOIN $wpdb->posts ON (ID = post_id) - WHERE cat_ID > 0 - "; - if ( $hide ) { - $query .= " AND cat_ID != $hide"; - $query .= get_category_children($hide, " AND cat_ID != "); - } - $query .=" GROUP BY cat_ID"; - if ( intval($hide_empty) == 1 ) - $query .= " HAVING cat_count > 0"; - $query .= " ORDER BY $sort_column $sort_order, post_date DESC"; + $r['include_last_update_time'] = $r['show_last_update']; - $categories = $wpdb->get_results($query); - echo "\n"; + + $output = apply_filters('wp_dropdown_cats', $output); + + if ( $echo ) + echo $output; + + return $output; +} + +function _category_dropdown_element($output, $category, $depth, $selected, $args) { + $pad = str_repeat(' ', $depth * 3); + + $cat_name = apply_filters('list_cats', $category->cat_name, $category); + $output .= "\t\n"; + + return $output; } -// out of the WordPress loop function wp_list_cats($args = '') { + return wp_list_categories($args); +} + +function wp_list_categories($args = '') { parse_str($args, $r); if ( !isset($r['optionall'])) $r['optionall'] = 0; @@ -238,16 +276,17 @@ function wp_list_cats($args = '') { $r['hierarchical'] = false; if ( !isset($r['title_li']) ) $r['title_li'] = ''; - - $q['orderby'] = $r['sort_column']; - $q['order'] = $r['sort_order']; - $q['include_last_update_time'] = $r['optiondates']; + if ( !isset($r['orderby']) ) + $r['orderby'] = $r['sort_column']; + if ( !isset($r['order']) ) + $r['order'] = $r['sort_order']; + $r['include_last_update_time'] = $r['optiondates']; extract($r); - $args = add_query_arg($q, $args); - $categories = get_categories($args); - + $query = add_query_arg($r, ''); + $categories = get_categories($query); + $output = ''; if ( $title_li && $list ) $output = '