mirror of
git://develop.git.wordpress.org/
synced 2025-01-18 05:18:42 +01:00
Check the return of wp_insert_term() for WP_Error or array. Prevents fatal erros and failure to add categories when adding terms via ajax. Props mdawaffe. fixes #17938 #17939
git-svn-id: https://develop.svn.wordpress.org/trunk@19792 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fed670768a
commit
9e6fbb0061
@ -234,10 +234,12 @@ function _wp_ajax_add_hierarchical_term( $action ) {
|
||||
$category_nicename = sanitize_title($cat_name);
|
||||
if ( '' === $category_nicename )
|
||||
continue;
|
||||
if ( !($cat_id = term_exists($cat_name, $taxonomy->name, $parent)) ) {
|
||||
$new_term = wp_insert_term($cat_name, $taxonomy->name, array('parent' => $parent));
|
||||
$cat_id = $new_term['term_id'];
|
||||
}
|
||||
if ( !$cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) )
|
||||
$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
|
||||
if ( is_wp_error( $cat_id ) )
|
||||
continue;
|
||||
else if ( is_array( $cat_id ) )
|
||||
$cat_id = $cat_id['term_id'];
|
||||
$checked_categories[] = $cat_id;
|
||||
if ( $parent ) // Do these all at once in a second
|
||||
continue;
|
||||
@ -488,10 +490,12 @@ function wp_ajax_add_link_category( $action ) {
|
||||
$slug = sanitize_title($cat_name);
|
||||
if ( '' === $slug )
|
||||
continue;
|
||||
if ( !$cat_id = term_exists( $cat_name, 'link_category' ) ) {
|
||||
if ( !$cat_id = term_exists( $cat_name, 'link_category' ) )
|
||||
$cat_id = wp_insert_term( $cat_name, 'link_category' );
|
||||
}
|
||||
$cat_id = $cat_id['term_id'];
|
||||
if ( is_wp_error( $cat_id ) )
|
||||
continue;
|
||||
else if ( is_array( $cat_id ) )
|
||||
$cat_id = $cat_id['term_id'];
|
||||
$cat_name = esc_html(stripslashes($cat_name));
|
||||
$x->add( array(
|
||||
'what' => 'link-category',
|
||||
|
Loading…
x
Reference in New Issue
Block a user