mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-14 09:34:41 +00:00
Posts, Post Types: Prevent categories from being overwritten when updating a post using wp_insert_post().
This prevents existing category relationships being overridden with the default category when none is provided in the post data. Props markoheijnen, leewillis77, desrosj Fixes #19954 git-svn-id: https://develop.svn.wordpress.org/trunk@53883 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -4142,6 +4142,8 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
|
||||
if ( ! empty( $postarr['post_category'] ) ) {
|
||||
// Filter out empty terms.
|
||||
$post_category = array_filter( $postarr['post_category'] );
|
||||
} elseif ( $update && ! isset( $postarr['post_category'] ) ) {
|
||||
$post_category = $post_before->post_category;
|
||||
}
|
||||
|
||||
// Make sure we set a valid category.
|
||||
|
||||
Reference in New Issue
Block a user