Make WordPress Core

Changeset 5150


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.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/options-permalink.php

    r4681 r5150  
    7474                $wp_rewrite->set_category_base($category_base);
    7575        }
     76
     77        if ( isset($_POST['tag_base']) ) {
     78                $tag_base = $_POST['tag_base'];
     79                if (! empty($tag_base) )
     80                        $tag_base = preg_replace('#/+#', '/', '/' . $_POST['tag_base']);
     81                $wp_rewrite->set_tag_base($tag_base);
     82        }
    7683}
    7784
    7885$permalink_structure = get_option('permalink_structure');
    7986$category_base = get_option('category_base');
     87$tag_base = get_option( 'tag_base' );
    8088
    8189if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
     
    160168        <p>
    161169  <?php _e('Category base'); ?>: <input name="category_base" type="text" class="code"  value="<?php echo attribute_escape($category_base); ?>" size="30" />
     170     </p>
     171          <p>
     172          <?php _e('Tag base'); ?>: <input name="tag_base" type="text" class="code"  value="<?php echo attribute_escape($tag_base); ?>" size="30" />
    162173     </p>
    163174    <p class="submit">
  • trunk/wp-admin/upgrade-schema.php

    r5110 r5150  
    243243        add_option('show_on_front', 'posts');
    244244
     245        // 2.2
     246        add_option('tag_base');
     247
    245248        // Delete unused options
    246249        $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing');
  • trunk/wp-includes/category-template.php

    r5149 r5150  
    4343function get_tag_link( $tag_id ) {
    4444        global $wp_rewrite;
    45         $catlink = $wp_rewrite->get_category_permastruct();
     45        $catlink = $wp_rewrite->get_tag_permastruct();
    4646
    4747        $category = &get_category($tag_id);
  • trunk/wp-includes/functions.php

    r5138 r5150  
    671671
    672672function update_post_caches(&$posts) {
    673         global $post_cache, $category_cache, $post_meta_cache;
     673        global $post_cache, $category_cache, $post_meta_cache, $tag_cache;
    674674        global $wpdb, $blog_id;
    675675
  • trunk/wp-includes/link-template.php

    r5087 r5150  
    6060                '%post_id%',
    6161                '%category%',
     62                '%tag%',
    6263                '%author%',
    6364                '%pagename%'
  • 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.