Index: wp-includes/default-filters.php
===================================================================
--- wp-includes/default-filters.php	(revision 18696)
+++ wp-includes/default-filters.php	(working copy)
@@ -203,7 +203,7 @@
 add_action( 'wp_head',             'feed_links_extra',                3     );
 add_action( 'wp_head',             'rsd_link'                               );
 add_action( 'wp_head',             'wlwmanifest_link'                       );
-add_action( 'wp_head',             'adjacent_posts_rel_link_wp_head', 10, 0 );
+add_action( 'wp_head',             'adjacent_rel_links', 			   10, 0 );
 add_action( 'wp_head',             'locale_stylesheet'                      );
 add_action( 'publish_future_post', 'check_and_publish_future_post',   10, 1 );
 add_action( 'wp_head',             'noindex',                          1    );
Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 18696)
+++ wp-includes/link-template.php	(working copy)
@@ -1163,98 +1163,6 @@
 }
 
 /**
- * Get adjacent post relational link.
- *
- * Can either be next or previous post relational link.
- *
- * @since 2.8.0
- *
- * @param string $title Optional. Link title format.
- * @param bool $in_same_cat Optional. Whether link should be in same category.
- * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
- * @param bool $previous Optional, default is true. Whether display link to previous post.
- * @return string
- */
-function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) {
-	if ( $previous && is_attachment() && is_object( $GLOBALS['post'] ) )
-		$post = & get_post($GLOBALS['post']->post_parent);
-	else
-		$post = get_adjacent_post($in_same_cat,$excluded_categories,$previous);
-
-	if ( empty($post) )
-		return;
-
-	if ( empty($post->post_title) )
-		$post->post_title = $previous ? __('Previous Post') : __('Next Post');
-
-	$date = mysql2date(get_option('date_format'), $post->post_date);
-
-	$title = str_replace('%title', $post->post_title, $title);
-	$title = str_replace('%date', $date, $title);
-	$title = apply_filters('the_title', $title, $post->ID);
-
-	$link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
-	$link .= esc_attr( $title );
-	$link .= "' href='" . get_permalink($post) . "' />\n";
-
-	$adjacent = $previous ? 'previous' : 'next';
-	return apply_filters( "{$adjacent}_post_rel_link", $link );
-}
-
-/**
- * Display relational links for the posts adjacent to the current post.
- *
- * @since 2.8.0
- *
- * @param string $title Optional. Link title format.
- * @param bool $in_same_cat Optional. Whether link should be in same category.
- * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
- */
-function adjacent_posts_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
-	echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', true);
-	echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', false);
-}
-
-/**
- * Display relational links for the posts adjacent to the current post for single post pages.
- *
- * This is meant to be attached to actions like 'wp_head'.  Do not call this directly in plugins or theme templates.
- * @since 3.0.0
- *
- */
-function adjacent_posts_rel_link_wp_head() {
-	if ( !is_singular() || is_attachment() )
-		return;
-	adjacent_posts_rel_link();
-}
-
-/**
- * Display relational link for the next post adjacent to the current post.
- *
- * @since 2.8.0
- *
- * @param string $title Optional. Link title format.
- * @param bool $in_same_cat Optional. Whether link should be in same category.
- * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
- */
-function next_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
-	echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', false);
-}
-
-/**
- * Display relational link for the previous post adjacent to the current post.
- *
- * @since 2.8.0
- *
- * @param string $title Optional. Link title format.
- * @param bool $in_same_cat Optional. Whether link should be in same category.
- * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
- */
-function prev_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '') {
-	echo get_adjacent_post_rel_link($title, $in_same_cat, $excluded_categories = '', true);
-}
-
-/**
  * Retrieve boundary post.
  *
  * Boundary being either the first or last post by publish date within the constraints specified
@@ -2245,24 +2153,155 @@
 }
 
 /**
- * Output rel=canonical for singular queries
+ * Get the current archive link
+ * 
+ * @param $paged boolean whether or not to return a link with the current page in the archive, default true
+ * @since 3.3
+ */
+function get_current_archive_link( $paged = true ) {
+	$link = false;
+	
+	if ( is_front_page() ) {
+		$link = home_url( '/' );
+	} else if ( is_home() && "page" == get_option('show_on_front') ) {
+		$link = get_permalink( get_option( 'page_for_posts' ) );
+	} else if ( is_tax() || is_tag() || is_category() ) {
+		$term = get_queried_object();
+		$link = get_term_link( $term, $term->taxonomy );
+	} else if ( is_post_type_archive() ) {
+		$link = get_post_type_archive_link( get_post_type() );
+	} else if ( is_author() ) {
+		$link = get_author_posts_url( get_query_var('author'), get_query_var('author_name') );
+	} else if ( is_archive() ) {
+		if ( is_date() ) {
+			if ( is_day() ) {
+				$link = get_day_link( get_query_var('year'), get_query_var('monthnum'), get_query_var('day') );
+			} else if ( is_month() ) {
+				$link = get_month_link( get_query_var('year'), get_query_var('monthnum') );
+			} else if ( is_year() ) {
+				$link = get_year_link( get_query_var('year') );
+			}						
+		}
+	}
+	
+	if ( $paged && $link && get_query_var('paged') > 1 ) {
+		global $wp_rewrite;
+		if ( !$wp_rewrite->using_permalinks() ) {
+			$link = add_query_arg( 'paged', get_query_var('paged'), $link );
+		} else {
+			$link = user_trailingslashit( trailingslashit( $link ) . trailingslashit( $wp_rewrite->pagination_base ) . get_query_var('paged'), 'archive' );
+		}
+	}
+	return $link;
+}
+
+/**
+ * Output rel=canonical
  *
  * @package WordPress
  * @since 2.9.0
 */
 function rel_canonical() {
-	if ( !is_singular() )
-		return;
+	$link = false;
+	
+	if ( is_singular() ) {
+		global $wp_rewrite;
 
-	global $wp_the_query;
-	if ( !$id = $wp_the_query->get_queried_object_id() )
-		return;
+		$link = get_permalink( get_queried_object() );
+		if ( get_query_var( 'page' ) > 1 ) {
+			if ( !$wp_rewrite->using_permalinks() )
+				$link = add_query_arg( 'page', get_query_var( 'page' ), $link );
+			else
+				$link = user_trailingslashit( trailingslashit( $link ) . get_query_var( 'page' ), 'single' );
+		}
+	} else {
+		$link = get_current_archive_link();
+	}
 
-	$link = get_permalink( $id );
-	echo "<link rel='canonical' href='$link' />\n";
+	$link = apply_filters( 'rel_canonical', $link );
+	
+	if ( $link )
+		echo "<link rel='canonical' href='" . esc_url( $link, 'canonical' ) . "' />\n";
 }
 
 /**
+ * Output rel=next and rel=prev links
+ * on archives pages these go to next and prev archive pages, when available
+ * on singular paginated posts & pages these go to the next page within the post or page
+ *
+ * @since 3.3
+ */
+function adjacent_rel_links() {
+	global $wp_query;
+
+	if ( !is_singular() ) {
+		$url = get_current_archive_link( false );
+
+		if ( $url ) {
+			$paged = get_query_var('paged');
+			
+			if ( 0 == $paged )
+				$paged = 1;
+
+			if ( $paged > 1 ) 
+				echo get_adjacent_rel_link( "prev", $url, $paged-1, true, 'category' );
+
+			if ( $paged < $wp_query->max_num_pages )
+				echo get_adjacent_rel_link( "next", $url, $paged+1, true, 'category' );
+		}
+	} else {
+		$numpages = substr_count( $wp_query->post->post_content, '<!--nextpage-->' ) + 1;
+		if ( $numpages > 1 ) {		
+			$page = get_query_var('page');
+			if ( !$page )
+				$page = 1;
+
+			$url = get_permalink( $wp_query->post->ID );
+
+			// If the current page is the frontpage, pagination should use /base/
+			if ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $wp_query->post->ID )
+				$usebase = true;
+			else
+				$usebase = false;
+				
+			if ( $page > 1 )
+				echo get_adjacent_rel_link( "prev", $url, $page-1, $usebase, 'single_paged' );
+			if ( $page < $numpages )
+				echo get_adjacent_rel_link( "next", $url, $page+1, $usebase, 'single_paged' );
+		}
+	}	
+}
+
+/**
+ * Get adjacent pages link for archives
+ *
+ * @param string $rel Link relationship, prev or next.
+ * @param string $url the unpaginated URL of the current archive.
+ * @param string $page the page number to add on to $url for the $link tag.
+ * @param boolean $incl_pagination_base whether or not to include /page/ or not.
+ * @param string $context context of the adjacent links, passed on to user_trailingslashit
+ * @return string $link link element
+ *
+ * @since 3.3
+ */
+function get_adjacent_rel_link( $rel, $url, $page, $incl_pagination_base, $context ) {
+	global $wp_rewrite;
+	if ( !$wp_rewrite->using_permalinks() ) {
+		if ( $page > 1 )
+			$url = add_query_arg( 'paged', $page, $url );
+	} else {
+		if ( $page > 1 ) {
+			$base = '';
+			if ( $incl_pagination_base )
+				$base = trailingslashit( $wp_rewrite->pagination_base );
+			$url = user_trailingslashit( trailingslashit( $url ) . $base . $page, $context );
+		}
+	}
+	$link = "<link rel='$rel' href='$url' />\n";
+	return apply_filters( $rel."_rel_link", $link );	
+}
+
+/**
  * Return a shortlink for a post, page, attachment, or blog.
  *
  * This function exists to provide a shortlink tag that all themes and plugins can target.  A plugin must hook in to
