Make WordPress Core

Ticket #7942: 7492.diff

File 7492.diff, 6.7 KB (added by DD32, 16 years ago)
  • wp-includes/canonical.php

     
    123123                }
    124124
    125125        // paging and feeds
    126                 if ( get_query_var('paged') || is_feed() ) {
     126                if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
    127127                        if ( !$redirect_url )
    128128                                $redirect_url = $requested_url;
    129129                        $paged_redirect = @parse_url($redirect_url);
    130                         while ( preg_match( '#page/[0-9]+?(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/feed(/[a-z0-9-]*?(/+)?)?$#', $paged_redirect['path'] ) ) {
     130                        while ( preg_match( '#page/[0-9]+?(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/feed(/[a-z0-9-]*?(/+)?)?$#', $paged_redirect['path'] ) || preg_match( '#comment-page-[0-9]+/?$#', $paged_redirect['path'] ) ) {
    131131                                // Strip off paging and feed
    132132                                $paged_redirect['path'] = preg_replace('#/page/[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing paging
    133133                                $paged_redirect['path'] = preg_replace('#/feed(/[a-z0-9-]*?(/+)?)?$#', '/', $paged_redirect['path']); // strip off any existing feed
     134                                $paged_redirect['path'] = preg_replace('#comment-page-[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing comment paging
    134135                        }
    135136
    136137                        $paged_redirect['path'] = preg_replace('|/index.php/?$|', '/', $paged_redirect['path']); // strip off trailing /index.php/
     
    148149                        if ( is_feed() ) {
    149150                                $paged_redirect['path'] = user_trailingslashit( trailingslashit( $paged_redirect['path'] ) . 'feed/' . ( ( 'rss2' ==  get_query_var('feed') || 'feed' == get_query_var('feed') ) ? '' : get_query_var('feed') ), 'feed' );
    150151                        }
     152                        if ( get_query_var('cpage') > 1 ) {
     153                                $paged_redirect['path'] = user_trailingslashit( trailingslashit( $paged_redirect['path'] ) . 'comment-page-' . get_query_var('cpage'), 'commentpaged' );
     154                        }
    151155                        $redirect_url = $paged_redirect['scheme'] . '://' . $paged_redirect['host'] . $paged_redirect['path'];
    152156                        $redirect['path'] = $paged_redirect['path'];
    153157                        $redirect['query'] = remove_query_arg( 'paged', $redirect['query'] );
    154                         $redirect['query'] = remove_query_arg(  'feed', $redirect['query'] );
     158                        $redirect['query'] = remove_query_arg( 'feed', $redirect['query'] );
     159                        $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] );
    155160                }
    156161        }
    157162
  • wp-includes/link-template.php

     
    12641264 * @return string Markup for pagination links
    12651265*/
    12661266function paginate_comments_links($args = array()) {
    1267         global $wp_query;
     1267        global $wp_query, $wp_rewrite;
    12681268
    12691269        if ( !is_singular() )
    12701270                return;
     
    12811281                'echo' => true,
    12821282                'add_fragment' => '#comments'
    12831283        );
     1284        if ( $wp_rewrite->using_permalinks() )
     1285                $defaults['base'] = user_trailingslashit(get_permalink() . 'comment-page-%#%', 'commentpaged');
     1286
    12841287        $args = wp_parse_args( $args, $defaults );
    12851288        $page_links = paginate_links( $args );
    12861289
  • wp-includes/rewrite.php

     
    12591259                //build a regex to match the trackback and page/xx parts of URLs
    12601260                $trackbackregex = 'trackback/?$';
    12611261                $pageregex = 'page/?([0-9]{1,})/?$';
     1262                $commentregex = 'comment-page-([0-9]{1,})/?$';
    12621263
    12631264                //build up an array of endpoint regexes to append => queries to append
    12641265                if ($endpoints) {
     
    13391340                        $pagematch = $match . $pageregex;
    13401341                        $pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1);
    13411342
     1343                        //create query for /comment-page-xx
     1344                        $commentmatch = $match . $commentregex;
     1345                        $commentquery = $index . '?' . $query . '&cpage=' . $this->preg_index($num_toks + 1);
     1346
    13421347                        //create query for /feed/(feed|atom|rss|rss2|rdf)
    13431348                        $feedmatch = $match . $feedregex;
    13441349                        $feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
     
    13601365                        if ($paged) //...and /page/xx ones
    13611366                                $rewrite = array_merge($rewrite, array($pagematch => $pagequery));
    13621367
     1368                        //only on pages with comments add ../comment-page-xx/
     1369                        if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask || EP_NONE & $ep_mask )
     1370                                $rewrite = array_merge($rewrite, array($commentmatch => $commentquery));
     1371
    13631372                        //do endpoints
    13641373                        if ($endpoints) {
    13651374                                foreach ( (array) $ep_query_append as $regex => $ep) {
     
    14031412                                        $sub1tb = $sub1 . $trackbackregex; //add trackback regex <permalink>/trackback/...
    14041413                                        $sub1feed = $sub1 . $feedregex; //and <permalink>/feed/(atom|...)
    14051414                                        $sub1feed2 = $sub1 . $feedregex2; //and <permalink>/(feed|atom...)
     1415                                        $sub1comment = $sub1 . $commentregex; //and <permalink>/comment-page-xx
    14061416                                        //add an ? as we don't have to match that last slash, and finally a $ so we
    14071417                                        //match to the end of the URL
    14081418
     
    14121422                                        $sub2tb = $sub2 . $trackbackregex; //and add trackbacks <permalink>/attachment/trackback
    14131423                                        $sub2feed = $sub2 . $feedregex;    //feeds, <permalink>/attachment/feed/(atom|...)
    14141424                                        $sub2feed2 = $sub2 . $feedregex2;  //and feeds again on to this <permalink>/attachment/(feed|atom...)
     1425                                        $sub2comment = $sub2 . $commentregex; //and <permalink>/comment-page-xx
    14151426
    14161427                                        //create queries for these extra tag-ons we've just dealt with
    14171428                                        $subquery = $index . '?attachment=' . $this->preg_index(1);
    14181429                                        $subtbquery = $subquery . '&tb=1';
    14191430                                        $subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
     1431                                        $subcommentquery = $subquery . '&cpage=' . $this->preg_index(2);
    14201432
    14211433                                        //do endpoints for attachments
    14221434                                        if ( !empty($endpoint) ) { foreach ( (array) $ep_query_append as $regex => $ep ) {
     
    14511463
    14521464                                        //add regexes/queries for attachments, attachment trackbacks and so on
    14531465                                        if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages
    1454                                                 $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery));
    1455                                         $rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery), $rewrite);
     1466                                                $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery, $sub1comment => $subcommentquery));
     1467                                        $rewrite = array_merge(array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery, $sub2comment => $subcommentquery), $rewrite);
    14561468                                }
    14571469                        } //if($num_toks)
    14581470                        //add the rules for this dir to the accumulating $post_rewrite