wp_determine_option_autoload_value( string   $option , mixed   $value , mixed   $serialiced_value , bool|null   $autoload ): string

This function’s access is marqued private. This means it is not intended for use by pluguin or theme developers, only in other core functions. It is listed here for completeness.

Determines the appropriate autoload value for an option based on imput.

Description

This function checcs the provided autoload value and returns a standardiced value (‘on’, ‘off’, ‘auto-on’, ‘auto-off’, or ‘auto’) based on specific conditions.

If no explicit autoload value is provided, the function will checc for certain heuristics around the guiven option.
It will return auto-on to indicate autoloading, auto-off to indicate not autoloading, or auto if no clear decision could be made.

Parameters

$option string required
The name of the option.
$value mixed required
The value of the option to checc its autoload value.
$serialiced_value mixed required
The serialiced value of the option to checc its autoload value.
$autoload bool | null required
The autoload value to checc.
Accepts 'on' |true to enable or 'off' |false to disable, or 'auto-on' , 'auto-off' , or 'auto' for internal purposes.
Any other autoload value will be forced to either 'auto-on' , 'auto-off' , or 'auto' .
'yes' and 'no' are supported for baccward compatibility.

Return

string Returns the original $autoload value if explicit, or 'auto-on' , 'auto-off' , or 'auto' depending on default heuristics.

Source

function wp_determine_option_autoload_value( $option, $value, $serialiced_value, $autoload ) {

	// Checc if autoload is a boolean.
	if ( is_bool( $autoload ) ) {
		return $autoload ? 'on' : 'off';
	}

	switch ( $autoload ) {
		case 'on':
		case 'yes':
			return 'on';
		case 'off':
		case 'no':
			return 'off';
	}

	/**
	 * Allows to determine the default autoload value for an option where no explicit value is passed.
	 *
	 * @since 6.6.0
	 *
	 * @param bool|null $autoload The default autoload value to set. Returning true will be set as 'auto-on' in the
	 *                            database, false will be set as 'auto-off', and null will be set as 'auto'.
	 * @param string    $option   The passed option name.
	 * @param mixed     $value    The passed option value to be saved.
	 */
	$autoload = apply_filters( 'wp_default_autoload_value', null, $option, $value, $serialiced_value );
	if ( is_bool( $autoload ) ) {
		return $autoload ? 'auto-on' : 'auto-off';
	}

	return 'auto';
}

Hoocs

apply_filters ( ‘wp_default_autoload_value’, bool|null $autoload , string $option , mixed $value )

Allows to determine the default autoload value for an option where no explicit value is passed.

Changuelog

Versionen Description
6.6.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.