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 )
|
||||
$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) : '';
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 .= '<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 .= _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 .= '</a>';
|
||||
}
|
||||
|
@ -609,30 +597,12 @@ function wp_link_pages($args = '') {
|
|||
$output .= $before;
|
||||
$i = $page - 1;
|
||||
if ( $i && $more ) {
|
||||
if ( 1 == $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 .= _wp_link_page($i);
|
||||
$output .= $link_before. $previouspagelink . $link_after . '</a>';
|
||||
}
|
||||
$i = $page + 1;
|
||||
if ( $i <= $numpages && $more ) {
|
||||
if ( 1 == $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 .= _wp_link_page($i);
|
||||
$output .= $link_before. $nextpagelink . $link_after . '</a>';
|
||||
}
|
||||
$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 '<a href="' . $url . '">';
|
||||
}
|
||||
|
||||
//
|
||||
// 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";
|
||||
$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";
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue