Press This: show error message when the user is attempting to add a category that already exists.
Fixes #32339. Built from https://develop.svn.wordpress.org/trunk@32827 git-svn-id: http://core.svn.wordpress.org/trunk@32798 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b14c6bea0b
commit
b77a3a33f5
|
@ -201,10 +201,16 @@ class WP_Press_This {
|
|||
continue;
|
||||
}
|
||||
|
||||
// @todo Find a more performant to check existence, maybe get_term() with a separate parent check.
|
||||
if ( ! $cat_id = term_exists( $cat_name, $taxonomy->name, $parent ) ) {
|
||||
$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
|
||||
// @todo Find a more performant way to check existence, maybe get_term() with a separate parent check.
|
||||
if ( term_exists( $cat_name, $taxonomy->name, $parent ) ) {
|
||||
if ( count( $names ) === 1 ) {
|
||||
wp_send_json_error( array( 'errorMessage' => __( 'This category already exists.' ) ) );
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$cat_id = wp_insert_term( $cat_name, $taxonomy->name, array( 'parent' => $parent ) );
|
||||
|
||||
if ( is_wp_error( $cat_id ) ) {
|
||||
continue;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.3-alpha-32826';
|
||||
$wp_version = '4.3-alpha-32827';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue