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


Top ↑

Return Return

(mixed) The option value.


Top ↑

Source Source

File: includes/abstracts/llms.abstract.options.data.php

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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;
 
}


Top ↑

Changelog 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.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.