Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_print_scripts ›

Seit2.1.0
Veraltetn/v
wp_print_scripts ( $handles = false )
Parameter:
  • (string|bool|array) $handles Optional. Scripts to be printed. Default 'false'.
    Erforderlich: Nein
    Standard: false
Siehe:
  • WP_Scripts::do_items()
Gibt zurück:
  • (array) On success, a processed array of WP_Dependencies items; otherwise, an empty array.
Definiert in:
Codex:

Prints scripts in document head that are in the $handles queue.

Called by admin-header.php and {@see '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 {@see 'wp_print_scripts'} hook to register/enqueue new scripts.



Quellcode

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
		$handles = false;
	}

	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );

	global $wp_scripts;
	if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
		if ( ! $handles ) {
			return array(); // No need to instantiate if nothing is there.
		}
	}

	return wp_scripts()->do_items( $handles );
}