Allow `map_deep()` to work with object properties containing a reference. Restores the previous behaviour of `stripslashes_deep()`.
Merges [36100] to the 4.4 branch. Props jeff@pyebrook.com, swissspidy. See #22300, [35252]. Fixes #35058. Built from https://develop.svn.wordpress.org/branches/4.4@36101 git-svn-id: http://core.svn.wordpress.org/branches/4.4@36066 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
dbb12be45a
commit
4680a9a281
|
@ -3896,14 +3896,20 @@ function sanitize_option( $option, $value ) {
|
||||||
* @return The value with the callback applied to all non-arrays and non-objects inside it.
|
* @return The value with the callback applied to all non-arrays and non-objects inside it.
|
||||||
*/
|
*/
|
||||||
function map_deep( $value, $callback ) {
|
function map_deep( $value, $callback ) {
|
||||||
if ( is_array( $value ) || is_object( $value ) ) {
|
if ( is_array( $value ) ) {
|
||||||
foreach ( $value as &$item ) {
|
foreach ( $value as $index => $item ) {
|
||||||
$item = map_deep( $item, $callback );
|
$value[ $index ] = map_deep( $item, $callback );
|
||||||
|
}
|
||||||
|
} elseif ( is_object( $value ) ) {
|
||||||
|
$object_vars = get_object_vars( $value );
|
||||||
|
foreach ( $object_vars as $property_name => $property_value ) {
|
||||||
|
$value->$property_name = map_deep( $property_value, $callback );
|
||||||
}
|
}
|
||||||
return $value;
|
|
||||||
} else {
|
} else {
|
||||||
return call_user_func( $callback, $value );
|
$value = call_user_func( $callback, $value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4.1-alpha-36098';
|
$wp_version = '4.4.1-alpha-36101';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue