From 987716720f2f9bbd4a2bf718ac3d5df374d7d8d4 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sun, 10 May 2015 19:57:25 +0000 Subject: [PATCH] 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 --- wp-includes/class.wp-dependencies.php | 2 +- wp-includes/functions.wp-scripts.php | 6 +++++- wp-includes/functions.wp-styles.php | 4 +++- wp-includes/version.php | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/wp-includes/class.wp-dependencies.php b/wp-includes/class.wp-dependencies.php index 7995a908c8..239f8f260b 100644 --- a/wp-includes/class.wp-dependencies.php +++ b/wp-includes/class.wp-dependencies.php @@ -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]) ) diff --git a/wp-includes/functions.wp-scripts.php b/wp-includes/functions.wp-scripts.php index c4be60c48a..f5328b09a3 100644 --- a/wp-includes/functions.wp-scripts.php +++ b/wp-includes/functions.wp-scripts.php @@ -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 or before . * 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; } /** diff --git a/wp-includes/functions.wp-styles.php b/wp-includes/functions.wp-styles.php index 76ca28fac0..8e38ce2ba0 100644 --- a/wp-includes/functions.wp-styles.php +++ b/wp-includes/functions.wp-styles.php @@ -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 ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 4e961fbe13..590722aafa 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.