Make WordPress Core


Ignore:
Timestamp:
12/09/2004 01:30:34 AM (21 years ago)
Author:
saxmatt
Message:

Related to: http://mosquito.wordpress.org/view.php?id=225

Allow optiondates to be a PHP date() formatted timestamp, maintains backward compatibility.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/template-functions-category.php

    r1908 r1931  
    328328    }
    329329   
    330     if (intval($optiondates) == 1) {
    331         $cat_dates = $wpdb->get_results("   SELECT cat_ID,
    332         DAYOFMONTH(MAX(post_date)) AS lastday, MONTH(MAX(post_date)) AS lastmonth
    333         FROM $wpdb->categories
    334         LEFT JOIN $wpdb->post2cat ON (cat_ID = category_id)
    335         LEFT JOIN $wpdb->posts ON (ID = post_id)
    336         WHERE post_status = 'publish' $exclusions
     330    if ( $optiondates ) {
     331        $cat_dates = $wpdb->get_results("   SELECT category_id,
     332        UNIX_TIMESTAMP( MAX(post_date) ) AS ts
     333        FROM $wpdb->posts, $wpdb->post2cat
     334        WHERE post_status = 'publish' AND post_id = ID $exclusions
    337335        GROUP BY category_id");
    338336        foreach ($cat_dates as $cat_date) {
    339             $category_lastday["$cat_date->cat_ID"] = $cat_date->lastday;
    340             $category_lastmonth["$cat_date->cat_ID"] = $cat_date->lastmonth;
     337            $category_timestamp["$cat_date->category_id"] = $cat_date->ts;
    341338        }
    342339    }
     
    402399                $link .= ' ('.intval($category_posts["$category->cat_ID"]).')';
    403400            }
    404             if (intval($optiondates) == 1) {
    405                 $link .= ' '.$category_lastday["$category->cat_ID"].'/'.$category_lastmonth["$category->cat_ID"];
     401            if ( $optiondates ) {
     402                if ( $optiondates == 1 ) $optiondates = 'Y-m-d';
     403                $link .= ' ' . gmdate($optiondates, $category_timestamp["$category->cat_ID"]);
    406404            }
    407405            if ($list) {
Note: See TracChangeset for help on using the changeset viewer.