Add a return value to `wp_register_script()` and `wp_register_style()` which matches the return value of `WP_Dependencies::add()`.

Props katzwebdesign, pareshradadiya, DrewAPicture.

Fixes #31126

Built from https://develop.svn.wordpress.org/trunk@32483


git-svn-id: http://core.svn.wordpress.org/trunk@32453 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2015-05-10 19:57:25 +00:00
parent 9ecaba2688
commit 987716720f
4 changed files with 10 additions and 4 deletions

View File

@ -213,7 +213,7 @@ class WP_Dependencies {
* @param array $deps Optional. An array of item handle strings on which this item depends.
* @param string $ver Optional. Version (used for cache busting).
* @param mixed $args Optional. Custom property of the item. NOT the class property $args. Examples: $media, $in_footer.
* @return bool True on success, false on failure.
* @return bool Whether the item has been registered. True on success, false on failure.
*/
public function add( $handle, $src, $deps = array(), $ver = false, $args = null ) {
if ( isset($this->registered[$handle]) )

View File

@ -94,6 +94,7 @@ function wp_print_scripts( $handles = false ) {
* @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
*
* @since 2.6.0
* @since 4.3.0 A return value was added.
*
* @param string $handle Name of the script. Should be unique.
* @param string $src Path to the script from the WordPress root directory. Example: '/js/myscript.js'.
@ -105,15 +106,18 @@ function wp_print_scripts( $handles = false ) {
* If set to null, no version is added. Default 'false'. Accepts 'false', 'null', or 'string'.
* @param bool $in_footer Optional. Whether to enqueue the script before </head> or before </body>.
* Default 'false'. Accepts 'false' or 'true'.
* @return bool Whether the script has been registered. True on success, false on failure.
*/
function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
$wp_scripts = wp_scripts();
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
$wp_scripts->add( $handle, $src, $deps, $ver );
$registered = $wp_scripts->add( $handle, $src, $deps, $ver );
if ( $in_footer ) {
$wp_scripts->add_data( $handle, 'group', 1 );
}
return $registered;
}
/**

View File

@ -98,6 +98,7 @@ function wp_add_inline_style( $handle, $data ) {
* @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
*
* @since 2.6.0
* @since 4.3.0 A return value was added.
*
* @param string $handle Name of the stylesheet.
* @param string|bool $src Path to the stylesheet from the WordPress root directory. Example: '/css/mystyle.css'.
@ -107,11 +108,12 @@ function wp_add_inline_style( $handle, $data ) {
* @param string $media Optional. The media for which this stylesheet has been defined.
* Default 'all'. Accepts 'all', 'aural', 'braille', 'handheld', 'projection', 'print',
* 'screen', 'tty', or 'tv'.
* @return bool Whether the style has been registered. True on success, false on failure.
*/
function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
wp_styles()->add( $handle, $src, $deps, $ver, $media );
return wp_styles()->add( $handle, $src, $deps, $ver, $media );
}
/**

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-32482';
$wp_version = '4.3-alpha-32483';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.