Index: /Applications/MAMP/htdocs/wptrunk/wp-includes/post-template.php
===================================================================
--- /Applications/MAMP/htdocs/wptrunk/wp-includes/post-template.php	(revision 20169)
+++ /Applications/MAMP/htdocs/wptrunk/wp-includes/post-template.php	(working copy)
@@ -605,15 +605,6 @@
  * Quicktag one or more times). This tag must be within The Loop.
  *
  * The defaults for overwriting are:
- * 'next_or_number' - Default is 'number' (string). Indicates whether page
- *      numbers should be used. Valid values are number and next.
- * 'nextpagelink' - Default is 'Next Page' (string). Text for link to next page.
- *      of the bookmark.
- * 'previouspagelink' - Default is 'Previous Page' (string). Text for link to
- *      previous page, if available.
- * 'pagelink' - Default is '%' (String).Format string for page numbers. The % in
- *      the parameter string will be replaced with the page number, so Page %
- *      generates "Page 1", "Page 2", etc. Defaults to %, just the page number.
  * 'before' - Default is '<p> Pages:' (string). The html or text to prepend to
  *      each bookmarks.
  * 'after' - Default is '</p>' (string). The html or text to append to each
@@ -624,9 +615,19 @@
  * 'link_after' - Default is '' (string). The html or text to append to each
  *      Pages link inside the <a> tag. Also appended to the current item, which
  *      is not linked.
+ * 'next_or_number' - Default is 'number' (string). Indicates whether page
+ *      numbers should be used. Valid values are number and next.
+ * 'separator' - Default is ' ' (string). Text used only between numbers.
+ * 'nextpagelink' - Default is 'Next Page' (string). Text for link to next page.
+ *      of the bookmark.
+ * 'previouspagelink' - Default is 'Previous Page' (string). Text for link to
+ *      previous page, if available.
+ * 'pagelink' - Default is '%' (String).Format string for page numbers. The % in
+ *      the parameter string will be replaced with the page number, so Page %
+ *      generates "Page 1", "Page 2", etc. Defaults to %, just the page number.
+ * 'echo' - Default is 1 (integer). When not 0, this triggers the HTML to be echoed and then returned.
  *
  * @since 1.2.0
- * @access private
  *
  * @param string|array $args Optional. Overwrite the defaults.
  * @return string Formatted output in HTML.
@@ -631,12 +632,17 @@
  * @param string|array $args Optional. Overwrite the defaults.
  * @return string Formatted output in HTML.
  */
-function wp_link_pages($args = '') {
+function wp_link_pages( $args = '' ) {
 	$defaults = array(
-		'before' => '<p>' . __('Pages:'), 'after' => '</p>',
-		'link_before' => '', 'link_after' => '',
-		'next_or_number' => 'number', 'nextpagelink' => __('Next page'),
-		'previouspagelink' => __('Previous page'), 'pagelink' => '%',
+		'before' => '<p>' . __('Pages:'),
+		'after' => '</p>',
+		'link_before' => '',
+		'link_after' => '',
+		'separator' => ' ',
+		'next_or_number' => 'number',
+		'nextpagelink' => __('Next page'),
+		'previouspagelink' => __('Previous page'),
+		'pagelink' => '%',
 		'echo' => 1
 	);
 
@@ -650,15 +656,13 @@
 	if ( $multipage ) {
 		if ( 'number' == $next_or_number ) {
 			$output .= $before;
-			for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) {
-				$j = str_replace('%',$i,$pagelink);
-				$output .= ' ';
+			for ( $i = 1; $i <= $numpages; $i++ ) {
+				$link = $link_before . str_replace( '%', $i, $pagelink ) . $link_after;
 				if ( ($i != $page) || ((!$more) && ($page==1)) ) {
-					$output .= _wp_link_page($i);
+					$link = _wp_link_page( $i ) . $link . '</a>';
 				}
-				$output .= $link_before . $j . $link_after;
-				if ( ($i != $page) || ((!$more) && ($page==1)) )
-					$output .= '</a>';
+				$link = apply_filters( 'wp_link_pages_link', $link, $i );
+				$output .= $separator . $link;
 			}
 			$output .= $after;
 		} else {
@@ -666,13 +670,16 @@
 				$output .= $before;
 				$i = $page - 1;
 				if ( $i && $more ) {
-					$output .= _wp_link_page($i);
-					$output .= $link_before. $previouspagelink . $link_after . '</a>';
+					$link = _wp_link_page( $i ) . $link_before. $previouspagelink . $link_after . '</a>';
+					$output .= apply_filters( 'wp_link_pages_link', $link, $i );
 				}
 				$i = $page + 1;
 				if ( $i <= $numpages && $more ) {
-					$output .= _wp_link_page($i);
-					$output .= $link_before. $nextpagelink . $link_after . '</a>';
+					$link = _wp_link_page( $i ) . $link_before. $nextpagelink . $link_after . '</a>';
+					// Only add the separator when we have a previous link
+					if ( strpos( $output, $previouspagelink ) )
+						$output .= $separator;
+					$output .= apply_filters( 'wp_link_pages_link', $link, $i );
 				}
 				$output .= $after;
 			}
@@ -678,6 +685,8 @@
 			}
 		}
 	}
+	
+	$output = apply_filters( 'wp_link_pages', $output, $args );
 
 	if ( $echo )
 		echo $output;
