diff --git a/wp-includes/feed-functions.php b/wp-includes/feed-functions.php
index 6e1992b2c6..a0cabec0fc 100644
--- a/wp-includes/feed-functions.php
+++ b/wp-includes/feed-functions.php
@@ -109,7 +109,7 @@ function get_category_rss_link($echo = false, $category_id, $category_nicename)
$file = get_settings('siteurl') . '/wp-rss2.php';
$link = $file . '?cat=' . $category_id;
} else {
- $link = get_category_link(0, $category_id, $category_nicename);
+ $link = get_category_link($category_id);
$link = $link . "feed/";
}
diff --git a/wp-includes/template-functions-category.php b/wp-includes/template-functions-category.php
index 42b9dbf561..cceee07e57 100644
--- a/wp-includes/template-functions-category.php
+++ b/wp-includes/template-functions-category.php
@@ -24,24 +24,26 @@ function get_the_category($id = false) {
return $categories;
}
-function get_category_link($echo = false, $category_id, $category_nicename) {
- global $wpdb, $wp_rewrite, $post, $cache_categories;
- $cat_ID = $category_id;
- $catlink = $wp_rewrite->get_category_permastruct();
-
- if (empty($catlink)) {
- $file = get_settings('home') . '/';
- $catlink = $file . '?cat=' . $cat_ID;
- } else {
- $category_nicename = $cache_categories[$category_id]->category_nicename;
- if ($parent=$cache_categories[$category_id]->category_parent) $category_nicename = get_category_parents($parent, FALSE, '/', TRUE) . $category_nicename . '/';
+function get_category_link($category_id) {
+ global $wpdb, $wp_rewrite, $querystring_start, $querystring_equal, $cache_categories;
+ $catlink = $wp_rewrite->get_category_permastruct();
- $catlink = str_replace('%category%', $category_nicename, $catlink);
- $catlink = get_settings('home') . trailingslashit($catlink);
- }
- $catlink = apply_filters('category_link', $catlink, $category_id, $category_nicename);
- if ($echo) echo $catlink;
- return $catlink;
+ if ( empty($catlink) ) {
+ $file = get_settings('home') . '/' . get_settings('blogfilename');
+ $catlink = $file . '?cat=' . $category_ID;
+ } else {
+ if ($cache_categories[$category_id]->category_nicename)
+ $category_nicename = $cache_categories[$category_id]->category_nicename;
+ else
+ $category_nicename = $wpdb->get_var('SELECT category_nicename FROM ' . $wpdb->categories . ' WHERE cat_ID=' . $category_id);
+
+ if ($parent = $cache_categories[$category_id]->category_parent)
+ $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/';
+
+ $catlink = str_replace('%category%', $category_nicename, $catlink);
+ $catlink = get_settings('home') . trailingslashit($catlink);
+ }
+ return $catlink;
}
function the_category($separator = '', $parents='') {
@@ -62,10 +64,10 @@ function the_category($separator = '', $parents='') {
if ($category->category_parent) {
$thelist .= get_category_parents($category->category_parent, TRUE);
}
- $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.'';
+ $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.'';
break;
case 'single':
- $thelist .= 'cat_name) . ' rel="category tag">';
+ $thelist .= 'cat_name) . ' rel="category tag">';
if ($category->category_parent) {
$thelist .= get_category_parents($category->category_parent, FALSE);
}
@@ -73,7 +75,7 @@ function the_category($separator = '', $parents='') {
break;
case '':
default:
- $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.'';
+ $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.'';
}
}
$thelist .= '';
@@ -85,16 +87,16 @@ function the_category($separator = '', $parents='') {
switch(strtolower($parents)) {
case 'multiple':
if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, TRUE);
- $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.'';
+ $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.'';
break;
case 'single':
- $thelist .= 'cat_name) . '" rel="category tag">';
+ $thelist .= 'cat_name) . '" rel="category tag">';
if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, FALSE);
$thelist .= "$category->cat_name";
break;
case '':
default:
- $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.'';
+ $thelist .= 'cat_name) . '" rel="category tag">'.$category->cat_name.'';
}
++$i;
}
@@ -124,7 +126,7 @@ function get_category_parents($id, $link = FALSE, $separator = '/', $nicename =
}
if ($parent->category_parent) $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename);
if ($link) {
- $chain .= 'cat_name) . '">'.$name.'' . $separator;
+ $chain .= 'cat_name) . '">'.$name.'' . $separator;
} else {
$chain .= $name.$separator;
}
@@ -314,7 +316,7 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
foreach ($categories as $category) {
if ((intval($hide_empty) == 0 || isset($category_posts["$category->cat_ID"])) && (!$hierarchical || $category->category_parent == $child_of) ) {
$num_found++;
- $link = 'category_description)) {
$link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name)) . '"';
} else {
diff --git a/xmlrpc.php b/xmlrpc.php
index 16db402c46..ad2cb6c199 100644
--- a/xmlrpc.php
+++ b/xmlrpc.php
@@ -764,7 +764,7 @@ class wp_xmlrpc_server extends IXR_Server {
$struct['categoryId'] = $cat['cat_ID'];
$struct['description'] = $cat['cat_name'];
$struct['categoryName'] = $cat['cat_name'];
- $struct['htmlUrl'] = wp_specialchars(get_category_link(false, $cat['cat_ID'], $cat['cat_name']));
+ $struct['htmlUrl'] = wp_specialchars(get_category_link($cat['cat_ID']);
$struct['rssUrl'] = wp_specialchars(get_category_rss_link(false, $cat['cat_ID'], $cat['cat_name']));
$categories_struct[] = $struct;