Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: removed

Dashboard: Remove redundant workaround for a dashboard loading edge case now fixed in bundled dependencies. No functional change.
61 changes: 0 additions & 61 deletions projects/packages/forms/src/dashboard/class-dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,66 +77,6 @@ public static function load_wp_build() {
);
}

/**
* Fix import map ordering for the wp-build boot script.
*
* In wp-admin, _wp_footer_scripts (classic scripts) and print_import_map
* both hook into admin_print_footer_scripts at priority 10, but
* _wp_footer_scripts is registered first. This causes the inline
* import("@wordpress/boot") to execute before the import map exists.
*
* This fix moves the import() call from the classic inline script to a
* <script type="module"> printed at priority 20 (after the import map).
*
* @todo Remove once @wordpress/build ships with the loader.js fix upstream
* (WordPress/gutenberg#76870) and Jetpack updates the dependency.
*/
public static function fix_boot_import_map_ordering() {
$handle = self::FORMS_WPBUILD_ADMIN_SLUG . '-prerequisites';

add_action(
'admin_enqueue_scripts',
static function () use ( $handle ) {
if ( ! Dashboard::is_jetpack_forms_admin_page() ) {
return;
}

$data = wp_scripts()->get_data( $handle, 'after' );
if ( empty( $data ) ) {
return;
}

// Find and extract the import("@wordpress/boot") inline script.
$boot_script = null;
$remaining = array();
foreach ( $data as $line ) {
if ( strpos( $line, '@wordpress/boot' ) !== false ) {
$boot_script = $line;
} else {
$remaining[] = $line;
}
}

if ( $boot_script === null ) {
return;
}

// Remove from the classic script handle.
wp_scripts()->add_data( $handle, 'after', $remaining );

// Re-emit as a module script after the import map.
add_action(
'admin_print_footer_scripts',
static function () use ( $boot_script ) {
wp_print_inline_script_tag( $boot_script, array( 'type' => 'module' ) );
},
20
);
},
PHP_INT_MAX
);
}

/**
* Script handle for the JS file we enqueue in the Feedback admin page.
*
Expand Down Expand Up @@ -184,7 +124,6 @@ public function init() {

if ( $is_wp_build_enabled ) {
self::load_wp_build();
self::fix_boot_import_map_ordering();
}

add_action( 'admin_enqueue_scripts', array( $this, 'load_admin_scripts' ) );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: removed

AI Launchpad: Remove redundant workaround for a page loading edge case now fixed in bundled dependencies. No functional change.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public static function init() {
}

self::load_wp_build();
self::fix_boot_import_map_ordering();
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_jwt_initial_state' ), 20 );
}

Expand Down Expand Up @@ -185,54 +184,4 @@ public static function enqueue_jwt_initial_state() {
)
);
}

/**
* Fix import map ordering for the wp-build boot script.
*
* In wp-admin both _wp_footer_scripts and print_import_map hook admin_print_footer_scripts at priority 10, but
* _wp_footer_scripts runs first, so the inline import("@wordpress/boot") executes before the import map exists.
* This moves the import() call to a <script type="module"> printed at priority 20, after the import map.
*
* @todo Remove once @wordpress/build ships the loader.js fix upstream
* (WordPress/gutenberg#76870) and Jetpack updates the dependency.
*/
private static function fix_boot_import_map_ordering() {
$handle = self::MENU_SLUG . '-prerequisites';

add_action(
'admin_enqueue_scripts',
static function () use ( $handle ) {
$data = wp_scripts()->get_data( $handle, 'after' );
if ( empty( $data ) ) {
return;
}

$boot_script = null;
$remaining = array();
foreach ( $data as $line ) {
if ( strpos( $line, '@wordpress/boot' ) !== false ) {
$boot_script = $line;
} else {
$remaining[] = $line;
}
}

if ( $boot_script === null ) {
return;
}

wp_scripts()->add_data( $handle, 'after', $remaining );

// Re-emit as a module script after the import map.
add_action(
'admin_print_footer_scripts',
static function () use ( $boot_script ) {
wp_print_inline_script_tag( $boot_script, array( 'type' => 'module' ) );
},
20
);
},
PHP_INT_MAX
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: removed

Remove redundant workaround for a page loading edge case now fixed in bundled dependencies. No functional change.
64 changes: 0 additions & 64 deletions projects/packages/scan/src/class-jetpack-scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
use function remove_action;
use function remove_all_actions;
use function sanitize_text_field;
use function wp_print_inline_script_tag;
use function wp_scripts;
use function wp_unslash;

/**
Expand Down Expand Up @@ -83,7 +81,6 @@ public static function initialize() {
}

self::load_wp_build();
self::fix_boot_import_map_ordering();
self::bridge_wp_build_enqueue();

add_action( 'admin_menu', array( __CLASS__, 'add_wp_admin_submenu' ) );
Expand Down Expand Up @@ -187,67 +184,6 @@ static function ( $hook_suffix ) {
);
}

/**
* Fix import map ordering for the wp-build boot script.
*
* In wp-admin, `_wp_footer_scripts` (classic scripts) and
* `print_import_map` both hook into `admin_print_footer_scripts` at
* priority 10, but `_wp_footer_scripts` is registered first. This
* causes the inline `import("@wordpress/boot")` to execute before
* the import map exists.
*
* This fix moves the import() call from the classic inline script to
* a `<script type="module">` printed at priority 20 (after the import
* map).
*
* @todo Remove once @wordpress/build ships with the loader.js fix
* upstream (WordPress/gutenberg#76870) and Jetpack updates the
* dependency.
*/
public static function fix_boot_import_map_ordering() {
$handle = self::WP_BUILD_SLUG . '-prerequisites';

add_action(
'admin_enqueue_scripts',
static function () use ( $handle ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( ! isset( $_GET['page'] ) || self::PAGE_SLUG !== $_GET['page'] ) {
return;
}

$data = wp_scripts()->get_data( $handle, 'after' );
if ( empty( $data ) ) {
return;
}

$boot_script = null;
$remaining = array();
foreach ( $data as $line ) {
if ( strpos( $line, '@wordpress/boot' ) !== false ) {
$boot_script = $line;
} else {
$remaining[] = $line;
}
}

if ( null === $boot_script ) {
return;
}

wp_scripts()->add_data( $handle, 'after', $remaining );

add_action(
'admin_print_footer_scripts',
static function () use ( $boot_script ) {
wp_print_inline_script_tag( $boot_script, array( 'type' => 'module' ) );
},
20
);
},
PHP_INT_MAX
);
}

/**
* Register the Scan submenu under Jetpack.
*
Expand Down
Loading