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


git-svn-id: https://develop.svn.wordpress.org/trunk@30403 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn 2014-11-20 05:17:42 +00:00
parent 10b611b0c3
commit 642f9cc7e7
1 changed files with 18 additions and 4 deletions

View File

@ -138,10 +138,24 @@ class WP_Scripts extends WP_Dependencies {
if ( ! $src )
return true;
if ( $this->do_concat )
$this->print_html .= "<script type='text/javascript' src='$src'></script>\n";
else
echo "<script type='text/javascript' src='$src'></script>\n";
$tag = "<script type='text/javascript' src='$src'></script>\n";
/**
* Filter the HTML script tag of an enqueued script.
*
* @since 4.1.0
*
* @param string $tag The `<script>` tag for the enqueued script.
* @param string $handle The script's registered handle.
* @param string $src The script's source URL.
*/
$tag = apply_filters( 'script_loader_tag', $tag, $handle, $src );
if ( $this->do_concat ) {
$this->print_html .= $tag;
} else {
echo $tag;
}
return true;
}