get_current_network_id example

$blogs           = (array) get_blogs_of_user( $user->ID );
        $struct          = array();
        $primary_blog_id = 0;
        $active_blog     = get_active_blog_for_user( $user->ID );
        if ( $active_blog ) {
            $primary_blog_id = (int) $active_blog->blog_id;
        }

        foreach ( $blogs as $blog ) {
            // Don't include blogs that aren't hosted at this site.             if ( get_current_network_id() != $blog->site_id ) {
                continue;
            }

            $blog_id = $blog->userblog_id;

            switch_to_blog( $blog_id );

            $is_admin   = current_user_can( 'manage_options' );
            $is_primary = ( (int) $blog_id === $primary_blog_id );

            $struct[] = array(
                

function wp_load_core_site_options( $network_id = null ) {
    global $wpdb;

    if ( ! is_multisite() || wp_installing() ) {
        return;
    }

    if ( empty( $network_id ) ) {
        $network_id = get_current_network_id();
    }

    $core_options = array( 'site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting' );

    if ( wp_using_ext_object_cache() ) {
        $cache_keys = array();
        foreach ( $core_options as $option ) {
            $cache_keys[] = "{$network_id}:{$option}";
        }
        wp_cache_get_multiple( $cache_keys, 'site-options' );

        

                $action = sprintf(
                    '<a href="%1$s" class="install-now" data-slug="%2$s" data-name="%2$s" aria-label="%3$s">%3$s</a>',
                    esc_url( $url ),
                    esc_attr( $plugin_slug ),
                    __( 'Install Now' )
                );
            } else {
                $action = sprintf(
                    /* translators: %s: URL to Press This bookmarklet on the main site. */
                    __( 'Press This is not installed. Please install Press This from <a href="%s">the main site</a>.' ),
                    get_admin_url( get_current_network_id(), 'press-this.php' )
                );
            }
        }
        wp_die(
            __( 'The Press This plugin is required.' ) . '<br />' . $action,
            __( 'Installation Required' ),
            200
        );
    } else {
        wp_die(
            __( 'Press This is not available. Please contact your site administrator.' ),
            

    $meta = apply_filters( 'add_signup_meta', $meta_defaults );

    $blog_id = wpmu_create_blog( $domain$path$blog_title$current_user->ID, $metaget_current_network_id() );

    if ( is_wp_error( $blog_id ) ) {
        return false;
    }

    confirm_another_blog_signup( $domain$path$blog_title$current_user->user_login, $current_user->user_email, $meta$blog_id );
    return true;
}

/** * Shows a message confirming that the new site has been created. * * @since MU (3.0.0) * @since 4.4.0 Added the `$blog_id` parameter. * * @param string $domain The domain URL. * @param string $path The site root path. * @param string $blog_title The site title. * @param string $user_name The username. * @param string $user_email The user's email address. * @param array $meta Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup(). * @param int $blog_id The site ID. */
/** * Fires after a new user has been created via the network site-new.php page. * * @since 4.4.0 * * @param int $user_id ID of the newly created user. */
        do_action( 'network_site_new_created_user', $user_id );
    }

    $wpdb->hide_errors();
    $id = wpmu_create_blog( $newdomain$path$title$user_id$metaget_current_network_id() );
    $wpdb->show_errors();

    if ( ! is_wp_error( $id ) ) {
        if ( ! is_super_admin( $user_id ) && ! get_user_option( 'primary_blog', $user_id ) ) {
            update_user_option( $user_id, 'primary_blog', $id, true );
        }

        wpmu_new_site_admin_notification( $id$user_id );
        wpmu_welcome_notification( $id$user_id$password$title, array( 'public' => 1 ) );
        wp_redirect(
            add_query_arg(
                

function wp_insert_site( array $data ) {
    global $wpdb;

    $now = current_time( 'mysql', true );

    $defaults = array(
        'domain'       => '',
        'path'         => '/',
        'network_id'   => get_current_network_id(),
        'registered'   => $now,
        'last_updated' => $now,
        'public'       => 1,
        'archived'     => 0,
        'mature'       => 0,
        'spam'         => 0,
        'deleted'      => 0,
        'lang_id'      => 0,
    );

    $prepared_data = wp_prepare_site_data( $data$defaults );
    

            global $wp_db_version;
            update_site_option( 'wpmu_upgrade_site', $wp_db_version );
        }

        $site_ids = get_sites(
            array(
                'spam'                   => 0,
                'deleted'                => 0,
                'archived'               => 0,
                'network_id'             => get_current_network_id(),
                'number'                 => 5,
                'offset'                 => $n,
                'fields'                 => 'ids',
                'order'                  => 'DESC',
                'orderby'                => 'id',
                'update_site_meta_cache' => false,
            )
        );
        if ( empty( $site_ids ) ) {
            echo '<p>' . __( 'All done!' ) . '</p>';
            break;
        }

function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) {
    global $wpdb;

    if ( ! empty( $deprecated ) ) {
        _deprecated_argument( __FUNCTION__, 'MU' ); // Never used.     }

    return $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", get_current_network_id()$start$quantity ), ARRAY_A );
}

/** * Handler for updating the site's last updated date when a post is published or * an already published post is changed. * * @since 3.3.0 * * @param string $new_status The new post status. * @param string $old_status The old post status. * @param WP_Post $post Post object. */

function can_edit_network( $network_id ) {
    if ( get_current_network_id() === (int) $network_id ) {
        $result = true;
    } else {
        $result = false;
    }

    /** * Filters whether this network can be edited from this page. * * @since 3.1.0 * * @param bool $result Whether the network can be edited from this page. * @param int $network_id The network ID to check. */
esc_url( $url ),
                        esc_attr( $plugin_slug ),
                        esc_attr( $data[0] ),
                        /* translators: %s: Importer name. */
                        esc_attr( sprintf( _x( 'Install %s now', 'plugin' )$data[0] ) ),
                        __( 'Install Now' )
                    );
                } else {
                    $action = sprintf(
                        /* translators: %s: URL to Import screen on the main site. */
                        __( 'This importer is not installed. Please install importers from <a href="%s">the main site</a>.' ),
                        get_admin_url( get_current_network_id(), 'import.php' )
                    );
                }
            }
        } else {
            $url    = add_query_arg(
                array(
                    'import' => $importer_id,
                ),
                self_admin_url( 'admin.php' )
            );
            $action = sprintf(
                

function get_blog_list( $start = 0, $num = 10, $deprecated = '' ) {
    _deprecated_function( __FUNCTION__, '3.0.0', 'wp_get_sites()' );

    global $wpdb;
    $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", get_current_network_id() ), ARRAY_A );

    $blog_list = array();
    foreach ( (array) $blogs as $details ) {
        $blog_list[ $details['blog_id'] ] = $details;
        $blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->get_blog_prefix( $details['blog_id'] ). "posts WHERE post_status='publish' AND post_type='post'" );
    }

    if ( ! $blog_list ) {
        return array();
    }

    
if ( ! is_wp_error( $result ) ) {
            update_user_meta( $user_id, 'primary_blog', $first_blog->userblog_id );
            $primary = $first_blog;
        }
    }

    if ( ( ! is_object( $primary ) ) || ( 1 == $primary->archived || 1 == $primary->spam || 1 == $primary->deleted ) ) {
        $blogs = get_blogs_of_user( $user_id, true ); // If a user's primary blog is shut down, check their other blogs.         $ret   = false;
        if ( is_array( $blogs ) && count( $blogs ) > 0 ) {
            foreach ( (array) $blogs as $blog_id => $blog ) {
                if ( get_current_network_id() != $blog->site_id ) {
                    continue;
                }
                $details = get_site( $blog_id );
                if ( is_object( $details ) && 0 == $details->archived && 0 == $details->spam && 0 == $details->deleted ) {
                    $ret = $details;
                    if ( get_user_meta( $user_id, 'primary_blog', true ) != $blog_id ) {
                        update_user_meta( $user_id, 'primary_blog', $blog_id );
                    }
                    if ( ! get_user_meta( $user_id, 'source_domain', true ) ) {
                        update_user_meta( $user_id, 'source_domain', $details->domain );
                    }
                    
$_REQUEST['orderby'] = '';
            }
            if ( ! isset( $_REQUEST['order'] ) ) {
                $_GET['order']     = 'DESC';
                $_REQUEST['order'] = 'DESC';
            }
        }

        $args = array(
            'number'     => (int) $per_page,
            'offset'     => (int) ( ( $pagenum - 1 ) * $per_page ),
            'network_id' => get_current_network_id(),
        );

        if ( empty( $s ) ) {
            // Nothing to do.         } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s )
            || preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s )
            || preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s )
            || preg_match( '/^[0-9]{1,3}\.$/', $s )
        ) {
            // IPv4 address.             $sql = $wpdb->prepare(
                "

function is_main_network( $network_id = null ) {
    if ( ! is_multisite() ) {
        return true;
    }

    if ( null === $network_id ) {
        $network_id = get_current_network_id();
    }

    $network_id = (int) $network_id;

    return ( get_main_network_id() === $network_id );
}

/** * Gets the main network ID. * * @since 4.3.0 * * @return int The ID of the main network. */
Home | Imprint | This part of the site doesn't use cookies.