From 28080bcaae9d19159fac21257a20f78969c76728 Mon Sep 17 00:00:00 2001 From: Matt Mullenweg Date: Thu, 9 Dec 2004 01:30:34 +0000 Subject: [PATCH] Related to: http://mosquito.wordpress.org/view.php?id=225 Allow optiondates to be a PHP date() formatted timestamp, maintains backward compatibility. git-svn-id: https://develop.svn.wordpress.org/trunk@1931 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/template-functions-category.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/wp-includes/template-functions-category.php b/wp-includes/template-functions-category.php index 425e4dbeda..431bc60393 100644 --- a/wp-includes/template-functions-category.php +++ b/wp-includes/template-functions-category.php @@ -327,17 +327,14 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde } } - if (intval($optiondates) == 1) { - $cat_dates = $wpdb->get_results(" SELECT cat_ID, - 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 post_status = 'publish' $exclusions + if ( $optiondates ) { + $cat_dates = $wpdb->get_results(" SELECT category_id, + UNIX_TIMESTAMP( MAX(post_date) ) AS ts + FROM $wpdb->posts, $wpdb->post2cat + WHERE post_status = 'publish' AND post_id = ID $exclusions GROUP BY category_id"); foreach ($cat_dates as $cat_date) { - $category_lastday["$cat_date->cat_ID"] = $cat_date->lastday; - $category_lastmonth["$cat_date->cat_ID"] = $cat_date->lastmonth; + $category_timestamp["$cat_date->category_id"] = $cat_date->ts; } } @@ -401,8 +398,9 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde if (intval($optioncount) == 1) { $link .= ' ('.intval($category_posts["$category->cat_ID"]).')'; } - if (intval($optiondates) == 1) { - $link .= ' '.$category_lastday["$category->cat_ID"].'/'.$category_lastmonth["$category->cat_ID"]; + if ( $optiondates ) { + if ( $optiondates == 1 ) $optiondates = 'Y-m-d'; + $link .= ' ' . gmdate($optiondates, $category_timestamp["$category->cat_ID"]); } if ($list) { $thelist .= "\t
  • $link\n";