Store Locator Plus®

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  : string
$activation_class_name  : mixed
$addon  : SLP_BaseClass_Addon
$admin  : SLP_BaseClass_Admin
$admin  : mixed
$admin_class_name  : string
$admin_menu_entries  : array<string|int, mixed>
$admin_menu_entries  : mixed
$ajax  : SLP_BaseClass_AJAX
$ajax  : mixed
$ajax_class_name  : string
$class_prefix  : string
$class_prefix  : string
$dir  : mixed
$dir  : string
$dir  : string
$dir  : string
$file  : string
$file  : mixed
$meta  : SLP_AddOns_Meta
$meta  : mixed
$metadata  : mixed
$min_slp_version  : string
$min_slp_version  : mixed
$name  : string
$name  : mixed
$objects  : array<string|int, mixed>
$objects  : array<string|int, mixed>
$objects  : array<string|int, mixed>
$option_defaults  : array<string|int, mixed>
$option_defaults  : mixed
$option_name  : mixed
$option_name  : string
$option_name  : string
$options  : mixed
$options  : array<string|int, mixed>
$options  : array<string|int, mixed>
$options_defaults  : array<string|int, mixed>
$options_defaults  : mixed
$short_slug  : string
$short_slug  : mixed
$slplus  : SLPlus
$slug  : string
$slug  : mixed
$Updates  : SLP_AddOn_Updates
$Updates  : mixed
$url  : string
$url  : mixed
$userinterface  : SLP_BaseClass_UI
$userinterface  : mixed
$userinterface_class_name  : string
$userinterface_class_name  : mixed
$uses_slplus  : bool
$version  : string
$version  : mixed
$widget  : SLP_BaseClass_Widget
$widget  : mixed
$widget_class_name  : string
$widget_class_name  : mixed
$WPOption_Manager  : SLP_WPOption_Manager
$WPOption_Manager  : mixed
$addon  : mixed
$admin_class_name  : mixed
$ajax_class_name  : mixed
$class_prefix  : mixed
$objects  : mixed
$slplus  : mixed
$uses_slplus  : mixed

Methods

__construct()  : mixed
__get()  : SLPlus_BaseClass_Object
__isset()  : bool
__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()  : SLPlus_BaseClass_Object
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.
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.
augment_class()  : string
Augment the class names so we can reference simple property names.
auto_instantiate()  : mixed
Any object with auto_instantiate set to true is instantiate during initialization.
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 string $activation_class_name

The name of the activation class for this add on.

$admin_class_name

public string $admin_class_name

The name of the admin class for this add on.

$admin_menu_entries

public array<string|int, mixed> $admin_menu_entries

array of menu entries, should be in a key=>value array where key = the menu text and value = the function or PHP file to execute.

$ajax_class_name

public string $ajax_class_name

The name of the AJAX class for this add on.

$min_slp_version

public string $min_slp_version

Minimum version of SLP required to run this add-on pack in x.y.zz format.

$objects read-only

public array<string|int, mixed> $objects

A named array of our instantiated objects, the key is the class name the value is the object itself.

$objects

public array<string|int, mixed> $objects

key = class name, array of attributes() object = the instantiated object subdir = the subdirectory (from theme root) that contains the class definition

$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

$option_defaults

public array<string|int, mixed> $option_defaults

The default values for options. Set this in init_options for any gettext elements. $option_defaults['setting'] = __('string to translate', 'textdomain')

$option_name

public string $option_name

The name of the wp_option to store serialized add-on pack settings.

$options

public array<string|int, mixed> $options

Settable options for this plugin. (Does NOT go into main plugin JavaScript)

$options

public array<string|int, mixed> $options

key = option slug, array of attributes() value = the value of the option

$options_defaults

public array<string|int, mixed> $options_defaults

Default options.

$slug

public string $slug

The slug for this plugin, usually matches the plugin subdirectory name.

$userinterface_class_name

public string $userinterface_class_name

The name of the user class for this add on.

$uses_slplus

public bool $uses_slplus

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

$version

public string $version

Current version of this add-on pack in x.y.zz format.

$widget_class_name

public string $widget_class_name

The name of the widget class for this add on.

Methods

__construct()

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_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.

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.

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
used-by

\MySLP_REST_API::get_options

used-by

\SLP_BaseClass_Addon::slp_init via WP Filter wp_enqueue_scripts

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
string

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_meta()

Get the add on metadata property as specified.

public get_meta(string $property) : string
Parameters
$property : string
Return values
string

get_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|object

load_options()

Load the options class to help the SLP smart options if we have that feature.

public load_options() : mixed

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
bool

set_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( $val,  $key) : mixed
Parameters
$val :
$key :

setting_name()

Generate a proper setting name for the settings class.

public setting_name( $setting) : string
Parameters
$setting :
Return values
string

slp_init()

Things to do once SLP is alive.

public slp_init() : mixed
Tags
used-by

\SLP_BaseClass_Addon::initialize via SLP Filter slp_init_complete

uses
SLP_BaseClass_Addon::createobject_UserInterface

via WP Filter wp_enqueue_scripts

at_startup()

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

protected at_startup() : mixed

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

augment_class()

Augment the class names so we can reference simple property names.

private augment_class(string $class) : string
Parameters
$class : string
Return values
string

auto_instantiate()

Any object with auto_instantiate set to true is instantiate during initialization.

private auto_instantiate() : 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
bool

create_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
string

VersionCheck()

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>

        
On this page

Search results