Метод | Описание | |
---|---|---|
__get ( string $name ) : mixed | Retrieve an option value | |
__isset ( $name ) | ||
__set ( string $name, mixed $value ) | Applies the option value to the options table | |
__unset ( string $name ) | Removes an option from the options table | |
clear_cache ( ) | Clears memory of cached options | |
delete ( string | array $name ) | Shortcut to unset an option in the options table | |
delete_group ( string $prefix ) | Delete a group of options with a specific prefix | |
get ( string | array $name, mixed $default_value = null ) : mixed | Shortcut to return the value of an option | |
get_all_options ( ) | Fetch all options from the options table into local storage | |
get_group ( string $prefix ) : array | Fetch a group of options with a specific prefix Useful for plugins that use FormUI to automatically store options with the plugin's prefix. | |
is_static ( string $name ) : boolean | Check if an option was set via the config, making it unsettable | |
out ( string $name ) | Shortcut to output the value of an option | |
set ( string | array $name, mixed $value = '' ) | function set Shortcut to set the value of an option | |
set_group ( string $prefix, array $values ) | Set a group of options with a specific prefix |
Метод | Описание | |
---|---|---|
instance ( ) | Enables singleton working properly |
public static clear_cache ( ) |
Options::delete_group( 'foo' );
would delete all foo__* option names
public static delete_group ( string $prefix ) | ||
$prefix | string | The prefix to delete |
$foo = Options::get('foo'); // returns null if the option 'foo' does not exist
list($foo, $bar, $baz) = Options::get( array('foo1', 'bar2', 'baz3') ); // useful with array_keys()
$bar = Options::get('foo', 'bar'); // returns 'bar' if the option 'foo' does not exist. useful for avoiding if/then blocks to detect unset options
public static get ( string | array $name, mixed $default_value = null ) : mixed | ||
$name | string | array | The name or an array of names of the option to fetch. |
$default_value | mixed | The value to return for an option if it does not exist. |
Результат | mixed | The option requested or an array of requested options, $default_value for each if the option does not exist |
public get_all_options ( ) |
protected static instance ( ) |
Options::out('foo');
Options::set('foo', 'newvalue');
Options::set( array( 'foo' => 'bar', 'baz' => 'qux' ) );
Options::set_group( 'foo', array( 'bar' => 'baz', 'qux' => 'quux' ) );
results in 2 options: foo__bar == baz and foo__qux == quux