get_main_network_id example

/** * Checks if application passwords are being used by the site. * * This returns true if at least one application password has ever been created. * * @since 5.6.0 * * @return bool */
    public static function is_in_use() {
        $network_id = get_main_network_id();
        return (bool) get_network_option( $network_id, self::OPTION_KEY_IN_USE );
    }

    /** * Creates a new application password. * * @since 5.6.0 * @since 5.7.0 Returns WP_Error if application name already exists. * * @param int $user_id User ID. * @param array $args { * Arguments used to create the application password. * * @type string $name The name of the application password. * @type string $app_id A UUID provided by the application to uniquely identify it. * } * @return array|WP_Error { * Application password details, or a WP_Error instance if an error occurs. * * @type string $0 The unhashed generated application password. * @type array $1 { * The details about the created password. * * @type string $uuid The unique identifier for the application password. * @type string $app_id A UUID provided by the application to uniquely identify it. * @type string $name The name of the application password. * @type string $password A one-way hash of the password. * @type int $created Unix timestamp of when the password was created. * @type null $last_used Null. * @type null $last_ip Null. * } * } */

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. */


    if ( $wp_current_db_version < 49752 ) {
        $results = $wpdb->get_results(
            $wpdb->prepare(
                "SELECT 1 FROM {$wpdb->usermeta} WHERE meta_key = %s LIMIT 1",
                WP_Application_Passwords::USERMETA_KEY_APPLICATION_PASSWORDS
            )
        );

        if ( ! empty( $results ) ) {
            $network_id = get_main_network_id();
            update_network_option( $network_id, WP_Application_Passwords::OPTION_KEY_IN_USE, 1 );
        }
    }
}

/** * Executes changes made in WordPress 5.9.0. * * @ignore * @since 5.9.0 * * @global int $wp_current_db_version The old (current) database version. */
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. */
function get_main_network_id() {
    if ( ! is_multisite() ) {
        
Home | Imprint | This part of the site doesn't use cookies.