Skip to:
Content

BuddyPress.org

Changeset 9586


Ignore:
Timestamp:
03/03/2015 04:16:23 AM (7 years ago)
Author:
tw2113
Message:

Adds hook documentation to class-bp-user-query.php.

See #5940.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-user-query.php

    r9486 r9586  
    174174            ) );
    175175
    176             // Plugins can use this filter to modify query args
    177             // before the query is constructed
     176            /**
     177             * Fires before the construction of the BP_User_Query query.
     178             *
     179             * @since BuddyPress (1.7.0)
     180             *
     181             * @param BP_User_Query $this Current instance of the BP_User_Query. Passed by reference.
     182             */
    178183            do_action_ref_array( 'bp_pre_user_query_construct', array( &$this ) );
    179184
     
    262267                $sql['select']  = "SELECT u.{$this->uid_name} as id FROM {$this->uid_table} u";
    263268                $sql['where'][] = $wpdb->prepare( "u.component = %s AND u.type = 'last_activity'", buddypress()->members->id );
     269
     270                /**
     271                 * Filters the threshold for activity timestamp minutes since to indicate online status.
     272                 *
     273                 * @since BuddyPress (1.8.0)
     274                 *
     275                 * @param int $value Amount of minutes for threshold. Default 15.
     276                 */
    264277                $sql['where'][] = $wpdb->prepare( "u.date_recorded >= DATE_SUB( UTC_TIMESTAMP(), INTERVAL %d MINUTE )", apply_filters( 'bp_user_query_online_interval', 15 ) );
    265278                $sql['orderby'] = "ORDER BY u.date_recorded";
     
    472485        }
    473486
    474         // Allow custom filters
     487        /**
     488         * Filters the clauses for the user query.
     489         *
     490         * @since BuddyPress (2.0.0)
     491         *
     492         * @param array         $sql  Array of SQL clauses to be used in the query.
     493         * @param BP_User_Query $this Current BP_User_Query instance.
     494         */
    475495        $sql = apply_filters_ref_array( 'bp_user_query_uid_clauses', array( $sql, &$this ) );
    476496
     
    482502        $this->uid_clauses['limit']   = $sql['limit'];
    483503
     504        /**
     505         * Fires before the BP_User_Query query is made.
     506         *
     507         * @since BuddyPress (1.7.0)
     508         *
     509         * @param BP_User_Query $this Current BP_User_Query instance. Passed by reference.
     510         */
    484511        do_action_ref_array( 'bp_pre_user_query', array( &$this ) );
    485512    }
     
    508535        // Get the total user count
    509536        if ( 'sql_calc_found_rows' == $this->query_vars['count_total'] ) {
     537
     538            /**
     539             * Filters the found user SQL statements before query.
     540             *
     541             * If "sql_calc_found_rows" is the provided count_total query var
     542             * then the value will be "SELECT FOUND_ROWS()". Otherwise it will
     543             * use a "SELECT COUNT()" query statement.
     544             *
     545             * @since BuddyPress (1.7.0)
     546             *
     547             * @param string        $value SQL statement to select FOUND_ROWS().
     548             * @param BP_User_Query $this  Current BP_User_Query instance.
     549             */
    510550            $this->total_users = $wpdb->get_var( apply_filters( 'bp_found_user_query', "SELECT FOUND_ROWS()", $this ) );
    511551        } elseif ( 'count_query' == $this->query_vars['count_total'] ) {
    512552            $count_select      = preg_replace( '/^SELECT.*?FROM (\S+) u/', "SELECT COUNT(u.{$this->uid_name}) FROM $1 u", $this->uid_clauses['select'] );
     553
     554            /** This filter is documented in bp-core/classes/class-bp-user-query.php */
    513555            $this->total_users = $wpdb->get_var( apply_filters( 'bp_found_user_query', "{$count_select} {$this->uid_clauses['where']}", $this ) );
    514556        }
     
    528570        }
    529571
     572        /**
     573         * Filters the WP User Query arguments before passing into the class.
     574         *
     575         * @since BuddyPress (1.7.0)
     576         *
     577         * @param array         $value Array of arguments for the user query.
     578         * @param BP_User_Query $this  Current BP_User_Query instance.
     579         */
    530580        $wp_user_query = new WP_User_Query( apply_filters( 'bp_wp_user_query_args', array(
    531581
     
    628678
    629679        /**
    630          * Use this action to independently populate your own custom extras.
     680         * Allows users to independently populate custom extras.
    631681         *
    632682         * Note that anything you add here should query using $user_ids_sql, to
     
    634684         *
    635685         * Two BuddyPress components currently do this:
    636          * - XProfile: To override display names
    637          * - Friends:  To set whether or not a user is the current users friend
     686         * - XProfile: To override display names.
     687         * - Friends:  To set whether or not a user is the current users friend.
    638688         *
    639689         * @see bp_xprofile_filter_user_query_populate_extras()
    640690         * @see bp_friends_filter_user_query_populate_extras()
     691         *
     692         * @since BuddyPress (1.7.0)
     693         *
     694         * @param BP_User_Query $this         Current BP_User_Query instance.
     695         * @param string        $user_ids_sql Comma-separated string of user IDs.
    641696         */
    642697        do_action_ref_array( 'bp_user_query_populate_extras', array( $this, $user_ids_sql ) );
Note: See TracChangeset for help on using the changeset viewer.