From 163f5e566fc55412d4fe70c56ebc123b9191efbb Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 13 Oct 2023 12:20:20 +0000 Subject: [PATCH] Media: Consistently call the `wp_create_file_in_uploads` hook as a filter. The filter was initially introduced for file replication purposes. Since the returned value is not always used directly, some instances were later converted to an action as part of removing unused variables, and the hook was documented as an action while still being called as a filter in other instances. This commit aims to correct the discrepancy between the code and the documentation. Follow-up to [4673], [4817], [4818], [6363], [6551], [13041], [25821], [33154], [33280]. Props Howdy_McGee, nicolefurlan, johnbillion, mhshujon, SergeyBiryukov. Fixes #57775. Built from https://develop.svn.wordpress.org/trunk@56929 git-svn-id: http://core.svn.wordpress.org/trunk@56440 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-custom-background.php | 5 +++-- wp-admin/includes/class-custom-image-header.php | 6 ++++-- wp-includes/version.php | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/class-custom-background.php b/wp-admin/includes/class-custom-background.php index b818016b28..2eb3ccfd64 100644 --- a/wp-admin/includes/class-custom-background.php +++ b/wp-admin/includes/class-custom-background.php @@ -571,8 +571,9 @@ class Custom_Background { $thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' ); set_theme_mod( 'background_image_thumb', sanitize_url( $thumbnail[0] ) ); - /** This action is documented in wp-admin/includes/class-custom-image-header.php */ - do_action( 'wp_create_file_in_uploads', $file, $id ); // For replication. + /** This filter is documented in wp-admin/includes/class-custom-image-header.php */ + $file = apply_filters( 'wp_create_file_in_uploads', $file, $id ); // For replication. + $this->updated = true; } diff --git a/wp-admin/includes/class-custom-image-header.php b/wp-admin/includes/class-custom-image-header.php index 9df725af0c..ee3bcb12ec 100644 --- a/wp-admin/includes/class-custom-image-header.php +++ b/wp-admin/includes/class-custom-image-header.php @@ -882,14 +882,16 @@ endif; $this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) ); /** - * Fires after the header image is set or an error is returned. + * Filters the attachment file path after the custom header or background image is set. + * + * Used for file replication. * * @since 2.1.0 * * @param string $file Path to the file. * @param int $attachment_id Attachment ID. */ - do_action( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication. + $file = apply_filters( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication. return $this->finished(); } elseif ( $width > $max_width ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 9fd2298c56..98ce719cc5 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-beta4-56928'; +$wp_version = '6.4-beta4-56929'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.