Make WordPress Core


Ignore:
Timestamp:
06/25/2026 10:26:14 AM (2 months ago)
Author:
cbravobernal
Message:

Emoji: Use the admin_print_footer_scripts action for printing the emoji 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 https://github.com/WordPress/wordpress-develop/pull/11931.
Follow-up to r60902.

Reviewed by jonsurrell.
Merges [62410] to the 7.0 branch.

Props westonruter, jonsurrell.
See #64076, #65260.
Fixes #65310.

Location:
branches/7.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/7.0

  • branches/7.0/src/wp-includes/formatting.php

    r61855 r62560  
    58995899 * @since 4.2.0
    59005900 */
    5901 function print_emoji_detection_script() {
     5901function print_emoji_detection_script(): void {
    59025902        static $printed = false;
    59035903
     
    59085908        $printed = true;
    59095909
    5910         if ( did_action( 'wp_print_footer_scripts' ) ) {
    5911                 _print_emoji_detection_script();
     5910        if ( is_admin() ) {
     5911                if ( did_action( 'admin_print_footer_scripts' ) ) {
     5912                        _print_emoji_detection_script();
     5913                } else {
     5914                        add_action( 'admin_print_footer_scripts', '_print_emoji_detection_script' );
     5915                }
    59125916        } else {
    5913                 add_action( 'wp_print_footer_scripts', '_print_emoji_detection_script' );
     5917                if ( did_action( 'wp_print_footer_scripts' ) ) {
     5918                        _print_emoji_detection_script();
     5919                } else {
     5920                        add_action( 'wp_print_footer_scripts', '_print_emoji_detection_script' );
     5921                }
    59145922        }
    59155923}
Note: See TracChangeset for help on using the changeset viewer.