wp/wp-includes/functions.wp-scripts.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
   164  * @param string[]         $deps      Optional. An array of registered script handles this script depends on. Default empty array.
   164  * @param string[]         $deps      Optional. An array of registered script handles this script depends on. Default empty array.
   165  * @param string|bool|null $ver       Optional. String specifying script version number, if it has one, which is added to the URL
   165  * @param string|bool|null $ver       Optional. String specifying script version number, if it has one, which is added to the URL
   166  *                                    as a query string for cache busting purposes. If version is set to false, a version
   166  *                                    as a query string for cache busting purposes. If version is set to false, a version
   167  *                                    number is automatically added equal to current installed WordPress version.
   167  *                                    number is automatically added equal to current installed WordPress version.
   168  *                                    If set to null, no version is added.
   168  *                                    If set to null, no version is added.
   169  * @param bool             $in_footer Optional. Whether to enqueue the script before </body> instead of in the <head>.
   169  * @param bool             $in_footer Optional. Whether to enqueue the script before `</body>` instead of in the `<head>`.
   170  *                                    Default 'false'.
   170  *                                    Default 'false'.
   171  * @return bool Whether the script has been registered. True on success, false on failure.
   171  * @return bool Whether the script has been registered. True on success, false on failure.
   172  */
   172  */
   173 function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
   173 function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
   174 	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
   174 	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
   184 }
   184 }
   185 
   185 
   186 /**
   186 /**
   187  * Localize a script.
   187  * Localize a script.
   188  *
   188  *
   189  * Works only if the script has already been added.
   189  * Works only if the script has already been registered.
   190  *
   190  *
   191  * Accepts an associative array $l10n and creates a JavaScript object:
   191  * Accepts an associative array $l10n and creates a JavaScript object:
   192  *
   192  *
   193  *     "$object_name" = {
   193  *     "$object_name" = {
   194  *         key: value,
   194  *         key: value,
   222 }
   222 }
   223 
   223 
   224 /**
   224 /**
   225  * Sets translated strings for a script.
   225  * Sets translated strings for a script.
   226  *
   226  *
   227  * Works only if the script has already been added.
   227  * Works only if the script has already been registered.
   228  *
   228  *
   229  * @see WP_Scripts::set_translations()
   229  * @see WP_Scripts::set_translations()
   230  * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
   230  * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
   231  *
   231  *
   232  * @since 5.0.0
   232  * @since 5.0.0
   256  *
   256  *
   257  * @see WP_Dependencies::remove()
   257  * @see WP_Dependencies::remove()
   258  *
   258  *
   259  * @since 2.1.0
   259  * @since 2.1.0
   260  *
   260  *
   261  * @global string $pagenow
   261  * @global string $pagenow The filename of the current screen.
   262  *
   262  *
   263  * @param string $handle Name of the script to be removed.
   263  * @param string $handle Name of the script to be removed.
   264  */
   264  */
   265 function wp_deregister_script( $handle ) {
   265 function wp_deregister_script( $handle ) {
   266 	global $pagenow;
   266 	global $pagenow;
   338  * @param string[]         $deps      Optional. An array of registered script handles this script depends on. Default empty array.
   338  * @param string[]         $deps      Optional. An array of registered script handles this script depends on. Default empty array.
   339  * @param string|bool|null $ver       Optional. String specifying script version number, if it has one, which is added to the URL
   339  * @param string|bool|null $ver       Optional. String specifying script version number, if it has one, which is added to the URL
   340  *                                    as a query string for cache busting purposes. If version is set to false, a version
   340  *                                    as a query string for cache busting purposes. If version is set to false, a version
   341  *                                    number is automatically added equal to current installed WordPress version.
   341  *                                    number is automatically added equal to current installed WordPress version.
   342  *                                    If set to null, no version is added.
   342  *                                    If set to null, no version is added.
   343  * @param bool             $in_footer Optional. Whether to enqueue the script before </body> instead of in the <head>.
   343  * @param bool             $in_footer Optional. Whether to enqueue the script before `</body>` instead of in the `<head>`.
   344  *                                    Default 'false'.
   344  *                                    Default 'false'.
   345  */
   345  */
   346 function wp_enqueue_script( $handle, $src = '', $deps = array(), $ver = false, $in_footer = false ) {
   346 function wp_enqueue_script( $handle, $src = '', $deps = array(), $ver = false, $in_footer = false ) {
   347 	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
   347 	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
   348 
   348 
   400 }
   400 }
   401 
   401 
   402 /**
   402 /**
   403  * Add metadata to a script.
   403  * Add metadata to a script.
   404  *
   404  *
   405  * Works only if the script has already been added.
   405  * Works only if the script has already been registered.
   406  *
   406  *
   407  * Possible values for $key and $value:
   407  * Possible values for $key and $value:
   408  * 'conditional' string Comments for IE 6, lte IE 7, etc.
   408  * 'conditional' string Comments for IE 6, lte IE 7, etc.
   409  *
   409  *
   410  * @since 4.2.0
   410  * @since 4.2.0