From 4a58f4f5236b6395a187580c2daa29913716f7c4 Mon Sep 17 00:00:00 2001 From: Matt Mullenweg Date: Sun, 9 May 2004 02:52:27 +0000 Subject: [PATCH] Fixes for silly category_base stuff. Now lets it be blank and acts accordingly, more sane. git-svn-id: https://develop.svn.wordpress.org/trunk@1244 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/options-permalink.php | 2 +- wp-admin/upgrade-functions.php | 2 +- wp-includes/functions.php | 6 +++++- wp-includes/template-functions-category.php | 7 +++++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php index 222fa1fc76..3316871569 100644 --- a/wp-admin/options-permalink.php +++ b/wp-admin/options-permalink.php @@ -95,7 +95,7 @@ if ($_POST['submit']) {

-

FIXME[THIS WORDING MAKES NO SENSE]

+

/taxonomy/categorias would make your category links like http://example.org/taxonomy/categorias/general/. If you leave this blank the default will be used.') ?>

diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index bba5c9c0f1..f94a7317fd 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -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 diff --git a/wp-includes/functions.php b/wp-includes/functions.php index d6a77d706d..8196caa086 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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; diff --git a/wp-includes/template-functions-category.php b/wp-includes/template-functions-category.php index ba0d3e5f5d..117adfd611 100644 --- a/wp-includes/template-functions-category.php +++ b/wp-includes/template-functions-category.php @@ -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 . '/'; }