diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/includes/taxonomy.php --- a/wp/wp-admin/includes/taxonomy.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/includes/taxonomy.php Tue Dec 15 13:49:49 2020 +0100 @@ -7,7 +7,7 @@ */ // -// Category +// Category. // /** @@ -53,7 +53,8 @@ * @return int|WP_Error */ function wp_create_category( $cat_name, $parent = 0 ) { - if ( $id = category_exists( $cat_name, $parent ) ) { + $id = category_exists( $cat_name, $parent ); + if ( $id ) { return $id; } @@ -72,15 +73,19 @@ * * @param string[] $categories Array of category names to create. * @param int $post_id Optional. The post ID. Default empty. - * @return array List of categories to create for the given post. + * @return int[] Array of IDs of categories assigned to the given post. */ function wp_create_categories( $categories, $post_id = '' ) { $cat_ids = array(); foreach ( $categories as $category ) { - if ( $id = category_exists( $category ) ) { + $id = category_exists( $category ); + if ( $id ) { $cat_ids[] = $id; - } elseif ( $id = wp_create_category( $category ) ) { - $cat_ids[] = $id; + } else { + $id = wp_create_category( $category ); + if ( $id ) { + $cat_ids[] = $id; + } } } @@ -124,7 +129,7 @@ ); $catarr = wp_parse_args( $catarr, $cat_defaults ); - if ( trim( $catarr['cat_name'] ) == '' ) { + if ( '' === trim( $catarr['cat_name'] ) ) { if ( ! $wp_error ) { return 0; } else { @@ -187,7 +192,7 @@ return false; } - // First, get all of the original fields + // First, get all of the original fields. $category = get_term( $cat_ID, 'category', ARRAY_A ); _make_cat_compat( $category ); @@ -201,7 +206,7 @@ } // -// Tags +// Tags. // /** @@ -295,12 +300,13 @@ * * @since 2.8.0 * - * @param int|string $tag_name - * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'. + * @param string $tag_name The term name. + * @param string $taxonomy Optional. The taxonomy within which to create the term. Default 'post_tag'. * @return array|WP_Error */ function wp_create_term( $tag_name, $taxonomy = 'post_tag' ) { - if ( $id = term_exists( $tag_name, $taxonomy ) ) { + $id = term_exists( $tag_name, $taxonomy ); + if ( $id ) { return $id; }