filter_default_option()WP 4.7.0

Filters the default value for the option.

For settings which register a default setting in register_setting(), this function is added as a filter to default_option_{$option}.

No Hooks.

Return

Mixed. Filtered default value.

Usage

filter_default_option( $default_value, $option, $passed_default );
$default_value(mixed) (required)
Existing default value to return.
$option(string) (required)
Option name.
$passed_default(true|false) (required)
Was get_option() a default value?

Changelog

Since 4.7.0 Introduced.

filter_default_option() code WP 6.6.2

function filter_default_option( $default_value, $option, $passed_default ) {
	if ( $passed_default ) {
		return $default_value;
	}

	$registered = get_registered_settings();
	if ( empty( $registered[ $option ] ) ) {
		return $default_value;
	}

	return $registered[ $option ]['default'];
}