Make WordPress Core

Ticket #14067: 14067.diff

File 14067.diff, 1.5 KB (added by ryan, 15 years ago)
  • wp-includes/taxonomy.php

     
    16471647                        if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
    16481648                                return new WP_Error('db_insert_error', __('Could not insert term into the database'), $wpdb->last_error);
    16491649                        $term_id = (int) $wpdb->insert_id;
    1650                 } elseif ( term_exists( (int) $term_id, $taxonomy ) )  {
     1650                } elseif ( $exists = term_exists( (int) $term_id, $taxonomy ) )  {
    16511651                        // Same name, same slug.
    1652                         return new WP_Error('term_exists', __('A term with the name provided already exists.'));
     1652                        return new WP_Error('term_exists', __('A term with the name provided already exists.'), $exists);
    16531653                }
    16541654        } else {
    16551655                // This term does not exist at all in the database, Create it.
  • xmlrpc.php

     
    933933                        "category_description"  => $category["description"]
    934934                );
    935935
    936                 $cat_id = wp_insert_category($new_category);
    937                 if ( !$cat_id )
     936                $cat_id = wp_insert_category($new_category, true);
     937                if ( is_wp_error( $cat_id ) ) {
     938                        if ( 'term_exists' == $cat_id->get_error_code() )
     939                                return $cat_id->get_error_data();
     940                        else
     941                                return(new IXR_Error(500, __("Sorry, the new category failed.")));
     942                } elseif ( ! $cat_id ) {
    938943                        return(new IXR_Error(500, __("Sorry, the new category failed.")));
     944                }
    939945
    940946                return($cat_id);
    941947        }