Make WordPress Core

Changeset 46287


Ignore:
Timestamp:
09/24/2019 02:55:56 AM (5 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class.wp-scripts.php

    r46171 r46287  
    150150     */
    151151    public function init() {
    152         if ( ! is_admin() && ! current_theme_supports( 'html5', 'script' ) ) {
     152        if (
     153            function_exists( 'is_admin' ) && ! is_admin()
     154        &&
     155            function_exists( 'current_theme_supports' ) && ! current_theme_supports( 'html5', 'script' )
     156        ) {
    153157            $this->type_attr = " type='text/javascript'";
    154158        }
     
    221225        }
    222226
    223         echo "<script{$this->type_attr}>\n"; // CDATA and type="text/javascript" is not needed for HTML 5.
    224         echo "/* <![CDATA[ */\n";
     227        echo "<script{$this->type_attr}>\n";
     228
     229        // CDATA is not needed for HTML 5.
     230        if ( $this->type_attr ) {
     231            echo "/* <![CDATA[ */\n";
     232        }
     233
    225234        echo "$output\n";
    226         echo "/* ]]> */\n";
     235
     236        if ( $this->type_attr ) {
     237            echo "/* ]]> */\n";
     238        }
     239
    227240        echo "</script>\n";
    228241
  • trunk/src/wp-includes/class.wp-styles.php

    r46171 r46287  
    118118     */
    119119    public function __construct() {
    120         if ( ! is_admin() && ! current_theme_supports( 'html5', 'style' ) ) {
     120        if (
     121            function_exists( 'is_admin' ) && ! is_admin()
     122        &&
     123            function_exists( 'current_theme_supports' ) && ! current_theme_supports( 'html5', 'style' )
     124        ) {
    121125            $this->type_attr = " type='text/css'";
    122126        }
Note: See TracChangeset for help on using the changeset viewer.