@@ -2211,10 +2211,8 @@ function _print_scripts() {
22112211 if ( $ concat ) {
22122212 if ( ! empty ( $ wp_scripts ->print_code ) ) {
22132213 echo "\n<script {$ type_attr }> \n" ;
2214- echo "/* <![CDATA[ */ \n" ; // Not needed in HTML 5.
22152214 echo $ wp_scripts ->print_code ;
22162215 echo sprintf ( "\n//# sourceURL=%s \n" , rawurlencode ( 'js-inline-concat- ' . $ concat ) );
2217- echo "/* ]]> */ \n" ;
22182216 echo "</script> \n" ;
22192217 }
22202218
@@ -2962,56 +2960,6 @@ function wp_get_inline_script_tag( $data, $attributes = array() ) {
29622960 );
29632961 }
29642962
2965- /*
2966- * XHTML extracts the contents of the SCRIPT element and then the XML parser
2967- * decodes character references and other syntax elements. This can lead to
2968- * misinterpretation of the script contents or invalid XHTML documents.
2969- *
2970- * Wrapping the contents in a CDATA section instructs the XML parser not to
2971- * transform the contents of the SCRIPT element before passing them to the
2972- * JavaScript engine.
2973- *
2974- * Example:
2975- *
2976- * <script>console.log('…');</script>
2977- *
2978- * In an HTML document this would print "…" to the console,
2979- * but in an XHTML document it would print "…" to the console.
2980- *
2981- * <script>console.log('An image is <img> in HTML');</script>
2982- *
2983- * In an HTML document this would print "An image is <img> in HTML",
2984- * but it's an invalid XHTML document because it interprets the `<img>`
2985- * as an empty tag missing its closing `/`.
2986- *
2987- * @see https://www.w3.org/TR/xhtml1/#h-4.8
2988- */
2989- if (
2990- ! $ is_html5 &&
2991- (
2992- ! isset ( $ attributes ['type ' ] ) ||
2993- 'module ' === $ attributes ['type ' ] ||
2994- str_contains ( $ attributes ['type ' ], 'javascript ' ) ||
2995- str_contains ( $ attributes ['type ' ], 'ecmascript ' ) ||
2996- str_contains ( $ attributes ['type ' ], 'jscript ' ) ||
2997- str_contains ( $ attributes ['type ' ], 'livescript ' )
2998- )
2999- ) {
3000- /*
3001- * If the string `]]>` exists within the JavaScript it would break
3002- * out of any wrapping CDATA section added here, so to start, it's
3003- * necessary to escape that sequence which requires splitting the
3004- * content into two CDATA sections wherever it's found.
3005- *
3006- * Note: it's only necessary to escape the closing `]]>` because
3007- * an additional `<![CDATA[` leaves the contents unchanged.
3008- */
3009- $ data = str_replace ( ']]> ' , ']]]]><![CDATA[> ' , $ data );
3010-
3011- // Wrap the entire escaped script inside a CDATA section.
3012- $ data = sprintf ( "/* <![CDATA[ */ \n%s \n/* ]]> */ " , $ data );
3013- }
3014-
30152963 $ data = "\n" . trim ( $ data , "\n\r " ) . "\n" ;
30162964
30172965 /**
0 commit comments