Changeset 10322 for trunk/src/bp-members/bp-members-template.php
- Timestamp:
- 11/02/2015 01:58:52 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-members/bp-members-template.php
r10248 r10322 433 433 */ 434 434 do_action('member_loop_end'); 435 // Do some cleaning up after the loop 435 // Do some cleaning up after the loop. 436 436 $this->rewind_members(); 437 437 } … … 455 455 $this->member = $this->next_member(); 456 456 457 // loop has just started457 // Loop has just started. 458 458 if ( 0 == $this->current_member ) { 459 459 … … 535 535 global $members_template; 536 536 537 // Default user ID 537 // Default user ID. 538 538 $user_id = 0; 539 539 540 // User filtering 540 // User filtering. 541 541 if ( bp_is_user_friends() && ! bp_is_user_friend_requests() ) { 542 542 $user_id = bp_displayed_user_id(); … … 559 559 } 560 560 561 // type: active ( default ) | random | newest | popular | online | alphabetical561 // Type: active ( default ) | random | newest | popular | online | alphabetical. 562 562 $r = bp_parse_args( $args, array( 563 563 'type' => 'active', … … 566 566 'max' => false, 567 567 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. 574 574 'member_type' => $member_type, 575 575 'member_type__in' => '', … … 577 577 'search_terms' => $search_terms_default, 578 578 579 'meta_key' => false, // Only return users with this usermeta580 'meta_value' => false, // Only return users where the usermeta value matches. Requires meta_key579 'meta_key' => false, // Only return users with this usermeta. 580 'meta_value' => false, // Only return users where the usermeta value matches. Requires meta_key. 581 581 582 582 'populate_extras' => true // Fetch usermeta? Friend count, last active etc. … … 592 592 } 593 593 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. 595 595 if ( !empty( $r['max'] ) && ( $r['per_page'] > $r['max'] ) ) { 596 596 $r['per_page'] = $r['max']; 597 597 } 598 598 599 // Query for members and populate $members_template global 599 // Query for members and populate $members_template global. 600 600 $members_template = new BP_Core_Members_Template( 601 601 $r['type'], … … 761 761 * @since 1.7.0 762 762 * 763 * @param array $classes Array of custom classes 763 * @param array $classes Array of custom classes. 764 764 */ 765 765 function bp_member_class( $classes = array() ) { … … 771 771 * @since 1.7.0 772 772 * 773 * @param array $classes Array of custom classes 773 * @param array $classes Array of custom classes. 774 774 * 775 775 * @return string Row class of the member … … 778 778 global $members_template; 779 779 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. 781 781 if ( $members_template->member_count > 1 ) { 782 782 $pos_in_loop = (int) $members_template->current_member; 783 783 $classes[] = ( $pos_in_loop % 2 ) ? 'even' : 'odd'; 784 784 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. 786 786 } else { 787 787 $classes[] = 'bp-single-member'; 788 788 } 789 789 790 // Maybe add 'is-online' class 790 // Maybe add 'is-online' class. 791 791 if ( ! empty( $members_template->member->last_activity ) ) { 792 792 793 // Calculate some times 793 // Calculate some times. 794 794 $current_time = strtotime( bp_core_current_time() ); 795 795 $last_activity = strtotime( $members_template->member->last_activity ); … … 802 802 } 803 803 804 // Add current user class 804 // Add current user class. 805 805 if ( bp_loggedin_user_id() === (int) $members_template->member->id ) { 806 806 $classes[] = 'is-current-user'; … … 925 925 * @since 1.2.0 926 926 * 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. 929 928 */ 930 929 echo apply_filters( 'bp_member_avatar', bp_get_member_avatar( $args ) ); … … 972 971 * @since 1.2.0 973 972 * 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. 976 974 */ 977 975 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 ) ) ); … … 1039 1037 global $members_template; 1040 1038 1041 // Generally, this only fires when xprofile is disabled 1039 // Generally, this only fires when xprofile is disabled. 1042 1040 if ( empty( $members_template->member->fullname ) ) { 1043 // Our order of preference for alternative fullnames 1041 // Our order of preference for alternative fullnames. 1044 1042 $name_stack = array( 1045 1043 'display_name', … … 1050 1048 foreach ( $name_stack as $source ) { 1051 1049 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. 1054 1051 $members_template->member->fullname = $members_template->member->{$source}; 1055 1052 break; … … 1095 1092 global $members_template; 1096 1093 1097 // Parse the activity format 1094 // Parse the activity format. 1098 1095 $r = bp_parse_args( $args, array( 1099 1096 'active_format' => true 1100 1097 ) ); 1101 1098 1102 // Backwards compatibility for anyone forcing a 'true' active_format 1099 // Backwards compatibility for anyone forcing a 'true' active_format. 1103 1100 if ( true === $r['active_format'] ) { 1104 1101 $r['active_format'] = __( 'active %s', 'buddypress' ); 1105 1102 } 1106 1103 1107 // Member has logged in at least one time 1104 // Member has logged in at least one time. 1108 1105 if ( isset( $members_template->member->last_activity ) ) { 1109 1106 1110 // Backwards compatibility for pre 1.5 'ago' strings 1107 // Backwards compatibility for pre 1.5 'ago' strings. 1111 1108 $last_activity = ! empty( $r['active_format'] ) 1112 1109 ? bp_core_get_last_activity( $members_template->member->last_activity, $r['active_format'] ) 1113 1110 : bp_core_time_since( $members_template->member->last_activity ); 1114 1111 1115 // Member has never logged in or been active 1112 // Member has never logged in or been active. 1116 1113 } else { 1117 1114 $last_activity = __( 'Never active', 'buddypress' ); … … 1132 1129 * Output the latest update of the current member in the loop. 1133 1130 * 1134 * @param array|string $args 1131 * @param array|string $args Array of arguments for latest update. 1135 1132 */ 1136 1133 function bp_member_latest_update( $args = '' ) { … … 1224 1221 } 1225 1222 1226 // Declare local variables 1223 // Declare local variables. 1227 1224 $data = false; 1228 1225 1229 // Guess at default $user_id 1226 // Guess at default $user_id. 1230 1227 $default_user_id = 0; 1231 1228 if ( ! empty( $members_template->member->id ) ) { … … 1242 1239 $r = wp_parse_args( $args, $defaults ); 1243 1240 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. 1245 1242 if ( ! empty( $members_template->member->profile_data ) ) { 1246 1243 $profile_data = $members_template->member->profile_data; 1247 1244 } 1248 1245 1249 // Otherwise query for the data 1246 // Otherwise query for the data. 1250 1247 if ( empty( $profile_data ) && method_exists( 'BP_XProfile_ProfileData', 'get_all_for_user' ) ) { 1251 1248 $profile_data = BP_XProfile_ProfileData::get_all_for_user( $r['user_id'] ); … … 1253 1250 1254 1251 // 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. 1256 1253 if ( ! empty( $members_template->member ) && empty( $members_template->member->profile_data ) ) { 1257 1254 $members_template->member->profile_data = $profile_data; 1258 1255 } 1259 1256 1260 // Get the data for the specific field requested 1257 // Get the data for the specific field requested. 1261 1258 if ( ! empty( $profile_data ) && ! empty( $profile_data[ $r['field'] ]['field_type'] ) && ! empty( $profile_data[ $r['field'] ]['field_data'] ) ) { 1262 1259 $data = xprofile_format_profile_field( $profile_data[ $r['field'] ]['field_type'], $profile_data[ $r['field'] ]['field_data'] ); … … 1397 1394 $bp = buddypress(); 1398 1395 1399 // Loop through each navigation item 1396 // Loop through each navigation item. 1400 1397 foreach( (array) $bp->bp_nav as $nav_item ) { 1401 1398 … … 1423 1420 } 1424 1421 1425 // echo out the final list item1422 // Echo out the final list item. 1426 1423 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 ) ); 1427 1424 } 1428 1425 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. 1430 1427 $logout_link = '<li><a id="wp-logout" href="' . wp_logout_url( bp_get_root_domain() ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>'; 1431 1428 … … 1490 1487 * @see bp_get_loggedin_user_avatar() for a description of params. 1491 1488 * 1492 * @param array|string $args 1489 * @param array|string $args Array of arguments for logged in user avatar. 1493 1490 */ 1494 1491 function bp_loggedin_user_avatar( $args = '' ) { … … 1539 1536 * @see bp_get_displayed_user_avatar() for a description of params. 1540 1537 * 1541 * @param array|string $args 1538 * @param array|string $args Array of arguments for displayed user avatar. 1542 1539 */ 1543 1540 function bp_displayed_user_avatar( $args = '' ) { … … 1597 1594 $bp = buddypress(); 1598 1595 1599 // If displayed user exists, return email address 1596 // If displayed user exists, return email address. 1600 1597 if ( isset( $bp->displayed_user->userdata->user_email ) ) 1601 1598 $retval = $bp->displayed_user->userdata->user_email; … … 1635 1632 * 1636 1633 * @param int $user_id ID of the user. Default: displayed user ID. 1637 *1638 1634 * @return string 1639 1635 */ … … 1673 1669 function bp_get_user_firstname( $name = false ) { 1674 1670 1675 // Try to get displayed user 1671 // Try to get displayed user. 1676 1672 if ( empty( $name ) ) 1677 1673 $name = bp_get_displayed_user_fullname(); 1678 1674 1679 // Fall back on logged in user 1675 // Fall back on logged in user. 1680 1676 if ( empty( $name ) ) 1681 1677 $name = bp_get_loggedin_user_fullname(); … … 1933 1929 * @uses bp_get_signup_slug() To make sure there is a slug assigned to the page. 1934 1930 * @uses bp_locate_template() To make sure a template exists to provide output. 1931 * 1935 1932 * @return bool True if page and template exist, false if not. 1936 1933 */ … … 2148 2145 global $current_site; 2149 2146 2150 // In case plugins are still using this filter 2147 // In case plugins are still using this filter. 2151 2148 $subdomain_base = apply_filters( 'bp_blogs_subdomain_base', preg_replace( '|^www\.|', '', $current_site->domain ) . $current_site->path ); 2152 2149 … … 2232 2229 $bp = buddypress(); 2233 2230 2234 // Check if signup_avatar_dir is passed 2231 // Check if signup_avatar_dir is passed. 2235 2232 if ( !empty( $_POST['signup_avatar_dir'] ) ) 2236 2233 $signup_avatar_dir = $_POST['signup_avatar_dir']; 2237 2234 2238 // If not, check if global is set 2235 // If not, check if global is set. 2239 2236 elseif ( !empty( $bp->signup->avatar_dir ) ) 2240 2237 $signup_avatar_dir = $bp->signup->avatar_dir; 2241 2238 2242 // If not, set false 2239 // If not, set false. 2243 2240 else 2244 2241 $signup_avatar_dir = false; … … 2305 2302 extract( $r, EXTR_SKIP ); 2306 2303 2307 // Avatar DIR is found 2304 // Avatar DIR is found. 2308 2305 if ( $signup_avatar_dir = bp_get_signup_avatar_dir_value() ) { 2309 2306 $gravatar_img = bp_core_fetch_avatar( array( … … 2318 2315 ) ); 2319 2316 2320 // No avatar DIR was found 2317 // No avatar DIR was found. 2321 2318 } else { 2322 2319 2323 // Set default gravatar type 2320 // Set default gravatar type. 2324 2321 if ( empty( $bp->grav_default->user ) ) 2325 2322 $default_grav = 'wavatar'; … … 2435 2432 function bp_get_members_component_link( $component, $action = '', $query_args = '', $nonce = false ) { 2436 2433 2437 // Must be displayed user 2434 // Must be displayed user. 2438 2435 if ( !bp_displayed_user_id() ) 2439 2436 return; … … 2441 2438 $bp = buddypress(); 2442 2439 2443 // Append $action to $url if there is no $type 2440 // Append $action to $url if there is no $type. 2444 2441 if ( !empty( $action ) ) 2445 2442 $url = bp_displayed_user_domain() . $bp->{$component}->slug . '/' . $action; … … 2447 2444 $url = bp_displayed_user_domain() . $bp->{$component}->slug; 2448 2445 2449 // Add a slash at the end of our user url 2446 // Add a slash at the end of our user url. 2450 2447 $url = trailingslashit( $url ); 2451 2448 2452 // Add possible query arg 2449 // Add possible query arg. 2453 2450 if ( !empty( $query_args ) && is_array( $query_args ) ) 2454 2451 $url = add_query_arg( $query_args, $url ); … … 2460 2457 $url = wp_nonce_url( $url, $nonce ); 2461 2458 2462 // Return the url, if there is one 2459 // Return the url, if there is one. 2463 2460 if ( !empty( $url ) ) 2464 2461 return $url;
Note: See TracChangeset
for help on using the changeset viewer.