WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/23/2008 06:55:22 PM (13 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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)
Note: See TracChangeset for help on using the changeset viewer.