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:
parent
49953705f1
commit
eb541a962f
|
@ -53,7 +53,7 @@ function wp_delete_link($link_id) {
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -333,7 +333,7 @@ function wp_list_bookmarks($args = '') {
|
|||
|
||||
if ( $categorize ) {
|
||||
//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 ) {
|
||||
$params = array_merge($r, array('category'=>$cat->term_id));
|
||||
|
|
|
@ -76,8 +76,8 @@ function get_bookmarks($args = '') {
|
|||
$exclusions .= ')';
|
||||
|
||||
if ( ! empty($category_name) ) {
|
||||
if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") )
|
||||
$category = $cat_id;
|
||||
if ( $category = get_term_by('name', $category_name, 'link_category') );
|
||||
$category = $category->term_id;
|
||||
}
|
||||
|
||||
$category_query = '';
|
||||
|
@ -87,15 +87,15 @@ function get_bookmarks($args = '') {
|
|||
if ( count($incategories) ) {
|
||||
foreach ( $incategories as $incat ) {
|
||||
if (empty($category_query))
|
||||
$category_query = ' AND ( category_id = ' . intval($incat) . ' ';
|
||||
$category_query = ' AND ( tt.term_id = ' . intval($incat) . ' ';
|
||||
else
|
||||
$category_query .= ' OR category_id = ' . intval($incat) . ' ';
|
||||
$category_query .= ' OR tt.term_id = ' . intval($incat) . ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($category_query)) {
|
||||
$category_query .= ')';
|
||||
$join = " LEFT JOIN $wpdb->link2cat ON ($wpdb->links.link_id = $wpdb->link2cat.link_id) ";
|
||||
$category_query .= ") AND taxonomy = 'link_category'";
|
||||
$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')) {
|
||||
|
|
|
@ -13,6 +13,7 @@ function get_all_category_ids() {
|
|||
|
||||
function &get_categories($args = '') {
|
||||
// TODO Add back compat fields into each object.
|
||||
// Set taxonomy to link_category if type=link
|
||||
return get_terms('category', $args);
|
||||
}
|
||||
|
||||
|
|
|
@ -242,6 +242,8 @@ function wp_update_term( $term, $taxonomy, $args = array() ) {
|
|||
}
|
||||
|
||||
function wp_update_term_count( $terms, $taxonomy ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( empty($terms) )
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue