Ticket #5342: inset_cat_wp_err.diff
| File inset_cat_wp_err.diff, 1.3 KB (added by ryan, 5 years ago) |
|---|
-
wp-admin/admin-ajax.php
199 199 $x->send(); 200 200 } 201 201 202 if ( !$cat = wp_insert_category( $_POST ) ) 202 $cat = wp_insert_category( $_POST, true ); 203 204 if ( is_wp_error($cat) ) { 205 $x = new WP_Ajax_Response( array( 206 'what' => 'cat', 207 'id' => $cat 208 ) ); 209 $x->send(); 210 } 211 212 if ( !$cat || (!$cat = get_category( $cat )) ) 203 213 die('0'); 204 if ( !$cat = get_category( $cat ) ) 205 die('0'); 214 206 215 $level = 0; 207 216 $cat_full_name = $cat->name; 208 217 $_cat = $cat; -
wp-admin/includes/taxonomy.php
52 52 return wp_delete_term($cat_ID, 'category', "default=$default"); 53 53 } 54 54 55 function wp_insert_category($catarr ) {55 function wp_insert_category($catarr, $wp_error = false) { 56 56 global $wpdb; 57 57 58 58 extract($catarr, EXTR_SKIP); … … 84 84 else 85 85 $cat_ID = wp_insert_term($cat_name, 'category', $args); 86 86 87 if ( is_wp_error($cat_ID) ) 88 return 0; 87 if ( is_wp_error($cat_ID) ) { 88 if ( $wp_error ) 89 return $cat_ID; 90 else 91 return 0; 92 } 89 93 90 94 return $cat_ID['term_id']; 91 95 }
