SLPĀ® phpDocs

SLP_Settings extends SLP_Base_ReactObject

The UI and management interface for a page full of settings for a WordPress admin page.

Tags
used-by
SLP_Admin_Locations::create_object_settings()

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
$scriptURL  : string
$sections  : mixed
$show_help_sidebar  : mixed
$slplus  : SLPlus
$uses_myslp  : bool
$pluginDir  : mixed
$pluginURL  : mixed
$scriptFilebase  : mixed
$scriptHandle  : mixed
$slug  : mixed
$uses_slplus  : bool
$wrapper_class  : mixed

Methods

__construct()  : mixed
Set some pre-load defaults.
__get()  : SLPlus_BaseClass_Object
__isset()  : bool
add_group()  : void
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()  : void
Create the HTML for the plugin settings page on the admin panel.
set_properties()  : void
Set our properties.
enqueueReact()  : void
Things we normally want to do before each render
get_vars_for_react()  : array<string|int, mixed>
Retrieve variables to be passed to the React application.
initialize()  : void
Do at invocation.
add_help_section()  : void
Add the help sidebar.
add_smart_options_to_section()  : void
Add smart option groups and settings to this section.
enqueue_help_script()  : void
Enqueue help text manager script.
extend_vars_for_react_with_items()  : array<string|int, mixed>
Allow setting items to contribute React bootstrap variables.
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.
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 a section slug by name if not provided.

Properties

$buildDir read-only

public string $buildDir

The build directory where the React script lives.

$pageName

public string $pageName

The page name for React, update with initialize() override.

$scriptAssetFile read-only

public string $scriptAssetFile

The fully qualified file name for the React script supporting an asset PHP file.

$scriptFile read-only

public string $scriptFile

The fully qualified file name for the React script.

$show_help_sidebar

public mixed $show_help_sidebar = \true

$scriptFilebase

protected mixed $scriptFilebase = 'slp_settings'

$scriptHandle

protected mixed $scriptHandle = 'slp_settings'

Methods

__construct()

Set some pre-load defaults.

public __construct([array<string|int, mixed> $options = [] ]) : mixed
Parameters
$options : array<string|int, mixed> = []

add_group()

Add a group to the specified section.

public add_group(mixed $params) : void

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
static

has_section()

Return true if the section identified by the slug exists.

public has_section(string $slug) : bool
Parameters
$slug : string
Return values
bool

render()

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() : void

set_properties()

Set our properties.

public set_properties([array<string|int, mixed> $options = array() ]) : void
Parameters
$options : array<string|int, mixed> = array()

enqueueReact()

Things we normally want to do before each render

protected enqueueReact() : void

get_vars_for_react()

Retrieve variables to be passed to the React application.

protected final get_vars_for_react() : array<string|int, mixed>

This method prepares and returns an array of variables, including processed section data, excluding sections with the slug 'navigation'.

Return values
array<string|int, mixed>

The array of variables for the React application.

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) : void
Parameters
$section : string

the section slug

enqueue_help_script()

Enqueue help text manager script.

private enqueue_help_script() : void

extend_vars_for_react_with_items()

Allow setting items to contribute React bootstrap variables.

private extend_vars_for_react_with_items(array<string|int, mixed> $vars) : array<string|int, mixed>
Parameters
$vars : array<string|int, mixed>

React variables.

Return values
array<string|int, 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
string

get_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[], add-on option_defaults[], or slplus defaults[]

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 a section slug by name if not provided.

private set_section_slug(string $name) : string
Parameters
$name : string
Return values
string
On this page

Search results