Changeset 17251 for trunk/wp-includes/functions.php
- Timestamp:
- 01/11/2011 06:56:59 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r17032 r17251 3050 3050 * @param array $list An array of objects to filter 3051 3051 * @param array $args An array of key => value arguments to match against each object 3052 * @param string $operator The logical operation to perform. 'or' means only one element 3053 * from the array needs to match; 'and' means all elements must match. The default is 'and'. 3052 * @param string $operator The logical operation to perform: 3053 * 'AND' means all elements from the array must match; 3054 * 'OR' means only one element needs to match; 3055 * 'NOT' means no elements may match. 3056 * The default is 'AND'. 3054 3057 * @return array 3055 3058 */ 3056 function wp_list_filter( $list, $args = array(), $operator = ' and' ) {3059 function wp_list_filter( $list, $args = array(), $operator = 'AND' ) { 3057 3060 if ( empty( $args ) ) 3058 3061 return $list; 3059 3062 3063 $operator = strtoupper( $operator ); 3060 3064 $count = count( $args ); 3061 3062 3065 $filtered = array(); 3063 3066 3064 3067 foreach ( $list as $key => $obj ) { 3065 3068 $matched = count( array_intersect_assoc( (array) $obj, $args ) ); 3066 if ( ('and' == $operator && $matched == $count) || ('or' == $operator && $matched <= $count) ) { 3069 if ( ( 'AND' == $operator && $matched == $count ) 3070 || ( 'OR' == $operator && $matched <= $count ) 3071 || ( 'NOT' == $operator && 0 == $matched ) ) { 3067 3072 $filtered[$key] = $obj; 3068 3073 }
Note: See TracChangeset
for help on using the changeset viewer.