Options_API
Options API Class.
Namespace: WebberZone\Image_Optimizer
Since: 1.0.0
Source: includes/class-options-api.php line 25
Methods
flush_cache() static
Flush the per-request settings cache.
Call after any write so a subsequent read in the same request sees the new value. Pass a blog ID to flush a single blog, or nothing to flush all.
Since: 0.10.0
Line: 78
static public function flush_cache( $blog_id = ... ): void;
| Type | Name | Description |
|---|---|---|
int|null |
$blog_id |
Blog ID to flush. Null flushes every cached blog. |
Returns: void
get_settings() static
Get Settings.
Retrieves all plugin settings.
Since: 1.0.0
Line: 96
static public function get_settings( ): array;
Returns: array — Settings array.
get_settings_with_defaults() static
Get the saved settings merged over the defaults.
Newly registered settings that are not yet present in the saved option still resolve to a value.
Since: 0.10.0
Line: 126
static public function get_settings_with_defaults( ): array;
Returns: array — Settings merged with defaults.
get_option() static
Get an option.
Looks to see if the specified setting exists, returns the default if not.
Since: 1.0.0
Line: 141
static public function get_option( $key = ..., $default_value = ... ): mixed;
| Type | Name | Description |
|---|---|---|
string |
$key |
Option to fetch. |
mixed |
$default_value |
Default value if the option is missing. |
Returns: mixed
get_blog_option() static
Get an option from a specific blog in a multisite network.
Since: 0.10.0
Line: 183
static public function get_blog_option( $blog_id, $key = ..., $default_value = ... ): mixed;
| Type | Name | Description |
|---|---|---|
int |
$blog_id |
Blog ID to fetch the option from. |
string |
$key |
Key of the option to fetch. |
mixed |
$default_value |
Default value to fetch if the option is missing. |
Returns: mixed
update_option() static
Update an option.
Warning: passing an empty, false or null value will store that value; use
delete_option() to remove the key entirely.
Since: 1.0.0
Line: 222
static public function update_option( $key = ..., $value = ... ): bool;
| Type | Name | Description |
|---|---|---|
string |
$key |
The key to update. |
string|bool|int |
$value |
The value to set the key to. |
Returns: bool — True if updated, false if not.
update_settings() static
Update all settings at once.
Since: 1.0.0
Line: 259
static public function update_settings( array $settings, bool $merge = ..., bool $autoload = ... ): bool;
| Type | Name | Description |
|---|---|---|
array |
$settings |
Settings array to save. |
bool |
$merge |
Whether to merge with existing settings. Default true. |
bool |
$autoload |
Whether to autoload the option. Default true. |
Returns: bool — True if updated, false otherwise.
delete_option() static
Remove an option.
Since: 1.0.0
Line: 281
static public function delete_option( $key = ... ): bool;
| Type | Name | Description |
|---|---|---|
string |
$key |
The key to delete. |
Returns: bool — True if updated, false if not.
get_settings_defaults() static
Default settings.
Built from the registered settings, so this runs the full field definitions
and is only safe to call after init. Use get_default_option() for a
single key when the read may happen earlier.
Since: 1.0.0
Line: 312
static public function get_settings_defaults( ): array;
Returns: array — Default settings.
get_default_option() static
Get the default option for a specific key.
Reads from Admin\Settings::get_defaults() rather than
settings_defaults(): the former is a flat array with no translation calls,
so this is safe before init and avoids building every field definition to
resolve one key.
Since: 1.0.0
Line: 329
static public function get_default_option( $key = ... ): mixed;
| Type | Name | Description |
|---|---|---|
string |
$key |
Key of the option to fetch. |
Returns: mixed — Default value, or false if the key is not registered.
get_registered_settings_types() static
Get the registered settings types, keyed by option ID.
Since: 0.10.0
Line: 360
static public function get_registered_settings_types( ): array;
Returns: array — Setting types keyed by option ID.
reset_settings() static
Reset settings to their defaults.
Since: 1.0.0
Line: 389
static public function reset_settings( ): bool;
Returns: bool — True if updated, false if not.