Fixes for silly category_base stuff. Now lets it be blank and acts accordingly, more sane.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-05-09 02:52:27 +00:00
parent d086da27e7
commit 4915acfefd
4 changed files with 12 additions and 5 deletions

View File

@ -95,7 +95,7 @@ if ($_POST['submit']) {
<p>
<input name="permalink_structure" type="text" style="width: 98%;" value="<?php echo $permalink_structure; ?>" />
</p>
<p><?php _e('Enter a path without templates for your categories:') ?> FIXME[THIS WORDING MAKES NO SENSE]</p>
<p><?php _e('If you like, you may enter a custom prefix for your category URIs here. For example, <code>/taxonomy/categorias</code> would make your category links like <code>http://example.org/taxonomy/categorias/general/</code>. If you leave this blank the default will be used.') ?></p>
<p>
<input name="category_base" type="text" style="width: 98%;" value="<?php echo $category_base; ?>" />
</p>

View File

@ -820,7 +820,7 @@ function upgrade_110() {
// Option for category base
if(!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'category_base'")) {
$wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('category_base', 3, '/category', 8)");
$wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('category_base', 3, '', 8)");
}
// Delete unused options

View File

@ -331,6 +331,7 @@ function get_alloptions() {
// never underestimate the ingenuity of the fools :)"
if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
if ('category_base' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
$all_options->{$option->option_name} = $option->option_value;
}
@ -1278,7 +1279,10 @@ function rewrite_rules($matches = '', $permalink_structure = '') {
// Code for nice categories and authors, currently not very flexible
$front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
$catmatch = get_settings( 'category_base' ) . '/';
if ( '' == get_settings('category_base') )
$catmatch = $front . 'category/';
else
$catmatch = get_settings('category_base') . '/';
$catmatch = preg_replace('|^/+|', '', $catmatch);
$catfeedmatch = $catmatch . '(.*)/' . $feedregex;

View File

@ -24,11 +24,14 @@ function get_category_link($echo = false, $category_id, $category_nicename) {
$file = get_settings('home') . '/' . get_settings('blogfilename');
$link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID;
} else {
$category_nicename = $cache_categories[$category_id]->cat_name;
$category_nicename = preg_replace( '|[^a-z0-9-]|i', '', $category_nicename );
$category_nicename = $cache_categories[$category_id]->category_nicename;
// Get any static stuff from the front
$front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
if ( '' == get_settings('category_base') ) :
$link = get_settings('home') . $front . 'category/';
else :
$link = get_settings('home') . get_settings('category_base') . '/';
endif;
if ($parent=$cache_categories[$category_id]->category_parent) $link .= get_category_parents($parent, FALSE, '/', TRUE);
$link .= $category_nicename . '/';
}