git-svn-id: http://svn.automattic.com/wordpress/trunk@2316 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2005-02-14 03:27:50 +00:00
parent 636fd6d92f
commit 72dc0ab63b
3 changed files with 29 additions and 27 deletions

View File

@ -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/";
}

View File

@ -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 .= '<a href="' . get_category_link(0, $category->category_id, $category->category_nicename) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>';
$thelist .= '<a href="' . get_category_link($category->category_id) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>';
break;
case 'single':
$thelist .= '<a href="' . get_category_link(0, $category->category_id, $category->category_nicename) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . ' rel="category tag">';
$thelist .= '<a href="' . get_category_link($category->category_id) . '" title="' . sprintf(__("View all posts in %s"), $category->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 .= '<a href="' . get_category_link(0, $category->category_id, $category->category_nicename) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>';
$thelist .= '<a href="' . get_category_link($category->category_id) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a></li>';
}
}
$thelist .= '</ul>';
@ -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 .= '<a href="' . get_category_link(0, $category->category_id, $category->category_nicename) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>';
$thelist .= '<a href="' . get_category_link($category->category_id) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>';
break;
case 'single':
$thelist .= '<a href="' . get_category_link(0, $category->category_id, $category->category_nicename) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">';
$thelist .= '<a href="' . get_category_link($category->category_id) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">';
if ($category->category_parent) $thelist .= get_category_parents($category->category_parent, FALSE);
$thelist .= "$category->cat_name</a>";
break;
case '':
default:
$thelist .= '<a href="' . get_category_link(0, $category->category_id, $category->category_nicename) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>';
$thelist .= '<a href="' . get_category_link($category->category_id) . '" title="' . sprintf(__("View all posts in %s"), $category->cat_name) . '" rel="category tag">'.$category->cat_name.'</a>';
}
++$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 .= '<a href="' . get_category_link(0, $parent->cat_ID, $parent->category_nicename) . '" title="' . sprintf(__("View all posts in %s"), $parent->cat_name) . '">'.$name.'</a>' . $separator;
$chain .= '<a href="' . get_category_link($parent->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $parent->cat_name) . '">'.$name.'</a>' . $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 = '<a href="'.get_category_link(0, $category->cat_ID, $category->category_nicename).'" ';
$link = '<a href="'.get_category_link($category->cat_ID).'" ';
if ($use_desc_for_title == 0 || empty($category->category_description)) {
$link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name)) . '"';
} else {

View File

@ -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;