Changeset 4639
- Timestamp:
- 12/10/2006 08:53:05 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-db.php
r4638 r4639 175 175 176 176 $cat_ID = (int) $cat_ID; 177 178 // Don't delete the default cat. 179 if ( $cat_ID == get_option('default_category') ) 177 $default_cat = get_option('default_category'); 178 $default_link_cat = get_option('default_link_category'); 179 180 // Don't delete either of the default cats 181 if ( $cat_ID == $default_cat || $cat_ID == $default_link_cat ) 180 182 return 0; 181 183 182 if ( $cat_ID == get_option('default_link_category') )183 return 0;184 185 184 $category = get_category($cat_ID); 186 185 187 186 $parent = $category->category_parent; 188 187 189 // Delete the category .188 // Delete the category 190 189 if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") ) 191 190 return 0; 192 191 193 // Update children to point to new parent .192 // Update children to point to new parent 194 193 $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'"); 195 194 196 // Only set posts and links to the default category if they're not in another category already. 197 $default_cat = get_option('default_category'); 195 // Only set posts and links to the default category if they're not in another category already 198 196 $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'"); 199 if ( is_array($posts) ) foreach ($posts as $post_id) {197 foreach ( (array) $posts as $post_id ) { 200 198 $cats = wp_get_post_categories($post_id); 201 199 if ( 1 == count($cats) ) … … 206 204 } 207 205 208 $default_link_cat = get_option('default_link_category');209 206 $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'"); 210 if ( is_array($links) ) foreach ($links as $link_id) {207 foreach ( (array) $links as $link_id ) { 211 208 $cats = wp_get_link_cats($link_id); 212 209 if ( 1 == count($cats) ) … … 218 215 219 216 clean_category_cache($cat_ID); 220 221 217 do_action('delete_category', $cat_ID); 222 223 218 return 1; 224 219 }
Note: See TracChangeset
for help on using the changeset viewer.