Jetpack::get_site_user_count PHP Method

get_site_user_count() private static method

private static get_site_user_count ( )
    private static function get_site_user_count()
    {
        global $wpdb;
        if (function_exists('wp_is_large_network')) {
            if (wp_is_large_network('users')) {
                return -1;
                // Not a real value but should tell us that we are dealing with a large network.
            }
        }
        if (false === ($user_count = get_transient('jetpack_site_user_count'))) {
            // It wasn't there, so regenerate the data and save the transient
            $user_count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->usermeta} WHERE meta_key = '{$wpdb->prefix}capabilities'");
            set_transient('jetpack_site_user_count', $user_count, DAY_IN_SECONDS);
        }
        return $user_count;
    }

Usage Example

Example #1
0
 /**
  * Get additional stat data to sync to WPCOM
  */
 public static function get_additional_stat_data($prefix = '')
 {
     $return["{$prefix}themes"] = Jetpack::get_parsed_theme_data();
     $return["{$prefix}plugins-extra"] = Jetpack::get_parsed_plugin_data();
     $return["{$prefix}users"] = (int) Jetpack::get_site_user_count();
     $return["{$prefix}site-count"] = 0;
     if (function_exists('get_blog_count')) {
         $return["{$prefix}site-count"] = get_blog_count();
     }
     return $return;
 }
Jetpack