get_network example


function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
    if ( ! is_wp_error( $errors ) ) {
        $errors = new WP_Error();
    }

    $current_network = get_network();
    // Site name.     if ( ! is_subdomain_install() ) {
        echo '<label for="blogname">' . __( 'Site Name (subdirectory only):' ) . '</label>';
    } else {
        echo '<label for="blogname">' . __( 'Site Domain (subdomain only):' ) . '</label>';
    }

    $errmsg_blogname      = $errors->get_error_message( 'blogname' );
    $errmsg_blogname_aria = '';
    if ( $errmsg_blogname ) {
        $errmsg_blogname_aria = 'wp-signup-blogname-error ';
        

function network_site_url( $path = '', $scheme = null ) {
    if ( ! is_multisite() ) {
        return site_url( $path$scheme );
    }

    $current_network = get_network();

    if ( 'relative' === $scheme ) {
        $url = $current_network->path;
    } else {
        $url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme );
    }

    if ( $path && is_string( $path ) ) {
        $url .= ltrim( $path, '/' );
    }

    
if ( isset( $blog['email'] ) && '' === trim( $blog['email'] ) ) {
        wp_die( __( 'Missing email address.' ) );
    }

    $email = sanitize_email( $blog['email'] );
    if ( ! is_email( $email ) ) {
        wp_die( __( 'Invalid email address.' ) );
    }

    if ( is_subdomain_install() ) {
        $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', get_network()->domain );
        $path      = get_network()->path;
    } else {
        $newdomain = get_network()->domain;
        $path      = get_network()->path . $domain . '/';
    }

    $password = 'N/A';
    $user_id  = email_exists( $email );
    if ( ! $user_id ) { // Create a new user with a random password.         /** * Fires immediately before a new user is created via the network site-new.php page. * * @since 4.5.0 * * @param string $email Email of the non-existent user. */

function ms_allowed_http_request_hosts( $is_external$host ) {
    global $wpdb;
    static $queried = array();
    if ( $is_external ) {
        return $is_external;
    }
    if ( get_network()->domain === $host ) {
        return true;
    }
    if ( isset( $queried[ $host ] ) ) {
        return $queried[ $host ];
    }
    $queried[ $host ] = (bool) $wpdb->get_var( $wpdb->prepare( "SELECT domain FROM $wpdb->blogs WHERE domain = %s LIMIT 1", $host ) );
    return $queried[ $host ];
}

/** * A wrapper for PHP's parse_url() function that handles consistency in the return values * across PHP versions. * * PHP 5.4.7 expanded parse_url()'s ability to handle non-absolute URLs, including * schemeless and relative URLs with "://" in the path. This function works around * those limitations providing a standard output on PHP 5.2~5.4+. * * Secondly, across various PHP versions, schemeless URLs containing a ":" in the query * are being handled inconsistently. This function works around those differences as well. * * @since 4.4.0 * @since 4.7.0 The `$component` parameter was added for parity with PHP's `parse_url()`. * * @link https://www.php.net/manual/en/function.parse-url.php * * @param string $url The URL to parse. * @param int $component The specific component to retrieve. Use one of the PHP * predefined constants to specify which one. * Defaults to -1 (= return all parts as an array). * @return mixed False on parse failure; Array of URL components on success; * When a specific component has been requested: null if the component * doesn't exist in the given URL; a string or - in the case of * PHP_URL_PORT - integer when it does. See parse_url()'s return values. */

function get_current_network_id() {
    if ( ! is_multisite() ) {
        return 1;
    }

    $current_network = get_network();

    if ( ! isset( $current_network->id ) ) {
        return get_main_network_id();
    }

    return absint( $current_network->id );
}

/** * Attempts an early load of translations. * * Used for errors encountered during the initial loading process, before * the locale has been properly detected and loaded. * * Designed for unusual load sequences (like setup-config.php) or for when * the script will then terminate with an error, otherwise there is a risk * that a file can be double-included. * * @since 3.4.0 * @access private * * @global WP_Textdomain_Registry $wp_textdomain_registry WordPress Textdomain Registry. * @global WP_Locale $wp_locale WordPress date and time locale object. */
$errors = new WP_Error();
    if ( '' === $domain ) {
        $errors->add( 'empty_domain', __( 'You must provide a domain name.' ) );
    }
    if ( '' === $site_name ) {
        $errors->add( 'empty_sitename', __( 'You must provide a name for your network of sites.' ) );
    }

    // Check for network collision.     $network_exists = false;
    if ( is_multisite() ) {
        if ( get_network( $network_id ) ) {
            $errors->add( 'siteid_exists', __( 'The network already exists.' ) );
        }
    } else {
        if ( $network_id === (int) $wpdb->get_var(
            $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id )
        ) ) {
            $errors->add( 'siteid_exists', __( 'The network already exists.' ) );
        }
    }

    if ( ! is_email( $email ) ) {
        

function wpmu_validate_blog_signup( $blogname$blog_title$user = '' ) {
    global $wpdb$domain;

    $current_network = get_network();
    $base            = $current_network->path;

    $blog_title = strip_tags( $blog_title );

    $errors        = new WP_Error();
    $illegal_names = get_site_option( 'illegal_names' );
    if ( false == $illegal_names ) {
        $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
        add_site_option( 'illegal_names', $illegal_names );
    }

    
if ( ! current_user_can( 'delete_site' ) ) {
    wp_die( __( 'Sorry, you are not allowed to delete this site.' ) );
}

if ( isset( $_GET['h'] ) && '' !== $_GET['h'] && false !== get_option( 'delete_blog_hash' ) ) {
    if ( hash_equals( get_option( 'delete_blog_hash' )$_GET['h'] ) ) {
        wpmu_delete_blog( get_current_blog_id() );
        wp_die(
            sprintf(
                /* translators: %s: Network title. */
                __( 'Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.' ),
                get_network()->site_name
            )
        );
    } else {
        wp_die( __( 'Sorry, the link you clicked is stale. Please select another option.' ) );
    }
}

$blog = get_site();
$user = wp_get_current_user();

// Used in the HTML title tag.
?> <div class="wrap"> <h1><?php echo esc_html( $title ); ?></h1> <form method="post" action="settings.php" novalidate="novalidate"> <?php wp_nonce_field( 'siteoptions' ); ?> <h2><?php _e( 'Operational Settings' ); ?></h2> <table class="form-table" role="presentation"> <tr> <th scope="row"><label for="site_name"><?php _e( 'Network Title' ); ?></label></th> <td> <input name="site_name" type="text" id="site_name" class="regular-text" value="<?php echo esc_attr( get_network()->site_name ); ?>" /> </td> </tr> <tr> <th scope="row"><label for="admin_email"><?php _e( 'Network Admin Email' ); ?></label></th> <td> <input name="new_admin_email" type="email" id="admin_email" aria-describedby="admin-email-desc" class="regular-text" value="<?php echo esc_attr( get_site_option( 'admin_email' ) ); ?>" /> <p class="description" id="admin-email-desc"> <?php _e( 'This address is used for admin purposes. If you change this, an email will be sent to your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?> </p> <?php
define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . '/blogs.dir/' . $site_id . '/files/' );
        }
    }
}

/** * Defines Multisite cookie constants. * * @since 3.0.0 */
function ms_cookie_constants() {
    $current_network = get_network();

    /** * @since 1.2.0 */
    if ( ! defined( 'COOKIEPATH' ) ) {
        define( 'COOKIEPATH', $current_network->path );
    }

    /** * @since 1.5.0 */
    


    $site = get_site( $site_id );
    if ( ! $site ) {
        return new WP_Error( 'site_invalid_id', __( 'Site with the ID does not exist.' ) );
    }

    if ( wp_is_site_initialized( $site ) ) {
        return new WP_Error( 'site_already_initialized', __( 'The site appears to be already initialized.' ) );
    }

    $network = get_network( $site->network_id );
    if ( ! $network ) {
        $network = get_network();
    }

    $args = wp_parse_args(
        $args,
        array(
            'user_id' => 0,
            /* translators: %d: Site ID. */
            'title'   => sprintf( __( 'Site %d' )$site->id ),
            'options' => array(),
            
$this->networks = $network_ids;
            return $this->networks;
        }

        if ( $this->query_vars['update_network_cache'] ) {
            _prime_network_caches( $network_ids );
        }

        // Fetch full network objects from the primed cache.         $_networks = array();
        foreach ( $network_ids as $network_id ) {
            $_network = get_network( $network_id );
            if ( $_network ) {
                $_networks[] = $_network;
            }
        }

        /** * Filters the network query results. * * @since 4.6.0 * * @param WP_Network[] $_networks An array of WP_Network objects. * @param WP_Network_Query $query Current instance of WP_Network_Query (passed by reference). */

function get_main_site_id( $network_id = null ) {
    if ( ! is_multisite() ) {
        return get_current_blog_id();
    }

    $network = get_network( $network_id );
    if ( ! $network ) {
        return 0;
    }

    return $network->site_id;
}

/** * Determines whether a network is the main network of the Multisite installation. * * @since 3.7.0 * * @param int $network_id Optional. Network ID to test. Defaults to current network. * @return bool True if $network_id is the main network, or if not running Multisite. */

function get_dashboard_blog() {
    _deprecated_function( __FUNCTION__, '3.1.0', 'get_site()' );
    if ( $blog = get_site_option( 'dashboard_blog' ) ) {
        return get_site( $blog );
    }

    return get_site( get_network()->site_id );
}

/** * Generates a random password. * * @since MU (3.0.0) * @deprecated 3.0.0 Use wp_generate_password() * @see wp_generate_password() * * @param int $len Optional. The length of password to generate. Default 8. */
if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) {
            return WP_CONTENT_DIR . '/blog-deleted.php';
        } else {
            wp_die( __( 'This site is no longer available.' ), '', array( 'response' => 410 ) );
        }
    }

    if ( '2' == $blog->deleted ) {
        if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) ) {
            return WP_CONTENT_DIR . '/blog-inactive.php';
        } else {
            $admin_email = str_replace( '@', ' AT ', get_site_option( 'admin_email', 'support@' . get_network()->domain ) );
            wp_die(
                sprintf(
                    /* translators: %s: Admin email link. */
                    __( 'This site has not been activated yet. If you are having problems activating your site, please contact %s.' ),
                    sprintf( '<a href="mailto:%1$s">%1$s</a>', $admin_email )
                )
            );
        }
    }

    if ( '1' == $blog->archived || '1' == $blog->spam ) {
        
Home | Imprint | This part of the site doesn't use cookies.