Move echo/return outside of loops. Props DD32. fixes #7749

git-svn-id: https://develop.svn.wordpress.org/trunk@9333 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-10-24 20:47:12 +00:00
parent 2b5d6d0b6e
commit ecaf4dbec8
1 changed files with 12 additions and 26 deletions

View File

@ -740,6 +740,8 @@ function wp_get_archives($args = '') {
$where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r ); $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
$join = apply_filters('getarchives_join', "", $r); $join = apply_filters('getarchives_join', "", $r);
$output = '';
if ( 'monthly' == $type ) { if ( 'monthly' == $type ) {
$query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit"; $query = "SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit";
$key = md5($query); $key = md5($query);
@ -758,11 +760,7 @@ function wp_get_archives($args = '') {
$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year); $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
if ( $show_post_count ) if ( $show_post_count )
$after = ' ('.$arcresult->posts.')' . $afterafter; $after = ' ('.$arcresult->posts.')' . $afterafter;
$output = get_archives_link($url, $text, $format, $before, $after); $output .= get_archives_link($url, $text, $format, $before, $after);
if ( $echo )
echo $output;
else
return $output;
} }
} }
} elseif ('yearly' == $type) { } elseif ('yearly' == $type) {
@ -783,11 +781,7 @@ function wp_get_archives($args = '') {
$text = sprintf('%d', $arcresult->year); $text = sprintf('%d', $arcresult->year);
if ($show_post_count) if ($show_post_count)
$after = ' ('.$arcresult->posts.')' . $afterafter; $after = ' ('.$arcresult->posts.')' . $afterafter;
$output = get_archives_link($url, $text, $format, $before, $after); $output .= get_archives_link($url, $text, $format, $before, $after);
if ( $echo )
echo $output;
else
return $output;
} }
} }
} elseif ( 'daily' == $type ) { } elseif ( 'daily' == $type ) {
@ -809,11 +803,7 @@ function wp_get_archives($args = '') {
$text = mysql2date($archive_day_date_format, $date); $text = mysql2date($archive_day_date_format, $date);
if ($show_post_count) if ($show_post_count)
$after = ' ('.$arcresult->posts.')'.$afterafter; $after = ' ('.$arcresult->posts.')'.$afterafter;
$output = get_archives_link($url, $text, $format, $before, $after); $output .= get_archives_link($url, $text, $format, $before, $after);
if ( $echo )
echo $output;
else
return $output;
} }
} }
} elseif ( 'weekly' == $type ) { } elseif ( 'weekly' == $type ) {
@ -842,16 +832,12 @@ function wp_get_archives($args = '') {
$text = $arc_week_start . $archive_week_separator . $arc_week_end; $text = $arc_week_start . $archive_week_separator . $arc_week_end;
if ($show_post_count) if ($show_post_count)
$after = ' ('.$arcresult->posts.')'.$afterafter; $after = ' ('.$arcresult->posts.')'.$afterafter;
$output = get_archives_link($url, $text, $format, $before, $after); $output .= get_archives_link($url, $text, $format, $before, $after);
if ( $echo )
echo $output;
else
return $output;
} }
} }
} }
} elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) { } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC "; $orderby = ('alpha' == $type) ? "post_title ASC " : "post_date DESC ";
$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit"; $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
$key = md5($query); $key = md5($query);
$cache = wp_cache_get( 'wp_get_archives' , 'general'); $cache = wp_cache_get( 'wp_get_archives' , 'general');
@ -871,15 +857,15 @@ function wp_get_archives($args = '') {
$text = strip_tags(apply_filters('the_title', $arc_title)); $text = strip_tags(apply_filters('the_title', $arc_title));
else else
$text = $arcresult->ID; $text = $arcresult->ID;
$output = get_archives_link($url, $text, $format, $before, $after); $output .= get_archives_link($url, $text, $format, $before, $after);
if ( $echo )
echo $output;
else
return $output;
} }
} }
} }
} }
if ( $echo )
echo $output;
else
return $output;
} }
/** /**