LLMS_Abstract_Options_Data::get_option( string $name, mixed $default = false )
Retrieve the value of an option from the database
Parameters Parameters
- $name
-
(string) (Required) Option name (unprefixed).
- $default
-
(mixed) (Optional) Default value to use if no option is found.
Default value: false
Return Return
(mixed) The option value.
Source Source
File: includes/abstracts/llms.abstract.options.data.php
public function get_option( $name, $default = false ) {
$full_name = $this->get_option_name( $name );
// If the class is version 1, use the old method.
if ( 1 === $this->version ) {
// If only one argument is passed switch the default to the old argument default (an empty string).
$default = 1 === func_num_args() ? '' : $default;
return $this->get_option_deprecated( $full_name, $default );
}
add_filter( "default_option_{$full_name}", array( $this, 'get_option_default_value' ), 10, 3 );
// Call this way so that the `$passed_default_value` of the filter is accurate based on the number of arguments actually passed.
$args = func_num_args() > 1 ? array( $full_name, $default ) : array( $full_name );
$val = get_option( ...$args );
remove_filter( "default_option_{$full_name}", array( $this, 'get_option_default_value' ), 10, 3 );
return $val;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 4.21.0 | Changed the behavior of the function when the concrete class defines $this->version greater than 1. |
| 3.8.0 | Introduced. |