Make WordPress Core

Ticket #12507: pagination_base.3.diff

File pagination_base.3.diff, 3.7 KB (added by scribu, 15 years ago)

fix canonical redirect and wp_unique_slug()

  • wp-includes/post.php

     
    24172417                $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";
    24182418                $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ID, $post_parent ) );
    24192419
    2420                 if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( '@^(page)?\d+$@', $slug ) ) {
     2420                if ( $post_name_check || in_array( $slug, $feeds ) || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) ) {
    24212421                        $suffix = 2;
    24222422                        do {
    24232423                                $alt_post_name = substr( $slug, 0, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
     
    45854585
    45864586                add_filter('the_preview', '_set_preview');
    45874587        }
    4588 }
    4589  No newline at end of file
     4588}
  • wp-includes/link-template.php

     
    13871387                        $query_string = '';
    13881388                }
    13891389
    1390                 $request = preg_replace( '|page/\d+/?$|', '', $request);
     1390                $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request);
    13911391                $request = preg_replace( '|^index\.php|', '', $request);
    13921392                $request = ltrim($request, '/');
    13931393
     
    13971397                        $base .= 'index.php/';
    13981398
    13991399                if ( $pagenum > 1 ) {
    1400                         $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' );
     1400                        $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' );
    14011401                }
    14021402
    14031403                $result = $base . $request . $query_string;
  • wp-includes/rewrite.php

     
    480480        var $comments_base = 'comments';
    481481
    482482        /**
     483         * Pagination permalink base.
     484         *
     485         * @since 3.1.0
     486         * @access private
     487         * @var string
     488         */
     489        var $pagination_base = 'page';
     490
     491        /**
    483492         * Feed permalink base.
    484493         *
    485494         * @since 1.5.0
     
    12791288
    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
    12851294                //build up an array of endpoint regexes to append => queries to append
  • wp-includes/canonical.php

     
    178178                        $paged_redirect = @parse_url($redirect_url);
    179179                        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'] ) ) {
    180180                                // Strip off paging and feed
    181                                 $paged_redirect['path'] = preg_replace('#/page/?[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing paging
     181                                $paged_redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $paged_redirect['path']); // strip off any existing paging
    182182                                $paged_redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $paged_redirect['path']); // strip off feed endings
    183183                                $paged_redirect['path'] = preg_replace('#/comment-page-[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing comment paging
    184184                        }