SLPĀ® phpDocs

SLP_Admin_UI extends SLP_BaseClass_Admin

Class SLP_Admin_UI

Table of Contents

Properties

$activation  : SLP_BaseClass_Activation
$addon  : SLP_BaseClass_Addon
$admin_page_slug  : string
$cache  : mixed
$class_prefix  : string
$current_group  : string
$current_section  : string
$dir  : string
$js_requirements  : array<string|int, string>
$js_settings  : array<string|int, string>
$menu_items  : mixed
$myslp  : MySLP
$objects  : array<string|int, mixed>
$ok_to_nq_js  : bool
$saved_option_state  : array<string|int, mixed>
$settings_interface  : SLP_Settings
$settings_pages  : array<string|int, mixed>
$slplus  : SLPlus
$styleHandle  : mixed
$uses_myslp  : bool
$uses_slplus  : bool
$slug  : mixed
$already_enqueued  : mixed
$icon_selector_files  : mixed
$icon_selector_urls  : mixed
$is_our_admin_page  : mixed
$slp_admin_slugs  : mixed

Methods

__construct()  : mixed
__get()  : mixed
Get the value, running it through a filter.
__isset()  : bool
Allow isset to be called on private properties.
add_hooks_and_filters()  : mixed
Add hooks and filters.
add_json_mime_type()  : array<string|int, mixed>
Allows WordPress to process JSON file types
add_meta_links()  : array<string|int, string>
Add meta links.
add_object()  : mixed
create_admin_menu()  : mixed
Create the admin menu.
create_string_icon_selector()  : string
Return the icon selector HTML for the icon images in saved markers and default icon directories.
enqueue_admin_css()  : mixed
If the file admin.css exists and the page prefix starts with slp_ , enqueue the admin style.
enqueue_admin_javascript()  : mixed
Enqueues Admin JavaScript for include/admin.js and js/admin.js and js/admin-<tabname>-tab.js (minified if present)
enqueue_admin_stylesheet()  : mixed
Enqueue the admin stylesheet when needed.
enqueue_block_editor_assets()  : void
enqueue_slp_core_and_google_maps()  : void
Ensure slp_core is localized/enqueued before the Google Maps dependency is enqueued.
filter_AddOurAdminSlug()  : array<string|int, string>
Add our admin pages to the valid admin page slugs.
get_instance()  : static
Return an instance of the object which is also registered to the slplus global less the SLP_ part.
get_newer_version()  : string
If there is a newer version get the link.
get_value()  : mixed
Get the value for a specific add-on option. If empty use add-on option_defaults. If still empty use slplus defaults.
initialize()  : mixed
Invoke the AdminUI class.
instantiate()  : null|object
Instantiate an object of the noted class.
is_our_admin_page()  : bool
Sets $this->isOurAdminPage true if we are on a SLP managed admin page. Returns true/false accordingly.
renderGeneralPage()  : void
renderInfoPage()  : void
Renders the information menu by invoking the render method of the SLP_Admin_Info instance.
renderLocationsPage()  : void
Render the Locations Page
renderSettingsPage()  : void
renderStylePage()  : void
Renders the style menu by invoking the appropriate method from the SLP_Admin_Style class.
save_current_option_state()  : mixed
Save the current addon option state.
save_my_settings()  : bool
Use this to save option settings far earlier in the admin process.
save_SerializedOption()  : array<string|int, mixed>
Merge existing options and POST options, then save to the wp_options table.
set_properties()  : void
Set our properties.
set_ValidOptions()  : mixed
Set valid options according to the addon options array.
setup_admin_screen()  : mixed
Attach the wanted screen object and save the settings if appropriate.
showNotifications()  : string
Show admin notifications.
at_startup()  : mixed
Things to do at startup after this baby is initialized. Override in your class.
being_deactivated()  : bool
Is this add-on being deactivated?
do_admin_startup()  : mixed
Things we want our add on packs to do when they start.
ok_to_enqueue_admin_js()  : bool
Check if it is OK to enqueue the admin JavaScript, assume so if the hook starts with our prefix.
set_default_object_options()  : mixed
Set default options for objects. Override in your class.
update_install_info()  : mixed
Update the install info for this add on.
get_messages()  : array<string|int, string>
Set the messages for us in the JS array.
localize_script_admin_safe()  : void
Localize only the data needed for admin enqueue paths without invoking shortcode SmartOptions callbacks.

Properties

$cache

public mixed $cache = array('admin_pages' => array())

$js_requirements

public array<string|int, string> $js_requirements

An array of the JavaScript hooks that are needed by the userinterface.js script.

$js_settings

public array<string|int, string> $js_settings

JavaScript settings that are to be localized as a _settings JS variable.

$objects

public array<string|int, mixed> $objects

key = class name, array of attributes() auto_instantiate = true , instantiate the object when this object initializes object = the instantiated object options = default startup options subdir = the subdirectory (from theme root) that contains the class definition

$ok_to_nq_js read-only

public bool $ok_to_nq_js

keep track of whether we have looked up this capability before or not.

$saved_option_state read-only

public array<string|int, mixed> $saved_option_state

What the option values where before we did admin save.

$settings_pages

public array<string|int, mixed> $settings_pages

The settings pages we support and the checkboxes that live there: $settings_pages[] = array( 'checkbox_option_1' , 'checkbox_option_2', ...) // = the page name

$uses_slplus

public bool $uses_slplus

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

$already_enqueued

private mixed $already_enqueued = \false

$is_our_admin_page

private mixed $is_our_admin_page = \false

$slp_admin_slugs

private mixed $slp_admin_slugs = array('toplevel_page_slp-network-admin', 'slp_general', 'settings_page_csl-slplus-options', 'slp_general', 'slp_info', 'slp_inforeact', 'slp_manage_locations', 'slp_experience')

Methods

__construct()

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

__get()

Get the value, running it through a filter.

public __get(string $property) : mixed
Parameters
$property : string
Return values
mixed

null if not set or the value

__isset()

Allow isset to be called on private properties.

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

add_hooks_and_filters()

Add hooks and filters.

public add_hooks_and_filters() : mixed
Tags
uses
SLP_Admin_UI::enqueue_block_editor_assets

add_json_mime_type()

Allows WordPress to process JSON file types

public add_json_mime_type([array<string|int, mixed> $existing_mimes = array() ]) : array<string|int, mixed>
Parameters
$existing_mimes : array<string|int, mixed> = array()
Tags
used-by

\get_allowed_mime_types

set-via

\SLPPower::add_hooks_and_filters

Return values
array<string|int, mixed>

Add meta links.

public add_meta_links(array<string|int, string> $links, string $file) : array<string|int, string>
Parameters
$links : array<string|int, string>
$file : string
Return values
array<string|int, string>

create_admin_menu()

Create the admin menu.

public create_admin_menu() : mixed
Tags
uses
SLP_Admin_UI::renderStylePage
SLP_Admin_UI::renderLocationsPage

Roles and Caps manage_slp_admin manage_slp_user

WordPress Store Locator Plus Menu Roles & Caps

Info : manage_slp_admin Locations: manage_slp_user Settings: manage_slp_admin General: manage_slp_admin

create_string_icon_selector()

Return the icon selector HTML for the icon images in saved markers and default icon directories.

public create_string_icon_selector([string|null $field_id = null ][, string|null $image_id = null ]) : string
Parameters
$field_id : string|null = null
$image_id : string|null = null
Tags
used-by

\SLP_Settings_icon::get_content

\SLP_Power_Category_Manager::render_ExtraCategoryFields

\MySLP_Admin::admin_hook

\MySLP_Admin::get_icons_array

Return values
string

enqueue_admin_css()

If the file admin.css exists and the page prefix starts with slp_ , enqueue the admin style.

public enqueue_admin_css(mixed $hook) : mixed
Parameters
$hook : mixed

enqueue_admin_stylesheet()

Enqueue the admin stylesheet when needed.

public enqueue_admin_stylesheet(string $hook) : mixed
Parameters
$hook : string

Current page hook.

enqueue_block_editor_assets()

public enqueue_block_editor_assets() : void
Tags
used-by

\SLP_Admin_UI::add_hooks_and_filters

enqueue_slp_core_and_google_maps()

Ensure slp_core is localized/enqueued before the Google Maps dependency is enqueued.

public enqueue_slp_core_and_google_maps([string $hook = '' ]) : void
Parameters
$hook : string = ''
Tags
uses
SLP_UI::enqueue_slp_core
SLPlus::enqueue_google_maps_script

filter_AddOurAdminSlug()

Add our admin pages to the valid admin page slugs.

public filter_AddOurAdminSlug(array<string|int, string> $slugs) : array<string|int, string>
Parameters
$slugs : array<string|int, string>

admin page slugs

Return values
array<string|int, string>

modified list of admin page slugs

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

get_newer_version()

If there is a newer version get the link.

public get_newer_version() : string
Return values
string

get_value()

Get the value for a specific add-on option. If empty use add-on option_defaults. If still empty use slplus defaults.

public get_value(string $setting) : mixed
Parameters
$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[]

initialize()

Invoke the AdminUI class.

public initialize() : mixed
Tags
uses
SLPlus::enqueue_google_maps_script

instantiate()

Instantiate an object of the noted class.

public instantiate(string $class[, array<string|int, mixed> $options = array() ]) : null|object
Parameters
$class : string
$options : array<string|int, mixed> = array()
Return values
null|object

is_our_admin_page()

Sets $this->isOurAdminPage true if we are on a SLP managed admin page. Returns true/false accordingly.

public is_our_admin_page(string $hook) : bool
Parameters
$hook : string
Return values
bool

renderInfoPage()

Renders the information menu by invoking the render method of the SLP_Admin_Info instance.

public renderInfoPage() : void

renderLocationsPage()

Render the Locations Page

public renderLocationsPage() : void
Tags
used-by

SLP_Admin_UI::create_admin_menu

renderSettingsPage()

public renderSettingsPage() : void

renderStylePage()

Renders the style menu by invoking the appropriate method from the SLP_Admin_Style class.

public renderStylePage() : void
Tags
used-by

SLP_Admin_UI::create_admin_menu

save_current_option_state()

Save the current addon option state.

public save_current_option_state() : mixed

Used to know what options were set to before an admin save.

save_my_settings()

Use this to save option settings far earlier in the admin process.

public save_my_settings() : bool

Necessary if you are going to use your options in localized admin scripts.

TODO: Refactor to save_experience_tab_settings

Make sure you set the settings_pages properties so the right checkboxes end up on the right pages.

Return values
bool

save_SerializedOption()

Merge existing options and POST options, then save to the wp_options table.

public save_SerializedOption(string $optionName, array<string|int, mixed> $currentOptions[, array<string|int, string> $cbOptionArray = null ]) : array<string|int, mixed>

NOTE: USED BY ADD ON PACKS ONLY

TODO: Rewire calls from add on packs afterwards (ELM, POWER, PRO, SME, UML)

Typically used to merge post options from admin interface changes with existing options in a class.

Parameters
$optionName : string

name of option to update

$currentOptions : array<string|int, mixed>

current options as a named array

$cbOptionArray : array<string|int, string> = null

array of options that are checkboxes

Return values
array<string|int, mixed>

the updated options

set_properties()

Set our properties.

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

set_ValidOptions()

Set valid options according to the addon options array.

public set_ValidOptions(mixed $val, mixed $key) : mixed

TODO: deprecate when all add-on packs use ($this->addon , 'set_ValidOptions') instead of $this->set_ValidOptions in admin class.

Use $this->addon->set_ValidOptions instead.

Parameters
$val : mixed
$key : mixed

setup_admin_screen()

Attach the wanted screen object and save the settings if appropriate.

public setup_admin_screen(WP_Screen $current_screen) : mixed
Parameters
$current_screen : WP_Screen

The current screen object.

showNotifications()

Show admin notifications.

public showNotifications() : string
Tags
global

mixed[] $submenu the WordPress Submenu array

Return values
string

at_startup()

Things to do at startup after this baby is initialized. Override in your class.

protected at_startup() : mixed

NOTE: this will not run at initialization if $this->objects is empty.

being_deactivated()

Is this add-on being deactivated?

protected being_deactivated() : bool
Return values
bool

do_admin_startup()

Things we want our add on packs to do when they start.

protected do_admin_startup() : mixed

Extend this by overriding this method and then calling parent::do_admin_startup() before or after your extension.

ok_to_enqueue_admin_js()

Check if it is OK to enqueue the admin JavaScript, assume so if the hook starts with our prefix.

protected ok_to_enqueue_admin_js(mixed $hook) : bool
Parameters
$hook : mixed
Return values
bool

set_default_object_options()

Set default options for objects. Override in your class.

protected set_default_object_options() : mixed

update_install_info()

Update the install info for this add on.

protected update_install_info() : mixed

get_messages()

Set the messages for us in the JS array.

private get_messages() : array<string|int, string>
Return values
array<string|int, string>

localize_script_admin_safe()

Localize only the data needed for admin enqueue paths without invoking shortcode SmartOptions callbacks.

private localize_script_admin_safe() : void
On this page

Search results