From b3051048be46c8cb9595ead94a150ad1597446ec Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Thu, 8 Oct 2015 02:14:25 +0000 Subject: [PATCH] REST API: Add wp_is_numeric_array helper function The API uses this to do special operations on list responses (used for collections), so we need to detect whether an array is associative or numeric-indexed. After much discussion, the bikeshed is to be painted green and gold. See #33982. Built from https://develop.svn.wordpress.org/trunk@34927 git-svn-id: http://core.svn.wordpress.org/trunk@34892 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 18 ++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 2fd2eb18cb..738b17838d 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3176,6 +3176,24 @@ 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; +} + /** * Filters a list of objects, based on a set of key => value arguments. * diff --git a/wp-includes/version.php b/wp-includes/version.php index b699697572..66b94e9248 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34926'; +$wp_version = '4.4-alpha-34927'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.