Skip to content

Commit e9fa9a5

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@53825 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 2fc9367 commit e9fa9a5

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/wp-includes/post.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5209,7 +5209,7 @@ function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
52095209
* @see wp_set_object_terms()
52105210
*
52115211
* @param int $post_id Optional. The Post ID. Does not default to the ID of the global $post.
5212-
* @param string|array $tags Optional. An array of terms to set for the post, or a string of terms
5212+
* @param string|array $terms Optional. An array of terms to set for the post, or a string of terms
52135213
* separated by commas. Hierarchical taxonomies must always pass IDs rather
52145214
* than names so that children with the same names but different parents
52155215
* aren't confused. Default empty.
@@ -5218,34 +5218,34 @@ function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
52185218
* replace the terms with the new terms. Default false.
52195219
* @return array|false|WP_Error Array of term taxonomy IDs of affected terms. WP_Error or false on failure.
52205220
*/
5221-
function wp_set_post_terms( $post_id = 0, $tags = '', $taxonomy = 'post_tag', $append = false ) {
5221+
function wp_set_post_terms( $post_id = 0, $terms = '', $taxonomy = 'post_tag', $append = false ) {
52225222
$post_id = (int) $post_id;
52235223

52245224
if ( ! $post_id ) {
52255225
return false;
52265226
}
52275227

5228-
if ( empty( $tags ) ) {
5229-
$tags = array();
5228+
if ( empty( $terms ) ) {
5229+
$terms = array();
52305230
}
52315231

5232-
if ( ! is_array( $tags ) ) {
5232+
if ( ! is_array( $terms ) ) {
52335233
$comma = _x( ',', 'tag delimiter' );
52345234
if ( ',' !== $comma ) {
5235-
$tags = str_replace( $comma, ',', $tags );
5235+
$terms = str_replace( $comma, ',', $terms );
52365236
}
5237-
$tags = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) );
5237+
$terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) );
52385238
}
52395239

52405240
/*
52415241
* Hierarchical taxonomies must always pass IDs rather than names so that
52425242
* children with the same names but different parents aren't confused.
52435243
*/
52445244
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
5245-
$tags = array_unique( array_map( 'intval', $tags ) );
5245+
$terms = array_unique( array_map( 'intval', $terms ) );
52465246
}
52475247

5248-
return wp_set_object_terms( $post_id, $tags, $taxonomy, $append );
5248+
return wp_set_object_terms( $post_id, $terms, $taxonomy, $append );
52495249
}
52505250

52515251
/**

0 commit comments

Comments
 (0)