Make WordPress Core


Ignore:
Timestamp:
03/31/2007 09:19:32 AM (19 years ago)
Author:
matt
Message:

Now tag pretty permalinks should work, and support custom tag bases.

File:
1 edited

Legend:

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

    r5131 r5150  
    4747define('EP_SEARCH',     256 );
    4848define('EP_CATEGORIES', 512 );
    49 define('EP_AUTHORS',    1024);
    50 define('EP_PAGES',      2048);
     49define('EP_TAGS', 1024 );
     50define('EP_AUTHORS',    2048);
     51define('EP_PAGES',      4096);
    5152//pseudo-places
    5253define('EP_NONE',       0  );
    53 define('EP_ALL',        4095);
     54define('EP_ALL',        8191);
    5455
    5556//and an endpoint, like /trackback/
     
    151152        var $use_trailing_slashes;
    152153        var $category_base;
     154        var $tag_base;
    153155        var $category_structure;
     156        var $tag_structure;
    154157        var $author_base = 'author';
    155158        var $author_structure;
     
    182185                                        '%post_id%',
    183186                                        '%category%',
     187                                        '%tag%',
    184188                                        '%author%',
    185189                                        '%pagename%',
     
    198202                                        '([0-9]+)',
    199203                                        '(.+?)',
     204                                        '(.+?)',
    200205                                        '([^/]+)',
    201206                                        '([^/]+)',
     
    214219                                        'p=',
    215220                                        'category_name=',
     221                                        'tag=',
    216222                                        'author_name=',
    217223                                        'pagename=',
     
    377383
    378384                return $this->category_structure;
     385        }
     386
     387        function get_tag_permastruct() {
     388                if (isset($this->tag_structure)) {
     389                        return $this->tag_structure;
     390                }
     391
     392                if (empty($this->permalink_structure)) {
     393                        $this->tag_structure = '';
     394                        return false;
     395                }
     396
     397                if (empty($this->tag_base))
     398                        $this->tag_structure = $this->front . 'tag/';
     399                else
     400                        $this->tag_structure = $this->tag_base . '/';
     401
     402                $this->tag_structure .= '%tag%';
     403
     404                return $this->tag_structure;
    379405        }
    380406
     
    735761                $category_rewrite = apply_filters('category_rewrite_rules', $category_rewrite);
    736762
     763                // Tags
     764                $tag_rewrite = $this->generate_rewrite_rules($this->get_tag_permastruct(), EP_TAGS);
     765                $tag_rewrite = apply_filters('tag_rewrite_rules', $tag_rewrite);
     766
    737767                // Authors
    738768                $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS);
     
    744774
    745775                // Put them together.
    746                 $this->rules = array_merge($robots_rewrite, $default_feeds, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
     776                $this->rules = array_merge($robots_rewrite, $default_feeds, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $tag_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
    747777
    748778                do_action_ref_array('generate_rewrite_rules', array(&$this));
     
    870900                        $this->root = $this->index . '/';
    871901                }
    872                 $this->category_base = get_option('category_base');
     902                $this->category_base = get_option( 'category_base' );
     903                $this->tag_base = get_option( 'tag_base' );
    873904                unset($this->category_structure);
    874905                unset($this->author_structure);
     
    895926        }
    896927
     928        function set_tag_base( $tag_base ) {
     929                if ( $tag_base != $this->tag_base ) {
     930                        update_option( 'tag_base', $tag_base );
     931                        $this->init();
     932                }
     933        }
     934
    897935        function WP_Rewrite() {
    898936                $this->init();
Note: See TracChangeset for help on using the changeset viewer.