Changeset 8754 for trunk/src/bp-friends/bp-friends-functions.php
- Timestamp:
- 08/03/2014 08:52:05 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-friends/bp-friends-functions.php
r8514 r8754 567 567 add_action( 'delete_user', 'friends_remove_data' ); 568 568 add_action( 'bp_make_spam_user', 'friends_remove_data' ); 569 570 /** 571 * Used by the Activity component's @mentions to print a JSON list of the current user's friends. 572 * 573 * This is intended to speed up @mentions lookups for a majority of use cases. 574 * 575 * @see bp_activity_mentions_script() 576 */ 577 function bp_friends_prime_mentions_results() { 578 if ( ! bp_activity_maybe_load_mentions_scripts() ) { 579 return; 580 } 581 582 $friends_query = array( 583 'count_total' => '', // Prevents total count 584 'populate_extras' => false, 585 586 'type' => 'alphabetical', 587 'user_id' => get_current_user_id(), 588 ); 589 590 $friends_query = new BP_User_Query( $friends_query ); 591 $results = array(); 592 593 foreach ( $friends_query->results as $user ) { 594 $result = new stdClass(); 595 $result->ID = $user->user_nicename; 596 $result->image = bp_core_fetch_avatar( array( 'html' => false, 'item_id' => $user->ID ) ); 597 $result->name = bp_core_get_user_displayname( $user->ID ); 598 599 $results[] = $result; 600 } 601 602 wp_localize_script( 'bp-mentions', 'BP_Suggestions', array( 603 'friends' => $results, 604 ) ); 605 } 606 add_action( 'bp_activity_mentions_prime_results', 'bp_friends_prime_mentions_results' );
Note: See TracChangeset
for help on using the changeset viewer.