wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_set_up_cross_origin_isolation › WordPress Function

Since7.1.0
Deprecatedn/a
wp_set_up_cross_origin_isolation ( No parameters )
Defined at:
Codex:

Enables cross-origin isolation in the block editor.

Required for enabling SharedArrayBuffer for WebAssembly-based media processing in the editor. Uses Document-Isolation-Policy on supported browsers (Chromium 137+). Skips setup when a third-party page builder overrides the block editor via a custom action query parameter, as DIP would block same-origin iframe access that these editors rely on.


Source

function wp_set_up_cross_origin_isolation(): void {
	if ( ! wp_is_client_side_media_processing_enabled() ) {
		return;
	}

	$screen = get_current_screen();

	if ( ! $screen ) {
		return;
	}

	if ( ! $screen->is_block_editor() && 'site-editor' !== $screen->id && ! ( 'widgets' === $screen->id && wp_use_widgets_block_editor() ) ) {
		return;
	}

	/*
	 * Skip when a third-party page builder overrides the block editor.
	 * DIP isolates the document into its own agent cluster,
	 * which blocks same-origin iframe access that these editors rely on.
	 */
	if ( isset( $_GET['action'] ) && 'edit' !== $_GET['action'] ) {
		return;
	}

	// Cross-origin isolation is not needed if users can't upload files anyway.
	if ( ! current_user_can( 'upload_files' ) ) {
		return;
	}

	wp_start_cross_origin_isolation_output_buffer();
}