Make WordPress Core

Changeset 15574


Ignore:
Timestamp:
09/05/2010 06:47:25 PM (14 years ago)
Author:
scribu
Message:

Use get_users() in wp_dropdown_users(). See #14572

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r15568 r15574  
    29812981
    29822982/**
     2983 * Extract a slice of an array, given a list of keys
     2984 *
     2985 * @since 3.1.0
     2986 *
     2987 * @param array $array The original array
     2988 * @param array $keys The list of keys
     2989 * @return array The array slice
     2990 */
     2991function wp_array_slice_assoc( $array, $keys ) {
     2992    $slice = array();
     2993    foreach ( $keys as $key )
     2994        if ( isset( $array[ $key ] ) )
     2995            $slice[ $key ] = $array[ $key ];
     2996
     2997    return $slice;
     2998}
     2999
     3000/**
    29833001 * Filters a list of objects, based on a set of key => value arguments
    29843002 *
  • trunk/wp-includes/user.php

    r15570 r15574  
    462462        }
    463463
    464         $meta_query = array();
    465         foreach ( array( 'meta_key', 'meta_value', 'meta_compare' ) as $key )
    466             if ( isset( $qv[ $key ] ) )
    467                 $meta_query[ $key ] = $qv[ $key ];
    468         $meta_queries[] = $meta_query;
     464        $meta_queries[] = wp_array_slice_assoc( $qv, array( 'meta_key', 'meta_value', 'meta_compare' ) );
    469465
    470466        $meta_query_sql = _wp_meta_sql( $meta_queries, 'user_id', $wpdb->usermeta );
     
    832828    extract( $r, EXTR_SKIP );
    833829
    834     $blog_prefix = $wpdb->get_blog_prefix( $blog_id );
    835     $query = "SELECT {$wpdb->users}.* FROM $wpdb->users, $wpdb->usermeta WHERE {$wpdb->users}.ID = {$wpdb->usermeta}.user_id AND meta_key = '{$blog_prefix}capabilities'";
    836 
    837     $query_where = array();
    838 
    839     if ( is_array($include) )
    840         $include = join(',', $include);
    841     $include = preg_replace('/[^0-9,]/', '', $include); // (int)
    842     if ( $include )
    843         $query_where[] = "ID IN ($include)";
    844 
    845     if ( is_array($exclude) )
    846         $exclude = join(',', $exclude);
    847     $exclude = preg_replace('/[^0-9,]/', '', $exclude); // (int)
    848     if ( $exclude )
    849         $query_where[] = "ID NOT IN ($exclude)";
    850 
    851     if ( $query_where )
    852         $query .= " AND " . join(' AND', $query_where);
    853 
    854     $query .= " ORDER BY $orderby $order";
    855 
    856     $users = $wpdb->get_results( $query );
     830    $users = get_users( wp_array_slice_assoc( $args, array( 'blog_id', 'include', 'exclude', 'orderby', 'order' ) ) );
    857831
    858832    $output = '';
Note: See TracChangeset for help on using the changeset viewer.