filter_default_option() WordPress Function
This function allows you to override the default option for a specified filter. This is useful if you want to change the default behavior of a filter for your entire site.
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']; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |