WordPress.org

Make WordPress Core

Ticket #27631: 27631.diff

File 27631.diff, 5.3 KB (added by jesin, 8 years ago)

Add a wp rewrite variable $comments_pagination_base

  • 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/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 {
  • 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/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 ) {