filter_default_option

Filter the default value for the option.

Description

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

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

Parameters (3)

0. $default (mixed)
Existing default value to return.
1. $option (string)
Option name.
2. $passed_default (bool)
Was get_option() passed a default value?

Usage

  1. if ( !function_exists( 'filter_default_option' ) ) { 
  2. require_once ABSPATH . WPINC . '/option.php'; 
  3.  
  4. // Existing default value to return. 
  5. $default = null; 
  6.  
  7. // Option name. 
  8. $option = ''; 
  9.  
  10. // Was `get_option()` passed a default value? 
  11. $passed_default = true; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = filter_default_option($default, $option, $passed_default); 
  15.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/option.php  
  1. function filter_default_option( $default, $option, $passed_default ) { 
  2. if ( $passed_default ) { 
  3. return $default; 
  4.  
  5. $registered = get_registered_settings(); 
  6. if ( empty( $registered[ $option ] ) ) { 
  7. return $default; 
  8.  
  9. return $registered[ $option ]['default'];