WP_Site_Health::get_autoloaded_options_size()publicWP 6.6.0

Calculates total amount of autoloaded data.

Method of the class: WP_Site_Health{}

No Hooks.

Return

Int. Autoloaded data in bytes.

Usage

$WP_Site_Health = new WP_Site_Health();
$WP_Site_Health->get_autoloaded_options_size();

Changelog

Since 6.6.0 Introduced.

WP_Site_Health::get_autoloaded_options_size() code WP 6.6.2

public function get_autoloaded_options_size() {
	$alloptions = wp_load_alloptions();

	$total_length = 0;

	foreach ( $alloptions as $option_value ) {
		if ( is_array( $option_value ) || is_object( $option_value ) ) {
			$option_value = maybe_serialize( $option_value );
		}
		$total_length += strlen( (string) $option_value );
	}

	return $total_length;
}