diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index c7b173621a..8f8c86f742 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -5496,27 +5496,24 @@ function sanitize_trackback_urls( $to_ping ) { } /** - * Add slashes to a string or array of strings. + * Add slashes to a string or array of strings, in a recursive manner. * * This should be used when preparing data for core API that expects slashed data. * This should not be used to escape data going directly into an SQL query. * * @since 3.6.0 + * @since 5.5.0 Leave a non-string value untouched. * * @param string|array $value String or array of strings to slash. * @return string|array Slashed $value */ function wp_slash( $value ) { if ( is_array( $value ) ) { - foreach ( $value as $k => $v ) { - if ( is_array( $v ) ) { - $value[ $k ] = wp_slash( $v ); - } else { - $value[ $k ] = addslashes( $v ); - } - } - } else { - $value = addslashes( $value ); + $value = array_map( 'wp_slash', $value ); + } + + if ( is_string( $value ) ) { + return addslashes( $value ); } return $value; diff --git a/wp-includes/version.php b/wp-includes/version.php index a1b7b92b1c..6e5acc9b3c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-beta1-48432'; +$wp_version = '5.5-beta1-48433'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.