Changeset 53825 for trunk/src/wp-includes/post.php
- Timestamp:
- 08/04/2022 02:07:28 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r53771 r53825 5210 5210 * 5211 5211 * @param int $post_id Optional. The Post ID. Does not default to the ID of the global $post. 5212 * @param string|array $t agsOptional. An array of terms to set for the post, or a string of terms5212 * @param string|array $terms Optional. An array of terms to set for the post, or a string of terms 5213 5213 * separated by commas. Hierarchical taxonomies must always pass IDs rather 5214 5214 * than names so that children with the same names but different parents … … 5219 5219 * @return array|false|WP_Error Array of term taxonomy IDs of affected terms. WP_Error or false on failure. 5220 5220 */ 5221 function wp_set_post_terms( $post_id = 0, $t ags = '', $taxonomy = 'post_tag', $append = false ) {5221 function wp_set_post_terms( $post_id = 0, $terms = '', $taxonomy = 'post_tag', $append = false ) { 5222 5222 $post_id = (int) $post_id; 5223 5223 … … 5226 5226 } 5227 5227 5228 if ( empty( $t ags ) ) {5229 $t ags = array();5230 } 5231 5232 if ( ! is_array( $t ags ) ) {5228 if ( empty( $terms ) ) { 5229 $terms = array(); 5230 } 5231 5232 if ( ! is_array( $terms ) ) { 5233 5233 $comma = _x( ',', 'tag delimiter' ); 5234 5234 if ( ',' !== $comma ) { 5235 $t ags = str_replace( $comma, ',', $tags );5236 } 5237 $t ags = explode( ',', trim( $tags, " \n\t\r\0\x0B," ) );5235 $terms = str_replace( $comma, ',', $terms ); 5236 } 5237 $terms = explode( ',', trim( $terms, " \n\t\r\0\x0B," ) ); 5238 5238 } 5239 5239 … … 5243 5243 */ 5244 5244 if ( is_taxonomy_hierarchical( $taxonomy ) ) { 5245 $t ags = array_unique( array_map( 'intval', $tags ) );5246 } 5247 5248 return wp_set_object_terms( $post_id, $t ags, $taxonomy, $append );5245 $terms = array_unique( array_map( 'intval', $terms ) ); 5246 } 5247 5248 return wp_set_object_terms( $post_id, $terms, $taxonomy, $append ); 5249 5249 } 5250 5250
Note: See TracChangeset
for help on using the changeset viewer.