Emoji: Print the emoji detection script in the admin footer.#11905
Emoji: Print the emoji detection script in the admin footer.#11905sirreal wants to merge 1 commit into
Conversation
|
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. |
Since [60899], the emoji detection script is output as a `<script type="module">`. In the admin it was hooked to `admin_print_scripts`, so the module script tag was emitted inside `<head>` ahead of the script-module import map (which is printed at `admin_print_footer_scripts` priority 9). Per the HTML spec, an import map encountered after a module script becomes inert, so importing modules such as `@wordpress/abilities` or `@wordpress/latex-to-mathml` in the Site Editor failed in spec-strict browsers (e.g. Firefox). Move the hook to `admin_print_footer_scripts`, mirroring the frontend behavior put in place by [60902] for #64076. Update the matching `remove_action()` in `edit-form-blocks.php` so the post editor continues to suppress the emoji detection script. Props westonruter, wildworks. See #65260.
56b5d24 to
345c2fa
Compare
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. |
| } | ||
|
|
||
| add_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | ||
| add_action( 'admin_print_footer_scripts', 'print_emoji_detection_script' ); |
There was a problem hiding this comment.
The only concern I have about this is back-compat for sites which gave sought to disable emoji. Thus change would cause emoji to show up again in the admin for them, no?
Move the emoji detection script to the footer in WP Admin. This ensures it should be printed after an importmap and avoid an issue where Firefox does not process importmaps once a module has been encountered.
This implements a minimal fix suggested by @westonruter.
Since [60899], the emoji detection script is output as a
<script type="module">. In the admin it was hooked toadmin_print_scripts, so the module script tag was emitted inside<head>ahead of the script-module import map (which is printed atadmin_print_footer_scriptspriority 9).Move the hook to
admin_print_footer_scripts, mirroring the frontend behavior put in place by [60902] for #64076. Update the matchingremove_action()inedit-form-blocks.phpso the post editor continues to suppress the emoji detection script.Trac ticket: https://core.trac.wordpress.org/ticket/65260
Testing
This can be tested by following the reproduction steps in the ticket. Firefox should be used.
In the site editor on
trunk, module specifiers cannot be resolved because the importmap is not processed. For exampleawait import('@wordpress/route')will throw an error like:On this branch, the import will work correctly.
Use of AI Tools
AI assistance: Yes
Tool(s): Claude
Model(s): Opus-4.7
Used for: Complete implementation, verification, and testing based on ticket.
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.