WordPress.org

Make WordPress Core

Changeset 9300


Ignore:
Timestamp:
10/23/08 18:55:22 (7 years ago)
Author:
ryan
Message:

pretty permalinks for comment paging. Props Viper007Bind. fixes #7942

Location:
trunk/wp-includes
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/canonical.php

    r9214 r9300  
    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 
     
    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    } 
  • trunk/wp-includes/link-template.php

    r9296 r9300  
    12431243*/ 
    12441244function paginate_comments_links($args = array()) { 
    1245     global $wp_query; 
     1245    global $wp_query, $wp_rewrite; 
    12461246 
    12471247    if ( !is_singular() ) 
     
    12601260        'add_fragment' => '#comments' 
    12611261    ); 
     1262    if ( $wp_rewrite->using_permalinks() ) 
     1263        $defaults['base'] = user_trailingslashit(get_permalink() . 'comment-page-%#%', 'commentpaged'); 
     1264 
    12621265    $args = wp_parse_args( $args, $defaults ); 
    12631266    $page_links = paginate_links( $args ); 
  • trunk/wp-includes/rewrite.php

    r8924 r9300  
    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 
     
    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; 
     
    13601365            if ($paged) //...and /page/xx ones 
    13611366                $rewrite = array_merge($rewrite, array($pagematch => $pagequery)); 
     1367 
     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)); 
    13621371 
    13631372            //do endpoints 
     
    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 
     
    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 
     
    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 
     
    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) 
  • trunk/wp-includes/version.php

    r9296 r9300  
    99 * @global string $wp_version 
    1010 */ 
    11 $wp_version = '2.7-almost-beta-9296'; 
     11$wp_version = '2.7-almost-beta-9300'; 
    1212 
    1313/** 
     
    1616 * @global int $wp_db_version 
    1717 */ 
    18 $wp_db_version = 9296; 
     18$wp_db_version = 9300; 
    1919 
    2020?> 
Note: See TracChangeset for help on using the changeset viewer.