Don't hardcode the pagination base. Fixes #12507
git-svn-id: http://svn.automattic.com/wordpress/trunk@15582 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
80e2918946
commit
f2c9a08521
|
@ -191,9 +191,9 @@ function redirect_canonical($requested_url=null, $do_redirect=true) {
|
||||||
if ( !$redirect_url )
|
if ( !$redirect_url )
|
||||||
$redirect_url = $requested_url;
|
$redirect_url = $requested_url;
|
||||||
$paged_redirect = @parse_url($redirect_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
|
// 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('#/(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
|
$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'] );
|
$redirect['query'] = remove_query_arg( 'paged', $redirect['query'] );
|
||||||
if ( !is_feed() ) {
|
if ( !is_feed() ) {
|
||||||
if ( $paged > 1 && !is_single() ) {
|
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() ) {
|
} elseif ( !is_single() ) {
|
||||||
$addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
|
$addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -1411,7 +1411,7 @@ function get_pagenum_link($pagenum = 1) {
|
||||||
$query_string = '';
|
$query_string = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = preg_replace( '|page/\d+/?$|', '', $request);
|
$request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request);
|
||||||
$request = preg_replace( '|^index\.php|', '', $request);
|
$request = preg_replace( '|^index\.php|', '', $request);
|
||||||
$request = ltrim($request, '/');
|
$request = ltrim($request, '/');
|
||||||
|
|
||||||
|
@ -1421,7 +1421,7 @@ function get_pagenum_link($pagenum = 1) {
|
||||||
$base .= 'index.php/';
|
$base .= 'index.php/';
|
||||||
|
|
||||||
if ( $pagenum > 1 ) {
|
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;
|
$result = $base . $request . $query_string;
|
||||||
|
|
|
@ -575,7 +575,7 @@ function wp_link_pages($args = '') {
|
||||||
$r = apply_filters( 'wp_link_pages_args', $r );
|
$r = apply_filters( 'wp_link_pages_args', $r );
|
||||||
extract( $r, EXTR_SKIP );
|
extract( $r, EXTR_SKIP );
|
||||||
|
|
||||||
global $post, $page, $numpages, $multipage, $more, $pagenow;
|
global $page, $numpages, $multipage, $more, $pagenow;
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
if ( $multipage ) {
|
if ( $multipage ) {
|
||||||
|
@ -585,21 +585,9 @@ function wp_link_pages($args = '') {
|
||||||
$j = str_replace('%',$i,$pagelink);
|
$j = str_replace('%',$i,$pagelink);
|
||||||
$output .= ' ';
|
$output .= ' ';
|
||||||
if ( ($i != $page) || ((!$more) && ($page==1)) ) {
|
if ( ($i != $page) || ((!$more) && ($page==1)) ) {
|
||||||
if ( 1 == $i ) {
|
$output .= _wp_link_page($i);
|
||||||
$output .= '<a href="' . get_permalink() . '">';
|
|
||||||
} else {
|
|
||||||
if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
|
|
||||||
$output .= '<a href="' . add_query_arg('page', $i, get_permalink()) . '">';
|
|
||||||
elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
|
|
||||||
$output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">';
|
|
||||||
else
|
|
||||||
$output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$output .= $link_before;
|
$output .= $link_before . $j . $link_after;
|
||||||
$output .= $j;
|
|
||||||
$output .= $link_after;
|
|
||||||
if ( ($i != $page) || ((!$more) && ($page==1)) )
|
if ( ($i != $page) || ((!$more) && ($page==1)) )
|
||||||
$output .= '</a>';
|
$output .= '</a>';
|
||||||
}
|
}
|
||||||
|
@ -609,30 +597,12 @@ function wp_link_pages($args = '') {
|
||||||
$output .= $before;
|
$output .= $before;
|
||||||
$i = $page - 1;
|
$i = $page - 1;
|
||||||
if ( $i && $more ) {
|
if ( $i && $more ) {
|
||||||
if ( 1 == $i ) {
|
$output .= _wp_link_page($i);
|
||||||
$output .= '<a href="' . get_permalink() . '">';
|
|
||||||
} else {
|
|
||||||
if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
|
|
||||||
$output .= '<a href="' . add_query_arg('page', $i, get_permalink()) . '">';
|
|
||||||
elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
|
|
||||||
$output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">';
|
|
||||||
else
|
|
||||||
$output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">';
|
|
||||||
}
|
|
||||||
$output .= $link_before. $previouspagelink . $link_after . '</a>';
|
$output .= $link_before. $previouspagelink . $link_after . '</a>';
|
||||||
}
|
}
|
||||||
$i = $page + 1;
|
$i = $page + 1;
|
||||||
if ( $i <= $numpages && $more ) {
|
if ( $i <= $numpages && $more ) {
|
||||||
if ( 1 == $i ) {
|
$output .= _wp_link_page($i);
|
||||||
$output .= '<a href="' . get_permalink() . '">';
|
|
||||||
} else {
|
|
||||||
if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
|
|
||||||
$output .= '<a href="' . add_query_arg('page', $i, get_permalink()) . '">';
|
|
||||||
elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
|
|
||||||
$output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">';
|
|
||||||
else
|
|
||||||
$output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">';
|
|
||||||
}
|
|
||||||
$output .= $link_before. $nextpagelink . $link_after . '</a>';
|
$output .= $link_before. $nextpagelink . $link_after . '</a>';
|
||||||
}
|
}
|
||||||
$output .= $after;
|
$output .= $after;
|
||||||
|
@ -646,6 +616,22 @@ function wp_link_pages($args = '') {
|
||||||
return $output;
|
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 '<a href="' . $url . '">';
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Post-meta: Custom per-post fields.
|
// Post-meta: Custom per-post fields.
|
||||||
|
|
|
@ -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";
|
$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 ) );
|
$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;
|
$suffix = 2;
|
||||||
do {
|
do {
|
||||||
$alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
|
$alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
|
||||||
|
|
|
@ -479,6 +479,15 @@ class WP_Rewrite {
|
||||||
*/
|
*/
|
||||||
var $comments_base = 'comments';
|
var $comments_base = 'comments';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pagination permalink base.
|
||||||
|
*
|
||||||
|
* @since 3.1.0
|
||||||
|
* @access private
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
var $pagination_base = 'page';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feed permalink base.
|
* Feed permalink base.
|
||||||
*
|
*
|
||||||
|
@ -1279,7 +1288,7 @@ class WP_Rewrite {
|
||||||
|
|
||||||
//build a regex to match the trackback and page/xx parts of URLs
|
//build a regex to match the trackback and page/xx parts of URLs
|
||||||
$trackbackregex = 'trackback/?$';
|
$trackbackregex = 'trackback/?$';
|
||||||
$pageregex = 'page/?([0-9]{1,})/?$';
|
$pageregex = $this->pagination_base . '/?([0-9]{1,})/?$';
|
||||||
$commentregex = 'comment-page-([0-9]{1,})/?$';
|
$commentregex = 'comment-page-([0-9]{1,})/?$';
|
||||||
|
|
||||||
//build up an array of endpoint regexes to append => queries to append
|
//build up an array of endpoint regexes to append => queries to append
|
||||||
|
|
Loading…
Reference in New Issue