diff --git a/inc/site-exporter/class-site-exporter.php b/inc/site-exporter/class-site-exporter.php index ffc50696..cf60e286 100644 --- a/inc/site-exporter/class-site-exporter.php +++ b/inc/site-exporter/class-site-exporter.php @@ -1420,10 +1420,14 @@ public function enqueue_wp_sites_scripts(string $hook): void { * registered on the parent page using event delegation so it is present * before the modal opens. * - * Hook: "wp-ultimo_page_wp-ultimo-sites" (network admin submenu under - * parent slug "wp-ultimo", menu slug "wp-ultimo-sites"). + * The `wp-ultimo` parent is an admin-bar menu rather than a registered + * WordPress admin-menu parent. WordPress therefore emits + * `admin_page_wp-ultimo-sites` for the network Sites page. Keep the + * legacy submenu hook too for installations that register that parent. */ - if ('wp-ultimo_page_wp-ultimo-sites' === $hook) { + $wp_sites_hooks = ['admin_page_wp-ultimo-sites', 'wp-ultimo_page_wp-ultimo-sites']; + + if (in_array($hook, $wp_sites_hooks, true)) { wp_enqueue_media(); wp_add_inline_script( diff --git a/tests/WP_Ultimo/Site_Exporter_Test.php b/tests/WP_Ultimo/Site_Exporter_Test.php index 4f54f911..843c4584 100644 --- a/tests/WP_Ultimo/Site_Exporter_Test.php +++ b/tests/WP_Ultimo/Site_Exporter_Test.php @@ -246,6 +246,24 @@ public function test_wp_sites_row_actions_include_subsite_export_and_promotion() $this->assertArrayHasKey('promote_main_site', $actions, 'Subsites must still offer Promote to Main Site'); } + /** + * Test the Ultimate Multisite Sites page receives the delegated ZIP-upload handler. + */ + public function test_wp_sites_scripts_enqueue_zip_upload_handler_for_actual_admin_hook(): void { + + $this->exporter->enqueue_wp_sites_scripts('admin_page_wp-ultimo-sites'); + + $this->assertTrue( + wp_script_is('media-editor', 'registered'), + 'The media editor script must be available on the Ultimate Multisite Sites page' + ); + + $inline_scripts = wp_scripts()->get_data('media-editor', 'after'); + + $this->assertIsArray($inline_scripts); + $this->assertStringContainsString('#wu-upload-zip-btn', implode("\n", $inline_scripts)); + } + /** * Test that bulk exports include the main site instead of silently skipping it. */