Changeset 6198
- Timestamp:
- 12/29/2016 05:15:57 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/users/functions.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/users/functions.php
r6196 r6198 270 270 * 271 271 * @param int $topic_id Optional. Topic id 272 * @uses wpdb::get_col() To execute our query and get the column back272 * @uses bbp_get_users_for_object() To get user IDs who favorited 273 273 * @uses apply_filters() Calls 'bbp_get_topic_favoriters' with the users and 274 274 * topic id … … 577 577 * 578 578 * @param int $topic_id Optional. Topic id 579 * @uses bbp_get_user _terms_by_object() To get the topic subscribers579 * @uses bbp_get_users_for_object() To get the topic subscribers 580 580 * @uses apply_filters() Calls 'bbp_get_topic_subscribers' with the subscribers 581 581 * @return array|bool Results if the topic has any subscribers, otherwise false … … 1339 1339 * @uses is_email() To check if the string is an email id or not 1340 1340 * @uses is_network_admin() To check if the user is the network admin 1341 * @uses revoke_super_admin() To revoke super admin privile dges1342 * @uses grant_super_admin() To grant super admin privile dges1341 * @uses revoke_super_admin() To revoke super admin privileges 1342 * @uses grant_super_admin() To grant super admin privileges 1343 1343 * @uses is_wp_error() To check if the value retrieved is a {@link WP_Error} 1344 1344 */ … … 1740 1740 1741 1741 // Default value 1742 $ user_ids= array();1742 $retval = array(); 1743 1743 1744 1744 // Only query if nicenames … … 1750 1750 : (array) $user_nicenames; 1751 1751 1752 // Do the query 1753 $users = implode( "', '", array_map( 'trim', $user_nicenames ) ); 1754 $bbp_db = bbp_db(); 1755 $query = "SELECT ID FROM `{$bbp_db->users}` WHERE user_nicename IN ('{$users}')"; 1756 $user_ids = $bbp_db->get_col( $query ); 1757 } 1758 1759 return apply_filters( 'bbp_get_user_ids_from_nicenames', $user_ids, $user_nicenames ); 1752 // Get users 1753 $users = get_users( array( 1754 'nicename__in' => $user_nicenames 1755 ) ); 1756 1757 // Pluck or empty 1758 if ( ! empty( $users ) ) { 1759 $retval = wp_list_pluck( $users, 'ID' ); 1760 } 1761 } 1762 1763 return apply_filters( 'bbp_get_user_ids_from_nicenames', $retval, $user_nicenames ); 1760 1764 } 1761 1765 … … 1773 1777 1774 1778 // Default value 1775 $ user_nicenames= array();1779 $retval = array(); 1776 1780 1777 1781 // Only query if nicenames 1778 1782 if ( ! empty( $user_ids ) ) { 1779 1783 1780 // Get user objects1784 // Get users 1781 1785 $users = get_users( array( 1782 1786 'include' => $user_ids … … 1785 1789 // Pluck or empty 1786 1790 if ( ! empty( $users ) ) { 1787 $ user_nicenames= wp_list_pluck( $users, 'user_nicename' );1791 $retval = wp_list_pluck( $users, 'user_nicename' ); 1788 1792 } 1789 1793 } 1790 1794 1791 return apply_filters( 'bbp_get_user_nicenames_from_ids', $ user_nicenames, $user_ids );1795 return apply_filters( 'bbp_get_user_nicenames_from_ids', $retval, $user_ids ); 1792 1796 } 1793 1797 … … 1814 1818 } 1815 1819 1816 $bbp_db = bbp_db(); 1817 $where = get_posts_by_author_sql( bbp_get_topic_post_type(), true, $user_id ); 1818 $count = (int) $bbp_db->get_var( "SELECT COUNT(*) FROM {$bbp_db->posts} {$where}" ); 1820 $count = count_user_posts( $user_id, bbp_get_topic_post_type(), false ); 1819 1821 // Manually add the user closed topic count, see #2978 and #WP12706 1820 $count = $count + bbp_get_user_closed_topic_count( $user_id );1822 $count = $count + bbp_get_user_closed_topic_count( $user_id ); 1821 1823 1822 1824 return (int) apply_filters( 'bbp_get_user_topic_count_raw', $count, $user_id ); … … 1843 1845 } 1844 1846 1845 $bbp_db = bbp_db(); 1846 $where = get_posts_by_author_sql( bbp_get_reply_post_type(), true, $user_id ); 1847 $count = (int) $bbp_db->get_var( "SELECT COUNT(*) FROM {$bbp_db->posts} {$where}" ); 1847 $count = count_user_posts( $user_id, bbp_get_reply_post_type(), false ); 1848 1848 1849 1849 return (int) apply_filters( 'bbp_get_user_reply_count_raw', $count, $user_id );
Note: See TracChangeset
for help on using the changeset viewer.