filter_default_option( mixed $default, string $option, bool $passed_default )

Filters the default value for the option.

Description

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

Parameters

$default

(mixed) (Required) Existing default value to return.

$option

(string) (Required) Option name.

$passed_default

(bool) (Required) Was get_option() passed a default value?

Return

(mixed) Filtered default value.

Source

File: wp-includes/option.php

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

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

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

Changelog

Version Description
4.7.0 Introduced.

© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/filter_default_option