Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 18539)
+++ wp-includes/link-template.php	(working copy)
@@ -1128,7 +1128,7 @@ function get_adjacent_post( $in_same_cat = false, $excluded_categories = '', $pr
 			}
 
 			$excluded_categories = array_map( 'intval', $excluded_categories );
-				
+
 			if ( ! empty( $cat_array ) ) {
 				$excluded_categories = array_diff($excluded_categories, $cat_array);
 				$posts_in_ex_cats_sql = '';
@@ -1276,7 +1276,7 @@ function get_boundary_post( $in_same_cat = false, $excluded_categories = '', $st
 	$cat_array = array();
 	if( ! is_array( $excluded_categories ) )
 		$excluded_categories = explode( ',', $excluded_categories );
-		
+
 	if ( $in_same_cat || ! empty( $excluded_categories ) ) {
 		if ( $in_same_cat )
 			$cat_array = wp_get_object_terms( $post->ID, 'category', array( 'fields' => 'ids' ) );
@@ -1410,9 +1410,25 @@ function parent_post_rel_link($title = '%title') {
 }
 
 /**
+ * Get previous post link that is adjacent to the current post.
+ *
+ * @since 3.3.0
+ *
+ * @param string $format Optional. Link anchor format.
+ * @param string $link Optional. Link permalink format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @return string
+ */
+function get_previous_post_link($format='&laquo; %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
+	return get_adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true);
+}
+
+/**
  * Display previous post link that is adjacent to the current post.
  *
  * @since 1.5.0
+ * @uses get_previous_post_link()
  *
  * @param string $format Optional. Link anchor format.
  * @param string $link Optional. Link permalink format.
@@ -1420,13 +1436,29 @@ function parent_post_rel_link($title = '%title') {
  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
  */
 function previous_post_link($format='&laquo; %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
-	adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true);
+	echo get_previous_post_link($format, $link, $in_same_cat, $excluded_categories);
+}
+
+/**
+ * Get previous post link that is adjacent to the current post.
+ *
+ * @since 3.3.0
+ *
+ * @param string $format Optional. Link anchor format.
+ * @param string $link Optional. Link permalink format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @return string
+ */
+function get_next_post_link($format='&laquo; %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
+	return get_adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);
 }
 
 /**
  * Display next post link that is adjacent to the current post.
  *
  * @since 1.5.0
+ * @uses get_next_post_link()
  *
  * @param string $format Optional. Link anchor format.
  * @param string $link Optional. Link permalink format.
@@ -1434,23 +1466,24 @@ function previous_post_link($format='&laquo; %link', $link='%title', $in_same_ca
  * @param array|string $excluded_categories Optional. Array or comma-separated list of excluded category IDs.
  */
 function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat = false, $excluded_categories = '') {
-	adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);
+	echo get_next_post_link($format, $link, $in_same_cat, $excluded_categories);
 }
 
 /**
- * Display adjacent post link.
+ * Get adjacent post link.
  *
  * Can be either next post link or previous.
  *
- * @since 2.5.0
+ * @since 3.3.0
  *
  * @param string $format Link anchor format.
  * @param string $link Link permalink 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 adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
+function get_adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
 	if ( $previous && is_attachment() )
 		$post = & get_post($GLOBALS['post']->post_parent);
 	else
@@ -1476,7 +1509,26 @@ function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_cate
 	$format = str_replace('%link', $link, $format);
 
 	$adjacent = $previous ? 'previous' : 'next';
-	echo apply_filters( "{$adjacent}_post_link", $format, $link );
+	return apply_filters( "{$adjacent}_post_link", $format, $link );
+}
+
+
+/**
+ * Display adjacent post link.
+ *
+ * Can be either next post link or previous.
+ *
+ * @since 2.5.0
+ * @uses get_adjacent_post_link()
+ *
+ * @param string $format Link anchor format.
+ * @param string $link Link permalink format.
+ * @param bool $in_same_cat Optional. Whether link should be in same category.
+ * @param string $excluded_categories Optional. Excluded categories IDs.
+ * @param bool $previous Optional, default is true. Whether display link to previous post.
+ */
+function adjacent_post_link( $format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
+	echo get_adjacent_post_link( $format, $link, $in_same_cat, $excluded_categories, $previous );
 }
 
 /**
