From 7a4f9cc9a66e2ba6453c25e33ce354a5b85fe7c5 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 4 Mar 2020 11:58:31 +0000 Subject: [PATCH] General: Correct the default value of the `$defaults` parameter in `wp_parse_args()` to match the documented type. Props subrataemfluence. See #45643. git-svn-id: https://develop.svn.wordpress.org/trunk@47429 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 088fe9d07f..658afaad3c 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -4349,10 +4349,11 @@ function smilies_init() { * @since 2.3.0 `$args` can now also be an object. * * @param string|array|object $args Value to merge with $defaults. - * @param array $defaults Optional. Array that serves as the defaults. Default empty. + * @param array $defaults Optional. Array that serves as the defaults. + * Default empty array. * @return array Merged user defined values with defaults. */ -function wp_parse_args( $args, $defaults = '' ) { +function wp_parse_args( $args, $defaults = array() ) { if ( is_object( $args ) ) { $parsed_args = get_object_vars( $args ); } elseif ( is_array( $args ) ) { @@ -4361,7 +4362,7 @@ function wp_parse_args( $args, $defaults = '' ) { wp_parse_str( $args, $parsed_args ); } - if ( is_array( $defaults ) ) { + if ( is_array( $defaults ) && $defaults ) { return array_merge( $defaults, $parsed_args ); } return $parsed_args;