get_network_option 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. * } * } */
                $this->blog_id = (string) BLOGID_CURRENT_SITE;

                return (int) $this->blog_id;
            }
        }

        $site = get_site();
        if ( $site->domain === $this->domain && $site->path === $this->path ) {
            $main_site_id = (int) $site->id;
        } else {

            $main_site_id = get_network_option( $this->id, 'main_site' );
            if ( false === $main_site_id ) {
                $_sites       = get_sites(
                    array(
                        'fields'     => 'ids',
                        'number'     => 1,
                        'domain'     => $this->domain,
                        'path'       => $this->path,
                        'network_id' => $this->id,
                    )
                );
                $main_site_id = ! empty( $_sites ) ? array_shift( $_sites ) : 0;

                

function is_site_meta_supported() {
    global $wpdb;

    if ( ! is_multisite() ) {
        return false;
    }

    $network_id = get_main_network_id();

    $supported = get_network_option( $network_id, 'site_meta_supported', false );
    if ( false === $supported ) {
        $supported = $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->blogmeta}'" ) ? 1 : 0;

        update_network_option( $network_id, 'site_meta_supported', $supported );
    }

    return (bool) $supported;
}

/** * Modifies gmt_offset for smart timezone handling. * * Overrides the gmt_offset option if we have a timezone_string available. * * @since 2.8.0 * * @return float|false Timezone GMT offset, false otherwise. */

function get_blog_count( $network_id = null ) {
    return get_network_option( $network_id, 'blog_count' );
}

/** * Gets a blog post from any site on the network. * * This function is similar to get_post(), except that it can retrieve a post * from any site on the network, not just the current site. * * @since MU (3.0.0) * * @param int $blog_id ID of the blog. * @param int $post_id ID of the post being looked for. * @return WP_Post|null WP_Post object on success, null on failure */

    do_action( 'wp_initialize_site', $new_site$args );

    // Only compute extra hook parameters if the deprecated hook is actually in use.     if ( has_action( 'wpmu_new_blog' ) ) {
        $user_id = ! empty( $args['user_id'] ) ? $args['user_id'] : 0;
        $meta    = ! empty( $args['options'] ) ? $args['options'] : array();

        // WPLANG was passed with `$meta` to the `wpmu_new_blog` hook prior to 5.1.0.         if ( ! array_key_exists( 'WPLANG', $meta ) ) {
            $meta['WPLANG'] = get_network_option( $new_site->network_id, 'WPLANG' );
        }

        /* * Rebuild the data expected by the `wpmu_new_blog` hook prior to 5.1.0 using allowed keys. * The `$allowed_data_fields` matches the one used in `wpmu_create_blog()`. */
        $allowed_data_fields = array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' );
        $meta                = array_merge( array_intersect_key( $dataarray_flip( $allowed_data_fields ) )$meta );

        /** * Fires immediately after a new site is created. * * @since MU (3.0.0) * @deprecated 5.1.0 Use {@see 'wp_initialize_site'} instead. * * @param int $site_id Site ID. * @param int $user_id User ID. * @param string $domain Site domain. * @param string $path Site path. * @param int $network_id Network ID. Only relevant on multi-network installations. * @param array $meta Meta data. Used to set initial site options. */

function get_site_option( $option$default_value = false, $deprecated = true ) {
    return get_network_option( null, $option$default_value );
}

/** * Adds a new option for the current network. * * Existing options will not be updated. Note that prior to 3.3 this wasn't the case. * * @since 2.8.0 * @since 4.4.0 Modified into wrapper for add_network_option() * * @see add_network_option() * * @param string $option Name of the option to add. Expected to not be SQL-escaped. * @param mixed $value Option value, can be anything. Expected to not be SQL-escaped. * @return bool True if the option was added, false otherwise. */
_doing_it_wrong(
            __FUNCTION__,
            sprintf(
                /* translators: %s: $network_id */
                __( 'Unable to pass %s if not using multisite.' ),
                '<code>$network_id</code>'
            ),
            '6.0.0'
        );
    }

    return (int) get_network_option( $network_id, 'user_count', -1 );
}

/** * Updates the total count of users on the site if live user counting is enabled. * * @since 6.0.0 * * @param int|null $network_id ID of the network. Defaults to the current network. * @return bool Whether the update was successful. */
function wp_maybe_update_user_counts( $network_id = null ) {
    
Home | Imprint | This part of the site doesn't use cookies.