From b31a5f7569cc96e83cafc428faf4fcd758515457 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 24 Jul 2020 12:19:05 +0000 Subject: [PATCH] Docs: Correct documentation for `wp_insert_term()`. The function is used for adding a new term, not updating an existing one. Props audrasjb, bmartinent. Fixes #50753. Built from https://develop.svn.wordpress.org/trunk@48600 git-svn-id: http://core.svn.wordpress.org/trunk@48362 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 8 ++++++-- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 40cc49d56e..e07e783528 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -2158,7 +2158,7 @@ function wp_get_object_terms( $object_ids, $taxonomies, $args = array() ) { * * @since 2.3.0 * - * @param string $term The term name to add or update. + * @param string $term The term name to add. * @param string $taxonomy The taxonomy to which to add the term. * @param array|string $args { * Optional. Array or string of arguments for inserting a term. @@ -2184,19 +2184,23 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) { * * @since 3.0.0 * - * @param string|WP_Error $term The term name to add or update, or a WP_Error object if there's an error. + * @param string|WP_Error $term The term name to add, or a WP_Error object if there's an error. * @param string $taxonomy Taxonomy slug. */ $term = apply_filters( 'pre_insert_term', $term, $taxonomy ); + if ( is_wp_error( $term ) ) { return $term; } + if ( is_int( $term ) && 0 === $term ) { return new WP_Error( 'invalid_term_id', __( 'Invalid term ID.' ) ); } + if ( '' === trim( $term ) ) { return new WP_Error( 'empty_term_name', __( 'A name is required for this term.' ) ); } + $defaults = array( 'alias_of' => '', 'description' => '', diff --git a/wp-includes/version.php b/wp-includes/version.php index 21c060193c..45a79f799e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-beta3-48599'; +$wp_version = '5.5-beta3-48600'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.