mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-14 01:24:27 +00:00
Posts, Post Types: Discard tags_input parameter in wp_update_post() if it's the same as existing post tags.
This ensures that `wp_update_post()` does not unintentionally modify post tags if the post has several tags with the same name but different slugs. Tags should only be modified if `tags_input` parameter was explicitly provided, and is different from the existing tags. Props kaggdesign, SergeyBiryukov. Fixes #45121. git-svn-id: https://develop.svn.wordpress.org/trunk@47317 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -4217,6 +4217,20 @@ function wp_update_post( $postarr = array(), $wp_error = false ) {
|
||||
return wp_insert_attachment( $postarr, false, 0, $wp_error );
|
||||
}
|
||||
|
||||
// Discard 'tags_input' parameter if it's the same as existing post tags.
|
||||
if ( isset( $postarr['tags_input'] ) && is_object_in_taxonomy( $postarr['post_type'], 'post_tag' ) ) {
|
||||
$tags = get_the_terms( $postarr['ID'], 'post_tag' );
|
||||
$tag_names = array();
|
||||
|
||||
if ( $tags && ! is_wp_error( $tags ) ) {
|
||||
$tag_names = wp_list_pluck( $tags, 'name' );
|
||||
}
|
||||
|
||||
if ( $postarr['tags_input'] === $tag_names ) {
|
||||
unset( $postarr['tags_input'] );
|
||||
}
|
||||
}
|
||||
|
||||
return wp_insert_post( $postarr, $wp_error );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user