SLP_Settings
extends SLP_Base_ReactObject
in package
The UI and management interface for a page full of settings for a WordPress admin page.
Table of Contents
Properties
- $addon : object
- $buildDir : string
- $buildURL : string
- $current_admin_page : mixed
- $form_action : mixed
- $form_enctype : mixed
- $form_name : mixed
- $known_classes : mixed
- $myslp : MySLP
- $name : mixed
- $pageName : string
- $save_text : mixed
- $scriptAssetFile : string
- $scriptFile : string
- $scriptFilebase : string
- $scriptHandle : string
- $scriptURL : string
- $sections : mixed
- $show_help_sidebar : mixed
- $slplus : SLPlus
- $uses_myslp : bool
- $uses_slplus : mixed
- $pluginDir : mixed
- $pluginURL : mixed
- $slug : mixed
- $wrapper_class : mixed
Methods
- __construct() : mixed
- Set some pre-load defaults.
- __get() : SLPlus_BaseClass_Object
- __isset() : bool
- add_group() : mixed
- Add a group to the specified section.
- add_ItemToGroup() : mixed
- Same as add_item but uses named params.
- add_section() : mixed
- Create a settings page panel.
- get_instance() : static
- Return an instance of the object which is also registered to the slplus global less the SLP_ part.
- get_section() : SLP_Settings_Section|WP_Error
- Return a section object.
- has_section() : bool
- Return true if the section identified by the slug exists.
- render() : void
- Render admin page - default can be overriden.
- render_settings_page() : mixed
- Create the HTML for the plugin settings page on the admin panel.
- set_properties() : mixed
- Set our properties.
- enqueueReact() : void
- Things we normally want to do before each render
- get_vars_for_react() : array<string|int, mixed>
- Pass data from PHP to React JavaScript environment.
- initialize() : void
- Do at invocation.
- add_help_section() : void
- Add the help sidebar.
- add_smart_options_to_section() : mixed
- Add smart option groups and settings to this section.
- enqueue_help_script() : mixed
- Enqueue help text manager script.
- get_option_setting() : string
- Get the option setting (name)
- get_value_for_setting() : mixed
- Get the value for a specific add-on option. If empty use add-on option_defaults. If still empty use slplus defaults.
- save_button() : void
- Create the save button text.
- set_item_params() : array<string|int, mixed>
- Set Add Item To Group Params
- set_item_params_new() : array<string|int, mixed>
- Set Add Item To Group Params to new defaults.
- set_item_params_old() : array<string|int, mixed>
- Set Add Item To Group Params to new defaults.
- set_section_slug() : string
- Set section slug by name if not provided.
Properties
$addon
public
object
$addon
$buildDir read-only
public
string
$buildDir
The build directory where the React script lives.
$buildURL read-only
public
string
$buildURL
The build URL where the React script lives.
$current_admin_page
public
mixed
$current_admin_page
$form_action
public
mixed
$form_action
= 'options.php'
$form_enctype
public
mixed
$form_enctype
= ''
$form_name
public
mixed
$form_name
= ''
$known_classes
public
mixed
$known_classes
= array()
$myslp
public
MySLP
$myslp
$name
public
mixed
$name
= ''
$pageName
public
string
$pageName
The page name for React, update with initialize() override.
$save_text
public
mixed
$save_text
= ''
$scriptAssetFile read-only
public
string
$scriptAssetFile
The fully qualified file name for the React script supporting asset PHP file.
$scriptFile read-only
public
string
$scriptFile
The fully qualified file name for the React script.
$scriptFilebase
public
string
$scriptFilebase
The name of the edit/view mode script file, default: script.js.
$scriptHandle
public
string
$scriptHandle
Both the WP handle for managing the react script and the build/
$scriptURL read-only
public
string
$scriptURL
The URL for the React script.
$sections
public
mixed
$sections
$show_help_sidebar
public
mixed
$show_help_sidebar
= \true
$slplus
public
SLPlus
$slplus
$uses_myslp
public
bool
$uses_myslp
Set to true to add a $myslp property pointing to global $myslp
$uses_slplus
public
mixed
$uses_slplus
= \true
$pluginDir
protected
mixed
$pluginDir
$pluginURL
protected
mixed
$pluginURL
$slug
protected
mixed
$slug
$wrapper_class
protected
mixed
$wrapper_class
= 'dashboard-wrapper react-wrapper'
Methods
__construct()
Set some pre-load defaults.
public
__construct([array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $options : array<string|int, mixed> = array()
__get()
public
__get(string $property) : SLPlus_BaseClass_Object
Parameters
- $property : string
Return values
SLPlus_BaseClass_Object__isset()
public
__isset(string $property) : bool
Parameters
- $property : string
Return values
booladd_group()
Add a group to the specified section.
public
add_group(mixed $params) : mixed
Params requires: 'section_slug' => slug for a section to add the group to 'group_slug' => slug for this group
Suggested: 'group' || 'header' => the text to name the group
Parameters
- $params : mixed
add_ItemToGroup()
Same as add_item but uses named params.
public
add_ItemToGroup(array<string|int, mixed> $params[, mixed $option = null ]) : mixed
'type' => textarea, text, checkbox, dropdown, slider, list, submit_button, ..custom..
NOTE: If use_prefix is false the automatic option saving in SLP 4.2 add-on framework will be disabled. This can be useful for admin settings you do not want saved/restored between sessions. It can suck if you do want that to happen though and will likely find this comment after spending the past 30 minutes tearing your hair out wondering WTF is going on.
Parameters
- $params : array<string|int, mixed>
-
optional parameters
- $option : mixed = null
-
if set this is the name of the option to add 'section' => string text for section heading to put the setting in 'label' => string text that precedes the input 'setting' => string name of the setting (input ID) 'type' => string type of interface element ('checkbox'|'dropdown'|'subheader'|'submit'|'textarea') 'show_label'=> boolean set to true to show the label (default: true) 'custom' => string the custom HTML output to render 'section_slug' => string the section slug, if set uses SLP 4.5 defaults.
add_section()
Create a settings page panel.
public
add_section(array<string|int, mixed> $params) : mixed
Does not render the panel, it simply creates the container to add stuff to for later rendering.
Parameters
- $params : array<string|int, mixed>
-
named array of the section properties, name is required.
get_instance()
Return an instance of the object which is also registered to the slplus global less the SLP_ part.
public
static get_instance([bool $no_global = false ][, mixed $params = array() ]) : static
Parameters
- $no_global : bool = false
-
set to true to skip assigning object to SLP global as a property.
- $params : mixed = array()
-
object init params
Return values
staticget_section()
Return a section object.
public
get_section(string $section_slug) : SLP_Settings_Section|WP_Error
Parameters
- $section_slug : string
Return values
SLP_Settings_Section|WP_Errorhas_section()
Return true if the section identified by the slug exists.
public
has_section(string $slug) : bool
Parameters
- $slug : string
Return values
boolrender()
Render admin page - default can be overriden.
public
render() : void
Provide the DOM element where the React app will render: slp-full-page-react-app
render_settings_page()
Create the HTML for the plugin settings page on the admin panel.
public
render_settings_page() : mixed
set_properties()
Set our properties.
public
set_properties([array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $options : array<string|int, mixed> = array()
enqueueReact()
Things we normally want to do before each render
protected
enqueueReact() : void
get_vars_for_react()
Pass data from PHP to React JavaScript environment.
protected
get_vars_for_react() : array<string|int, mixed>
Use this for one-time setup, things that are mostly static in PHP but you need to send to JS.
Return values
array<string|int, mixed>initialize()
Do at invocation.
protected
initialize() : void
..
add_help_section()
Add the help sidebar.
private
add_help_section() : void
add_smart_options_to_section()
Add smart option groups and settings to this section.
private
add_smart_options_to_section(string $section) : mixed
Parameters
- $section : string
-
the section slug
enqueue_help_script()
Enqueue help text manager script.
private
enqueue_help_script() : mixed
get_option_setting()
Get the option setting (name)
private
get_option_setting(array<string|int, mixed> $params) : string
Parameters
- $params : array<string|int, mixed>
Return values
stringget_value_for_setting()
Get the value for a specific add-on option. If empty use add-on option_defaults. If still empty use slplus defaults.
private
get_value_for_setting(mixed $plugin, string $option_name, string $setting) : mixed
Parameters
- $plugin : mixed
-
An instantiated SLP Plugin object.
- $option_name : string
-
Name of the options property to fetch from (default: 'options')
- $setting : string
-
The key name for the setting to retrieve.
Return values
mixed —The value of the add-on options[
save_button()
Create the save button text.
private
save_button() : void
Set save_text to '' to prevent the save button.
set_item_params()
Set Add Item To Group Params
private
set_item_params(bool $new_defaults, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $new_defaults : bool
-
If true use the new-style SLP 4.5 defaults
- $params : array<string|int, mixed>
Return values
array<string|int, mixed>set_item_params_new()
Set Add Item To Group Params to new defaults.
private
set_item_params_new(array<string|int, mixed> $params) : array<string|int, mixed>
use_prefix = false show_label = true type = text name = params['setting']
If 'plugin' param is set also use 'option' param to set the name and value for the setting.
Parameters
- $params : array<string|int, mixed>
Return values
array<string|int, mixed>set_item_params_old()
Set Add Item To Group Params to new defaults.
private
set_item_params_old(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
Return values
array<string|int, mixed>set_section_slug()
Set section slug by name if not provided.
private
set_section_slug(mixed $name) : string
Parameters
- $name : mixed