$terms =
explode( ',',
trim( $terms, " \n\t\r\0\x0B,"
) );
} /*
* Hierarchical taxonomies must always pass IDs rather than names so that
* children with the same names but different parents aren't confused.
*/
if ( is_taxonomy_hierarchical( $taxonomy ) ) { $terms =
array_unique( array_map( 'intval',
$terms ) );
} return wp_set_object_terms( $post_id,
$terms,
$taxonomy,
$append );
}/**
* Sets categories for a post.
*
* If no categories are provided, the default category is used.
*
* @since 2.1.0
*
* @param int $post_id Optional. The Post ID. Does not default to the ID
* of the global $post. Default 0.
* @param int[]|int $post_categories Optional. List of category IDs, or the ID of a single category.
* Default empty array.
* @param bool $append If true, don't delete existing categories, just add on.
* If false, replace the categories with the new categories.
* @return array|false|WP_Error Array of term taxonomy IDs of affected categories. WP_Error or false on failure.
*/