General: Move `wp_array_get()` from a separate file to `wp-includes/functions.php`, for consistency.
Add missing `@since` tag, adjust the DocBlock per the documentation standards. Follow-up to [49135]. Props isabel_brison, ocean90. Fixes #51461. Built from https://develop.svn.wordpress.org/trunk@49143 git-svn-id: http://core.svn.wordpress.org/trunk@48905 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a706c4505e
commit
620c069fe8
|
@ -1,34 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* Array API: WordPress array utilities.
|
|
||||||
*
|
|
||||||
* @package WordPress
|
|
||||||
* @since 5.6.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Accesses an array in depth based on a path of keys.
|
|
||||||
* It is the PHP equivalent of JavaScript's lodash.get, and mirroring it may help other components
|
|
||||||
* retain some symmetry between client and server implementations.
|
|
||||||
*
|
|
||||||
* @param array $array An array from which we want to retrieve some information.
|
|
||||||
* @param array $path An array of keys describing the path with which to retrieve information.
|
|
||||||
* @param array $default The return value if the path is not set on the array or if the types of array and path are not arrays.
|
|
||||||
*
|
|
||||||
* @return array An array matching the path specified.
|
|
||||||
*/
|
|
||||||
function wp_array_get( $array, $path, $default = array() ) {
|
|
||||||
// Confirm input values are expected type to avoid notice warnings.
|
|
||||||
if ( ! is_array( $array ) || ! is_array( $path ) ) {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
|
|
||||||
$path_length = count( $path );
|
|
||||||
for ( $i = 0; $i < $path_length; ++$i ) {
|
|
||||||
if ( ! isset( $array[ $path[ $i ] ] ) ) {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
$array = $array[ $path[ $i ] ];
|
|
||||||
}
|
|
||||||
return $array;
|
|
||||||
}
|
|
|
@ -4526,6 +4526,38 @@ function wp_is_numeric_array( $data ) {
|
||||||
return count( $string_keys ) === 0;
|
return count( $string_keys ) === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accesses an array in depth based on a path of keys.
|
||||||
|
*
|
||||||
|
* It is the PHP equivalent of JavaScript's lodash.get, and mirroring it may help other components
|
||||||
|
* retain some symmetry between client and server implementations.
|
||||||
|
*
|
||||||
|
* @since 5.6.0
|
||||||
|
*
|
||||||
|
* @param array $array An array from which we want to retrieve some information.
|
||||||
|
* @param array $path An array of keys describing the path with which to retrieve information.
|
||||||
|
* @param array $default The return value if the path is not set on the array,
|
||||||
|
* or if the types of array and path are not arrays.
|
||||||
|
* @return array An array matching the path specified.
|
||||||
|
*/
|
||||||
|
function wp_array_get( $array, $path, $default = array() ) {
|
||||||
|
// Confirm input values are expected type to avoid notice warnings.
|
||||||
|
if ( ! is_array( $array ) || ! is_array( $path ) ) {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path_length = count( $path );
|
||||||
|
|
||||||
|
for ( $i = 0; $i < $path_length; ++$i ) {
|
||||||
|
if ( ! isset( $array[ $path[ $i ] ] ) ) {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
$array = $array[ $path[ $i ] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $array;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters a list of objects, based on a set of key => value arguments.
|
* Filters a list of objects, based on a set of key => value arguments.
|
||||||
*
|
*
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.6-alpha-49142';
|
$wp_version = '5.6-alpha-49143';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
|
|
@ -179,7 +179,6 @@ require ABSPATH . WPINC . '/class-wp-user-meta-session-tokens.php';
|
||||||
require ABSPATH . WPINC . '/class-wp-metadata-lazyloader.php';
|
require ABSPATH . WPINC . '/class-wp-metadata-lazyloader.php';
|
||||||
require ABSPATH . WPINC . '/general-template.php';
|
require ABSPATH . WPINC . '/general-template.php';
|
||||||
require ABSPATH . WPINC . '/link-template.php';
|
require ABSPATH . WPINC . '/link-template.php';
|
||||||
require ABSPATH . WPINC . '/array.php';
|
|
||||||
require ABSPATH . WPINC . '/author-template.php';
|
require ABSPATH . WPINC . '/author-template.php';
|
||||||
require ABSPATH . WPINC . '/post.php';
|
require ABSPATH . WPINC . '/post.php';
|
||||||
require ABSPATH . WPINC . '/class-walker-page.php';
|
require ABSPATH . WPINC . '/class-walker-page.php';
|
||||||
|
|
Loading…
Reference in New Issue