Make WordPress Core

Ticket #12507: pagination_base.diff

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

Introduce 'pagination_base' filter

  • wp-includes/link-template.php

     
    13821382                        $query_string = '';
    13831383                }
    13841384
    1385                 $request = preg_replace( '|page/\d+/?$|', '', $request);
     1385                $pagination_base = get_pagination_base();
     1386
     1387                $request = preg_replace( "|$pagination_base/\d+/?$|", '', $request);
    13861388                $request = preg_replace( '|^index\.php|', '', $request);
    13871389                $request = ltrim($request, '/');
    13881390
     
    13921394                        $base .= 'index.php/';
    13931395
    13941396                if ( $pagenum > 1 ) {
    1395                         $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' );
     1397                        $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( "$pagination_base/" . $pagenum, 'paged' );
    13961398                }
    13971399
    13981400                $result = $base . $request . $query_string;
     
    14031405        return $result;
    14041406}
    14051407
     1408function get_pagination_base() {
     1409        return apply_filters('pagination_base', 'page');
     1410}
     1411
    14061412/**
    14071413 * Retrieve next posts pages link.
    14081414 *
  • wp-includes/rewrite.php

     
    12931293
    12941294                //build a regex to match the trackback and page/xx parts of URLs
    12951295                $trackbackregex = 'trackback/?$';
    1296                 $pageregex = 'page/?([0-9]{1,})/?$';
     1296                $pageregex = get_pagination_base() . '/?([0-9]{1,})/?$';
    12971297                $commentregex = 'comment-page-([0-9]{1,})/?$';
    12981298
    12991299                //build up an array of endpoint regexes to append => queries to append