Changeset 2439 for trunk/bp-core.php
- Timestamp:
- 01/25/2010 12:33:37 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core.php
r2433 r2439 2001 2001 2002 2002 /** 2003 * bp_core_filter_comments() 2004 * 2005 * Filter the blog post comments array and insert BuddyPress URLs for users. 2006 * 2007 * @package BuddyPress Core 2008 */ 2009 function bp_core_filter_comments( $comments, $post_id ) { 2010 global $wpdb; 2011 2012 if ( !is_site_admin() ) 2013 return $comments; 2014 2015 foreach( $comments as $comment ) { 2016 if ( $comment->user_id ) 2017 $user_ids[] = $comment->user_id; 2018 } 2019 2020 if ( empty( $user_ids ) ) 2021 return $comments; 2022 2023 $user_ids = implode( ',', $user_ids ); 2024 2025 if ( !$userdata = $wpdb->get_results( $wpdb->prepare( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" ) ) ) 2026 return $comments; 2027 2028 foreach( $userdata as $user ) 2029 $users[$user->user_id] = bp_core_get_user_domain( $user->user_id, $user->user_nicename, $user->user_login ); 2030 2031 foreach( $comments as $i => $comment ) { 2032 if ( !empty( $comment->user_id ) ) { 2033 if ( !empty( $users[$comment->user_id] ) ) 2034 $comments[$i]->comment_author_url = $users[$comment->user_id]; 2035 } 2036 } 2037 2038 return $comments; 2039 } 2040 add_filter( 'comments_array', 'bp_core_filter_comments', 10, 2 ); 2041 2042 /** 2003 2043 * bp_core_clear_user_object_cache() 2004 2044 *
Note: See TracChangeset
for help on using the changeset viewer.