Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/wp-admin/edit-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static function ( $classes ) {
/*
* Emoji replacement is disabled for now, until it plays nicely with React.
*/
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_footer_scripts', 'print_emoji_detection_script' );

/*
* Block editor implements its own Options menu for toggling Document Panels.
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/admin-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
add_action( 'admin_print_styles', 'wp_resource_hints', 1 );
}

add_action( 'admin_print_scripts', 'print_emoji_detection_script' );
add_action( 'admin_print_footer_scripts', 'print_emoji_detection_script' );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

add_action( 'admin_print_scripts', 'print_head_scripts', 20 );
add_action( 'admin_print_footer_scripts', '_wp_footer_scripts' );
add_action( 'admin_enqueue_scripts', 'wp_enqueue_emoji_styles' );
Expand Down
24 changes: 24 additions & 0 deletions tests/phpunit/tests/formatting/emoji.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,28 @@ public function data_wp_staticize_emoji() {
public function test_wp_staticize_emoji( $emoji, $expected ) {
$this->assertSame( $expected, wp_staticize_emoji( $emoji ) );
}

/**
* The emoji detection script outputs a `<script type="module">`. In the admin it must
* be printed in the footer (after the script-module import map) rather than the head,
* otherwise the import map is encountered after a module script and is treated as
* inert by browsers that follow the spec strictly (e.g. Firefox).
*
* @ticket 65260
*
* @covers ::print_emoji_detection_script
*/
public function test_print_emoji_detection_script_is_hooked_to_admin_footer() {
require_once ABSPATH . 'wp-admin/includes/admin-filters.php';

$this->assertFalse(
has_action( 'admin_print_scripts', 'print_emoji_detection_script' ),
'print_emoji_detection_script must not run on admin_print_scripts; the resulting <script type="module"> would precede the import map.'
);
$this->assertSame(
10,
has_action( 'admin_print_footer_scripts', 'print_emoji_detection_script' ),
'print_emoji_detection_script must run on admin_print_footer_scripts, after the import map.'
);
}
}
Loading