Make WordPress Core

Ticket #1762: customise_other_bases.diff

File customise_other_bases.diff, 5.9 KB (added by davidhouse, 19 years ago)
  • wp-includes/classes.php

     
    13561356                if ($this->using_index_permalinks()) {
    13571357                        $this->root = $this->index . '/';
    13581358                }
    1359                 $this->category_base = get_settings('category_base');
     1359                foreach (array('category_base', 'author_base', 'feed_base', 'comments_base') as $base) {
     1360                        $this->$base = get_settings($base);
     1361                }
    13601362                unset($this->category_structure);
    13611363                unset($this->author_structure);
    13621364                unset($this->date_structure);
     
    13791381                        $this->init();
    13801382                }
    13811383        }
     1384       
     1385        function set_author_base($author_base) {
     1386                if ($author_base != $this->author_base) {
     1387                        update_option('author_base', $author_base);
     1388                        $this->init();
     1389                }
     1390        }
     1391       
     1392        function set_feed_base($feed_base) {
     1393                if ($feed_base != $this->feed_base) {
     1394                        update_option('feed_base', $feed_base);
     1395                        $this->init();
     1396                }
     1397        }
     1398       
     1399        function set_comments_base($comments_base) {
     1400                if ($comments_base != $this->comments_base) {
     1401                        update_option('comments_base', $comments_base);
     1402                        $this->init();
     1403                }
     1404        }
    13821405
    13831406        function WP_Rewrite() {
    13841407                $this->init();
  • wp-includes/feed-functions.php

     
    7979}
    8080
    8181function comments_rss($commentsrssfilename = '') {
    82         global $id;
     82        global $id, $wp_rewrite;
    8383
    8484        if ('' != get_settings('permalink_structure'))
    85                 $url = trailingslashit( get_permalink() ) . 'feed/';
     85                $url = trailingslashit( get_permalink() ) . $wp_rewrite->feed_base;
    8686        else
    8787                $url = get_settings('home') . "/$commentsrssfilename?feed=rss2&p=$id";
    8888
  • wp-admin/options-permalink.php

     
    6262                $wp_rewrite->set_permalink_structure($permalink_structure);
    6363        }
    6464       
    65         if ( isset($_POST['category_base']) ) {
    66                 $category_base = $_POST['category_base'];
    67                 if (! empty($category_base) )
    68                         $category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']);
    69                 $wp_rewrite->set_category_base($category_base);
     65        foreach (array('category_base', 'author_base', 'feed_base', 'comments_base') as $base) {
     66                if ( isset($_POST[$base]) ) {
     67                        if (! empty($_POST[$base]) )
     68                                $_POST[$base] = preg_replace('#/+#', '/', '/' . $_POST[$base]);
     69                        $set_base_func = 'set_' . $base;
     70                        $wp_rewrite->$set_base_func($_POST[$base]);
     71                }
    7072        }
    7173}
    7274       
    73 $permalink_structure = get_settings('permalink_structure');
    74 $category_base = get_settings('category_base');
     75$permalink_structure    = get_settings('permalink_structure');
     76$category_base                  = get_settings('category_base');
     77$author_base                    = get_settings('author_base');
     78$feed_base                              = get_settings('feed_base');
     79$comments_base                  = get_settings('comments_base');
    7580
    7681generate_page_rewrite_rules();
    7782
     
    133138</p>
    134139<p id="customstructure"><?php _e('Custom structure'); ?>: <input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo $permalink_structure; ?>" size="50" /></p>
    135140
     141<input type="submit" name="submit" value="<?php _e('Update Permalink Structure &raquo;') ?>" />
     142
    136143<h3><?php _e('Optional'); ?></h3>
    137 <?php if ($is_apache) : ?>
    138         <p><?php _e('If you like, you may enter a custom prefix for your category URIs here. For example, <code>/taxonomy/tags</code> would make your category links like <code>http://example.org/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
    139 <?php else : ?>
    140         <p><?php _e('If you like, you may enter a custom prefix for your category URIs here. For example, <code>/index.php/taxonomy/tags</code> would make your category links like <code>http://example.org/index.php/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
    141 <?php endif; ?>
    142         <p>
    143   <?php _e('Category base'); ?>: <input name="category_base" type="text" class="code"  value="<?php echo $category_base; ?>" size="30" />
    144      </p>
    145     <p class="submit">
    146       <input type="submit" name="submit" value="<?php _e('Update Permalink Structure &raquo;') ?>" />
     144<p><?php _e('Extra options: these following options govern how your different permalinks for categories, authors, feeds and so on are constructed. For example, changing the category base option to \'/taxonomy/tags\' means that the archives for your categories will be at \'/taxonomy/tags/[category name]\'. The feed base will be appended to permalinks to make feed URLs. The comment base will be appended to permalinks then the feed base appended to that to make comment base URLs. If any of these are left blank the defaults will be used.'); ?></p>
     145<table width="100%" cellspacing="2" cellpadding="5" class="editform">
     146        <tr valign="top">
     147                <th width="33%" scope="row"><?php _e('Category Base:') ?></th>
     148                <td><input name="category_base" type="text" class="code"  value="<?php echo $category_base; ?>" size="30" /></td>
     149        </tr>
     150        <tr valign="top">
     151                <th width="33%" scope="row"><?php _e('Author Base:') ?></th>
     152                <td><input name="author_base" type="text" class="code"  value="<?php echo $author_base; ?>" size="30" /></td>
     153        </tr>
     154        <tr valign="top">
     155                <th width="33%" scope="row"><?php _e('Feed Base:') ?></th>
     156                <td><input name="feed_base" type="text" class="code"  value="<?php echo $feed_base; ?>" size="30" /></td>
     157        </tr>
     158        <tr valign="top">
     159                <th width="33%" scope="row"><?php _e('Comments feed Base:') ?></th>
     160                <td><input name="comments_base" type="text" class="code"  value="<?php echo $comments_base; ?>" size="30" /></td>
     161        </tr>
     162</table>
     163       
     164      <input type="submit" name="submit" value="<?php _e('Update Bases &raquo;') ?>" />
    147165    </p>
    148166  </form>
    149167<?php if ( $permalink_structure && !$usingpi && !$writable ) : ?>