Make WordPress Core

Changeset 57699


Ignore:
Timestamp:
02/23/2024 05:43:42 AM (3 months ago)
Author:
kadamwhite
Message:

Script Loader: Inject wp_remove_surrounding_empty_script_tags function name in returned error string using sprintf.

The name of this function should not be editable by the translator in the internationalized return error string.

Props naoki0h, swissspidy, kirasong.
Fixes #60590.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r57682 r57699  
    33923392        $error_message = __( 'Expected string to start with script tag (without attributes) and end with script tag, with optional whitespace.' );
    33933393        _doing_it_wrong( __FUNCTION__, $error_message, '6.4' );
    3394         return sprintf( 'console.error(%s)', wp_json_encode( __( 'Function wp_remove_surrounding_empty_script_tags() used incorrectly in PHP.' ) . ' ' . $error_message ) );
    3395     }
    3396 }
     3394        return sprintf(
     3395            'console.error(%s)',
     3396            wp_json_encode(
     3397                sprintf(
     3398                    /* translators: %s: wp_remove_surrounding_empty_script_tags() */
     3399                    __( 'Function %s used incorrectly in PHP.' ),
     3400                    'wp_remove_surrounding_empty_script_tags()'
     3401                ) . ' ' . $error_message
     3402            )
     3403        );
     3404    }
     3405}
Note: See TracChangeset for help on using the changeset viewer.