Commit 7a46363e33 for wordpress.org
commit 7a46363e3334a4611351f5e5236b91ce60f8289f
Author: jonsurrell <jonsurrell@git.wordpress.org>
Date: Fri Jan 23 17:03:36 2026 +0000
Script Loader: Deprecate `wp_sanitize_script_attributes()`.
The function is no longer used by WordPress and better alternatives are available: `wp_get_script_tag()` and `wp_get_inline_script_tag()`.
Developed in https://github.com/WordPress/wordpress-develop/pull/10742.
Follow-up to [61415], [61485].
Props jonsurrell, westonruter.
Fixes #64511. See #64442.
Built from https://develop.svn.wordpress.org/trunk@61518
git-svn-id: http://core.svn.wordpress.org/trunk@60829 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php
index 19ccaf7e6d..360acf5d46 100644
--- a/wp-includes/deprecated.php
+++ b/wp-includes/deprecated.php
@@ -6479,3 +6479,33 @@ function wp_print_auto_sizes_contain_css_fix() {
<style>img:is([sizes="auto" i], [sizes^="auto," i]) { contain-intrinsic-size: 3000px 1500px }</style>
<?php
}
+
+/**
+ * Sanitizes an attributes array into an attributes string to be placed inside a `<script>` tag.
+ *
+ * This function is deprecated, use {@see wp_get_script_tag()} or {@see wp_get_inline_script_tag()} instead.
+ *
+ * @since 5.7.0
+ * @deprecated 7.0.0 Use wp_get_script_tag() or wp_get_inline_script_tag().
+ * @see wp_get_script_tag()
+ * @see wp_get_inline_script_tag()
+ *
+ * @param array<string, string|bool> $attributes Key-value pairs representing `<script>` tag attributes.
+ * @return string String made of sanitized `<script>` tag attributes.
+ */
+function wp_sanitize_script_attributes( $attributes ) {
+ _deprecated_function( __FUNCTION__, '7.0.0', 'wp_get_script_tag() or wp_get_inline_script_tag()' );
+
+ $attributes_string = '';
+ foreach ( $attributes as $attribute_name => $attribute_value ) {
+ if ( is_bool( $attribute_value ) ) {
+ if ( $attribute_value ) {
+ $attributes_string .= ' ' . esc_attr( $attribute_name );
+ }
+ } else {
+ $attributes_string .= sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) );
+ }
+ }
+ return $attributes_string;
+}
+
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index b26533421f..ab980b35e4 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -2882,37 +2882,6 @@ function wp_enqueue_editor_format_library_assets() {
wp_enqueue_style( 'wp-format-library' );
}
-/**
- * Sanitizes an attributes array into an attributes string to be placed inside a `<script>` tag.
- *
- * Automatically injects type attribute if needed.
- * Used by {@see wp_get_script_tag()} and {@see wp_get_inline_script_tag()}.
- *
- * @since 5.7.0
- *
- * @param array<string, string|bool> $attributes Key-value pairs representing `<script>` tag attributes.
- * @return string String made of sanitized `<script>` tag attributes.
- */
-function wp_sanitize_script_attributes( $attributes ) {
- $attributes_string = '';
-
- /*
- * If HTML5 script tag is supported, only the attribute name is added
- * to $attributes_string for entries with a boolean value, and that are true.
- */
- foreach ( $attributes as $attribute_name => $attribute_value ) {
- if ( is_bool( $attribute_value ) ) {
- if ( $attribute_value ) {
- $attributes_string .= ' ' . esc_attr( $attribute_name );
- }
- } else {
- $attributes_string .= sprintf( ' %1$s="%2$s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) );
- }
- }
-
- return $attributes_string;
-}
-
/**
* Formats `<script>` loader tags.
*
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 59a4c02711..a22184b0eb 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61517';
+$wp_version = '7.0-alpha-61518';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.