Store Locator Plus®

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

$buildDir  : string
$buildURL  : string
$current_admin_page  : string
$current_admin_page  : mixed
$form_action  : string
$form_action  : mixed
$form_enctype  : string
$form_enctype  : mixed
$form_name  : string
$form_name  : mixed
$known_classes  : array<string|int, string>
$known_classes  : mixed
$name  : string
$name  : mixed
$pageName  : string
$save_text  : string
$save_text  : mixed
$scriptAssetFile  : string
$scriptFile  : string
$scriptFilebase  : string
$scriptHandle  : string
$scriptURL  : string
$sections  : array<string|int, SLP_Settings_Section>
$sections  : mixed
$show_help_sidebar  : mixed
$slplus  : SLPlus
$uses_slplus  : mixed
$uses_slplus  : bool
$uses_slplus  : bool
$pageName  : mixed
$scriptFilebase  : mixed
$scriptHandle  : mixed
$slplus  : mixed
$buildDir  : mixed
$buildURL  : mixed
$scriptAssetFile  : mixed
$scriptFile  : mixed
$scriptURL  : 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()  : SLPlus_BaseClass_Object
Return an instance of the object which is also registered to the slplus global less the SLP_ part.
get_section()  : string|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()  : string
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()  : string
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

$buildDir read-only

public string $buildDir

The build directory where the React script lives.

$form_action

public string $form_action

what action to take with the form.

$form_enctype

public string $form_enctype

form encryption type default: '' , often 'multipart/form-data'

$known_classes

public array<string|int, string> $known_classes

named array, [ 'key' ] is an item type, => is the FQ filename of the interface definition.

$pageName

public string $pageName

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

$save_text

public string $save_text

optional: The text for the save button. (default: blank, don't show save button)

$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/ subdir in which ot find the react scripts.

$show_help_sidebar

public mixed $show_help_sidebar = \true

$uses_slplus

public bool $uses_slplus

Default false try to use SLPlus::get_instance() legacy models that use $this->slplus must set this to true.

$uses_slplus

public bool $uses_slplus

Set to true (default) if the object needs access to the SLPlus plugin object.

Methods

__construct()

Set some pre-load defaults.

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

__isset()

public __isset(string $property) : bool
Parameters
$property : string
Return values
bool

add_group()

Add a group to the specified section.

public add_group( $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 :

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

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() ]) : SLPlus_BaseClass_Object

TODO: PHP7.4 and PHP8.0 the static instance variable returns an object matching $class TODO: PHP8.1 the static instance continually returns the FIRST object (SLP_Admin_Helper) every time -- it is like PHP8.1 static instance is bound to base_class-object versus the calling class object

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
SLPlus_BaseClass_Object

get_section()

Return a section object.

public get_section(string $section_slug) : string|WP_Error
Parameters
$section_slug : string
Return values
string|WP_Error

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() : 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() : string
Return values
string

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
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[]

save_button()

Create the save button text.

private save_button() : string

Set save_text to '' to prevent the save button.

Return values
string

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( $name) : string
Parameters
$name :
Return values
string

        
On this page

Search results