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_value
mixedrequired- Existing default value to return.
$option
stringrequired- Option name.
$passed_default
boolrequired- Was
get_option()
passed a default value?
Source
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'];
}
Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.