Script Loader: Add `function_exists()` checks for `is_admin()` and `current_theme_supports()`, to accomodate for using `WP_Dependencies` as a standalone class.
Remove `<![CDATA[` when outputting HTML5 script tags. Props azaozz. Fixes #42804. Built from https://develop.svn.wordpress.org/trunk@46287 git-svn-id: http://core.svn.wordpress.org/trunk@46099 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c00074e6aa
commit
b35c5b9746
|
@ -149,7 +149,11 @@ class WP_Scripts extends WP_Dependencies {
|
||||||
* @since 3.4.0
|
* @since 3.4.0
|
||||||
*/
|
*/
|
||||||
public function init() {
|
public function init() {
|
||||||
if ( ! is_admin() && ! current_theme_supports( 'html5', 'script' ) ) {
|
if (
|
||||||
|
function_exists( 'is_admin' ) && ! is_admin()
|
||||||
|
&&
|
||||||
|
function_exists( 'current_theme_supports' ) && ! current_theme_supports( 'html5', 'script' )
|
||||||
|
) {
|
||||||
$this->type_attr = " type='text/javascript'";
|
$this->type_attr = " type='text/javascript'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,10 +224,19 @@ class WP_Scripts extends WP_Dependencies {
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<script{$this->type_attr}>\n"; // CDATA and type="text/javascript" is not needed for HTML 5.
|
echo "<script{$this->type_attr}>\n";
|
||||||
echo "/* <![CDATA[ */\n";
|
|
||||||
|
// CDATA is not needed for HTML 5.
|
||||||
|
if ( $this->type_attr ) {
|
||||||
|
echo "/* <![CDATA[ */\n";
|
||||||
|
}
|
||||||
|
|
||||||
echo "$output\n";
|
echo "$output\n";
|
||||||
echo "/* ]]> */\n";
|
|
||||||
|
if ( $this->type_attr ) {
|
||||||
|
echo "/* ]]> */\n";
|
||||||
|
}
|
||||||
|
|
||||||
echo "</script>\n";
|
echo "</script>\n";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -117,7 +117,11 @@ class WP_Styles extends WP_Dependencies {
|
||||||
* @since 2.6.0
|
* @since 2.6.0
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
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'";
|
$this->type_attr = " type='text/css'";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.3-beta1-46286';
|
$wp_version = '5.3-beta1-46287';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue