reverting the previous patch: it made it impossible to sort the list by category name

git-svn-id: http://svn.automattic.com/wordpress/trunk@2364 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
michelvaldrighi 2005-02-18 16:42:49 +00:00
parent 7431bdd75a
commit a7110c0663
1 changed files with 9 additions and 19 deletions

View File

@ -269,27 +269,20 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
} }
} }
if ($hide_empty) { if (intval($categories)==0){
$categories = array(); $sort_column = 'cat_'.$sort_column;
$extra_fields = 'cat_name, category_nicename, category_description,';
} else {
if (intval($categories)==0 && !$hide_empty){
$sort_column = 'cat_'.$sort_column;
$query = " $query = "
SELECT cat_ID, cat_name, category_nicename, category_description, category_parent SELECT cat_ID, cat_name, category_nicename, category_description, category_parent
FROM $wpdb->categories FROM $wpdb->categories
WHERE cat_ID > 0 $exclusions WHERE cat_ID > 0 $exclusions
ORDER BY $sort_column $sort_order"; ORDER BY $sort_column $sort_order";
$categories = $wpdb->get_results($query); $categories = $wpdb->get_results($query);
}
$extra_fields = '';
} }
if (!count($category_posts)) { if (!count($category_posts)) {
$now = current_time('mysql', 1); $now = current_time('mysql', 1);
$cat_counts = $wpdb->get_results(" SELECT cat_ID, $extra_fields $cat_counts = $wpdb->get_results(" SELECT cat_ID,
COUNT($wpdb->post2cat.post_id) AS cat_count COUNT($wpdb->post2cat.post_id) AS cat_count
FROM $wpdb->categories FROM $wpdb->categories
INNER JOIN $wpdb->post2cat ON (cat_ID = category_id) INNER JOIN $wpdb->post2cat ON (cat_ID = category_id)
@ -301,9 +294,6 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
foreach ($cat_counts as $cat_count) { foreach ($cat_counts as $cat_count) {
if (1 != intval($hide_empty) || $cat_count > 0) { if (1 != intval($hide_empty) || $cat_count > 0) {
$category_posts["$cat_count->cat_ID"] = $cat_count->cat_count; $category_posts["$cat_count->cat_ID"] = $cat_count->cat_count;
if ($hide_empty) {
$categories[] = $cat_count;
}
} }
} }
} }