wpseek.com
A WordPress-centric search engine for devs and theme authors



filter_default_option › WordPress Function

Since4.7.0
Deprecatedn/a
filter_default_option ( $default_value, $option, $passed_default )
Parameters: (3)
  • (mixed) $default_value Existing default value to return.
    Required: Yes
  • (string) $option Option name.
    Required: Yes
  • (bool) $passed_default Was `get_option()` passed a default value?
    Required: Yes
Returns:
  • (mixed) Filtered default value.
Defined at:
Codex:

Filters the default value for the option.

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


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