| 227 | | $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'"); |
| | 227 | clean_category_cache($cat_ID); |
| | 228 | do_action('delete_category', $cat_ID); |
| | 229 | return 1; |
| | 230 | } |
| | 231 | |
| | 232 | function wp_create_category($cat_name) { |
| | 233 | $cat_array = compact('cat_name'); |
| | 234 | return wp_insert_category($cat_array); |
| | 235 | } |
| | 236 | |
| | 237 | function wp_create_link_category($cat_name) { |
| | 238 | $type = TAXONOMY_LINK_CATEGORY; |
| | 239 | $cat_array = compact('cat_name', 'type'); |
| | 240 | return wp_insert_category($cat_array); |
| | 241 | } |
| | 242 | |
| | 243 | function wp_delete_link_category($cat_ID) { |
| | 244 | global $wpdb; |
| | 245 | |
| | 246 | $cat_ID = (int) $cat_ID; |
| | 247 | $default_link_cat = get_option('default_link_category'); |
| | 248 | |
| | 249 | // Don't delete either of the default cats |
| | 250 | if ( $cat_ID == $default_link_cat ) |
| | 251 | return 0; |
| | 252 | |
| | 253 | $category = get_category($cat_ID); |
| | 254 | $parent = $category->category_parent; |
| | 255 | |
| | 256 | // Delete the category if it is not also a tag or regular category. |
| | 257 | if ( 0 == ($category->type & TAXONOMY_TAG) || 0 == ($category->type & TAXONOMY_CATEGORY) ) { |
| | 258 | if ($wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'")) { |
| | 259 | // Update children to point to new parent |
| | 260 | $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'"); |
| | 261 | } else { |
| | 262 | return false; |
| | 263 | } |
| | 264 | } else { |
| | 265 | $wpdb->query("UPDATE $wpdb->categories SET type = type & ~" . TAXONOMY_LINK_CATEGORY . " WHERE cat_ID = '$cat_ID'"); |
| | 266 | } |
| | 267 | |
| | 268 | // Only set links to the default category if they're not in another category already |
| | 269 | $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id = '$cat_ID'"); |