function fd_hot_list($type = '', $timescale = 'today', $offset = 0, $length = 5, $cat = '') { $time_start = ''; $time_end = time(); switch($timescale) { case 'today': $time_start = $time_end - (60 * 60 * 24); break; case 'week': $time_start = $time_end - (60 * 60 * 24 * 7); break; case 'month': $time_start = $time_end - (60 * 60 * 24 * 30); break; case 'ever': $time_start = ''; } if($time_start != '') $time_start = fd_dt2sql($time_start); $time_end = fd_dt2sql($time_end); if($type = 'hits') { $top_hits = fd_hot_tophits($time_start, $time_end, $offset, $length, $cat); echo ""; } } function fd_hot_tophits($time_start = '', $time_end = '', $offset = 0, $length = 5, $cat = '') { global $wpdb; $tbl = $wpdb->prefix.'hot_hits'; $timescale = "'1'"; if($time_start != '') { $timescale .= " and date > '$time_start'"; } if($time_end != '') { $timescale .= " and date < '$time_end'"; } $query = "SELECT post_id FROM $tbl WHERE $timescale"; $results = $wpdb->get_col($query); foreach($results as $result) { $hitcounts[$result] = $hitcounts[$result] + 1; } arsort($hitcounts); //$sorted_ids = array_keys($hitcounts); if($length > count($hitcounts)) $length = count($hitcounts); return array_slice($hitcounts, $offset, $length, true); }