From 7d9b54b1313577b6489e0aefc742e0ff75967d53 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 8 Feb 2022 12:24:02 +0000 Subject: [PATCH] Posts, Post Types: Pass the `$update` parameter to `wp_insert_post_data` and `wp_insert_attachment_data` filters. This makes it easier to determine in a callback function whether this is an existing post being updated or not. Follow-up to [8635], [8702], [27130], [27138], [28106], [28788], [47633]. Props nhadsall, mukesh27. Fixes #46228. Built from https://develop.svn.wordpress.org/trunk@52691 git-svn-id: http://core.svn.wordpress.org/trunk@52280 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 12 ++++++++---- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 3d5ba21d95..51752b5070 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -4364,27 +4364,31 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true ) * Filters attachment post data before it is updated in or added to the database. * * @since 3.9.0 - * @since 5.4.1 `$unsanitized_postarr` argument added. + * @since 5.4.1 The `$unsanitized_postarr` parameter was added. + * @since 6.0.0 The `$update` parameter was added. * * @param array $data An array of slashed, sanitized, and processed attachment post data. * @param array $postarr An array of slashed and sanitized attachment post data, but not processed. * @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed attachment post data * as originally passed to wp_insert_post(). + * @param bool $update Whether this is an existing attachment post being updated. */ - $data = apply_filters( 'wp_insert_attachment_data', $data, $postarr, $unsanitized_postarr ); + $data = apply_filters( 'wp_insert_attachment_data', $data, $postarr, $unsanitized_postarr, $update ); } else { /** * Filters slashed post data just before it is inserted into the database. * * @since 2.7.0 - * @since 5.4.1 `$unsanitized_postarr` argument added. + * @since 5.4.1 The `$unsanitized_postarr` parameter was added. + * @since 6.0.0 The `$update` parameter was added. * * @param array $data An array of slashed, sanitized, and processed post data. * @param array $postarr An array of sanitized (and slashed) but otherwise unmodified post data. * @param array $unsanitized_postarr An array of slashed yet *unsanitized* and unprocessed post data as * originally passed to wp_insert_post(). + * @param bool $update Whether this is an existing post being updated. */ - $data = apply_filters( 'wp_insert_post_data', $data, $postarr, $unsanitized_postarr ); + $data = apply_filters( 'wp_insert_post_data', $data, $postarr, $unsanitized_postarr, $update ); } $data = wp_unslash( $data ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 9c3f5d9c77..51a24473c2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-52690'; +$wp_version = '6.0-alpha-52691'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.