Skip to:
Content

BuddyPress.org

Ticket #5815: 5815.01.patch

File 5815.01.patch, 990 bytes (added by r-a-y, 6 years ago)
  • src/bp-blogs/bp-blogs-functions.php

     
    11271127/**
    11281128 * Get the total number of blogs being tracked by BP for a specific user.
    11291129 *
     1130 * @since BuddyPress (1.2.0)
     1131 *
    11301132 * @param int $user_id ID of the user being queried. Default: on a user page,
    11311133 *        the displayed user. Otherwise, the logged-in user.
    11321134 * @return int $count Total blog count for the user.
    11331135 */
    11341136function bp_blogs_total_blogs_for_user( $user_id = 0 ) {
    1135 
    1136         if ( empty( $user_id ) )
     1137        if ( empty( $user_id ) ) {
    11371138                $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id();
     1139        }
     1140
     1141        // no user ID? do not attempt to look at cache
     1142        if ( empty( $user_id ) ) {
     1143                return 0;
     1144        }
    11381145
    11391146        if ( !$count = wp_cache_get( 'bp_total_blogs_for_user_' . $user_id, 'bp' ) ) {
    11401147                $count = BP_Blogs_Blog::total_blog_count_for_user( $user_id );