Make WordPress Core


Ignore:
Timestamp:
09/24/2019 02:55:56 AM (6 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.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.