Changeset 5534
- Timestamp:
- 05/23/2007 10:11:02 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-db.php
r5533 r5534 163 163 if ( $id = category_exists($cat_name) ) 164 164 return $id; 165 $cat_array = array('cat_name' => $cat_name, 'type' => TAXONOMY_CATEGORY); 166 167 if ( $id = category_object_exists($cat_name) ) { 168 $category = get_category($id); 169 $cat_array['type'] = $category->type | $cat_array['type']; 170 $cat_array['cat_ID'] = $id; 171 return wp_update_category($cat_array); 172 } else { 173 return wp_insert_category($cat_array); 174 } 165 166 return wp_insert_category( array('cat_name' => $cat_name) ); 175 167 } 176 168 … … 191 183 } 192 184 193 function category_object_exists($cat_name) {194 global $wpdb;195 if (!$category_nicename = sanitize_title($cat_name))196 return 0;197 198 return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");199 }200 201 185 function category_exists($cat_name) { 202 global $wpdb; 203 if (!$category_nicename = sanitize_title($cat_name)) 204 return 0; 205 206 return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename' AND ( type & " . TAXONOMY_CATEGORY . " != 0 )"); 186 return is_term($cat_name, 'category'); 207 187 } 208 188 … … 215 195 return $id; 216 196 217 $tag_id =wp_insert_term($tag_name, 'post_tag');197 return wp_insert_term($tag_name, 'post_tag'); 218 198 } 219 199 -
trunk/wp-includes/category.php
r5529 r5534 1 1 <?php 2 3 define('TAXONOMY_CATEGORY', 1);4 define('TAXONOMY_TAG', 2);5 2 6 3 function get_all_category_ids() {
Note: See TracChangeset
for help on using the changeset viewer.