Make WordPress Core

Ticket #27631: 27631.2.diff

File 27631.2.diff, 6.4 KB (added by jesin, 10 years ago)

Renames /comment-page-n/ to /comment-page/n/ and redirects old URL

  • wp-includes/link-template.php

     
    17861786        if ( 'newest' == get_option('default_comments_page') ) {
    17871787                if ( $pagenum != $max_page ) {
    17881788                        if ( $wp_rewrite->using_permalinks() )
    1789                                 $result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
     1789                                $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '/' . $pagenum, 'commentpaged');
    17901790                        else
    17911791                                $result = add_query_arg( 'cpage', $pagenum, $result );
    17921792                }
    17931793        } elseif ( $pagenum > 1 ) {
    17941794                if ( $wp_rewrite->using_permalinks() )
    1795                         $result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged');
     1795                        $result = user_trailingslashit( trailingslashit($result) . $wp_rewrite->comments_pagination_base . '/' . $pagenum, 'commentpaged');
    17961796                else
    17971797                        $result = add_query_arg( 'cpage', $pagenum, $result );
    17981798        }
     
    19141914                'add_fragment' => '#comments'
    19151915        );
    19161916        if ( $wp_rewrite->using_permalinks() )
    1917                 $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . 'comment-page-%#%', 'commentpaged');
     1917                $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '/%#%', 'commentpaged');
    19181918
    19191919        $args = wp_parse_args( $args, $defaults );
    19201920        $page_links = paginate_links( $args );
  • wp-includes/rewrite.php

     
    509509        var $pagination_base = 'page';
    510510
    511511        /**
     512         * Comments pagination permalink base.
     513         *
     514         * @since 3.9.0
     515         * @access private
     516         * @var string
     517         */
     518        var $comments_pagination_base = 'comment-page';
     519
     520        /**
    512521         * Feed permalink base.
    513522         *
    514523         * @since 1.5.0
     
    12641273                //build a regex to match the trackback and page/xx parts of URLs
    12651274                $trackbackregex = 'trackback/?$';
    12661275                $pageregex = $this->pagination_base . '/?([0-9]{1,})/?$';
    1267                 $commentregex = 'comment-page-([0-9]{1,})/?$';
     1276                $commentregex = $this->comments_pagination_base . '[-/]?([0-9]{1,})/?$';       
    12681277
    12691278                //build up an array of endpoint regexes to append => queries to append
    12701279                if ( $endpoints ) {
     
    13511360                        $pagematch = $match . $pageregex;
    13521361                        $pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1);
    13531362
    1354                         //create query for /comment-page-xx
     1363                        //create query for /comment-page/xx
    13551364                        $commentmatch = $match . $commentregex;
    13561365                        $commentquery = $index . '?' . $query . '&cpage=' . $this->preg_index($num_toks + 1);
    13571366
    13581367                        if ( get_option('page_on_front') ) {
    1359                                 //create query for Root /comment-page-xx
     1368                                //create query for Root /comment-page/xx
    13601369                                $rootcommentmatch = $match . $commentregex;
    13611370                                $rootcommentquery = $index . '?' . $query . '&page_id=' . get_option('page_on_front') . '&cpage=' . $this->preg_index($num_toks + 1);
    13621371                        }
     
    13821391                        if ( $paged ) //...and /page/xx ones
    13831392                                $rewrite = array_merge($rewrite, array($pagematch => $pagequery));
    13841393
    1385                         //only on pages with comments add ../comment-page-xx/
     1394                        //only on pages with comments add ../comment-page/xx/
    13861395                        if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask )
    13871396                                $rewrite = array_merge($rewrite, array($commentmatch => $commentquery));
    13881397                        else if ( EP_ROOT & $ep_mask && get_option('page_on_front') )
  • wp-includes/canonical.php

     
    234234
    235235                // paging and feeds
    236236                if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
    237                         while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( '#/comment-page-[0-9]+(/+)?$#', $redirect['path'] ) ) {
     237                        while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( '#/' . $wp_rewrite->comments_pagination_base . '[-/]?[0-9]+(/+)?$#', $redirect['path'] ) ) {
    238238                                // Strip off paging and feed
    239239                                $redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging
    240240                                $redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings
    241                                 $redirect['path'] = preg_replace('#/comment-page-[0-9]+?(/+)?$#', '/', $redirect['path']); // strip off any existing comment paging
     241                                $redirect['path'] = preg_replace('#/' . $wp_rewrite->comments_pagination_base . '[-/]?[0-9]+?(/+)?$#', '/', $redirect['path']); // strip off any existing comment paging       
    242242                        }
    243243
    244244                        $addl_path = '';
     
    282282                        }
    283283
    284284                        if ( get_option('page_comments') && ( ( 'newest' == get_option('default_comments_page') && get_query_var('cpage') > 0 ) || ( 'newest' != get_option('default_comments_page') && get_query_var('cpage') > 1 ) ) ) {
    285                                 $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit( 'comment-page-' . get_query_var('cpage'), 'commentpaged' );
     285                                $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit( $wp_rewrite->comments_pagination_base . '/' . get_query_var('cpage'), 'commentpaged' );       
    286286                                $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] );
    287287                        }
    288288
  • wp-includes/comment-template.php

     
    606606                        $args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args );
    607607
    608608                if ( $wp_rewrite->using_permalinks() )
    609                         $link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' );
     609                        $link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . $wp_rewrite->comments_pagination_base . '/' . $args['page'], 'comment' );
    610610                else
    611611                        $link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) );
    612612        } else {