Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/wp-includes/user.php

    r18178 r17635  
    166166 *
    167167 * @since 3.0.0
    168  * @param array $user_ids Array of user IDs.
    169  * @param string|array $post_type Optional. Post type to check. Defaults to post.
     168 * @param array $users User ID number list.
    170169 * @return array Amount of posts each user has written.
    171170 */
    172 function count_many_users_posts($users, $post_type = 'post' ) {
     171function count_many_users_posts($users) {
    173172    global $wpdb;
    174173
    175174    $count = array();
    176     if ( empty( $users ) || ! is_array( $users ) )
     175    if ( ! is_array($users) || empty( $users ) )
    177176        return $count;
    178177
    179     $userlist = implode( ',', array_map( 'absint', $users ) );
    180     $where = get_posts_by_author_sql( $post_type );
     178    $userlist = implode( ',', $users );
     179    $where = get_posts_by_author_sql( 'post' );
    181180
    182181    $result = $wpdb->get_results( "SELECT post_author, COUNT(*) FROM $wpdb->posts $where AND post_author IN ($userlist) GROUP BY post_author", ARRAY_N );
     
    362361    var $query_limit;
    363362
     363    /**
     364     * PHP4 constructor
     365     */
     366    function WP_User_Query( $query = null ) {
     367        $this->__construct( $query );
     368    }
    364369
    365370    /**
     
    384389                'orderby' => 'login',
    385390                'order' => 'ASC',
    386                 'offset' => '',
    387                 'number' => '',
     391                'offset' => '', 'number' => '',
    388392                'count_total' => true,
    389393                'fields' => 'all',
     
    419423            $this->query_fields = "$wpdb->users.ID";
    420424        }
    421 
    422         if ( $this->query_vars['count_total'] )
    423             $this->query_fields = 'SQL_CALC_FOUND_ROWS ' . $this->query_fields;
    424425
    425426        $this->query_from = "FROM $wpdb->users";
     
    496497        if ( 'authors' == $qv['who'] && $blog_id ) {
    497498            $qv['meta_key'] = $wpdb->get_blog_prefix( $blog_id ) . 'user_level';
    498             $qv['meta_value'] = 0;
     499            $qv['meta_value'] = '_wp_zero_value'; // Hack to pass '0'
    499500            $qv['meta_compare'] = '!=';
    500501            $qv['blog_id'] = $blog_id = 0; // Prevent extra meta query
    501502        }
     503
     504        _parse_meta_query( $qv );
    502505
    503506        $role = trim( $qv['role'] );
     
    515518        }
    516519
    517         $meta_query = new WP_Meta_Query();
    518         $meta_query->parse_query_vars( $qv );
    519 
    520         if ( !empty( $meta_query->queries ) ) {
    521             $clauses = $meta_query->get_sql( 'user', $wpdb->users, 'ID', $this );
     520        if ( !empty( $qv['meta_query'] ) ) {
     521            $clauses = call_user_func_array( '_get_meta_sql', array( $qv['meta_query'], 'user', $wpdb->users, 'ID', &$this ) );
    522522            $this->query_from .= $clauses['join'];
    523523            $this->query_where .= $clauses['where'];
    524 
    525             if ( 'OR' == $meta_query->relation )
    526                 $this->query_fields = 'DISTINCT ' . $this->query_fields;
    527524        }
    528525
     
    554551
    555552        if ( $this->query_vars['count_total'] )
    556             $this->total_users = $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) );
     553            $this->total_users = $wpdb->get_var("SELECT COUNT(*) $this->query_from $this->query_where");
    557554
    558555        if ( !$this->results )
     
    744741 * Add meta data field to a user.
    745742 *
    746  * Post meta data is called "Custom Fields" on the Administration Screens.
     743 * Post meta data is called "Custom Fields" on the Administration Panels.
    747744 *
    748745 * @since 3.0.0
     
    13591356 * 'user_email' - A string containing the user's email address.
    13601357 * 'display_name' - A string that will be shown on the site. Defaults to user's
    1361  *      username. It is likely that you will want to change this, for appearance.
     1358 *      username. It is likely that you will want to change this, for both
     1359 *      appearance and security through obscurity (that is if you don't use and
     1360 *      delete the default 'admin' user).
    13621361 * 'nickname' - The user's nickname, defaults to the user's username.
    13631362 * 'first_name' - The user's first name.
Note: See TracChangeset for help on using the changeset viewer.