apply_filters( "default_option_{$option}", mixed $default_value, string $option, bool $passed_default )
- Since
- 3.4.0, 4.4.0, 4.7.0
Filters the default value for an option.
Description
The dynamic portion of the hook name, $option, refers to the option name.
Compatibility
- WordPress
- since 4.7.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$default_valuemixed- The default value to return if the option does not exist in the database.
$optionstring- Option name.
$passed_defaultbool- Was
get_option()passed a default value?
Where this hook fires · 5
wp-includes/option.php:194get_option()wp-includes/option.php:208get_option()wp-includes/option.php:221get_option()wp-includes/option.php:920update_option()wp-includes/option.php:1115add_option()
Source code
* * @param mixed $default_value The default value to return if the option does not exist * in the database. * @param string $option Option name. * @param bool $passed_default Was `get_option()` passed a default value? */ return apply_filters( "default_option_{$option}", $default_value, $option, $passed_default ); } $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values. if ( is_object( $row ) ) {Changelog
Introduced in 3.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
4.7.0
The
$passed_default parameter was added to distinguish between a false value and the default parameter value.from the docblock4.4.0
The
$option parameter was added.from the docblock3.4.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.