diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php
index 20520a41cc..cf8bcb4a08 100644
--- a/wp-includes/canonical.php
+++ b/wp-includes/canonical.php
@@ -191,9 +191,9 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
if ( !$redirect_url )
$redirect_url = $requested_url;
$paged_redirect = @parse_url($redirect_url);
- while ( preg_match( '#/page/?[0-9]+?(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/comment-page-[0-9]+(/+)?$#', $paged_redirect['path'] ) ) {
+ while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $paged_redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/comment-page-[0-9]+(/+)?$#', $paged_redirect['path'] ) ) {
// Strip off paging and feed
- $paged_redirect['path'] = preg_replace('#/page/?[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing paging
+ $paged_redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $paged_redirect['path']); // strip off any existing paging
$paged_redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $paged_redirect['path']); // strip off feed endings
$paged_redirect['path'] = preg_replace('#/comment-page-[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing comment paging
}
@@ -212,7 +212,7 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
$redirect['query'] = remove_query_arg( 'paged', $redirect['query'] );
if ( !is_feed() ) {
if ( $paged > 1 && !is_single() ) {
- $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("page/$paged", 'paged');
+ $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("$wp_rewrite->pagination_base/$paged", 'paged');
} elseif ( !is_single() ) {
$addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
}
diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
index c0dffbd42c..effbbc5cf1 100644
--- a/wp-includes/link-template.php
+++ b/wp-includes/link-template.php
@@ -1411,7 +1411,7 @@ function get_pagenum_link($pagenum = 1) {
$query_string = '';
}
- $request = preg_replace( '|page/\d+/?$|', '', $request);
+ $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request);
$request = preg_replace( '|^index\.php|', '', $request);
$request = ltrim($request, '/');
@@ -1421,7 +1421,7 @@ function get_pagenum_link($pagenum = 1) {
$base .= 'index.php/';
if ( $pagenum > 1 ) {
- $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' );
+ $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' );
}
$result = $base . $request . $query_string;
diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
index e9fcb88cba..034248c6f6 100644
--- a/wp-includes/post-template.php
+++ b/wp-includes/post-template.php
@@ -575,7 +575,7 @@ function wp_link_pages($args = '') {
$r = apply_filters( 'wp_link_pages_args', $r );
extract( $r, EXTR_SKIP );
- global $post, $page, $numpages, $multipage, $more, $pagenow;
+ global $page, $numpages, $multipage, $more, $pagenow;
$output = '';
if ( $multipage ) {
@@ -585,21 +585,9 @@ function wp_link_pages($args = '') {
$j = str_replace('%',$i,$pagelink);
$output .= ' ';
if ( ($i != $page) || ((!$more) && ($page==1)) ) {
- if ( 1 == $i ) {
- $output .= '';
- } else {
- if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
- $output .= '';
- elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
- $output .= '';
- else
- $output .= '';
- }
-
+ $output .= _wp_link_page($i);
}
- $output .= $link_before;
- $output .= $j;
- $output .= $link_after;
+ $output .= $link_before . $j . $link_after;
if ( ($i != $page) || ((!$more) && ($page==1)) )
$output .= '';
}
@@ -609,30 +597,12 @@ function wp_link_pages($args = '') {
$output .= $before;
$i = $page - 1;
if ( $i && $more ) {
- if ( 1 == $i ) {
- $output .= '';
- } else {
- if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
- $output .= '';
- elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
- $output .= '';
- else
- $output .= '';
- }
+ $output .= _wp_link_page($i);
$output .= $link_before. $previouspagelink . $link_after . '';
}
$i = $page + 1;
if ( $i <= $numpages && $more ) {
- if ( 1 == $i ) {
- $output .= '';
- } else {
- if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
- $output .= '';
- elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
- $output .= '';
- else
- $output .= '';
- }
+ $output .= _wp_link_page($i);
$output .= $link_before. $nextpagelink . $link_after . '';
}
$output .= $after;
@@ -646,6 +616,22 @@ function wp_link_pages($args = '') {
return $output;
}
+function _wp_link_page( $i ) {
+ global $post, $wp_rewrite;
+
+ if ( 1 == $i ) {
+ $url .= get_permalink();
+ } else {
+ if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
+ $url = add_query_arg( 'page', $i, get_permalink() );
+ elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
+ $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged');
+ else
+ $url .= trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
+ }
+
+ return '';
+}
//
// Post-meta: Custom per-post fields.
diff --git a/wp-includes/post.php b/wp-includes/post.php
index 0da73c4198..b5923ea398 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -2550,7 +2550,7 @@ function wp_unique_post_slug( $slug, $post_ID, $post_status, $post_type, $post_p
$check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode( "', '", esc_sql( $hierarchical_post_types ) ) . "' ) AND ID != %d AND post_parent = %d LIMIT 1";
$post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) );
- if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( '@^(page)?\d+$@', $slug ) ) {
+ if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) ) {
$suffix = 2;
do {
$alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php
index ae5a3b396b..269d712091 100644
--- a/wp-includes/rewrite.php
+++ b/wp-includes/rewrite.php
@@ -479,6 +479,15 @@ class WP_Rewrite {
*/
var $comments_base = 'comments';
+ /**
+ * Pagination permalink base.
+ *
+ * @since 3.1.0
+ * @access private
+ * @var string
+ */
+ var $pagination_base = 'page';
+
/**
* Feed permalink base.
*
@@ -1279,7 +1288,7 @@ class WP_Rewrite {
//build a regex to match the trackback and page/xx parts of URLs
$trackbackregex = 'trackback/?$';
- $pageregex = 'page/?([0-9]{1,})/?$';
+ $pageregex = $this->pagination_base . '/?([0-9]{1,})/?$';
$commentregex = 'comment-page-([0-9]{1,})/?$';
//build up an array of endpoint regexes to append => queries to append