mirror of
git://develop.git.wordpress.org/
synced 2025-01-18 05:18:42 +01:00
Return error if term DB insert fails
git-svn-id: https://develop.svn.wordpress.org/trunk@7430 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e685b5edc2
commit
2553a64d19
@ -1152,13 +1152,15 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
||||
}
|
||||
|
||||
if ( ! $term_id = is_term($slug) ) {
|
||||
$wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) );
|
||||
if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
|
||||
return new WP_Error('db_insert_error', __('Could not insert term into the database'));
|
||||
$term_id = (int) $wpdb->insert_id;
|
||||
} else if ( is_taxonomy_hierarchical($taxonomy) && !empty($parent) ) {
|
||||
// If the taxonomy supports hierarchy and the term has a parent, make the slug unique
|
||||
// by incorporating parent slugs.
|
||||
$slug = wp_unique_term_slug($slug, (object) $args);
|
||||
$wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) );
|
||||
if ( false === $wpdb->insert( $wpdb->terms, compact( 'name', 'slug', 'term_group' ) ) )
|
||||
return new WP_Error('db_insert_error', __('Could not insert term into the database'));
|
||||
$term_id = (int) $wpdb->insert_id;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user