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.

Built from https://develop.svn.wordpress.org/trunk@57699


git-svn-id: http://core.svn.wordpress.org/trunk@57200 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
K. Adam White 2024-02-23 05:45:12 +00:00
parent 648cab6abe
commit 9a3210759f
2 changed files with 11 additions and 2 deletions

View File

@ -3391,6 +3391,15 @@ function wp_remove_surrounding_empty_script_tags( $contents ) {
} else {
$error_message = __( 'Expected string to start with script tag (without attributes) and end with script tag, with optional whitespace.' );
_doing_it_wrong( __FUNCTION__, $error_message, '6.4' );
return sprintf( 'console.error(%s)', wp_json_encode( __( 'Function wp_remove_surrounding_empty_script_tags() used incorrectly in PHP.' ) . ' ' . $error_message ) );
return sprintf(
'console.error(%s)',
wp_json_encode(
sprintf(
/* translators: %s: wp_remove_surrounding_empty_script_tags() */
__( 'Function %s used incorrectly in PHP.' ),
'wp_remove_surrounding_empty_script_tags()'
) . ' ' . $error_message
)
);
}
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.5-beta2-57698';
$wp_version = '6.5-beta2-57699';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.