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 Built from https://develop.svn.wordpress.org/trunk@53883 git-svn-id: http://core.svn.wordpress.org/trunk@53442 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c1db3198ce
commit
20edeb6e09
|
@ -4142,6 +4142,8 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
|
||||||
if ( ! empty( $postarr['post_category'] ) ) {
|
if ( ! empty( $postarr['post_category'] ) ) {
|
||||||
// Filter out empty terms.
|
// Filter out empty terms.
|
||||||
$post_category = array_filter( $postarr['post_category'] );
|
$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.
|
// Make sure we set a valid category.
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.1-alpha-53882';
|
$wp_version = '6.1-alpha-53883';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue