SLP_BaseClass_Admin
extends SLP_Object_With_Objects
in package
A base class that helps add-on packs separate admin functionality.
Add on packs should include and extend this class.
This allows the main plugin to only include this file in admin mode via the admin_menu call. Reduces the front-end footprint.
Table of Contents
Properties
- $addon : mixed
- $class_prefix : string
- $current_group : mixed
- $current_section : mixed
- $dir : string
- $js_settings : mixed
- $myslp : MySLP
- $objects : array<string|int, mixed>
- $slplus : SLPlus
- $uses_myslp : bool
- $uses_slplus : bool
- $activation : mixed
- $admin_page_slug : mixed
- $js_requirements : mixed
- $settings_interface : mixed
- $settings_pages : mixed
- $slug : mixed
- $ok_to_nq_js : mixed
- $saved_option_state : mixed
- $settings_have_been_saved : 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 the plugin specific hooks and filter configurations here.
- add_meta_links() : array<string|int, string>
- Add meta links.
- add_object() : mixed
- 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)
- 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.
- instantiate() : null|object
- Instantiate an object of the noted 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() : mixed
- Set our properties.
- set_ValidOptions() : mixed
- Set valid options according to the addon options array.
- 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.
- initialize() : mixed
- Run these things during invocation.
- 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.
- add_setting() : mixed
- Add setting.
- get_my_checkboxes() : array<string|int, string>
- Return an array of checkbox names for the current settings page being processed.
- is_legacy_needed_for() : mixed
- Is legacy support needed for any active add-on packs?
- needed_for_addon() : bool
- Determine if any add-on packs are installed that require legacy support.
- nq_this_file() : bool
- Enqueue a CSS file.
- update_prior_installs() : mixed
- Update prior add-on pack installations.
Properties
$addon
public
mixed
$addon
$class_prefix
public
string
$class_prefix
the prefix that goes before all our classes
$current_group
public
mixed
$current_group
$current_section
public
mixed
$current_section
$dir
public
string
$dir
the root directory for this theme
$js_settings
public
mixed
$js_settings
= array()
$myslp
public
MySLP
$myslp
$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
$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
bool
$uses_slplus
Set to true (default) if the object needs access to the SLPlus plugin object.
$activation
protected
mixed
$activation
$admin_page_slug
protected
mixed
$admin_page_slug
$js_requirements
protected
mixed
$js_requirements
= array('jquery')
$settings_interface
protected
mixed
$settings_interface
$settings_pages
protected
mixed
$settings_pages
$slug
protected
mixed
$slug
$ok_to_nq_js
private
mixed
$ok_to_nq_js
$saved_option_state
private
mixed
$saved_option_state
= array()
$settings_have_been_saved
private
mixed
$settings_have_been_saved
= \false
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
booladd_hooks_and_filters()
Add the plugin specific hooks and filter configurations here.
public
add_hooks_and_filters() : mixed
Add your hooks and filters in the class that extends this base class. Then call parent::add_hooks_and_filters()
Should include WordPress and SLP specific hooks and filters.
Tags
add_meta_links()
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>add_object()
public
add_object(mixed $object) : mixed
Parameters
- $object : mixed
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_javascript()
Enqueues Admin JavaScript for include/admin.js and js/admin.js and js/admin-<tabname>-tab.js (minified if present)
public
enqueue_admin_javascript(string $hook) : mixed
Parameters
- $hook : string
Tags
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
staticget_newer_version()
If there is a newer version get the link.
public
get_newer_version() : string
Return values
stringget_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[
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|objectsave_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
boolsave_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() ]) : mixed
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
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
booldo_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.
initialize()
Run these things during invocation.
protected
initialize() : mixed
Fires from \SLPlus_BaseClass_Object::__construct
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
boolset_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
add_setting()
Add setting.
private
add_setting(string $label, string $description, string $setting, string $type) : mixed
Parameters
- $label : string
- $description : string
- $setting : string
- $type : string
get_my_checkboxes()
Return an array of checkbox names for the current settings page being processed.
private
get_my_checkboxes() : array<string|int, string>
If settings_pages is in use (and it should be) - return the array of checkbox names for the currently active tab (page slug).
Return values
array<string|int, string>is_legacy_needed_for()
Is legacy support needed for any active add-on packs?
private
is_legacy_needed_for(string $fq_method) : mixed
Some add-on packs break when things are updated in the base plugin.
Parameters
- $fq_method : string
-
The specific method we are checking in ClassName::MethodName format.
Tags
needed_for_addon()
Determine if any add-on packs are installed that require legacy support.
private
needed_for_addon(string $fq_method) : bool
Parameters
- $fq_method : string
-
The specific method we are checking in ClassName::MethodName format.
Return values
bool —Whether or not an add-on is in use that requires legacy support.
nq_this_file()
Enqueue a CSS file.
private
nq_this_file(string $hook, string $css_file[, string $augmentation = '' ]) : bool
Parameters
- $hook : string
- $css_file : string
- $augmentation : string = ''
Return values
bool —true if file exists and we did the enqueue (we think)
update_prior_installs()
Update prior add-on pack installations.
private
update_prior_installs() : mixed