Index: wp-includes/general-template.php
===================================================================
--- wp-includes/general-template.php	(revision 22879)
+++ wp-includes/general-template.php	(working copy)
@@ -879,14 +879,13 @@
 	);
 
 	$r = wp_parse_args( $args, $defaults );
-	extract( $r, EXTR_SKIP );
 
-	if ( '' == $type )
-		$type = 'monthly';
+	if ( '' == $r['type'] )
+		$r['type'] = 'monthly';
 
-	if ( '' != $limit ) {
-		$limit = absint($limit);
-		$limit = ' LIMIT '.$limit;
+	if ( '' != $r['limit'] ) {
+		$r['limit'] = absint( $r['limit'] );
+		$r['limit'] = ' LIMIT '.$r['limit'];
 	}
 
 	$order = strtoupper( $order );
@@ -907,9 +906,9 @@
 	$archive_week_end_date_format	= 'Y/m/d';
 
 	if ( !$archive_date_format_over_ride ) {
-		$archive_day_date_format = get_option('date_format');
-		$archive_week_start_date_format = get_option('date_format');
-		$archive_week_end_date_format = get_option('date_format');
+		$archive_day_date_format = get_option( 'date_format' );
+		$archive_week_start_date_format = get_option( 'date_format' );
+		$archive_week_end_date_format = get_option( 'date_format' );
 	}
 
 	//filters
@@ -918,108 +917,108 @@
 
 	$output = '';
 
-	if ( 'monthly' == $type ) {
-		$query = "SELECT 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 $order $limit";
-		$key = md5($query);
+	if ( 'monthly' == $r['type'] ) {
+		$query = "SELECT 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 $order " . $r['limit'];
+		$key = md5( $query );
 		$cache = wp_cache_get( 'wp_get_archives' , 'general');
 		if ( !isset( $cache[ $key ] ) ) {
-			$arcresults = $wpdb->get_results($query);
+			$arcresults = $wpdb->get_results( $query );
 			$cache[ $key ] = $arcresults;
 			wp_cache_set( 'wp_get_archives', $cache, 'general' );
 		} else {
 			$arcresults = $cache[ $key ];
 		}
 		if ( $arcresults ) {
-			$afterafter = $after;
+			$afterafter = $r['after'];
 			foreach ( (array) $arcresults as $arcresult ) {
 				$url = get_month_link( $arcresult->year, $arcresult->month );
 				/* translators: 1: month name, 2: 4-digit year */
-				$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
-				if ( $show_post_count )
-					$after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
-				$output .= get_archives_link($url, $text, $format, $before, $after);
+				$text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $arcresult->month ), $arcresult->year );
+				if ( $r['show_post_count'] )
+					$r['after'] = '&nbsp;('.$arcresult->posts.')' . $afterafter;
+				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
 			}
 		}
-	} elseif ('yearly' == $type) {
-		$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit";
-		$key = md5($query);
+	} elseif ( 'yearly' == $r['type'] ) {
+		$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order " . $r['limit'];
+		$key = md5( $query );
 		$cache = wp_cache_get( 'wp_get_archives' , 'general');
 		if ( !isset( $cache[ $key ] ) ) {
-			$arcresults = $wpdb->get_results($query);
+			$arcresults = $wpdb->get_results( $query );
 			$cache[ $key ] = $arcresults;
 			wp_cache_set( 'wp_get_archives', $cache, 'general' );
 		} else {
 			$arcresults = $cache[ $key ];
 		}
-		if ($arcresults) {
-			$afterafter = $after;
+		if ( $arcresults ) {
+			$afterafter = $r['after'];
 			foreach ( (array) $arcresults as $arcresult) {
-				$url = get_year_link($arcresult->year);
-				$text = sprintf('%d', $arcresult->year);
-				if ($show_post_count)
-					$after = '&nbsp;('.$arcresult->posts.')' . $afterafter;
-				$output .= get_archives_link($url, $text, $format, $before, $after);
+				$url = get_year_link( $arcresult->year );
+				$text = sprintf( '%d', $arcresult->year );
+				if ($r['show_post_count'])
+					$r['after'] = '&nbsp;('.$arcresult->posts.')' . $afterafter;
+				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
 			}
 		}
-	} elseif ( 'daily' == $type ) {
-		$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit";
-		$key = md5($query);
+	} elseif ( 'daily' == $r['type'] ) {
+		$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order " . $r['limit'];
+		$key = md5( $query );
 		$cache = wp_cache_get( 'wp_get_archives' , 'general');
 		if ( !isset( $cache[ $key ] ) ) {
-			$arcresults = $wpdb->get_results($query);
+			$arcresults = $wpdb->get_results( $query );
 			$cache[ $key ] = $arcresults;
 			wp_cache_set( 'wp_get_archives', $cache, 'general' );
 		} else {
 			$arcresults = $cache[ $key ];
 		}
 		if ( $arcresults ) {
-			$afterafter = $after;
+			$afterafter = $r['after'];
 			foreach ( (array) $arcresults as $arcresult ) {
-				$url	= get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
-				$date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
-				$text = mysql2date($archive_day_date_format, $date);
-				if ($show_post_count)
-					$after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
-				$output .= get_archives_link($url, $text, $format, $before, $after);
+				$url	= get_day_link( $arcresult->year, $arcresult->month, $arcresult->dayofmonth );
+				$date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth );
+				$text = mysql2date( $archive_day_date_format, $date );
+				if ( $r['show_post_count'] )
+					$r['after'] = '&nbsp;('.$arcresult->posts.')'.$afterafter;
+				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
 			}
 		}
-	} elseif ( 'weekly' == $type ) {
+	} elseif ( 'weekly' == $r['type'] ) {
 		$week = _wp_mysql_week( '`post_date`' );
-		$query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
-		$key = md5($query);
+		$query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order " . $r['limit'];
+		$key = md5( $query );
 		$cache = wp_cache_get( 'wp_get_archives' , 'general');
 		if ( !isset( $cache[ $key ] ) ) {
-			$arcresults = $wpdb->get_results($query);
+			$arcresults = $wpdb->get_results( $query );
 			$cache[ $key ] = $arcresults;
 			wp_cache_set( 'wp_get_archives', $cache, 'general' );
 		} else {
 			$arcresults = $cache[ $key ];
 		}
 		$arc_w_last = '';
-		$afterafter = $after;
+		$afterafter = $r['after'];
 		if ( $arcresults ) {
 				foreach ( (array) $arcresults as $arcresult ) {
 					if ( $arcresult->week != $arc_w_last ) {
 						$arc_year = $arcresult->yr;
 						$arc_w_last = $arcresult->week;
-						$arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week'));
-						$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
-						$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
-						$url  = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&amp;', '=', $arcresult->week);
+						$arc_week = get_weekstartend( $arcresult->yyyymmdd, get_option( 'start_of_week' ) );
+						$arc_week_start = date_i18n( $archive_week_start_date_format, $arc_week['start'] );
+						$arc_week_end = date_i18n( $archive_week_end_date_format, $arc_week['end'] );
+						$url  = sprintf( '%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&amp;', '=', $arcresult->week );
 						$text = $arc_week_start . $archive_week_separator . $arc_week_end;
-						if ($show_post_count)
-							$after = '&nbsp;('.$arcresult->posts.')'.$afterafter;
-						$output .= get_archives_link($url, $text, $format, $before, $after);
+						if ( $r['show_post_count'] )
+							$r['after'] = '&nbsp;('.$arcresult->posts.')'.$afterafter;
+						$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
 					}
 				}
 		}
-	} elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
-		$orderby = ('alpha' == $type) ? 'post_title ASC ' : 'post_date DESC ';
-		$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
-		$key = md5($query);
+	} elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type']) ) {
+		$orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC ';
+		$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby " . $r['limit'];
+		$key = md5( $query );
 		$cache = wp_cache_get( 'wp_get_archives' , 'general');
 		if ( !isset( $cache[ $key ] ) ) {
-			$arcresults = $wpdb->get_results($query);
+			$arcresults = $wpdb->get_results( $query );
 			$cache[ $key ] = $arcresults;
 			wp_cache_set( 'wp_get_archives', $cache, 'general' );
 		} else {
@@ -1033,12 +1032,12 @@
 						$text = strip_tags( apply_filters( 'the_title', $arcresult->post_title, $arcresult->ID ) );
 					else
 						$text = $arcresult->ID;
-					$output .= get_archives_link($url, $text, $format, $before, $after);
+					$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
 				}
 			}
 		}
 	}
-	if ( $echo )
+	if ( $r['echo'] )
 		echo $output;
 	else
 		return $output;
@@ -1937,58 +1936,57 @@
 	);
 
 	$args = wp_parse_args( $args, $defaults );
-	extract($args, EXTR_SKIP);
 
 	// Who knows what else people pass in $args
-	$total = (int) $total;
-	if ( $total < 2 )
+	$args['total'] = (int) $args['total'];
+	if ( $args['total'] < 2 )
 		return;
-	$current  = (int) $current;
-	$end_size = 0  < (int) $end_size ? (int) $end_size : 1; // Out of bounds?  Make it the default.
-	$mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2;
-	$add_args = is_array($add_args) ? $add_args : false;
+	$args['current']  = (int) $args['current'];
+	$args['end_size'] = 0  < (int) $args['end_size'] ? (int) $args['end_size'] : 1; // Out of bounds?  Make it the default.
+	$args['mid_size'] = 0 <= (int) $args['mid_size'] ? (int) $args['mid_size'] : 2;
+	$args['add_args'] = is_array( $args['add_args '] ) ? $args['add_args '] : false;
 	$r = '';
 	$page_links = array();
 	$n = 0;
 	$dots = false;
 
-	if ( $prev_next && $current && 1 < $current ) :
-		$link = str_replace('%_%', 2 == $current ? '' : $format, $base);
-		$link = str_replace('%#%', $current - 1, $link);
-		if ( $add_args )
-			$link = add_query_arg( $add_args, $link );
-		$link .= $add_fragment;
-		$page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $prev_text . '</a>';
+	if ( $args['prev_next'] && $args['current'] && 1 < $args['current'] ) :
+		$link = str_replace('%_%', 2 == $args['current'] ? '' : $args['format'], $linkdata['link_category']);
+		$link = str_replace('%#%', $args['current'] - 1, $link);
+		if ( $args['add_args '] )
+			$link = add_query_arg( $args['add_args '], $link );
+		$link .= $args['add_fragment'];
+		$page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
 	endif;
-	for ( $n = 1; $n <= $total; $n++ ) :
+	for ( $n = 1; $n <= $args['total']; $n++ ) :
 		$n_display = number_format_i18n($n);
-		if ( $n == $current ) :
+		if ( $n == $args['current'] ) :
 			$page_links[] = "<span class='page-numbers current'>$n_display</span>";
 			$dots = true;
 		else :
-			if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
-				$link = str_replace('%_%', 1 == $n ? '' : $format, $base);
+			if ( $args['show_all'] || ( $n <= $args['end_size'] || ( $args['current'] && $n >= $args['current'] - $args['mid_size'] && $n <= $args['current'] + $args['mid_size'] ) || $n > $args['total'] - $args['end_size'] ) ) :
+				$link = str_replace('%_%', 1 == $n ? '' : $args['format'], $args['base']);
 				$link = str_replace('%#%', $n, $link);
-				if ( $add_args )
-					$link = add_query_arg( $add_args, $link );
-				$link .= $add_fragment;
+				if ( $args['add_args '] )
+					$link = add_query_arg( $args['add_args '], $link );
+				$link .= $args['add_fragment'];
 				$page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$n_display</a>";
 				$dots = true;
-			elseif ( $dots && !$show_all ) :
+			elseif ( $dots && !$args['show_all'] ) :
 				$page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
 				$dots = false;
 			endif;
 		endif;
 	endfor;
-	if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
-		$link = str_replace('%_%', $format, $base);
-		$link = str_replace('%#%', $current + 1, $link);
-		if ( $add_args )
-			$link = add_query_arg( $add_args, $link );
-		$link .= $add_fragment;
-		$page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $next_text . '</a>';
+	if ( $args['prev_next'] && $args['current'] && ( $args['current'] < $args['total'] || -1 == $args['total'] ) ) :
+		$link = str_replace('%_%', $args['format'], $args['base']);
+		$link = str_replace('%#%', $args['current'] + 1, $link);
+		if ( $args['add_args '] )
+			$link = add_query_arg( $args['add_args '], $link );
+		$link .= $args['add_fragment'];
+		$page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
 	endif;
-	switch ( $type ) :
+	switch ( $args['type'] ) :
 		case 'array' :
 			return $page_links;
 			break;
