Make WordPress Core

Ticket #43025: 43025.2.diff

File 43025.2.diff, 2.4 KB (added by jarednova, 7 years ago)

Reaction to feedback on patch

  • wp-includes/class-wp-list-util.php

    diff --git a/wp-includes/class-wp-list-util.php b/wp-includes/class-wp-list-util.php
    index 0fbefd0..a2fbc0e 100644
    a b class WP_List_Util { 
    125125        }
    126126
    127127        /**
     128         * Determined whether the input is an iterable object.
     129         *
     130         * @since 4.9.4
     131         *
     132         * @param mixed $input The potential iterable object we want to evaluate
     133         *
     134         * @return iterable The original input if it was an iterable object. Or if not, an empty array
     135         */
     136        public static function maybe_list( $input ) {
     137                if ( ! is_array( $input ) && ! $input instanceof Traversable ) {
     138                        return array();
     139                }
     140                return $input;
     141        }
     142
     143        /**
    128144         * Plucks a certain field out of each object in the list.
    129145         *
    130146         * This has the same functionality and prototype of
  • wp-includes/functions.php

    diff --git a/wp-includes/functions.php b/wp-includes/functions.php
    index 9b5f292..d01ae2e 100644
    a b function wp_filter_object_list( $list, $args = array(), $operator = 'and', $fiel 
    37463746 * @since 3.1.0
    37473747 * @since 4.7.0 Uses WP_List_Util class.
    37483748 *
    3749  * @param array $list     An array of objects to filter.
    3750  * @param array  $args     Optional. An array of key => value arguments to match
    3751  *                         against each object. Default empty array.
    3752  * @param string $operator Optional. The logical operation to perform. 'AND' means
    3753  *                         all elements from the array must match. 'OR' means only
    3754  *                         one element needs to match. 'NOT' means no elements may
    3755  *                         match. Default 'AND'.
     3749 * @param iterable $list     An array of objects to filter.
     3750 * @param array    $args     Optional. An array of key => value arguments to match
     3751 *                           against each object. Default empty array.
     3752 * @param string   $operator Optional. The logical operation to perform. 'AND' means
     3753 *                           all elements from the array must match. 'OR' means only
     3754 *                           one element needs to match. 'NOT' means no elements may
     3755 *                           match. Default 'AND'.
    37563756 * @return array Array of found values.
    37573757 */
    37583758function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
    3759         if ( ! is_array( $list ) ) {
    3760                 return array();
    3761         }
     3759
     3760        $list = WP_List_Util::maybe_list($list);
    37623761
    37633762        $util = new WP_List_Util( $list );
    37643763        return $util->filter( $args, $operator );