get_blog_count example


function get_sitestats() {
    $stats = array(
        'blogs' => get_blog_count(),
        'users' => get_user_count(),
    );

    return $stats;
}

/** * Gets one of a user's active blogs. * * Returns the user's primary blog, if they have one and * it is active. If it's inactive, function returns another * active blog of the user. If none are found, the user * is added as a Subscriber to the Dashboard Blog and that blog * is returned. * * @since MU (3.0.0) * * @param int $user_id The unique ID of the user * @return WP_Site|void The blog object */
set_site_transient( 'update_core', $current );

    if ( method_exists( $wpdb, 'db_server_info' ) ) {
        $mysql_version = $wpdb->db_server_info();
    } elseif ( method_exists( $wpdb, 'db_version' ) ) {
        $mysql_version = preg_replace( '/[^0-9.].*/', '', $wpdb->db_version() );
    } else {
        $mysql_version = 'N/A';
    }

    if ( is_multisite() ) {
        $num_blogs         = get_blog_count();
        $wp_install        = network_site_url();
        $multisite_enabled = 1;
    } else {
        $multisite_enabled = 0;
        $num_blogs         = 1;
        $wp_install        = home_url( '/' );
    }

    $extensions = get_loaded_extensions();
    sort( $extensions, SORT_STRING | SORT_FLAG_CASE );
    $query = array(
        
$network_query = new WP_Network_Query();
            $network_ids   = $network_query->query(
                array(
                    'fields'        => 'ids',
                    'number'        => 100,
                    'no_found_rows' => false,
                )
            );

            $site_count = 0;
            foreach ( $network_ids as $network_id ) {
                $site_count += get_blog_count( $network_id );
            }

            $info['wp-core']['fields']['site_count'] = array(
                'label' => __( 'Site count' ),
                'value' => $site_count,
            );

            $info['wp-core']['fields']['network_count'] = array(
                'label' => __( 'Network count' ),
                'value' => $network_query->found_networks,
            );
        }
function wp_network_dashboard_right_now() {
    $actions = array();

    if ( current_user_can( 'create_sites' ) ) {
        $actions['create-site'] = '<a href="' . network_admin_url( 'site-new.php' ) . '">' . __( 'Create a New Site' ) . '</a>';
    }
    if ( current_user_can( 'create_users' ) ) {
        $actions['create-user'] = '<a href="' . network_admin_url( 'user-new.php' ) . '">' . __( 'Create a New User' ) . '</a>';
    }

    $c_users = get_user_count();
    $c_blogs = get_blog_count();

    /* translators: %s: Number of users on the network. */
    $user_text = sprintf( _n( '%s user', '%s users', $c_users )number_format_i18n( $c_users ) );
    /* translators: %s: Number of sites on the network. */
    $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs )number_format_i18n( $c_blogs ) );

    /* translators: 1: Text indicating the number of sites on the network, 2: Text indicating the number of users on the network. */
    $sentence = sprintf( __( 'You have %1$s and %2$s.' )$blog_text$user_text );

    if ( $actions ) {
        echo '<ul class="subsubsub">';
        

    if ( apply_filters( 'do_mu_upgrade', true ) ) {
        $c = get_blog_count();

        /* * If there are 50 or fewer sites, run every time. Otherwise, throttle to reduce load: * attempt to do no more than threshold value, with some +/- allowed. */
        if ( $c <= 50 || ( $c > 50 && mt_rand( 0, (int) ( $c / 50 ) ) === 1 ) ) {
            require_once ABSPATH . WPINC . '/http.php';
            $response = wp_remote_get(
                admin_url( 'upgrade.php?step=1' ),
                array(
                    'timeout'     => 120,
                    
Home | Imprint | This part of the site doesn't use cookies.