Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/02/2015 01:58:52 AM (8 years ago)
Author:
tw2113
Message:

More documentation cleanup for the Members component.

See #6402.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-template.php

    r10248 r10322  
    433433             */
    434434            do_action('member_loop_end');
    435             // Do some cleaning up after the loop
     435            // Do some cleaning up after the loop.
    436436            $this->rewind_members();
    437437        }
     
    455455        $this->member      = $this->next_member();
    456456
    457         // loop has just started
     457        // Loop has just started.
    458458        if ( 0 == $this->current_member ) {
    459459
     
    535535    global $members_template;
    536536
    537     // Default user ID
     537    // Default user ID.
    538538    $user_id = 0;
    539539
    540     // User filtering
     540    // User filtering.
    541541    if ( bp_is_user_friends() && ! bp_is_user_friend_requests() ) {
    542542        $user_id = bp_displayed_user_id();
     
    559559    }
    560560
    561     // type: active ( default ) | random | newest | popular | online | alphabetical
     561    // Type: active ( default ) | random | newest | popular | online | alphabetical.
    562562    $r = bp_parse_args( $args, array(
    563563        'type'                => 'active',
     
    566566        'max'                 => false,
    567567
    568         'page_arg'            => 'upage',  // See https://buddypress.trac.wordpress.org/ticket/3679
    569 
    570         'include'             => false,    // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users
    571         'exclude'             => false,    // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users
    572 
    573         'user_id'             => $user_id, // Pass a user_id to only show friends of this user
     568        'page_arg'            => 'upage',  // See https://buddypress.trac.wordpress.org/ticket/3679.
     569
     570        'include'             => false,    // Pass a user_id or a list (comma-separated or array) of user_ids to only show these users.
     571        'exclude'             => false,    // Pass a user_id or a list (comma-separated or array) of user_ids to exclude these users.
     572
     573        'user_id'             => $user_id, // Pass a user_id to only show friends of this user.
    574574        'member_type'         => $member_type,
    575575        'member_type__in'     => '',
     
    577577        'search_terms'        => $search_terms_default,
    578578
    579         'meta_key'            => false,    // Only return users with this usermeta
    580         'meta_value'          => false,    // Only return users where the usermeta value matches. Requires meta_key
     579        'meta_key'            => false,    // Only return users with this usermeta.
     580        'meta_value'          => false,    // Only return users where the usermeta value matches. Requires meta_key.
    581581
    582582        'populate_extras'     => true      // Fetch usermeta? Friend count, last active etc.
     
    592592    }
    593593
    594     // Set per_page to max if max is larger than per_page
     594    // Set per_page to max if max is larger than per_page.
    595595    if ( !empty( $r['max'] ) && ( $r['per_page'] > $r['max'] ) ) {
    596596        $r['per_page'] = $r['max'];
    597597    }
    598598
    599     // Query for members and populate $members_template global
     599    // Query for members and populate $members_template global.
    600600    $members_template = new BP_Core_Members_Template(
    601601        $r['type'],
     
    761761 * @since 1.7.0
    762762 *
    763  * @param array $classes Array of custom classes
     763 * @param array $classes Array of custom classes.
    764764 */
    765765function bp_member_class( $classes = array() ) {
     
    771771     * @since 1.7.0
    772772     *
    773      * @param array $classes Array of custom classes
     773     * @param array $classes Array of custom classes.
    774774     *
    775775     * @return string Row class of the member
     
    778778        global $members_template;
    779779
    780         // Add even/odd classes, but only if there's more than 1 member
     780        // Add even/odd classes, but only if there's more than 1 member.
    781781        if ( $members_template->member_count > 1 ) {
    782782            $pos_in_loop = (int) $members_template->current_member;
    783783            $classes[]   = ( $pos_in_loop % 2 ) ? 'even' : 'odd';
    784784
    785         // If we've only one member in the loop, don't bother with odd and even
     785        // If we've only one member in the loop, don't bother with odd and even.
    786786        } else {
    787787            $classes[] = 'bp-single-member';
    788788        }
    789789
    790         // Maybe add 'is-online' class
     790        // Maybe add 'is-online' class.
    791791        if ( ! empty( $members_template->member->last_activity ) ) {
    792792
    793             // Calculate some times
     793            // Calculate some times.
    794794            $current_time  = strtotime( bp_core_current_time() );
    795795            $last_activity = strtotime( $members_template->member->last_activity );
     
    802802        }
    803803
    804         // Add current user class
     804        // Add current user class.
    805805        if ( bp_loggedin_user_id() === (int) $members_template->member->id ) {
    806806            $classes[] = 'is-current-user';
     
    925925     * @since 1.2.0
    926926     *
    927      * @param string $value Formatted HTML <img> element,
    928      *                      or raw avatar URL based on $html arg.
     927     * @param string $value Formatted HTML <img> element, or raw avatar URL based on $html arg.
    929928     */
    930929    echo apply_filters( 'bp_member_avatar', bp_get_member_avatar( $args ) );
     
    972971         * @since 1.2.0
    973972         *
    974          * @param string $value Formatted HTML <img> element,
    975          *                      or raw avatar URL based on $html arg.
     973         * @param string $value Formatted HTML <img> element, or raw avatar URL based on $html arg.
    976974         */
    977975        return apply_filters( 'bp_get_member_avatar', bp_core_fetch_avatar( array( 'item_id' => $members_template->member->id, 'type' => $type, 'alt' => $alt, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'email' => $members_template->member->user_email ) ) );
     
    10391037        global $members_template;
    10401038
    1041         // Generally, this only fires when xprofile is disabled
     1039        // Generally, this only fires when xprofile is disabled.
    10421040        if ( empty( $members_template->member->fullname ) ) {
    1043             // Our order of preference for alternative fullnames
     1041            // Our order of preference for alternative fullnames.
    10441042            $name_stack = array(
    10451043                'display_name',
     
    10501048            foreach ( $name_stack as $source ) {
    10511049                if ( !empty( $members_template->member->{$source} ) ) {
    1052                     // When a value is found, set it as fullname and be done
    1053                     // with it
     1050                    // When a value is found, set it as fullname and be done with it.
    10541051                    $members_template->member->fullname = $members_template->member->{$source};
    10551052                    break;
     
    10951092        global $members_template;
    10961093
    1097         // Parse the activity format
     1094        // Parse the activity format.
    10981095        $r = bp_parse_args( $args, array(
    10991096            'active_format' => true
    11001097        ) );
    11011098
    1102         // Backwards compatibility for anyone forcing a 'true' active_format
     1099        // Backwards compatibility for anyone forcing a 'true' active_format.
    11031100        if ( true === $r['active_format'] ) {
    11041101            $r['active_format'] = __( 'active %s', 'buddypress' );
    11051102        }
    11061103
    1107         // Member has logged in at least one time
     1104        // Member has logged in at least one time.
    11081105        if ( isset( $members_template->member->last_activity ) ) {
    11091106
    1110             // Backwards compatibility for pre 1.5 'ago' strings
     1107            // Backwards compatibility for pre 1.5 'ago' strings.
    11111108            $last_activity = ! empty( $r['active_format'] )
    11121109                ? bp_core_get_last_activity( $members_template->member->last_activity, $r['active_format'] )
    11131110                : bp_core_time_since( $members_template->member->last_activity );
    11141111
    1115         // Member has never logged in or been active
     1112        // Member has never logged in or been active.
    11161113        } else {
    11171114            $last_activity = __( 'Never active', 'buddypress' );
     
    11321129 * Output the latest update of the current member in the loop.
    11331130 *
    1134  * @param array|string $args
     1131 * @param array|string $args Array of arguments for latest update.
    11351132 */
    11361133function bp_member_latest_update( $args = '' ) {
     
    12241221        }
    12251222
    1226         // Declare local variables
     1223        // Declare local variables.
    12271224        $data = false;
    12281225
    1229         // Guess at default $user_id
     1226        // Guess at default $user_id.
    12301227        $default_user_id = 0;
    12311228        if ( ! empty( $members_template->member->id ) ) {
     
    12421239        $r = wp_parse_args( $args, $defaults );
    12431240
    1244         // If we're in a members loop, get the data from the global
     1241        // If we're in a members loop, get the data from the global.
    12451242        if ( ! empty( $members_template->member->profile_data ) ) {
    12461243            $profile_data = $members_template->member->profile_data;
    12471244        }
    12481245
    1249         // Otherwise query for the data
     1246        // Otherwise query for the data.
    12501247        if ( empty( $profile_data ) && method_exists( 'BP_XProfile_ProfileData', 'get_all_for_user' ) ) {
    12511248            $profile_data = BP_XProfile_ProfileData::get_all_for_user( $r['user_id'] );
     
    12531250
    12541251        // If we're in the members loop, but the profile data has not
    1255         // been loaded into the global, cache it there for later use
     1252        // been loaded into the global, cache it there for later use.
    12561253        if ( ! empty( $members_template->member ) && empty( $members_template->member->profile_data ) ) {
    12571254            $members_template->member->profile_data = $profile_data;
    12581255        }
    12591256
    1260         // Get the data for the specific field requested
     1257        // Get the data for the specific field requested.
    12611258        if ( ! empty( $profile_data ) && ! empty( $profile_data[ $r['field'] ]['field_type'] ) && ! empty( $profile_data[ $r['field'] ]['field_data'] ) ) {
    12621259            $data = xprofile_format_profile_field( $profile_data[ $r['field'] ]['field_type'], $profile_data[ $r['field'] ]['field_data'] );
     
    13971394    $bp = buddypress();
    13981395
    1399     // Loop through each navigation item
     1396    // Loop through each navigation item.
    14001397    foreach( (array) $bp->bp_nav as $nav_item ) {
    14011398
     
    14231420        }
    14241421
    1425         // echo out the final list item
     1422        // Echo out the final list item.
    14261423        echo apply_filters_ref_array( 'bp_get_loggedin_user_nav_' . $nav_item['css_id'], array( '<li id="li-nav-' . $nav_item['css_id'] . '" ' . $selected . '><a id="my-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a></li>', &$nav_item ) );
    14271424    }
    14281425
    1429     // Always add a log out list item to the end of the navigation
     1426    // Always add a log out list item to the end of the navigation.
    14301427    $logout_link = '<li><a id="wp-logout" href="' .  wp_logout_url( bp_get_root_domain() ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
    14311428
     
    14901487 * @see bp_get_loggedin_user_avatar() for a description of params.
    14911488 *
    1492  * @param array|string $args
     1489 * @param array|string $args Array of arguments for logged in user avatar.
    14931490 */
    14941491function bp_loggedin_user_avatar( $args = '' ) {
     
    15391536 * @see bp_get_displayed_user_avatar() for a description of params.
    15401537 *
    1541  * @param array|string $args
     1538 * @param array|string $args Array of arguments for displayed user avatar.
    15421539 */
    15431540function bp_displayed_user_avatar( $args = '' ) {
     
    15971594        $bp = buddypress();
    15981595
    1599         // If displayed user exists, return email address
     1596        // If displayed user exists, return email address.
    16001597        if ( isset( $bp->displayed_user->userdata->user_email ) )
    16011598            $retval = $bp->displayed_user->userdata->user_email;
     
    16351632     *
    16361633     * @param int $user_id ID of the user. Default: displayed user ID.
    1637      *
    16381634     * @return string
    16391635     */
     
    16731669    function bp_get_user_firstname( $name = false ) {
    16741670
    1675         // Try to get displayed user
     1671        // Try to get displayed user.
    16761672        if ( empty( $name ) )
    16771673            $name = bp_get_displayed_user_fullname();
    16781674
    1679         // Fall back on logged in user
     1675        // Fall back on logged in user.
    16801676        if ( empty( $name ) )
    16811677            $name = bp_get_loggedin_user_fullname();
     
    19331929 * @uses bp_get_signup_slug() To make sure there is a slug assigned to the page.
    19341930 * @uses bp_locate_template() To make sure a template exists to provide output.
     1931 *
    19351932 * @return bool True if page and template exist, false if not.
    19361933 */
     
    21482145        global $current_site;
    21492146
    2150         // In case plugins are still using this filter
     2147        // In case plugins are still using this filter.
    21512148        $subdomain_base = apply_filters( 'bp_blogs_subdomain_base', preg_replace( '|^www\.|', '', $current_site->domain ) . $current_site->path );
    21522149
     
    22322229        $bp = buddypress();
    22332230
    2234         // Check if signup_avatar_dir is passed
     2231        // Check if signup_avatar_dir is passed.
    22352232        if ( !empty( $_POST['signup_avatar_dir'] ) )
    22362233            $signup_avatar_dir = $_POST['signup_avatar_dir'];
    22372234
    2238         // If not, check if global is set
     2235        // If not, check if global is set.
    22392236        elseif ( !empty( $bp->signup->avatar_dir ) )
    22402237            $signup_avatar_dir = $bp->signup->avatar_dir;
    22412238
    2242         // If not, set false
     2239        // If not, set false.
    22432240        else
    22442241            $signup_avatar_dir = false;
     
    23052302        extract( $r, EXTR_SKIP );
    23062303
    2307         // Avatar DIR is found
     2304        // Avatar DIR is found.
    23082305        if ( $signup_avatar_dir = bp_get_signup_avatar_dir_value() ) {
    23092306            $gravatar_img = bp_core_fetch_avatar( array(
     
    23182315            ) );
    23192316
    2320         // No avatar DIR was found
     2317        // No avatar DIR was found.
    23212318        } else {
    23222319
    2323             // Set default gravatar type
     2320            // Set default gravatar type.
    23242321            if ( empty( $bp->grav_default->user ) )
    23252322                $default_grav = 'wavatar';
     
    24352432    function bp_get_members_component_link( $component, $action = '', $query_args = '', $nonce = false ) {
    24362433
    2437         // Must be displayed user
     2434        // Must be displayed user.
    24382435        if ( !bp_displayed_user_id() )
    24392436            return;
     
    24412438        $bp = buddypress();
    24422439
    2443         // Append $action to $url if there is no $type
     2440        // Append $action to $url if there is no $type.
    24442441        if ( !empty( $action ) )
    24452442            $url = bp_displayed_user_domain() . $bp->{$component}->slug . '/' . $action;
     
    24472444            $url = bp_displayed_user_domain() . $bp->{$component}->slug;
    24482445
    2449         // Add a slash at the end of our user url
     2446        // Add a slash at the end of our user url.
    24502447        $url = trailingslashit( $url );
    24512448
    2452         // Add possible query arg
     2449        // Add possible query arg.
    24532450        if ( !empty( $query_args ) && is_array( $query_args ) )
    24542451            $url = add_query_arg( $query_args, $url );
     
    24602457            $url = wp_nonce_url( $url, $nonce );
    24612458
    2462         // Return the url, if there is one
     2459        // Return the url, if there is one.
    24632460        if ( !empty( $url ) )
    24642461            return $url;
Note: See TracChangeset for help on using the changeset viewer.