Skip to content

Commit

Permalink
General: Move wp_array_get() next to wp_array_slice_assoc(), for …
Browse files Browse the repository at this point in the history
…a bit more consistent placement.

Follow-up to [49135], [49143].

See #51461.

git-svn-id: https://develop.svn.wordpress.org/trunk@49144 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Oct 14, 2020
1 parent f3f53fb commit 3a19ff1
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4499,6 +4499,7 @@ function wp_parse_slug_list( $list ) {
*/
function wp_array_slice_assoc( $array, $keys ) {
$slice = array();

foreach ( $keys as $key ) {
if ( isset( $array[ $key ] ) ) {
$slice[ $key ] = $array[ $key ];
Expand All @@ -4508,24 +4509,6 @@ function wp_array_slice_assoc( $array, $keys ) {
return $slice;
}

/**
* Determines if the variable is a numeric-indexed array.
*
* @since 4.4.0
*
* @param mixed $data Variable to check.
* @return bool Whether the variable is a list.
*/
function wp_is_numeric_array( $data ) {
if ( ! is_array( $data ) ) {
return false;
}

$keys = array_keys( $data );
$string_keys = array_filter( $keys, 'is_string' );
return count( $string_keys ) === 0;
}

/**
* Accesses an array in depth based on a path of keys.
*
Expand Down Expand Up @@ -4558,6 +4541,25 @@ function wp_array_get( $array, $path, $default = array() ) {
return $array;
}

/**
* Determines if the variable is a numeric-indexed array.
*
* @since 4.4.0
*
* @param mixed $data Variable to check.
* @return bool Whether the variable is a list.
*/
function wp_is_numeric_array( $data ) {
if ( ! is_array( $data ) ) {
return false;
}

$keys = array_keys( $data );
$string_keys = array_filter( $keys, 'is_string' );

return count( $string_keys ) === 0;
}

/**
* Filters a list of objects, based on a set of key => value arguments.
*
Expand Down

0 comments on commit 3a19ff1

Please sign in to comment.