From be28a3217375a33dddebdf5b64d9b89b3252aa16 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 25 Nov 2026 15:42:44 +0530 Subject: [PATCH 1/5] Tests: Cover `wp_enqueue_editor()` default asset enqueue --- .../phpunit/tests/general/wpEnqueueEditor.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/phpunit/tests/general/wpEnqueueEditor.php diff --git a/tests/phpunit/tests/general/wpEnqueueEditor.php b/tests/phpunit/tests/general/wpEnqueueEditor.php new file mode 100644 index 0000000000000..743b27483b66c --- /dev/null +++ b/tests/phpunit/tests/general/wpEnqueueEditor.php @@ -0,0 +1,32 @@ +assertTrue( wp_script_is( 'editor', 'enqueued' ) ); + $this->assertTrue( wp_style_is( 'editor-buttons', 'enqueued' ) ); + $this->assertSame( + 45, + has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'print_default_editor_scripts' ) ) + ); + $this->assertSame( + 1, + has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'force_uncompressed_tinymce' ) ) + ); + } +} From d14521c4df8555c3c7c4cd43751863ae4d18f458 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Wed, 25 Nov 2026 15:50:59 +0530 Subject: [PATCH 2/5] Apply Feedback changes Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../phpunit/tests/general/wpEnqueueEditor.php | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/tests/general/wpEnqueueEditor.php b/tests/phpunit/tests/general/wpEnqueueEditor.php index 743b27483b66c..af4d2929b8561 100644 --- a/tests/phpunit/tests/general/wpEnqueueEditor.php +++ b/tests/phpunit/tests/general/wpEnqueueEditor.php @@ -16,17 +16,28 @@ class Tests_General_WpEnqueueEditor extends WP_UnitTestCase { * @ticket 66757 */ public function test_wp_enqueue_editor_enqueues_default_assets() { - wp_enqueue_editor(); + $old_wp_scripts = $GLOBALS['wp_scripts'] ?? null; + $old_wp_styles = $GLOBALS['wp_styles'] ?? null; - $this->assertTrue( wp_script_is( 'editor', 'enqueued' ) ); - $this->assertTrue( wp_style_is( 'editor-buttons', 'enqueued' ) ); - $this->assertSame( - 45, - has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'print_default_editor_scripts' ) ) - ); - $this->assertSame( - 1, - has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'force_uncompressed_tinymce' ) ) - ); + try { + $GLOBALS['wp_scripts'] = new WP_Scripts(); + $GLOBALS['wp_styles'] = new WP_Styles(); + + wp_enqueue_editor(); + + $this->assertTrue( wp_script_is( 'editor', 'enqueued' ) ); + $this->assertTrue( wp_style_is( 'editor-buttons', 'enqueued' ) ); + $this->assertSame( + 45, + has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'print_default_editor_scripts' ) ) + ); + $this->assertSame( + 1, + has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'force_uncompressed_tinymce' ) ) + ); + } finally { + $GLOBALS['wp_scripts'] = $old_wp_scripts; + $GLOBALS['wp_styles'] = $old_wp_styles; + } } } From 6f1ead0779ca581547705613faea620f55545af1 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Thu, 26 Nov 2026 10:24:07 +0530 Subject: [PATCH 3/5] Update ticket number in wp_enqueue_editor test --- tests/phpunit/tests/general/wpEnqueueEditor.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/general/wpEnqueueEditor.php b/tests/phpunit/tests/general/wpEnqueueEditor.php index af4d2929b8561..510f86ef5f05f 100644 --- a/tests/phpunit/tests/general/wpEnqueueEditor.php +++ b/tests/phpunit/tests/general/wpEnqueueEditor.php @@ -13,7 +13,7 @@ class Tests_General_WpEnqueueEditor extends WP_UnitTestCase { /** * Tests that wp_enqueue_editor() loads the default editor assets and footer hooks. * - * @ticket 66757 + * @ticket 66822 */ public function test_wp_enqueue_editor_enqueues_default_assets() { $old_wp_scripts = $GLOBALS['wp_scripts'] ?? null; @@ -29,11 +29,13 @@ public function test_wp_enqueue_editor_enqueues_default_assets() { $this->assertTrue( wp_style_is( 'editor-buttons', 'enqueued' ) ); $this->assertSame( 45, - has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'print_default_editor_scripts' ) ) + has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'print_default_editor_scripts' ) ), + 'print_default_editor_scripts should be hooked at priority 45.' ); $this->assertSame( 1, - has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'force_uncompressed_tinymce' ) ) + has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'force_uncompressed_tinymce' ) ), + 'force_uncompressed_tinymce should be hooked at priority 1.' ); } finally { $GLOBALS['wp_scripts'] = $old_wp_scripts; From da7460b74c8a350d2ba3a988c6c6a1e883cd414f Mon Sep 17 00:00:00 2001 From: shail-mehta Date: Thu, 26 Nov 2026 15:00:37 +0000 Subject: [PATCH 4/5] Apply Feedback changes --- .../phpunit/tests/general/wpEnqueueEditor.php | 42 ++++++++++++++++++- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/general/wpEnqueueEditor.php b/tests/phpunit/tests/general/wpEnqueueEditor.php index 510f86ef5f05f..585a784a954cb 100644 --- a/tests/phpunit/tests/general/wpEnqueueEditor.php +++ b/tests/phpunit/tests/general/wpEnqueueEditor.php @@ -25,8 +25,8 @@ public function test_wp_enqueue_editor_enqueues_default_assets() { wp_enqueue_editor(); - $this->assertTrue( wp_script_is( 'editor', 'enqueued' ) ); - $this->assertTrue( wp_style_is( 'editor-buttons', 'enqueued' ) ); + $this->assertTrue( wp_script_is( 'editor', 'enqueued' ), 'The editor script should be enqueued.' ); + $this->assertTrue( wp_style_is( 'editor-buttons', 'enqueued' ), 'The editor-buttons style should be enqueued.' ); $this->assertSame( 45, has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'print_default_editor_scripts' ) ), @@ -42,4 +42,42 @@ public function test_wp_enqueue_editor_enqueues_default_assets() { $GLOBALS['wp_styles'] = $old_wp_styles; } } + + /** + * Tests that wp_enqueue_editor() hooks the footer callbacks to the admin footer in the admin. + * + * @ticket 66822 + */ + public function test_wp_enqueue_editor_uses_admin_footer_hook_in_admin() { + $old_wp_scripts = $GLOBALS['wp_scripts'] ?? null; + $old_wp_styles = $GLOBALS['wp_styles'] ?? null; + + try { + $GLOBALS['wp_scripts'] = new WP_Scripts(); + $GLOBALS['wp_styles'] = new WP_Styles(); + + set_current_screen( 'dashboard' ); + + wp_enqueue_editor(); + + $this->assertSame( + 45, + has_action( 'admin_print_footer_scripts', array( '_WP_Editors', 'print_default_editor_scripts' ) ), + 'The default editor scripts should be printed in the admin footer.' + ); + $this->assertSame( + 1, + has_action( 'admin_print_footer_scripts', array( '_WP_Editors', 'force_uncompressed_tinymce' ) ), + 'TinyMCE should be forced uncompressed in the admin footer.' + ); + $this->assertFalse( + has_action( 'wp_print_footer_scripts', array( '_WP_Editors', 'print_default_editor_scripts' ) ), + 'The front-end footer hook should not be used in the admin.' + ); + } finally { + $GLOBALS['wp_scripts'] = $old_wp_scripts; + $GLOBALS['wp_styles'] = $old_wp_styles; + set_current_screen( 'front' ); + } + } } From 7062c6e18162dce77bc037263f92d0fb9a9cc8d8 Mon Sep 17 00:00:00 2001 From: shail-mehta Date: Thu, 26 Nov 2026 17:04:39 +0000 Subject: [PATCH 5/5] Remove redundant set_current_screen( 'front' ) cleanup call --- tests/phpunit/tests/general/wpEnqueueEditor.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/phpunit/tests/general/wpEnqueueEditor.php b/tests/phpunit/tests/general/wpEnqueueEditor.php index 585a784a954cb..b5d10548c1e1d 100644 --- a/tests/phpunit/tests/general/wpEnqueueEditor.php +++ b/tests/phpunit/tests/general/wpEnqueueEditor.php @@ -77,7 +77,6 @@ public function test_wp_enqueue_editor_uses_admin_footer_hook_in_admin() { } finally { $GLOBALS['wp_scripts'] = $old_wp_scripts; $GLOBALS['wp_styles'] = $old_wp_styles; - set_current_screen( 'front' ); } } }