Setting
in package
Class defining a configurable plugin setting.
Tags
Table of Contents
- FONT_SIZE_UNIT_OPTIONS = array('em' => 'em', 'rem' => 'rem', 'px' => 'pixels', 'pt' => 'points', 'pc' => 'picas', 'mm' => 'millimeters', '%' => 'per cent')
- Options for the custom font size units (per cent is a ratio, not a unit).
- TEXT_ELEMENT_OPTIONS = array('p' => 'paragraph', 'h2' => 'heading 2', 'h3' => 'heading 3', 'h4' => 'heading 4', 'h5' => 'heading 5', 'h6' => 'heading 6')
- Options for the HTML text elements.
- WIDTH_UNIT_OPTIONS = array('%' => 'per cent', 'px' => 'pixels', 'rem' => 'root em', 'em' => 'em', 'vw' => 'viewport width')
- Options for the custom width units (per cent is a ratio, not a unit).
- $description : string|null
- Setting description.
- $key : string
- Setting slug.
- $name : string
- Setting name.
- $value : mixed
- Setting value.
- $default_value : mixed
- Setting default value.
- $enabled_by : string|null
- The setting for whether this setting is enabled or not.
- $group_id : string
- Setting group ID.
- $input_max : int|float|null
- Setting input field max. value (for 'number' inputs).
- $input_min : int|float|null
- Setting input field min. value (for 'number' inputs).
- $input_options : array<string|int, mixed>|null
- Setting input field options (for 'select' inputs).
- $input_type : string
- Setting input field type.
- $options_group_slug : string
- Setting section slug.
- $overridden_by : string|null
- Any setting that overrides this setting.
- $section_slug : string
- Setting section slug.
- $settings : Settings
- The plugin settings object.
- $type : string
- Setting data type.
- __construct() : mixed
- Constructs the setting.
- get_default_value() : mixed
- Gets the default value of the setting.
- get_input_options() : array<string|int, mixed>|null
- Gets the input options of the setting.
- get_options_group_slug() : string
- Gets the slug of the setting's options group.
- get_section_slug() : string
- Gets the slug of the setting's section.
- get_setting_args() : array<string|int, mixed>
- Get the args for registering the settings with WordPress.
- get_setting_field_args() : array<string|int, mixed>
- Get the args for rendering setting fields on the admin. dashboard.
- get_value() : mixed
- Gets the value of the setting.
- set_value() : bool
- Sets the value of the setting.
- is_disabled_or_overridden() : bool|null
- Check whether a setting is enabled and/or overridden.
Constants
FONT_SIZE_UNIT_OPTIONS
Options for the custom font size units (per cent is a ratio, not a unit).
public
array<string|int, mixed>
FONT_SIZE_UNIT_OPTIONS
= array('em' => 'em', 'rem' => 'rem', 'px' => 'pixels', 'pt' => 'points', 'pc' => 'picas', 'mm' => 'millimeters', '%' => 'per cent')
Tags
TEXT_ELEMENT_OPTIONS
Options for the HTML text elements.
public
array<string|int, mixed>
TEXT_ELEMENT_OPTIONS
= array('p' => 'paragraph', 'h2' => 'heading 2', 'h3' => 'heading 3', 'h4' => 'heading 4', 'h5' => 'heading 5', 'h6' => 'heading 6')
Tags
WIDTH_UNIT_OPTIONS
Options for the custom width units (per cent is a ratio, not a unit).
public
array<string|int, mixed>
WIDTH_UNIT_OPTIONS
= array('%' => 'per cent', 'px' => 'pixels', 'rem' => 'root em', 'em' => 'em', 'vw' => 'viewport width')
Tags
Properties
$description
Setting description.
public
string|null
$description
Tags
$key
Setting slug.
public
string
$key
Tags
$name
Setting name.
public
string
$name
Tags
$value
Setting value.
protected
mixed
$value
Tags
$default_value
Setting default value.
private
mixed
$default_value
Tags
$enabled_by
The setting for whether this setting is enabled or not.
private
string|null
$enabled_by
Tags
$group_id
Setting group ID.
private
string
$group_id
Tags
$input_max
Setting input field max. value (for 'number' inputs).
private
int|float|null
$input_max
Tags
$input_min
Setting input field min. value (for 'number' inputs).
private
int|float|null
$input_min
Tags
$input_options
Setting input field options (for 'select' inputs).
private
array<string|int, mixed>|null
$input_options
Tags
$input_type
Setting input field type.
private
string
$input_type
Tags
$options_group_slug
Setting section slug.
private
string
$options_group_slug
Tags
$overridden_by
Any setting that overrides this setting.
private
string|null
$overridden_by
Tags
$section_slug
Setting section slug.
private
string
$section_slug
Tags
$settings
The plugin settings object.
private
Settings
$settings
Tags
$type
Setting data type.
private
string
$type
Tags
Methods
__construct()
Constructs the setting.
public
__construct(string $group_id, string $options_group_slug, string $section_slug, string $key, string $name, string|null $description, mixed $default_value, string $type, string $input_type, array<string|int, mixed>|null $input_options, int|float|null $input_max, int|float|null $input_min, string|null $enabled_by, string|null $overridden_by, Settings $settings) : mixed
Parameters
- $group_id : string
- $options_group_slug : string
- $section_slug : string
- $key : string
- $name : string
- $description : string|null
- $default_value : mixed
- $type : string
- $input_type : string
- $input_options : array<string|int, mixed>|null
- $input_max : int|float|null
- $input_min : int|float|null
- $enabled_by : string|null
- $overridden_by : string|null
- $settings : Settings
Tags
Return values
mixed —get_default_value()
Gets the default value of the setting.
public
get_default_value() : mixed
Tags
Return values
mixed —The default value of the setting. 'None' if one is not set.
get_input_options()
Gets the input options of the setting.
public
get_input_options() : array<string|int, mixed>|null
Tags
Return values
array<string|int, mixed>|null —The possible options of the setting. 'None' if no options are set.
get_options_group_slug()
Gets the slug of the setting's options group.
public
get_options_group_slug() : string
Tags
Return values
string —The options group slug.
get_section_slug()
Gets the slug of the setting's section.
public
get_section_slug() : string
Tags
Return values
string —The section slug.
get_setting_args()
Get the args for registering the settings with WordPress.
public
get_setting_args() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —The setting field args.
get_setting_field_args()
Get the args for rendering setting fields on the admin. dashboard.
public
get_setting_field_args() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —The setting field args.
get_value()
Gets the value of the setting.
public
get_value() : mixed
Tags
Return values
mixed —The value of the setting, or the default value if none is set. 'None' if neither are set.
set_value()
Sets the value of the setting.
public
set_value(mixed $value) : bool
Parameters
- $value : mixed
-
The new value to set.
Tags
Return values
bool —'True' if the value was successfully set. 'False' otherwise.
is_disabled_or_overridden()
Check whether a setting is enabled and/or overridden.
private
is_disabled_or_overridden() : bool|null
Tags
Return values
bool|null —'True' if the setting is disabled or overridden. 'False' if it could be, but isn't currently. 'None' if the setting is not enabled/overridden by another.