Make WordPress Core


Ignore:
Timestamp:
10/17/2010 05:41:22 AM (14 years ago)
Author:
dd32
Message:

Merge Category/Tag URL creation/rewriting into general Taxonomy system. Removes the legacy handling for these url's. See #12659

File:
1 edited

Legend:

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

    r15590 r15825  
    380380     */
    381381    var $use_trailing_slashes;
    382 
    383     /**
    384      * Customized or default category permalink base ( example.com/xx/tagname ).
    385      *
    386      * @since 1.5.0
    387      * @access private
    388      * @var string
    389      */
    390     var $category_base;
    391 
    392     /**
    393      * Customized or default tag permalink base ( example.com/xx/tagname ).
    394      *
    395      * @since 2.3.0
    396      * @access private
    397      * @var string
    398      */
    399     var $tag_base;
    400 
    401     /**
    402      * Permalink request structure for categories.
    403      *
    404      * @since 1.5.0
    405      * @access private
    406      * @var string
    407      */
    408     var $category_structure;
    409 
    410     /**
    411      * Permalink request structure for tags.
    412      *
    413      * @since 2.3.0
    414      * @access private
    415      * @var string
    416      */
    417     var $tag_structure;
    418382
    419383    /**
     
    682646                    '([^/]+)',
    683647                    '([0-9]+)',
    684                     '(.+?)',
    685                     '(.+?)',
    686648                    '([^/]+)',
    687649                    '([^/]+?)',
     
    706668                    'name=',
    707669                    'p=',
    708                     'category_name=',
    709                     'tag=',
    710670                    'author_name=',
    711671                    'pagename=',
     
    1029989     */
    1030990    function get_category_permastruct() {
    1031         if ( isset($this->category_structure) )
    1032             return $this->category_structure;
    1033 
    1034         if ( empty($this->permalink_structure) ) {
    1035             $this->category_structure = '';
    1036             return false;
    1037         }
    1038 
    1039         if ( empty($this->category_base) )
    1040             $this->category_structure = trailingslashit( $this->front . 'category' );
    1041         else
    1042             $this->category_structure = trailingslashit( '/' . $this->root . $this->category_base );
    1043 
    1044         $this->category_structure .= '%category%';
    1045 
    1046         return $this->category_structure;
     991        return $this->get_extra_permastruct('category');
    1047992    }
    1048993
     
    10611006     */
    10621007    function get_tag_permastruct() {
    1063         if ( isset($this->tag_structure) )
    1064             return $this->tag_structure;
    1065 
    1066         if ( empty($this->permalink_structure) ) {
    1067             $this->tag_structure = '';
    1068             return false;
    1069         }
    1070 
    1071         if ( empty($this->tag_base) )
    1072             $this->tag_structure = trailingslashit( $this->front . 'tag' );
    1073         else
    1074             $this->tag_structure = trailingslashit( '/' . $this->root . $this->tag_base );
    1075 
    1076         $this->tag_structure .= '%tag%';
    1077 
    1078         return $this->tag_structure;
     1008        return $this->get_extra_permastruct('post_tag');
    10791009    }
    10801010
     
    16141544        $search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
    16151545
    1616         // Categories
    1617         $category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct(), EP_CATEGORIES);
    1618         $category_rewrite = apply_filters('category_rewrite_rules', $category_rewrite);
    1619 
    1620         // Tags
    1621         $tag_rewrite = $this->generate_rewrite_rules($this->get_tag_permastruct(), EP_TAGS);
    1622         $tag_rewrite = apply_filters('tag_rewrite_rules', $tag_rewrite);
    1623 
    16241546        // Authors
    16251547        $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct(), EP_AUTHORS);
     
    16311553
    16321554        // Extra permastructs
    1633         foreach ( $this->extra_permastructs as $permastruct ) {
     1555        foreach ( $this->extra_permastructs as $permastructname => $permastruct ) {
    16341556            if ( is_array($permastruct) )
    1635                 $this->extra_rules_top = array_merge($this->extra_rules_top, $this->generate_rewrite_rules($permastruct[0], $permastruct[1]));
     1557                $rules = $this->generate_rewrite_rules($permastruct[0], $permastruct[1]);
    16361558            else
    1637                 $this->extra_rules_top = array_merge($this->extra_rules_top, $this->generate_rewrite_rules($permastruct, EP_NONE));
     1559                $rules = $this->generate_rewrite_rules($permastruct, EP_NONE);
     1560
     1561            $rules = apply_filters($permastructname . '_rewrite_rules', $rules);
     1562            if ( 'post_tag' == $permastructname )
     1563                $rules = apply_filters('tag_rewrite_rules', $rules);
     1564
     1565            $this->extra_rules_top = array_merge($this->extra_rules_top, $rules);
    16381566        }
    16391567
    16401568        // Put them together.
    16411569        if ( $this->use_verbose_page_rules )
    1642             $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $registration_pages, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $tag_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
     1570            $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $registration_pages, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
    16431571        else
    1644             $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $tag_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
     1572            $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules);
    16451573
    16461574        do_action_ref_array('generate_rewrite_rules', array(&$this));
     
    19791907        if ( $this->using_index_permalinks() )
    19801908            $this->root = $this->index . '/';
    1981         $this->category_base = get_option( 'category_base' );
    1982         $this->tag_base = get_option( 'tag_base' );
    1983         unset($this->category_structure);
    19841909        unset($this->author_structure);
    19851910        unset($this->date_structure);
     
    20331958     */
    20341959    function set_category_base($category_base) {
    2035         if ( $category_base != $this->category_base ) {
     1960        if ( $category_base != get_option('category_base') ) {
    20361961            update_option('category_base', $category_base);
    20371962            $this->init();
     
    20521977     */
    20531978    function set_tag_base( $tag_base ) {
    2054         if ( $tag_base != $this->tag_base ) {
     1979        if ( $tag_base != get_option( 'tag_base') ) {
    20551980            update_option( 'tag_base', $tag_base );
    20561981            $this->init();
Note: See TracChangeset for help on using the changeset viewer.