Skip to:
Content

bbPress.org


Ignore:
Timestamp:
03/01/2017 02:17:21 AM (9 years ago)
Author:
johnjamesjacoby
Message:

Engagements: Integrate the user_query into favorites, subscriptions, and engagements.

  • Add to admin metabox avatar loops
  • Fix a few bugs in BBP_User_Query, and include a custom constructor to set the loop counter

See #3068.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/users/template.php

    r6332 r6334  
    5757
    5858    /**
    59      * Set up the next user and iterate current user index.
     59     * PHP5 constructor.
    6060     *
    6161     * @since 2.6.0 bbPress (r6330)
    6262     * @access public
    6363     *
     64     * @param null|string|array $query Optional. The query variables.
     65     */
     66    public function __construct( $query = null ) {
     67        if ( ! empty( $query ) ) {
     68            parent::__construct( $query );
     69            $this->user_count = count( $this->results );
     70        }
     71    }
     72
     73    /**
     74     * Set up the next user and iterate current user index.
     75     *
     76     * @since 2.6.0 bbPress (r6330)
     77     * @access public
     78     *
    6479     * @return WP_User Next user.
    6580     */
    6681    public function next_user() {
    67 
    6882        $this->current_user++;
    69 
    70         $this->user = $this->users[ $this->current_user ];
     83        $this->user = $this->results[ $this->current_user ];
    7184
    7285        return $this->user;
     
    89102        // loop has just started
    90103        if ( $this->current_user === -1 ) {
     104
    91105            /**
    92106             * Fires once the loop is started.
    93107             *
    94              * @since 2.6.0 bbPress
     108             * @since 2.6.0 bbPress (r6330)
    95109             *
    96110             * @param WP_Query &$this The WP_Query instance (passed by reference).
     
    99113        }
    100114
    101         $this->user = $this->next_user();
     115        $this->next_user();
    102116    }
    103117
     
    120134             * Fires once the loop has ended.
    121135             *
    122              * @since 2.0.0
     136             * @since 2.6.0 bbPress (r6330)
    123137             *
    124138             * @param WP_Query &$this The WP_Query instance (passed by reference).
     
    145159
    146160        if ( $this->user_count > 0 ) {
    147             $this->user = $this->users[ 0 ];
     161            $this->user = $this->results[ 0 ];
    148162        }
    149163    }
     
    190204 */
    191205function bbp_users() {
    192     return bbpress()->user_query->have_users();;
     206    return bbpress()->user_query->have_users();
    193207}
    194208
     
    238252        if ( ! empty( $user_id ) && is_numeric( $user_id ) ) {
    239253            $bbp_user_id = $user_id;
     254
     255        // Currently inside a user loop
     256        } elseif ( ! empty( $bbp->user_query->in_the_loop ) && isset( $bbp->user_query->user->ID ) ) {
     257            $bbp_user_id = $bbp->user_query->user->ID;
    240258
    241259        // Currently viewing or editing a user
Note: See TracChangeset for help on using the changeset viewer.