Make WordPress Core


Ignore:
Timestamp:
01/11/2011 06:56:59 PM (13 years ago)
Author:
ryan
Message:

Set tag_id for tag queries. Add NOT support to wp_list_filter(). Props scribu. fixes #16170

File:
1 edited

Legend:

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

    r17032 r17251  
    30503050 * @param array $list An array of objects to filter
    30513051 * @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'.
    30543057 * @return array
    30553058 */
    3056 function wp_list_filter( $list, $args = array(), $operator = 'and' ) {
     3059function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
    30573060    if ( empty( $args ) )
    30583061        return $list;
    30593062
     3063    $operator = strtoupper( $operator );
    30603064    $count = count( $args );
    3061 
    30623065    $filtered = array();
    30633066
    30643067    foreach ( $list as $key => $obj ) {
    30653068        $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 ) ) {
    30673072            $filtered[$key] = $obj;
    30683073        }
Note: See TracChangeset for help on using the changeset viewer.