Commit 14379412f0 for wordpress.org
commit 14379412f0449e939743c4efba3dfd1d88fb8f99
Author: adamsilverstein <adamsilverstein@git.wordpress.org>
Date: Mon Nov 16 17:46:09 2026 +0000
Media: Stop enabling client-side uploads on plugin-isolated screens.
Fix an issue where a plugin screen that sends its own `Document-Isolation-Policy` header, such as the Elementor editor, got the client-side upload pipeline in every media frame without asking for it. `wp_is_cross_origin_isolated_request()` treated any queued `Document-Isolation-Policy` header as a sign the screen was set up for the pipeline, so it could not tell core's isolation apart from a plugin's.
The function now returns true only when `wp_send_document_isolation_policy_header()` has sent the header. Media frames on a screen a plugin isolates itself upload through plupload again, as they did in 7.1. To opt a screen into the pipeline, call `wp_send_document_isolation_policy_header()` before `wp_enqueue_media()` runs.
The Gutenberg plugin sends the header itself on the editor screens, so its media modal uses classic uploads until a site updates to a release that includes https://github.com/WordPress/gutenberg/pull/86542. Uploads made in the block editor itself are unaffected.
Follow-up to [64588].
Props andrewserong.
Fixes #66490.
Built from https://develop.svn.wordpress.org/trunk@65532
git-svn-id: http://core.svn.wordpress.org/trunk@64605 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/media.php b/wp-includes/media.php
index 3e84e97f40..b4a862c166 100644
--- a/wp-includes/media.php
+++ b/wp-includes/media.php
@@ -6890,9 +6890,9 @@ function wp_get_media_library_upload_settings(): array {
* browser honors Document-Isolation-Policy: without isolation the page never
* becomes cross-origin isolated, the script would no-op, and the whole
* wp-upload-media dependency chain would be loaded for nothing. The same
- * goes for a screen wp_set_up_cross_origin_isolation() did not isolate,
- * such as the Customizer or the Site Icon picker: the media frame loads
- * there too, but its uploads stay on the classic path.
+ * goes for a screen wp_send_document_isolation_policy_header() did not
+ * isolate, such as the Customizer or the Site Icon picker: the media frame
+ * loads there too, but its uploads stay on the classic path.
*
* The screen script self-guards at runtime too: when the browser turns out
* not to be isolated or lacks client-side media support, it no-ops and the
@@ -6950,7 +6950,8 @@ function _wp_enqueue_media_upload_pipeline_script( string $handle ): void {
* Covers every `wp.media` frame that uploads through `wp.Uploader`: the
* Media Library grid and the media modal the block editor, the site editor
* and the block widgets screen open. wp_enqueue_media() calls this on any
- * screen that was cross-origin isolated, so it rarely needs calling directly.
+ * screen wp_send_document_isolation_policy_header() isolated, so it rarely
+ * needs calling directly.
*
* @since 7.2.0
*/
@@ -6977,6 +6978,9 @@ function wp_enqueue_media_new_upload(): void {
* Forcing `crossorigin="anonymous"` would turn those into CORS requests
* and break any resource served without `Access-Control-Allow-Origin`.
*
+ * Sending the header also opts the screen's media frames into client-side
+ * uploads, so call this before wp_enqueue_media() runs.
+ *
* @since 7.2.0
*
* @global bool $_wp_cross_origin_isolated Whether the Document-Isolation-Policy header was sent.
@@ -7001,14 +7005,15 @@ function wp_send_document_isolation_policy_header(): bool {
/**
* Whether the current request has been set up for cross-origin isolation.
*
- * True once wp_set_up_cross_origin_isolation() has sent the
+ * True once wp_send_document_isolation_policy_header() has sent the
* Document-Isolation-Policy header for the screen being rendered, which is
* what lets scripts that need a cross-origin isolated page, such as the
* client-side media upload integration, decide whether to load at all.
*
- * A plugin can isolate a screen on its own by sending the header directly,
- * as the Gutenberg plugin does on the block editor screens, so a header
- * already queued for the response counts too.
+ * A header a plugin sends itself does not count, since the plugin may
+ * isolate its screen for reasons of its own. To run the client-side
+ * pipeline on a screen core does not isolate, call
+ * wp_send_document_isolation_policy_header() before wp_enqueue_media().
*
* @since 7.2.0
*
@@ -7019,13 +7024,6 @@ function wp_send_document_isolation_policy_header(): bool {
function wp_is_cross_origin_isolated_request(): bool {
global $_wp_cross_origin_isolated;
- if ( true === $_wp_cross_origin_isolated ) {
- return true;
- }
-
- return array_any(
- headers_list(),
- fn( $header ) => 0 === stripos( $header, 'Document-Isolation-Policy:' )
- );
+ return true === $_wp_cross_origin_isolated;
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 21de7fce5e..8c2222f9ac 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta5-65531';
+$wp_version = '7.2-beta5-65532';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.