Allow passing an empty tag set to wp_set_post_tags() so all tags can be removed from a post. see #3723
git-svn-id: https://develop.svn.wordpress.org/trunk@5243 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
0fced13a94
commit
73feece365
|
@ -800,6 +800,8 @@ function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
|
||||||
// prevent warnings for unintialized variables
|
// prevent warnings for unintialized variables
|
||||||
$tag_ids = array();
|
$tag_ids = array();
|
||||||
|
|
||||||
|
if ( empty($tags) )
|
||||||
|
$tags = array();
|
||||||
$tags = (is_array($tags)) ? $tags : explode( ',', $tags );
|
$tags = (is_array($tags)) ? $tags : explode( ',', $tags );
|
||||||
|
|
||||||
foreach ( $tags as $tag ) {
|
foreach ( $tags as $tag ) {
|
||||||
|
@ -811,7 +813,7 @@ function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) {
|
||||||
$tag_ids[] = $tag_id;
|
$tag_ids[] = $tag_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( empty($tag_ids) )
|
if ( empty($tag_ids) && ( !empty($tags) || $append ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$tag_ids = array_unique( $tag_ids );
|
$tag_ids = array_unique( $tag_ids );
|
||||||
|
|
Loading…
Reference in New Issue