SLP_BaseClass_Addon
extends SLP_Object_WithOptions
in package
A base class that consolidates common add-on pack methods.
Add on packs should base based on and extend this class.
Setting the following properties will activate hooks to various classes that will be instantiated as objects when needed:
o 'admin_class_name' => 'Your_SLP_Admin_Class' o 'user_class_name' => 'Your_SLP_UI_Class'
The admin class definition needs to go in your add-on pack under the ./include directory and be named 'class.admin.php'. The name of the class needs to match the provided string. The admin object will only be instantiated when WordPress is rendering the admin interface.
The user class definition needs to go in your add-on pack under the ./include directory and be named 'class.userinterface.php'. The name of the class needs to match the provided string. The user object will only be instantiated when WordPress is rendering the WordPress front end.
This methodology provides a standard construct for coding admin-only and user-interface-only elements of a WordPress add-on pack. This will mean less code is loaded into active ram, avoiding loading UI only code when on the admin panel and vice versa.
Table of Contents
Properties
- $activation_class_name : mixed
- $admin : mixed
- $admin_menu_entries : mixed
- $ajax : mixed
- $class_prefix : string
- $dir : mixed
- $file : mixed
- $language_dir : mixed
- $latest_version : mixed
- $meta : mixed
- $metadata : mixed
- $min_slp_version : mixed
- $myslp : MySLP
- $name : mixed
- $option_defaults : mixed
- $option_name : mixed
- $options : mixed
- $options_defaults : mixed
- $short_slug : mixed
- $slplus : SLPlus
- $slug : mixed
- $textdomain : mixed
- $Updates : mixed
- $url : mixed
- $userinterface : mixed
- $userinterface_class_name : mixed
- $uses_myslp : bool
- $uses_slplus : bool
- $version : mixed
- $widget : mixed
- $widget_class_name : mixed
- $WPOption_Manager : mixed
- $addon : mixed
- $admin_class_name : mixed
- $ajax_class_name : mixed
- $objects : mixed
Methods
- __construct() : mixed
- __get() : mixed
- Get the value, running it through a filter.
- __isset() : bool
- Allow isset to be called on private properties.
- __set() : SLP_Option|null
- Allow value to be set directly.
- add_hooks_and_filters() : mixed
- Add the plugin specific hooks and filter configurations here.
- add_object() : mixed
- create_object() : mixed
- Instantiate our objects ONCE and refer to them in an object array.
- create_object_Updates() : mixed
- Creates updates object AND checks for updates for this add-on.
- createobject_Admin() : mixed
- Create the admin interface object and attach to this->admin
- createobject_AJAX() : mixed
- Create the AJAX processing object and attach to this->ajax
- createobject_UserInterface() : mixed
- Create the user interface object and attach to this->UserInterface
- filter_AddMenuItems() : array<string|int, mixed>
- Add the items specified in the menu_entries property to the SLP menu.
- get_addon_version() : string
- Get the add-on pack version.
- get_instance() : static
- Return an instance of the object which is also registered to the slplus global less the SLP_ part.
- get_meta() : string
- Get the add on metadata property as specified.
- get_option() : mixed
- Get an option attribute.
- init_options() : mixed
- Initialize the options properties from the WordPress database.
- instantiate() : null|object
- Instantiate an object of the noted class.
- load_options() : mixed
- Load the options class to help the SLP smart options if we have that feature.
- run_during_init() : void
- Always run this stuff during the WordPress init hook.
- set_option() : bool
- Set an option attribute.
- set_option_defaults() : mixed
- Set option defaults outside of hard-coded property values via an array.
- set_properties() : mixed
- Set our properties.
- set_ValidOptions() : mixed
- Set valid options according to the addon options array.
- setting_name() : string
- Generate a proper setting name for the settings class.
- slp_init() : mixed
- Things to do once SLP is alive.
- at_startup() : mixed
- Things to do at startup after this baby is initialized. Override in your class.
- initialize() : mixed
- Run these things during invocation. (called from base object in __construct)
- set_default_object_options() : mixed
- Set default options for objects. Override in your class.
- check_my_version_compatibility() : bool
- Check the current version of this Add On works with the latest version of the SLP base plugin.
- create_object_option_manager() : mixed
- Create an option manager object for this addon.
- create_object_widget() : mixed
- Create and attach the widget object as needed.
- get_short_slug() : string
- Get the short slug, just the base/directory part of the fully qualified WP slug for this plugin.
- VersionCheck() : mixed
- Compare current plugin version with minimum required.
Properties
$activation_class_name
public
mixed
$activation_class_name
$admin
public
mixed
$admin
$admin_menu_entries
public
mixed
$admin_menu_entries
$ajax
public
mixed
$ajax
$class_prefix
public
string
$class_prefix
the prefix that goes before all our classes
$dir
public
mixed
$dir
$file
public
mixed
$file
$language_dir
public
mixed
$language_dir
$latest_version
public
mixed
$latest_version
= '0.0.0'
$meta
public
mixed
$meta
$metadata
public
mixed
$metadata
$min_slp_version
public
mixed
$min_slp_version
$myslp
public
MySLP
$myslp
$name
public
mixed
$name
$option_defaults
public
mixed
$option_defaults
= array()
$option_name
public
mixed
$option_name
$options
public
mixed
$options
= array('installed_version' => '')
$options_defaults
public
mixed
$options_defaults
= array()
$short_slug
public
mixed
$short_slug
$slplus
public
SLPlus
$slplus
$slug
public
mixed
$slug
$textdomain
public
mixed
$textdomain
$Updates
public
mixed
$Updates
$url
public
mixed
$url
$userinterface
public
mixed
$userinterface
$userinterface_class_name
public
mixed
$userinterface_class_name
$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.
$version
public
mixed
$version
$widget
public
mixed
$widget
$widget_class_name
public
mixed
$widget_class_name
$WPOption_Manager
public
mixed
$WPOption_Manager
$addon
protected
mixed
$addon
$admin_class_name
protected
mixed
$admin_class_name
$ajax_class_name
protected
mixed
$ajax_class_name
$objects
protected
mixed
$objects
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__set()
Allow value to be set directly.
public
__set(mixed $property, mixed $value) : SLP_Option|null
Parameters
- $property : mixed
- $value : mixed
Return values
SLP_Option|nulladd_hooks_and_filters()
Add the plugin specific hooks and filter configurations here.
public
add_hooks_and_filters() : mixed
The hooks & filters that go here are cross-interface element hooks/filters needed in 2+ locations:
- AJAX
- Admin Interface
- User Interface
For example, custom taxonomy hooks and filters.
Should include WordPress and SLP specific hooks and filters.
add_object()
public
add_object(mixed $object) : mixed
Parameters
- $object : mixed
create_object()
Instantiate our objects ONCE and refer to them in an object array.
public
create_object(string $class[, string $subdir = '.' ]) : mixed
TODO: Remove and update Power compat to 4.9.1
Parameters
- $class : string
- $subdir : string = '.'
create_object_Updates()
Creates updates object AND checks for updates for this add-on.
public
create_object_Updates(bool $force) : mixed
Parameters
- $force : bool
createobject_Admin()
Create the admin interface object and attach to this->admin
public
createobject_Admin() : mixed
Called on slp_admin_menu_starting. If that menu is rendering, we are on an admin page. Called via hook slp_admin_menu_starting setup in this class.
createobject_AJAX()
Create the AJAX processing object and attach to this->ajax
public
createobject_AJAX() : mixed
createobject_UserInterface()
Create the user interface object and attach to this->UserInterface
public
createobject_UserInterface() : mixed
Tags
filter_AddMenuItems()
Add the items specified in the menu_entries property to the SLP menu.
public
filter_AddMenuItems(array<string|int, mixed> $menuItems) : array<string|int, mixed>
If you make the 'slug' property of the $admin_menu_entries array = $this->addon->short_slug you won't need to set this->addon->admin->admin_page_slug
Parameters
- $menuItems : array<string|int, mixed>
Return values
array<string|int, mixed>get_addon_version()
Get the add-on pack version.
public
get_addon_version() : string
Return values
stringget_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_meta()
Get the add on metadata property as specified.
public
get_meta(string $property) : string
Parameters
- $property : string
Return values
stringget_option()
Get an option attribute.
public
get_option(string $property, string $attribute) : mixed
Parameters
- $property : string
- $attribute : string
init_options()
Initialize the options properties from the WordPress database.
public
init_options() : mixed
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|objectload_options()
Load the options class to help the SLP smart options if we have that feature.
public
load_options() : mixed
run_during_init()
Always run this stuff during the WordPress init hook.
public
run_during_init() : void
set_option()
Set an option attribute.
public
set_option(string $property, string $attribute, mixed $value) : bool
Parameters
- $property : string
- $attribute : string
- $value : mixed
Return values
boolset_option_defaults()
Set option defaults outside of hard-coded property values via an array.
public
set_option_defaults() : mixed
This allows for gettext() string translations of defaults.
Only bring over items in default_value_array that have matching keys in $this->options already.
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
Parameters
- $val : mixed
- $key : mixed
setting_name()
Generate a proper setting name for the settings class.
public
setting_name(mixed $setting) : string
Parameters
- $setting : mixed
Return values
stringslp_init()
Things to do once SLP is alive.
public
slp_init() : mixed
Tags
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.
initialize()
Run these things during invocation. (called from base object in __construct)
protected
initialize() : mixed
set_default_object_options()
Set default options for objects. Override in your class.
protected
set_default_object_options() : mixed
check_my_version_compatibility()
Check the current version of this Add On works with the latest version of the SLP base plugin.
private
check_my_version_compatibility() : bool
Return values
boolcreate_object_option_manager()
Create an option manager object for this addon.
private
create_object_option_manager() : mixed
If an addon has ./include/options/<class_prefix>Options.php load it up.
create_object_widget()
Create and attach the widget object as needed.
private
create_object_widget() : mixed
get_short_slug()
Get the short slug, just the base/directory part of the fully qualified WP slug for this plugin.
private
get_short_slug() : string
Return values
stringVersionCheck()
Compare current plugin version with minimum required.
private
VersionCheck(array<string|int, mixed> $params) : mixed
Set a notification message. Disable the requesting add-on pack if requirement is not met.
$params['addon_name'] - the plain text name for the add-on pack. $params['addon_slug'] - the slug for the add-on pack. $params['min_required_version'] - the minimum required version of the base plugin.
Parameters
- $params : array<string|int, mixed>