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 { |
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
| 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 | /** |
128 | 144 | * Plucks a certain field out of each object in the list. |
129 | 145 | * |
130 | 146 | * This has the same functionality and prototype of |
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 |
3746 | 3746 | * @since 3.1.0 |
3747 | 3747 | * @since 4.7.0 Uses WP_List_Util class. |
3748 | 3748 | * |
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'. |
3756 | 3756 | * @return array Array of found values. |
3757 | 3757 | */ |
3758 | 3758 | function 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); |
3762 | 3761 | |
3763 | 3762 | $util = new WP_List_Util( $list ); |
3764 | 3763 | return $util->filter( $args, $operator ); |