Emoji: Fix printing the emoji detection script in the admin#11931
Emoji: Fix printing the emoji detection script in the admin#11931westonruter wants to merge 5 commits into
Conversation
…ontexts Covers all four branches of print_emoji_detection_script(): hooking _print_emoji_detection_script onto the correct footer action (wp_print_footer_scripts on the front end, admin_print_footer_scripts in the admin), and printing the script directly when that action has already fired. Each test runs in a separate process since the function guards against repeat output with a static variable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Pull request overview
Fixes a regression where the emoji detection script stopped being printed in wp-admin after being moved to the footer, by ensuring it hooks into the correct footer action for admin vs front end.
Changes:
- Update
print_emoji_detection_script()to useadmin_print_footer_scriptsin admin contexts andwp_print_footer_scriptson the front end, printing immediately if the relevant action already fired. - Add PHPUnit coverage for all four execution branches (admin/front end × action fired/not fired).
- Add parameter/return type declarations (and docblock) to the
get_echo()PHPUnit utility helper.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/wp-includes/formatting.php |
Routes emoji detection script output/hooking to the correct footer action in admin vs front end. |
tests/phpunit/tests/formatting/emoji.php |
Adds tests covering hook-vs-direct-print behavior in both contexts. |
tests/phpunit/includes/utils.php |
Strengthens get_echo() helper typing and documentation used by the new tests (and existing suite). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
sirreal
left a comment
There was a problem hiding this comment.
Good fix, this is testing well.
It also seems to fix https://core.trac.wordpress.org/ticket/65260 in my testing in Firefox.
This is surprising! |
…moji detection script in the admin. This corrects an oversight in an optimization made to `print_emoji_detection_script()` which moved the emoji detection script to the `wp_print_footer_scripts` action. Since this action doesn't fire in the admin, no script was printed. Now in the admin, the script is printed at the `admin_print_footer_scripts` action. Existing sites that wish to omit emoji can continue to do `remove_action( 'admin_print_scripts', 'print_emoji_detection_script' )`. Tests are added covering all four branches of `print_emoji_detection_script()`: hooking the script onto the appropriate footer action, and printing it directly when that action has already fired, in both the admin and the frontend. Missing parameter and return types are added to the `get_echo()` test helper. Developed in #11931. Follow-up to r60902. Props westonruter, jonsurrell. See #64076, #65260. Fixes #65310. git-svn-id: https://develop.svn.wordpress.org/trunk@62410 602fd350-edb4-49c9-b593-d223f7449a82
…moji detection script in the admin. This corrects an oversight in an optimization made to `print_emoji_detection_script()` which moved the emoji detection script to the `wp_print_footer_scripts` action. Since this action doesn't fire in the admin, no script was printed. Now in the admin, the script is printed at the `admin_print_footer_scripts` action. Existing sites that wish to omit emoji can continue to do `remove_action( 'admin_print_scripts', 'print_emoji_detection_script' )`. Tests are added covering all four branches of `print_emoji_detection_script()`: hooking the script onto the appropriate footer action, and printing it directly when that action has already fired, in both the admin and the frontend. Missing parameter and return types are added to the `get_echo()` test helper. Developed in WordPress/wordpress-develop#11931. Follow-up to r60902. Props westonruter, jonsurrell. See #64076, #65260. Fixes #65310. Built from https://develop.svn.wordpress.org/trunk@62410 git-svn-id: http://core.svn.wordpress.org/trunk@61691 1a063a9b-81f0-0310-95a4-ce76da25c4cd


This fixes the emoji detection script not being printed in the admin.
This is a follow-up to a regression introduced in 3cba156 (r60902), which fixed Core-63842 and Core-64076 in the 6.9 release. That change moved the emoji detection script from the document head to the footer, but only accounted for the front end: it hooked
_print_emoji_detection_scriptonto thewp_print_footer_scriptsaction, which never fires in the admin. Theadmin_print_footer_scriptsaction fires there instead, so the script was never printed in the admin.print_emoji_detection_script()now branches onis_admin()and uses the appropriate footer action for each context.Changes
print_emoji_detection_script()to hook_print_emoji_detection_scriptontoadmin_print_footer_scriptsin the admin andwp_print_footer_scriptson the front end, and to print directly when that action has already fired.print_emoji_detection_script()— hooking onto the correct footer action, and printing the script directly when that action has already fired — in both admin and front-end contexts.get_echo()test helper.Trac ticket: https://core.trac.wordpress.org/ticket/65310
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 4.7
Used for: Authoring the PHPUnit tests for
print_emoji_detection_script(). All AI-generated code was reviewed, directed, and edited by me.This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.