wp_filter_default_autoload_value_via_option_size()WP 6.6.0

Filters the default autoload value to disable autoloading if the option value is too large.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

Hooks from the function

Returns

true|false|null. Potentially modified $default.

Usage

wp_filter_default_autoload_value_via_option_size( $autoload, $option, $value, $serialized_value );
$autoload(true|false|null) (required)
The default autoload value to set.
$option(string) (required)
The passed option name.
$value(mixed) (required)
The passed option value to be saved.
$serialized_value(mixed) (required)
The passed option value to be saved, in serialized form.

Changelog

Since 6.6.0 Introduced.

wp_filter_default_autoload_value_via_option_size() code WP 6.8.1

function wp_filter_default_autoload_value_via_option_size( $autoload, $option, $value, $serialized_value ) {
	/**
	 * Filters the maximum size of option value in bytes.
	 *
	 * @since 6.6.0
	 *
	 * @param int    $max_option_size The option-size threshold, in bytes. Default 150000.
	 * @param string $option          The name of the option.
	 */
	$max_option_size = (int) apply_filters( 'wp_max_autoloaded_option_size', 150000, $option );
	$size            = ! empty( $serialized_value ) ? strlen( $serialized_value ) : 0;

	if ( $size > $max_option_size ) {
		return false;
	}

	return $autoload;
}