Link category fixes. see #4189

git-svn-id: http://svn.automattic.com/wordpress/trunk@5560 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-05-27 17:21:04 +00:00
parent 49953705f1
commit eb541a962f
5 changed files with 11 additions and 8 deletions

View File

@ -53,7 +53,7 @@ function wp_delete_link($link_id) {
function wp_get_link_cats($link_id = 0) { function wp_get_link_cats($link_id = 0) {
$cats = get_object_terms($link_id, 'link_category', 'get=ids'); $cats = get_object_terms($link_id, 'link_category', 'fields=ids');
return array_unique($cats); return array_unique($cats);
} }

View File

@ -333,7 +333,7 @@ function wp_list_bookmarks($args = '') {
if ( $categorize ) { if ( $categorize ) {
//Split the bookmarks into ul's for each category //Split the bookmarks into ul's for each category
$cats = get_categories("type=link&category_name=$category_name&include=$category&orderby=$category_orderby&order=$category_order&hierarchical=0"); $cats = get_terms('link_category', "category_name=$category_name&include=$category&orderby=$category_orderby&order=$category_order&hierarchical=0");
foreach ( (array) $cats as $cat ) { foreach ( (array) $cats as $cat ) {
$params = array_merge($r, array('category'=>$cat->term_id)); $params = array_merge($r, array('category'=>$cat->term_id));

View File

@ -76,8 +76,8 @@ function get_bookmarks($args = '') {
$exclusions .= ')'; $exclusions .= ')';
if ( ! empty($category_name) ) { if ( ! empty($category_name) ) {
if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") ) if ( $category = get_term_by('name', $category_name, 'link_category') );
$category = $cat_id; $category = $category->term_id;
} }
$category_query = ''; $category_query = '';
@ -87,15 +87,15 @@ function get_bookmarks($args = '') {
if ( count($incategories) ) { if ( count($incategories) ) {
foreach ( $incategories as $incat ) { foreach ( $incategories as $incat ) {
if (empty($category_query)) if (empty($category_query))
$category_query = ' AND ( category_id = ' . intval($incat) . ' '; $category_query = ' AND ( tt.term_id = ' . intval($incat) . ' ';
else else
$category_query .= ' OR category_id = ' . intval($incat) . ' '; $category_query .= ' OR tt.term_id = ' . intval($incat) . ' ';
} }
} }
} }
if (!empty($category_query)) { if (!empty($category_query)) {
$category_query .= ')'; $category_query .= ") AND taxonomy = 'link_category'";
$join = " LEFT JOIN $wpdb->link2cat ON ($wpdb->links.link_id = $wpdb->link2cat.link_id) "; $join = " LEFT JOIN $wpdb->term_relationships AS tr ON ($wpdb->links.link_id = tr.object_id) LEFT JOIN $wpdb->term_taxonomy as tt ON tt.term_taxonomy_id = tr.term_taxonomy_id";
} }
if (get_option('links_recently_updated_time')) { if (get_option('links_recently_updated_time')) {

View File

@ -13,6 +13,7 @@ function get_all_category_ids() {
function &get_categories($args = '') { function &get_categories($args = '') {
// TODO Add back compat fields into each object. // TODO Add back compat fields into each object.
// Set taxonomy to link_category if type=link
return get_terms('category', $args); return get_terms('category', $args);
} }

View File

@ -242,6 +242,8 @@ function wp_update_term( $term, $taxonomy, $args = array() ) {
} }
function wp_update_term_count( $terms, $taxonomy ) { function wp_update_term_count( $terms, $taxonomy ) {
global $wpdb;
if ( empty($terms) ) if ( empty($terms) )
return false; return false;