Usage
nebula()->get_option($option, $fallback)
Parameters
$option
(Required) (String) The name of the option.
Default: None
$fallback
(Optional) (String) The data to use if the option is not set or false.
Default: false
Parameter Notes
For a list of core Nebula option names, refer to the default_options documentation.
Examples
Echo a string-based option.
<?php echo nebula()->option('ga_tracking_id'); ?>
String-based with a default if false.
<?php echo nebula()->option('fax_number', 'No fax number'); ?>
Check if a boolean option is enabled.
if ( nebula()->option('scss') ){
//Do something if Sass is enabled.
}
Check if a boolean option is disabled.
if ( !nebula()->option('scss') ){
//Do something if Sass is disabled
}
Source File
Located in /libs/Options/Options.php on line 46.
No Hooks
This function does not have any filters or actions available. Request one? public function get_option($option, $fallback=null){
$nebula_options = get_option('nebula_options');
//Always return the exact, unfiltered value for WP-CLI
if ( $this->is_cli() ){
return $nebula_options[$option];
}
//If the value is not set or false, return the provided fallback value
if ( empty($nebula_options[$option]) ){
return $fallback;
}
//Normalize boolean-like strings/numbers to bool type
$boolean_value = filter_var($nebula_options[$option], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
if ( $boolean_value !== null ){ //This means it is a boolean value of true or false
return $boolean_value;
}
return $nebula_options[$option];
}
Override
This function can not be short-circuited with an override filter. Request one?