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

Filter the default value for the option.


Description Description

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


Parameters 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?


Top ↑

Return Return

(mixed) Filtered default value.


Top ↑

Source 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'];
}

Top ↑

Changelog Changelog

Changelog
Version Description
4.7.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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