diff --git a/b2-include/b2template.functions.php b/b2-include/b2template.functions.php index 73e425e682..f1903ec90e 100644 --- a/b2-include/b2template.functions.php +++ b/b2-include/b2template.functions.php @@ -111,27 +111,45 @@ function single_month_title($prefix = '', $display = true ) { } function get_archives($type, $limit='') { - global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename, $querystring_start, $querystring_equal, $month, $wpdb; - // weekly and daily are *broken* + global $tableposts, $dateformat, $time_difference, $siteurl, $blogfilename, $querystring_start, $querystring_equal, $month, $wpdb, $start_of_week; + if ('' != $limit) { - $limit = (int) $limit; - $limit= " LIMIT $limit"; + $limit = (int) $limit; + $limit = " LIMIT $limit"; } // this is what will separate dates on weekly archive links $archive_week_separator = '–'; - - + // archive link url - $archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal; # monthly archive - $archive_link_w = $siteurl.'/'.$blogfilename.$querystring_start.'w'.$querystring_equal; # weekly archive - $archive_link_p = $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal; # post-by-post archive + $archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal; # monthly archive; + $archive_link_w = $siteurl.'/'.$blogfilename.$querystring_start.'w'.$querystring_equal; # weekly archive; + $archive_link_p = $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal; # post-by-post archive; + // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride + $archive_date_format_over_ride = 0; + + // options for daily archive (only if you over-ride the general date format) + $archive_day_date_format = 'Y/m/d'; + + // options for weekly archive (only if you over-ride the general date format) + $archive_week_start_date_format = 'Y/m/d'; + $archive_week_end_date_format = 'Y/m/d'; + + + //$dateformat=get_settings('date_format'); + //$time_difference=get_settings('time_difference'); + + if (!$archive_date_format_over_ride) { + $archive_day_date_format = $dateformat; + $archive_week_start_date_format = $dateformat; + $archive_week_end_date_format = $dateformat; + } $now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600))); if ('monthly' == $type) { ++$querycount; - $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month` FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC" . $limit); + $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month` FROM $tableposts WHERE post_date < '$now' AND post_category > 0 AND post_status = 'publish' ORDER BY post_date DESC" . $limit); foreach ($arcresults as $arcresult) { echo "