Skip to content
Permalink
Browse files

Build/Test tools: Ensure the `create_and_get()` factory method return…

…s the appropriate WP_Error when creating a term fails.

Fixes: #47952 


git-svn-id: https://develop.svn.wordpress.org/trunk@46262 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
johnbillion committed Sep 23, 2019
1 parent 2b076b7 commit f3a268f58c7e5cbf0a5ae7125483663892606c4f
@@ -85,6 +85,11 @@ public function add_post_terms( $post_id, $terms, $taxonomy, $append = true ) {
*/
public function create_and_get( $args = array(), $generation_definitions = null ) {
$term_id = $this->create( $args, $generation_definitions );
if ( is_wp_error( $term_id ) ) {
return $term_id;
}
$taxonomy = isset( $args['taxonomy'] ) ? $args['taxonomy'] : $this->taxonomy;
return get_term( $term_id, $taxonomy );
}
@@ -79,6 +79,11 @@ public function create( $args = array(), $generation_definitions = null ) {
*/
public function create_and_get( $args = array(), $generation_definitions = null ) {
$object_id = $this->create( $args, $generation_definitions );
if ( is_wp_error( $object_id ) ) {
return $object_id;
}
return $this->get_object_by_id( $object_id );
}

0 comments on commit f3a268f

Please sign in to comment.
You can’t perform that action at this time.