update_network_option example

'6.0.0'
        );
    }

    $query = "SELECT COUNT(ID) as c FROM $wpdb->users";
    if ( is_multisite() ) {
        $query .= " WHERE spam = '0' AND deleted = '0'";
    }

    $count = $wpdb->get_var( $query );

    return update_network_option( $network_id, 'user_count', $count );
}

/** * Schedules a recurring recalculation of the total count of users. * * @since 6.0.0 */
function wp_schedule_update_user_counts() {
    if ( ! is_main_site() ) {
        return;
    }

    
$passwords   = static::get_user_application_passwords( $user_id );
        $passwords[] = $new_item;
        $saved       = static::set_user_application_passwords( $user_id$passwords );

        if ( ! $saved ) {
            return new WP_Error( 'db_error', __( 'Could not save application password.' ) );
        }

        $network_id = get_main_network_id();
        if ( ! get_network_option( $network_id, self::OPTION_KEY_IN_USE ) ) {
            update_network_option( $network_id, self::OPTION_KEY_IN_USE, true );
        }

        /** * Fires when an application password is created. * * @since 5.6.0 * * @param int $user_id The user ID. * @param array $new_item { * 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. * } * @param string $new_password The unhashed generated application password. * @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. * } */
$_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;

                update_network_option( $this->id, 'main_site', $main_site_id );
            }
        }

        $this->blog_id = (string) $main_site_id;

        return (int) $this->blog_id;
    }

    /** * Sets the site name assigned to the network if one has not been populated. * * @since 4.4.0 */

function update_site_option( $option$value ) {
    return update_network_option( null, $option$value );
}

/** * Retrieves a network's option value based on the option name. * * @since 4.4.0 * * @see get_option() * * @global wpdb $wpdb WordPress database abstraction object. * * @param int $network_id ID of the network. Can be null to default to the current network ID. * @param string $option Name of the option to retrieve. Expected to not be SQL-escaped. * @param mixed $default_value Optional. Value to return if the option doesn't exist. Default false. * @return mixed Value set for the option. */
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. */
$count = get_sites(
        array(
            'network_id'             => $network_id,
            'spam'                   => 0,
            'deleted'                => 0,
            'archived'               => 0,
            'count'                  => true,
            'update_site_meta_cache' => false,
        )
    );

    update_network_option( $network_id, 'blog_count', $count );
}

/** * Updates the network-wide user count. * * @since 3.7.0 * @since 4.8.0 The `$network_id` parameter has been added. * @since 6.0.0 This function is now a wrapper for wp_update_user_counts(). * * @param int|null $network_id ID of the network. Default is the current network. */
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. */
Home | Imprint | This part of the site doesn't use cookies.