+ * Initialize $wp_scripts if it has not been set.
+ *
+ * @global WP_Scripts $wp_scripts
+ *
+ * @since 4.2.0
+ *
+ * @return WP_Scripts WP_Scripts instance.
+ */
+function wp_scripts() {
+ global $wp_scripts;
+ if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
+ $wp_scripts = new WP_Scripts();
+ }
+ return $wp_scripts;
+}
+
+/**
+ * Helper function to output a _doing_it_wrong message when applicable.
+ *
+ * @ignore
+ * @since 4.2.0
+ *
+ * @param string $function Function name.
+ */
+function _wp_scripts_maybe_doing_it_wrong( $function ) {
+ if ( did_action( 'init' ) ) {
+ return;
+ }
+
+ _doing_it_wrong( $function, sprintf(
+ __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
+ '<code>wp_enqueue_scripts</code>',
+ '<code>admin_enqueue_scripts</code>',
+ '<code>login_enqueue_scripts</code>'
+ ), '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.