From 7d27dfb9678a03bd6595245762fb2d61193e882e Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 16 Sep 2008 04:52:47 +0000 Subject: [PATCH] Add echo option to wp_get_archives(). Props ShaneF. fixes #7749 git-svn-id: http://svn.automattic.com/wordpress/trunk@8902 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/general-template.php | 33 ++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index fce6c13d2..1aa51c490 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -642,7 +642,8 @@ function wp_get_archives($args = '') { $defaults = array( 'type' => 'monthly', 'limit' => '', 'format' => 'html', 'before' => '', - 'after' => '', 'show_post_count' => false + 'after' => '', 'show_post_count' => false, + 'echo' => 1 ); $r = wp_parse_args( $args, $defaults ); @@ -697,7 +698,11 @@ function wp_get_archives($args = '') { $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year); if ( $show_post_count ) $after = ' ('.$arcresult->posts.')' . $afterafter; - echo 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) { @@ -718,7 +723,11 @@ function wp_get_archives($args = '') { $text = sprintf('%d', $arcresult->year); if ($show_post_count) $after = ' ('.$arcresult->posts.')' . $afterafter; - echo 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 ) { @@ -740,7 +749,11 @@ function wp_get_archives($args = '') { $text = mysql2date($archive_day_date_format, $date); if ($show_post_count) $after = ' ('.$arcresult->posts.')'.$afterafter; - echo 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 ) { @@ -769,7 +782,11 @@ function wp_get_archives($args = '') { $text = $arc_week_start . $archive_week_separator . $arc_week_end; if ($show_post_count) $after = ' ('.$arcresult->posts.')'.$afterafter; - echo get_archives_link($url, $text, $format, $before, $after); + $output = get_archives_link($url, $text, $format, $before, $after); + if ( $echo ) + echo $output; + else + return $output; } } } @@ -794,7 +811,11 @@ function wp_get_archives($args = '') { $text = strip_tags(apply_filters('the_title', $arc_title)); else $text = $arcresult->ID; - echo get_archives_link($url, $text, $format, $before, $after); + $output = get_archives_link($url, $text, $format, $before, $after); + if ( $echo ) + echo $output; + else + return $output; } } }