WordPress.org

Make WordPress Core

Changeset 49144


Ignore:
Timestamp:
10/14/2020 02:14:34 AM (10 months ago)
Author:
SergeyBiryukov
Message:

General: Move wp_array_get() next to wp_array_slice_assoc(), for a bit more consistent placement.

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

See #51461.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r49143 r49144  
    45004500function wp_array_slice_assoc( $array, $keys ) {
    45014501    $slice = array();
     4502
    45024503    foreach ( $keys as $key ) {
    45034504        if ( isset( $array[ $key ] ) ) {
     
    45074508
    45084509    return $slice;
    4509 }
    4510 
    4511 /**
    4512  * Determines if the variable is a numeric-indexed array.
    4513  *
    4514  * @since 4.4.0
    4515  *
    4516  * @param mixed $data Variable to check.
    4517  * @return bool Whether the variable is a list.
    4518  */
    4519 function wp_is_numeric_array( $data ) {
    4520     if ( ! is_array( $data ) ) {
    4521         return false;
    4522     }
    4523 
    4524     $keys        = array_keys( $data );
    4525     $string_keys = array_filter( $keys, 'is_string' );
    4526     return count( $string_keys ) === 0;
    45274510}
    45284511
     
    45574540
    45584541    return $array;
     4542}
     4543
     4544/**
     4545 * Determines if the variable is a numeric-indexed array.
     4546 *
     4547 * @since 4.4.0
     4548 *
     4549 * @param mixed $data Variable to check.
     4550 * @return bool Whether the variable is a list.
     4551 */
     4552function wp_is_numeric_array( $data ) {
     4553    if ( ! is_array( $data ) ) {
     4554        return false;
     4555    }
     4556
     4557    $keys        = array_keys( $data );
     4558    $string_keys = array_filter( $keys, 'is_string' );
     4559
     4560    return count( $string_keys ) === 0;
    45594561}
    45604562
Note: See TracChangeset for help on using the changeset viewer.