]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/class.wp-scripts.php
WordPress 4.1.1-scripts
[autoinstalls/wordpress.git] / wp-includes / class.wp-scripts.php
index 89a9ec91d4ee0d13f651b614e46f812f0c88f303..fbb8b2202dcd269fe6588b1f412a928bf6d3d4f4 100644 (file)
@@ -47,13 +47,15 @@ class WP_Scripts extends WP_Dependencies {
        }
 
        /**
-        * Prints scripts
+        * Prints scripts.
         *
         * Prints the scripts passed to it or the print queue. Also prints all necessary dependencies.
         *
-        * @param mixed $handles (optional) Scripts to be printed. (void) prints queue, (string) prints that script, (array of strings) prints those scripts.
-        * @param int $group (optional) If scripts were queued in groups prints this group number.
-        * @return array Scripts that have been printed
+        * @param mixed $handles Optional. Scripts to be printed. (void) prints queue, (string) prints
+        *                       that script, (array of strings) prints those scripts. Default false.
+        * @param int   $group   Optional. If scripts were queued in groups prints this group number.
+        *                       Default false.
+        * @return array Scripts that have been printed.
         */
        public function print_scripts( $handles = false, $group = false ) {
                return $this->do_items( $handles, $group );
@@ -138,10 +140,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;
        }
@@ -167,7 +183,7 @@ class WP_Scripts extends WP_Dependencies {
                        $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
                }
 
-               $script = "var $object_name = " . json_encode($l10n) . ';';
+               $script = "var $object_name = " . wp_json_encode( $l10n ) . ';';
 
                if ( !empty($after) )
                        $script .= "\n$after;";