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
This commit is contained in:
parent
68e50c583c
commit
0d62f02303
|
@ -5209,7 +5209,7 @@ function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
|
||||||
* @see wp_set_object_terms()
|
* @see wp_set_object_terms()
|
||||||
*
|
*
|
||||||
* @param int $post_id Optional. The Post ID. Does not default to the ID of the global $post.
|
* @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
|
* separated by commas. Hierarchical taxonomies must always pass IDs rather
|
||||||
* than names so that children with the same names but different parents
|
* than names so that children with the same names but different parents
|
||||||
* aren't confused. Default empty.
|
* 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.
|
* 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.
|
* @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;
|
$post_id = (int) $post_id;
|
||||||
|
|
||||||
if ( ! $post_id ) {
|
if ( ! $post_id ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty( $tags ) ) {
|
if ( empty( $terms ) ) {
|
||||||
$tags = array();
|
$terms = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! is_array( $tags ) ) {
|
if ( ! is_array( $terms ) ) {
|
||||||
$comma = _x( ',', 'tag delimiter' );
|
$comma = _x( ',', 'tag delimiter' );
|
||||||
if ( ',' !== $comma ) {
|
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.
|
* children with the same names but different parents aren't confused.
|
||||||
*/
|
*/
|
||||||
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
|
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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue