]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/class.wp-scripts.php
WordPress 3.9.1-scripts
[autoinstalls/wordpress.git] / wp-includes / class.wp-scripts.php
index ff0ca4d5dc52cc164e89fdfb96bd5cda2bf35c6f..1ceb51d8836e5f130d1c1fd3b8d92ff419b76454 100644 (file)
@@ -31,13 +31,18 @@ class WP_Scripts extends WP_Dependencies {
        var $default_dirs;
 
        function __construct() {
-               if ( ! function_exists( 'did_action' ) || did_action( 'init' ) )
-                       $this->init();
-               else
-                       add_action( 'init', array( $this, 'init' ), 0 );
+               $this->init();
+               add_action( 'init', array( $this, 'init' ), 0 );
        }
 
        function init() {
+               /**
+                * Fires when the WP_Scripts instance is initialized.
+                *
+                * @since 2.6.0
+                *
+                * @param WP_Scripts &$this WP_Scripts instance, passed by reference.
+                */
                do_action_ref_array( 'wp_default_scripts', array(&$this) );
        }
 
@@ -99,6 +104,14 @@ class WP_Scripts extends WP_Dependencies {
                $src = $this->registered[$handle]->src;
 
                if ( $this->do_concat ) {
+                       /**
+                        * Filter the script loader source.
+                        *
+                        * @since 2.2.0
+                        *
+                        * @param string $src    Script loader source path.
+                        * @param string $handle Script handle.
+                        */
                        $srce = apply_filters( 'script_loader_src', $src, $handle );
                        if ( $this->in_default_dir($srce) ) {
                                $this->print_code .= $this->print_extra_script( $handle, false );
@@ -112,15 +125,19 @@ class WP_Scripts extends WP_Dependencies {
                }
 
                $this->print_extra_script( $handle );
-               if ( !preg_match('|^https?://|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) {
+               if ( !preg_match('|^(https?:)?//|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) {
                        $src = $this->base_url . $src;
                }
 
                if ( !empty($ver) )
                        $src = add_query_arg('ver', $ver, $src);
 
+               /** This filter is documented in wp-includes/class.wp-scripts.php */
                $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );
 
+               if ( ! $src )
+                       return true;
+
                if ( $this->do_concat )
                        $this->print_html .= "<script type='text/javascript' src='$src'></script>\n";
                else
@@ -135,6 +152,9 @@ class WP_Scripts extends WP_Dependencies {
         * Localizes only if the script has already been added
         */
        function localize( $handle, $object_name, $l10n ) {
+               if ( $handle === 'jquery' )
+                       $handle = 'jquery-core';
+
                if ( is_array($l10n) && isset($l10n['l10n_print_after']) ) { // back compat, preserve the code in 'l10n_print_after' if present
                        $after = $l10n['l10n_print_after'];
                        unset($l10n['l10n_print_after']);
@@ -175,8 +195,16 @@ class WP_Scripts extends WP_Dependencies {
 
        function all_deps( $handles, $recursion = false, $group = false ) {
                $r = parent::all_deps( $handles, $recursion );
-               if ( !$recursion )
+               if ( ! $recursion ) {
+                       /**
+                        * Filter the list of script dependencies left to print.
+                        *
+                        * @since 2.3.0
+                        *
+                        * @param array $to_do An array of script dependencies.
+                        */
                        $this->to_do = apply_filters( 'print_scripts_array', $this->to_do );
+               }
                return $r;
        }