WP_Network example

if ( empty( $_network ) || is_wp_error( $_network ) ) {
                $_network = -1;
            }

            wp_cache_add( $network_id$_network, 'networks' );
        }

        if ( is_numeric( $_network ) ) {
            return false;
        }

        return new WP_Network( $_network );
    }

    /** * Creates a new WP_Network object. * * Will populate object properties from the object provided and assign other * default properties based on that information. * * @since 4.4.0 * * @param WP_Network|object $network A network object. */

function get_network( $network = null ) {
    global $current_site;
    if ( empty( $network ) && isset( $current_site ) ) {
        $network = $current_site;
    }

    if ( $network instanceof WP_Network ) {
        $_network = $network;
    } elseif ( is_object( $network ) ) {
        $_network = new WP_Network( $network );
    } else {
        $_network = WP_Network::get_instance( $network );
    }

    if ( ! $_network ) {
        return null;
    }

    /** * Fires after a network is retrieved. * * @since 4.6.0 * * @param WP_Network $_network Network data. */
$wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php. $wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id );
$table_prefix       = $wpdb->get_blog_prefix();
$_wp_switched_stack = array();
$switched           = false;

// Need to init cache again after blog_id is set. wp_start_object_cache();

if ( ! $current_site instanceof WP_Network ) {
    $current_site = new WP_Network( $current_site );
}

if ( ! $current_blog instanceof WP_Site ) {
    $current_blog = new WP_Site( $current_blog );
}

// Define upload directory constants. ms_upload_constants();

/** * Fires after the current site and network have been detected and loaded * in multisite's bootstrap. * * @since 4.6.0 */
Home | Imprint | This part of the site doesn't use cookies.