Outil de recherche WordPress pour les développeurs et auteurs de thèmes



wp_register_script ›

Depuis2.1.0
Dépréciéen/a
wp_register_script ( $handle, $src, $deps = array(), $ver = false, $in_footer = false )
Paramètres: (5)
  • (string) $handle Name of the script. Should be unique.
    Requis: Oui
  • (string|bool) $src Full URL of the script, or path of the script relative to the WordPress root directory. If source is set to false, script is an alias of other scripts it depends on.
    Requis: Oui
  • (array) $deps Optional. An array of registered script handles this script depends on. Default empty array.
    Requis: Non
    Défaut: array()
  • (string|bool|null) $ver Optional. String specifying script version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added.
    Requis: Non
    Défaut: false
  • (bool) $in_footer Optional. Whether to enqueue the script before </body> instead of in the <head>. Default 'false'.
    Requis: Non
    Défaut: false
Voir:
  • WP_Dependencies::add()
  • WP_Dependencies::add_data()
Retourne:
  • (bool) Whether the script has been registered. True on success, false on failure.
Défini(e) dans:
Codex:
Changelog:
  • 4.3.0

Register a new script.

Registers a script to be enqueued later using the wp_enqueue_script() function.



Source

function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
	$wp_scripts = wp_scripts();
	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );

	$registered = $wp_scripts->add( $handle, $src, $deps, $ver );
	if ( $in_footer ) {
		$wp_scripts->add_data( $handle, 'group', 1 );
	}

	return $registered;
}