Make WordPress Core

Changeset 30403


Ignore:
Timestamp:
11/20/2014 05:17:42 AM (10 years ago)
Author:
johnbillion
Message:

Apply a filter to the <script> tag for enqueued scripts in the same way a filter is applied to the <link> tag for enqueued styles.

Fixes #13592
Props quietnic, MikeHansenMe

File:
1 edited

Legend:

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

    r30055 r30403  
    139139            return true;
    140140
    141         if ( $this->do_concat )
    142             $this->print_html .= "<script type='text/javascript' src='$src'></script>\n";
    143         else
    144             echo "<script type='text/javascript' src='$src'></script>\n";
     141        $tag = "<script type='text/javascript' src='$src'></script>\n";
     142
     143        /**
     144         * Filter the HTML script tag of an enqueued script.
     145         *
     146         * @since 4.1.0
     147         *
     148         * @param string $tag    The `<script>` tag for the enqueued script.
     149         * @param string $handle The script's registered handle.
     150         * @param string $src    The script's source URL.
     151         */
     152        $tag = apply_filters( 'script_loader_tag', $tag, $handle, $src );
     153
     154        if ( $this->do_concat ) {
     155            $this->print_html .= $tag;
     156        } else {
     157            echo $tag;
     158        }
    145159
    146160        return true;
Note: See TracChangeset for help on using the changeset viewer.