Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/14/2017 02:14:39 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Statistics: Improvements to "At a Glance" integration.

  • Prefer bbp_get_total_users() over count_users() to speed up loading
  • Don't include empty array values
  • Don't link to areas the current user cannot access
  • Skip if current user cannot at least spectate (blocked or no access)

Fixes #2770.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/core/abstraction.php

    r6438 r6542  
    169169function bbp_is_large_install() {
    170170
    171     // Default to false
    172     $retval = false;
     171    // Multisite has a function specifically for this
     172    $retval = function_exists( 'wp_is_large_network' )
     173        ? wp_is_large_network( 'users' )
     174        : ( bbp_get_total_users() > 10000 );
    173175
    174     // Multisite has a function specifically for this
    175     if ( function_exists( 'wp_is_large_network' ) ) {
    176         $retval = wp_is_large_network( 'users' );
    177     } else {
    178         $bbp_db = bbp_db();
    179         $count  = $bbp_db->get_var( "SELECT COUNT(ID) as c FROM {$bbp_db->users} WHERE user_status = '0'" );
    180         $retval = apply_filters( 'wp_is_large_network', ( $count > 10000 ), 'users', $count );
    181     }
     176    // Filter & return
     177    return (bool) apply_filters( 'bbp_is_large_install', $retval );
     178}
    182179
    183     return (bool) $retval;
     180/**
     181 * Get the total number of users on the forums
     182 *
     183 * @since 2.0.0 bbPress (r2769)
     184 *
     185 * @uses apply_filters() Calls 'bbp_get_total_users' with number of users
     186 * @return int Total number of users
     187 */
     188function bbp_get_total_users() {
     189    $bbp_db = bbp_db();
     190    $count  = $bbp_db->get_var( "SELECT COUNT(ID) as c FROM {$bbp_db->users} WHERE user_status = '0'" );
     191
     192    // Filter & return
     193    return (int) apply_filters( 'bbp_get_total_users', (int) $count );
    184194}
Note: See TracChangeset for help on using the changeset viewer.