From f8688bb43b8e9a9478de356c086dfdab11bd1f77 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 24 Sep 2019 02:55:56 +0000 Subject: [PATCH] Script Loader: Add `function_exists()` checks for `is_admin()` and `current_theme_supports()`, to accomodate for using `WP_Dependencies` as a standalone class. Remove `type_attr = " type='text/javascript'"; } @@ -220,10 +224,19 @@ class WP_Scripts extends WP_Dependencies { return $output; } - echo "type_attr}>\n"; // CDATA and type="text/javascript" is not needed for HTML 5. - echo "/* type_attr}>\n"; + + // CDATA is not needed for HTML 5. + if ( $this->type_attr ) { + echo "/* */\n"; + + if ( $this->type_attr ) { + echo "/* ]]> */\n"; + } + echo "\n"; return true; diff --git a/src/wp-includes/class.wp-styles.php b/src/wp-includes/class.wp-styles.php index 4c1d4f53a1..17bfef8b2e 100644 --- a/src/wp-includes/class.wp-styles.php +++ b/src/wp-includes/class.wp-styles.php @@ -117,7 +117,11 @@ class WP_Styles extends WP_Dependencies { * @since 2.6.0 */ public function __construct() { - if ( ! is_admin() && ! current_theme_supports( 'html5', 'style' ) ) { + if ( + function_exists( 'is_admin' ) && ! is_admin() + && + function_exists( 'current_theme_supports' ) && ! current_theme_supports( 'html5', 'style' ) + ) { $this->type_attr = " type='text/css'"; }