From 0d62f02303b10e163b53f240c9fb3a322741ad42 Mon Sep 17 00:00:00 2001 From: desrosj Date: Thu, 4 Aug 2022 14:09:23 +0000 Subject: [PATCH] Posts, Post Types: Change variable name in `wp_set_post_terms()` for clarity. This changes the `$tags` variable used within `wp_set_post_terms()` to `$terms`. While the default for the `$taxonomy` argument is `post_tag`, the function can be used to assign terms to a post for any taxonomy. When a different taxonomy is passed, `$tags` is an inaccurate name and could be confusing. Props hilayt24, costdev, SergeyBiryukov, krishaweb, desrosj. Fixes #56331. Built from https://develop.svn.wordpress.org/trunk@53825 git-svn-id: http://core.svn.wordpress.org/trunk@53384 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 18 +++++++++--------- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index df509fd114..d8f21403ca 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -5209,7 +5209,7 @@ function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) { * @see wp_set_object_terms() * * @param int $post_id Optional. The Post ID. Does not default to the ID of the global $post. - * @param string|array $tags Optional. An array of terms to set for the post, or a string of terms + * @param string|array $terms Optional. An array of terms to set for the post, or a string of terms * separated by commas. Hierarchical taxonomies must always pass IDs rather * than names so that children with the same names but different parents * aren't confused. Default empty. @@ -5218,23 +5218,23 @@ function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) { * replace the terms with the new terms. Default false. * @return array|false|WP_Error Array of term taxonomy IDs of affected terms. WP_Error or false on failure. */ -function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false ) { +function wp_set_post_terms( $post_id = 0, $terms = '', $taxonomy = 'post_tag', $append = false ) { $post_id = (int) $post_id; if ( ! $post_id ) { return false; } - if ( empty( $tags ) ) { - $tags = array(); + if ( empty( $terms ) ) { + $terms = array(); } - if ( ! is_array( $tags ) ) { + if ( ! is_array( $terms ) ) { $comma = _x( ',', 'tag delimiter' ); if ( ',' !== $comma ) { - $tags = str_replace( $comma, ',', $tags ); + $terms = str_replace( $comma, ',', $terms ); } - $tags = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) ); + $terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); } /* @@ -5242,10 +5242,10 @@ function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $a * children with the same names but different parents aren't confused. */ if ( is_taxonomy_hierarchical( $taxonomy ) ) { - $tags = array_unique( array_map( 'intval', $tags ) ); + $terms = array_unique( array_map( 'intval', $terms ) ); } - return wp_set_object_terms( $post_id, $tags, $taxonomy, $append ); + return wp_set_object_terms( $post_id, $terms, $taxonomy, $append ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index d10ea9d50c..8ad74a6e3c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53824'; +$wp_version = '6.1-alpha-53825'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.