X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/8f374b7233bc2815ccc387e448d208c5434eb961..53f4633144ed68c8b8fb5861f992b5489894a940:/wp-includes/functions.wp-scripts.php
diff --git a/wp-includes/functions.wp-scripts.php b/wp-includes/functions.wp-scripts.php
index a8dac35c..01ad19b1 100644
--- a/wp-includes/functions.wp-scripts.php
+++ b/wp-includes/functions.wp-scripts.php
@@ -1,95 +1,156 @@
wp_enqueue_scripts',
+ 'admin_enqueue_scripts
',
+ 'login_enqueue_scripts
'
+ ), '3.3' );
+}
+
+/**
+ * Print scripts in document head that are in the $handles queue.
+ *
+ * Called by admin-header.php and wp_head hook. Since it is called by wp_head on every page load,
+ * the function does not instantiate the WP_Scripts object unless script names are explicitly passed.
+ * Makes use of already-instantiated $wp_scripts global if present. Use provided wp_print_scripts
+ * hook to register/enqueue new scripts.
+ *
+ * @see WP_Scripts::do_items()
+ * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
+ *
+ * @since 2.6.0
+ *
+ * @param string|bool|array $handles Optional. Scripts to be printed. Default 'false'.
+ * @return array On success, a processed array of WP_Dependencies items; otherwise, an empty array.
*/
function wp_print_scripts( $handles = false ) {
+ /**
+ * Fires before scripts in the $handles queue are printed.
+ *
+ * @since 2.1.0
+ */
do_action( 'wp_print_scripts' );
- if ( '' === $handles ) // for wp_head
+ if ( '' === $handles ) { // for wp_head
$handles = false;
+ }
- global $wp_scripts;
- if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
- if ( ! did_action( 'init' ) )
- _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
- 'wp_enqueue_scripts
', 'admin_enqueue_scripts
', 'init
' ), '3.3' );
+ _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
- if ( !$handles )
+ global $wp_scripts;
+ if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
+ if ( ! $handles ) {
return array(); // No need to instantiate if nothing is there.
- else
- $wp_scripts = new WP_Scripts();
+ }
}
- return $wp_scripts->do_items( $handles );
+ return wp_scripts()->do_items( $handles );
}
/**
- * Register new Javascript file.
- *
- * @since r16
- * @param string $handle Script name
- * @param string $src Script url
- * @param array $deps (optional) Array of script names on which this script depends
- * @param string|bool $ver (optional) Script version (used for cache busting), set to null to disable
- * @param bool $in_footer (optional) Whether to enqueue the script before or before