Make WordPress Core


Ignore:
Timestamp:
11/19/2006 07:56:05 AM (20 years ago)
Author:
ryan
Message:

Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixes #986

File:
1 edited

Legend:

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

    r4279 r4495  
    1717                return;
    1818        }
    19        
     19
    2020        $qv = trim($tagname, '%');
    21        
     21
    2222        global $wp_rewrite, $wp;
    2323        $wp->add_query_var($qv);
    … …  
    2525}
    2626
    27 //Add a new feed type like /atom1/ 
     27//Add a new feed type like /atom1/
    2828function add_feed($feedname, $function) {
    2929        global $wp_rewrite;
    … …  
    170170        var $endpoints;
    171171        var $use_verbose_rules = false;
    172         var $rewritecode = 
     172        var $rewritecode =
    173173                array(
    174174                                        '%year%',
    … …  
    186186                                        );
    187187
    188         var $rewritereplace = 
     188        var $rewritereplace =
    189189                array(
    190190                                        '([0-9]{4})',
    … …  
    202202                                        );
    203203
    204         var $queryreplace = 
     204        var $queryreplace =
    205205                array (
    206206                                        'year=',
    … …  
    219219
    220220        var $feeds = array ( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
    221        
     221
    222222        function using_permalinks() {
    223223                if (empty($this->permalink_structure))
    … …  
    236236                        return true;
    237237                }
    238    
     238
    239239                return false;
    240240        }
    … …  
    252252
    253253                if (! empty($this->matches)) {
    254                         $match_prefix = '$' . $this->matches . '['; 
     254                        $match_prefix = '$' . $this->matches . '[';
    255255                        $match_suffix = ']';
    256                 }       
    257 
    258                 return "$match_prefix$number$match_suffix";       
     256                }
     257
     258                return "$match_prefix$number$match_suffix";
    259259        }
    260260
    … …  
    302302                                break;
    303303                        }
    304                 } 
     304                }
    305305
    306306                if ( empty($date_endian) )
    … …  
    308308
    309309                // Do not allow the date tags and %post_id% to overlap in the permalink
    310                 // structure. If they do, move the date tags to $front/date/. 
     310                // structure. If they do, move the date tags to $front/date/.
    311311                $front = $this->front;
    312312                preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
    … …  
    483483                $trackbackregex = 'trackback/?$';
    484484                $pageregex = 'page/?([0-9]{1,})/?$';
    485                
     485
    486486                //build up an array of endpoint regexes to append => queries to append
    487487                if ($endpoints) {
    488488                        $ep_query_append = array ();
    489                         foreach ($this->endpoints as $endpoint) { 
     489                        foreach ($this->endpoints as $endpoint) {
    490490                                //match everything after the endpoint name, but allow for nothing to appear there
    491491                                $epmatch = $endpoint[1] . '(/(.*))?/?$';
    … …  
    512512                                $queries[$i] = $queries[$i - 1] . '&';
    513513                        }
    514              
     514
    515515                        $query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1);
    516516                        $queries[$i] .= $query_token;
    … …  
    549549                        //get the 'tagname=$matches[i]'
    550550                        $query = $queries[$num_toks - 1];
    551                        
     551
    552552                        //set up $ep_mask_specific which is used to match more specific URL types
    553553                        switch ($dirs[$j]) {
    … …  
    581581                        if ($paged) //...and /page/xx ones
    582582                                $rewrite = array_merge($rewrite, array($pagematch => $pagequery));
    583                        
     583
    584584                        //if we've got some tags in this dir
    585585                        if ($num_toks) {
    586586                                $post = false;
    587587                                $page = false;
    588                                
    589                                 //check to see if this dir is permalink-level: i.e. the structure specifies an 
     588
     589                                //check to see if this dir is permalink-level: i.e. the structure specifies an
    590590                                //individual post. Do this by checking it contains at least one of 1) post name,
    591                                 //2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and 
     591                                //2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and
    592592                                //minute all present). Set these flags now as we need them for the endpoints.
    593593                                if (strstr($struct, '%postname%') || strstr($struct, '%post_id%')
    … …  
    598598                                                $page = true;
    599599                                }
    600                                
     600
    601601                                //do endpoints
    602602                                if ($endpoints) {
    … …  
    608608                                        }
    609609                                }
    610                                
     610
    611611                                //if we're creating rules for a permalink, do all the endpoints like attachments etc
    612612                                if ($post) {
    … …  
    619619                                        //get rid of brackets
    620620                                        $submatchbase = str_replace(array('(',')'),'',$match);
    621                                        
     621
    622622                                        //add a rule for at attachments, which take the form of <permalink>/some-text
    623623                                        $sub1 = $submatchbase . '/([^/]+)/';
    … …  
    627627                                        //add an ? as we don't have to match that last slash, and finally a $ so we
    628628                                        //match to the end of the URL
    629                                        
     629
    630630                                        //add another rule to match attachments in the explicit form:
    631631                                        //<permalink>/attachment/some-text
    … …  
    634634                                        $sub2feed = $sub2 . $feedregex;    //feeds, <permalink>/attachment/feed/(atom|...)
    635635                                        $sub2feed2 = $sub2 . $feedregex2;  //and feeds again on to this <permalink>/attachment/(feed|atom...)
    636                                        
     636
    637637                                        //create queries for these extra tag-ons we've just dealt with
    638638                                        $subquery = $index . '?attachment=' . $this->preg_index(1);
    639639                                        $subtbquery = $subquery . '&tb=1';
    640640                                        $subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
    641                                        
     641
    642642                                        //do endpoints for attachments
    643643                                        if ($endpoint) { foreach ($ep_query_append as $regex => $ep) {
    … …  
    647647                                                }
    648648                                        } }
    649                                        
     649
    650650                                        //now we've finished with endpoints, finish off the $sub1 and $sub2 matches
    651651                                        $sub1 .= '?$';
    652652                                        $sub2 .= '?$';
    653                                        
     653
    654654                                        //allow URLs like <permalink>/2 for <permalink>/page/2
    655655                                        $match = $match . '(/[0-9]+)?/?$';
    … …  
    660660                                        $query = $index . '?' . $query;
    661661                                }
    662                                
     662
    663663                                //create the final array for this dir by joining the $rewrite array (which currently
    664664                                //only contains rules/queries for trackback, pages etc) to the main regex/query for
    … …  
    670670                                        //add trackback
    671671                                        $rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite);
    672                                        
     672
    673673                                        //add regexes/queries for attachments, attachment trackbacks and so on
    674674                                        if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages
    … …  
    764764                $home_root = parse_url(get_option('home'));
    765765                $home_root = trailingslashit($home_root['path']);
    766    
     766
    767767                $rules = "<IfModule mod_rewrite.c>\n";
    768768                $rules .= "RewriteEngine On\n";
    769769                $rules .= "RewriteBase $home_root\n";
    770                
     770
    771771                //add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
    772772                foreach ($this->non_wp_rules as $match => $query) {
    … …  
    820820                return $rules;
    821821        }
    822        
     822
    823823        //Add a straight rewrite rule
    824824        function add_rule($regex, $redirect) {
    … …  
    832832                }
    833833        }
    834        
     834
    835835        //add a rule that doesn't redirect to index.php
    836836        function add_external_rule($regex, $redirect) {
    837837                $this->non_wp_rules[$regex] = $redirect;
    838838        }
    839        
     839
    840840        //add an endpoint, like /trackback/, to be inserted after certain URL types (specified in $places)
    841841        function add_endpoint($name, $places) {
Note: See TracChangeset for help on using the changeset viewer.