From c4b48b6ef0edd99d8f63e81d4cc940c1dab2ea88 Mon Sep 17 00:00:00 2001 From: Carlos Bravo Date: Thu, 8 Feb 2024 12:08:35 +0100 Subject: [PATCH] Move to 6.5 compat folder --- lib/compat/wordpress-6.4/script-loader.php | 106 --------------------- lib/compat/wordpress-6.5/script-loader.php | 105 ++++++++++++++++++++ 2 files changed, 105 insertions(+), 106 deletions(-) diff --git a/lib/compat/wordpress-6.4/script-loader.php b/lib/compat/wordpress-6.4/script-loader.php index 7cc7bea952a301..373bb9e90f8583 100644 --- a/lib/compat/wordpress-6.4/script-loader.php +++ b/lib/compat/wordpress-6.4/script-loader.php @@ -107,109 +107,3 @@ static function ( $settings ) { return $settings; } ); - - -/** - * Prints inline JavaScript wrapped in ` - * - * In an HTML document this would print "…" to the console, - * but in an XHTML document it would print "…" to the console. - * - * - * - * In an HTML document this would print "An image is in HTML", - * but it's an invalid XHTML document because it interprets the `` - * as an empty tag missing its closing `/`. - * - * @see https://www.w3.org/TR/xhtml1/#h-4.8 - */ - if ( - ! $is_html5 && - ( - ! isset( $attributes['type'] ) || - 'module' === $attributes['type'] || - str_contains( $attributes['type'], 'javascript' ) || - str_contains( $attributes['type'], 'ecmascript' ) || - str_contains( $attributes['type'], 'jscript' ) || - str_contains( $attributes['type'], 'livescript' ) - ) - ) { - /* - * If the string `]]>` exists within the JavaScript it would break - * out of any wrapping CDATA section added here, so to start, it's - * necessary to escape that sequence which requires splitting the - * content into two CDATA sections wherever it's found. - * - * Note: it's only necessary to escape the closing `]]>` because - * an additional `', ']]]]>', $data ); - - // Wrap the entire escaped script inside a CDATA section. - $data = sprintf( "/* */", $data ); - } - - $data = "\n" . trim( $data, "\n\r " ) . "\n"; - - /** - * Filters attributes to be added to a script tag. - * - * @since 5.7.0 - * - * @param array $attributes Key-value pairs representing `\n", wp_sanitize_script_attributes( $attributes ), $data ); -} diff --git a/lib/compat/wordpress-6.5/script-loader.php b/lib/compat/wordpress-6.5/script-loader.php index d6acab264b3a15..a77134d9182f93 100644 --- a/lib/compat/wordpress-6.5/script-loader.php +++ b/lib/compat/wordpress-6.5/script-loader.php @@ -100,3 +100,108 @@ function gutenberg_update_wp_date_settings( $scripts ) { } add_action( 'wp_default_scripts', 'gutenberg_update_wp_date_settings' ); + +/** + * Prints inline JavaScript wrapped in ` + * + * In an HTML document this would print "…" to the console, + * but in an XHTML document it would print "…" to the console. + * + * + * + * In an HTML document this would print "An image is in HTML", + * but it's an invalid XHTML document because it interprets the `` + * as an empty tag missing its closing `/`. + * + * @see https://www.w3.org/TR/xhtml1/#h-4.8 + */ + if ( + ! $is_html5 && + ( + ! isset( $attributes['type'] ) || + 'module' === $attributes['type'] || + str_contains( $attributes['type'], 'javascript' ) || + str_contains( $attributes['type'], 'ecmascript' ) || + str_contains( $attributes['type'], 'jscript' ) || + str_contains( $attributes['type'], 'livescript' ) + ) + ) { + /* + * If the string `]]>` exists within the JavaScript it would break + * out of any wrapping CDATA section added here, so to start, it's + * necessary to escape that sequence which requires splitting the + * content into two CDATA sections wherever it's found. + * + * Note: it's only necessary to escape the closing `]]>` because + * an additional `', ']]]]>', $data ); + + // Wrap the entire escaped script inside a CDATA section. + $data = sprintf( "/* */", $data ); + } + + $data = "\n" . trim( $data, "\n\r " ) . "\n"; + + /** + * Filters attributes to be added to a script tag. + * + * @since 5.7.0 + * + * @param array $attributes Key-value pairs representing `\n", wp_sanitize_script_attributes( $attributes ), $data ); +}