Make WordPress Core

Changeset 15582


Ignore:
Timestamp:
09/07/2010 01:18:42 AM (13 years ago)
Author:
scribu
Message:

Don't hardcode the pagination base. Fixes #12507

Location:
trunk/wp-includes
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/canonical.php

    r15462 r15582  
    192192                $redirect_url = $requested_url;
    193193            $paged_redirect = @parse_url($redirect_url);
    194             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'] ) ) {
     194            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'] ) ) {
    195195                // Strip off paging and feed
    196                 $paged_redirect['path'] = preg_replace('#/page/?[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing paging
     196                $paged_redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $paged_redirect['path']); // strip off any existing paging
    197197                $paged_redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $paged_redirect['path']); // strip off feed endings
    198198                $paged_redirect['path'] = preg_replace('#/comment-page-[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing comment paging
     
    213213                if ( !is_feed() ) {
    214214                    if ( $paged > 1 && !is_single() ) {
    215                         $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("page/$paged", 'paged');
     215                        $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit("$wp_rewrite->pagination_base/$paged", 'paged');
    216216                    } elseif ( !is_single() ) {
    217217                        $addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';
  • trunk/wp-includes/link-template.php

    r15563 r15582  
    14121412        }
    14131413
    1414         $request = preg_replace( '|page/\d+/?$|', '', $request);
     1414        $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request);
    14151415        $request = preg_replace( '|^index\.php|', '', $request);
    14161416        $request = ltrim($request, '/');
     
    14221422
    14231423        if ( $pagenum > 1 ) {
    1424             $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' );
     1424            $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' );
    14251425        }
    14261426
  • trunk/wp-includes/post-template.php

    r15549 r15582  
    576576    extract( $r, EXTR_SKIP );
    577577
    578     global $post, $page, $numpages, $multipage, $more, $pagenow;
     578    global $page, $numpages, $multipage, $more, $pagenow;
    579579
    580580    $output = '';
     
    586586                $output .= ' ';
    587587                if ( ($i != $page) || ((!$more) && ($page==1)) ) {
    588                     if ( 1 == $i ) {
    589                         $output .= '<a href="' . get_permalink() . '">';
    590                     } else {
    591                         if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
    592                             $output .= '<a href="' . add_query_arg('page', $i, get_permalink()) . '">';
    593                         elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
    594                             $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">';
    595                         else
    596                             $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">';
    597                     }
    598 
     588                    $output .= _wp_link_page($i);
    599589                }
    600                 $output .= $link_before;
    601                 $output .= $j;
    602                 $output .= $link_after;
     590                $output .= $link_before . $j . $link_after;
    603591                if ( ($i != $page) || ((!$more) && ($page==1)) )
    604592                    $output .= '</a>';
     
    610598                $i = $page - 1;
    611599                if ( $i && $more ) {
    612                     if ( 1 == $i ) {
    613                         $output .= '<a href="' . get_permalink() . '">';
    614                     } else {
    615                         if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
    616                             $output .= '<a href="' . add_query_arg('page', $i, get_permalink()) . '">';
    617                         elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
    618                             $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">';
    619                         else
    620                             $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">';
    621                     }
     600                    $output .= _wp_link_page($i);
    622601                    $output .= $link_before. $previouspagelink . $link_after . '</a>';
    623602                }
    624603                $i = $page + 1;
    625604                if ( $i <= $numpages && $more ) {
    626                     if ( 1 == $i ) {
    627                         $output .= '<a href="' . get_permalink() . '">';
    628                     } else {
    629                         if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
    630                             $output .= '<a href="' . add_query_arg('page', $i, get_permalink()) . '">';
    631                         elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
    632                             $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit('page/' . $i, 'single_paged'). '">';
    633                         else
    634                             $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">';
    635                     }
     605                    $output .= _wp_link_page($i);
    636606                    $output .= $link_before. $nextpagelink . $link_after . '</a>';
    637607                }
     
    647617}
    648618
     619function _wp_link_page( $i ) {
     620    global $post, $wp_rewrite;
     621
     622    if ( 1 == $i ) {
     623        $url .= get_permalink();
     624    } else {
     625        if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )
     626            $url = add_query_arg( 'page', $i, get_permalink() );
     627        elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
     628            $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged');
     629        else
     630            $url .= trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
     631    }
     632
     633    return '<a href="' . $url  . '">';
     634}
    649635
    650636//
  • trunk/wp-includes/post.php

    r15564 r15582  
    25512551        $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) );
    25522552
    2553         if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( '@^(page)?\d+$@', $slug ) ) {
     2553        if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) ) {
    25542554            $suffix = 2;
    25552555            do {
  • trunk/wp-includes/rewrite.php

    r15109 r15582  
    479479     */
    480480    var $comments_base = 'comments';
     481
     482    /**
     483     * Pagination permalink base.
     484     *
     485     * @since 3.1.0
     486     * @access private
     487     * @var string
     488     */
     489    var $pagination_base = 'page';
    481490
    482491    /**
     
    12801289        //build a regex to match the trackback and page/xx parts of URLs
    12811290        $trackbackregex = 'trackback/?$';
    1282         $pageregex = 'page/?([0-9]{1,})/?$';
     1291        $pageregex = $this->pagination_base . '/?([0-9]{1,})/?$';
    12831292        $commentregex = 'comment-page-([0-9]{1,})/?$';
    12841293
Note: See TracChangeset for help on using the changeset viewer.