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

	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.