abstract class Admin_Module extends Plugin

A class to represent and help deal with common plugin admin functionality.

Traits

A trait to extend the Plugin functionality by providing methods for running tasks on version updates.

Properties

static protected Singleton[] $_instances from  Singleton
protected bool $is_submodule from  Module
protected bool $enabled from  Module
static string $includes_dir from  Module
static string $modules_dir from  Module
static array $includes
protected array $loaded_modules from  Module
static protected string $upgrades_dir from  Plugin_Upgrader_Trait
protected Admin_Module $admin_module from  Plugin
static protected string $templates_dir from  Plugin
static protected string $post_types_dir from  Plugin
protected array $loaded_post_types from  Plugin
static protected string $screens_dir
protected array $loaded_screens

Methods

__construct()

A protected constructor to ensure only singleton instances exist.

static Singleton
instance(mixed $args = null)

Maybe initialize singleton instance and return the instance.

static array
get_instances()

Return a copy of the instances array.

get_class_reflection()

A short one-liner tool to get a ReflectionClass so we can get runtime info for the static class instance and not this abstract.

static 
construct()

An empty, placeholder function for overriding, this is where the module "starts" it's WordPress code.

from  Module
static 
submodule_construct()

The function which gets called when a module is being constructed. This ensures the submodule construct sequences don't get fired when a submodule is first initialized.

from  Module
static 
submodule_instance()

The function which gets called if this module is being imported as a submodule.

from  Module
register_submodules()

Our special function for searching for submodule folders, loading them into the current module and PHP environment.

from  Module
construct_submodules()

Loop through all loaded modules and run their initialization functions.

from  Module
import_module(string $module_path)

Given a Module class name and a file path, loads the file into the PHP environment, then checks to make sure the given class extends Module and adds it to { $this->loaded_modules }

from  Module
string|false
load_class_file(string $file_path)

Load a class from a file and return the full class name.

from  Module
array
get_loaded_modules()

Get the currently loaded modules.

from  Module
init_upgrader()

Check if the Upgraders need to be run, then run them and update the current version if so.

bool
requires_version_upgrade()

Check if the Plugin version is newer than the currently stored version.

run_upgrades()

Find all upgrade Schemas and run them.

update_current_version()

Update the current Plugin version in the database.

static array
sort_upgrade_schemas(array $upgrade_schemas)

Sort Schema actions by version.

static 
execute_schemas(string $current_version, array $upgrade_schemas)

Loop through and execute all Schema actions.

null|Admin_Module
get_admin_module()

Get the Admin Module.

from  Plugin
static 
activation()

A default, empty function to run on plugin activation.

from  Plugin
static 
deactivation()

A default, empty function to run on plugin deactivation.

from  Plugin
get_template(string $template, array $args = array())

A function to retrieve a template file from the templates directory.

from  Plugin
enqueue_js(string $script, array $reqs = array(), array $locatization_data = array())

Enqueue a script from the assets folder.

from  Plugin
enqueue_css(string $style, array $reqs = array())

Enqueue a stylesheet from the assets folder.

from  Plugin
deactivate()

Force deactivate this Plugin by updating the WordPress options. There was an 'activate' function, but you must require the Plugin file before using the class anyway.

from  Plugin
string
get_plugin_file()

Return the file location of the Plugin instance.

from  Plugin
string
get_plugin_id()

Return the Plugin site ID, which should be the plugin folder name and the name of the PHP file.

from  Plugin

Details

at line 44
final protected __construct()

A protected constructor to ensure only singleton instances exist.

in Singleton at line 42
final static Singleton instance(mixed $args = null)

Maybe initialize singleton instance and return the instance.

Parameters

mixed $args

The arguments to pass to the singleton constructor if constructing.

Return Value

Singleton

This instance.

in Singleton at line 63
final static array get_instances()

Return a copy of the instances array.

Return Value

array

A list of Singleton instances that have been instantiated.

in Singleton at line 72
final protected ReflectionClass get_class_reflection()

A short one-liner tool to get a ReflectionClass so we can get runtime info for the static class instance and not this abstract.

Return Value

ReflectionClass

The runtime instance of this class being evalutated.

in Module at line 82
static construct()

An empty, placeholder function for overriding, this is where the module "starts" it's WordPress code.

in Module at line 87
static submodule_construct()

The function which gets called when a module is being constructed. This ensures the submodule construct sequences don't get fired when a submodule is first initialized.

in Module at line 98
final static submodule_instance()

The function which gets called if this module is being imported as a submodule.

in Module at line 105
final protected register_submodules()

Our special function for searching for submodule folders, loading them into the current module and PHP environment.

in Module at line 136
final protected construct_submodules()

Loop through all loaded modules and run their initialization functions.

in Module at line 149
final protected import_module(string $module_path)

Given a Module class name and a file path, loads the file into the PHP environment, then checks to make sure the given class extends Module and adds it to { $this->loaded_modules }

Parameters

string $module_path

The full path/file combination pointing to the module file.

in Module at line 173
final protected string|false load_class_file(string $file_path)

Load a class from a file and return the full class name.

Parameters

string $file_path

The path to the file containing the class.

Return Value

string|false

The fully-qualified class name or FALSE on failure.

in Module at line 225
final array get_loaded_modules()

Get the currently loaded modules.

Return Value

array

The modules currently loaded.

final init_upgrader()

Check if the Upgraders need to be run, then run them and update the current version if so.

final bool requires_version_upgrade()

Check if the Plugin version is newer than the currently stored version.

Return Value

bool

Whether or not there may be upgrade actions to run.

final run_upgrades()

Find all upgrade Schemas and run them.

final update_current_version()

Update the current Plugin version in the database.

final static array sort_upgrade_schemas(array $upgrade_schemas)

Sort Schema actions by version.

Parameters

array $upgrade_schemas

The Upgrade Schemas.

Return Value

array

The sorted Upgrade Schemas.

final static execute_schemas(string $current_version, array $upgrade_schemas)

Loop through and execute all Schema actions.

Parameters

string $current_version

The current stored version; run all actions newer.

array $upgrade_schemas

The upgrade Schema actions.

in Plugin at line 52
final null|Admin_Module get_admin_module()

Get the Admin Module.

Return Value

null|Admin_Module

The Admin Module.

in Plugin at line 83
static activation()

A default, empty function to run on plugin activation.

in Plugin at line 90
static deactivation()

A default, empty function to run on plugin deactivation.

in Plugin at line 98
final get_template(string $template, array $args = array())

A function to retrieve a template file from the templates directory.

Parameters

string $template

The template slug to retrieve and require.

array $args

The variables to set locally for the template.

in Plugin at line 122
final enqueue_js(string $script, array $reqs = array(), array $locatization_data = array())

Enqueue a script from the assets folder.

Parameters

string $script

The script file name (including extension).

array $reqs

The required Javascript files by reference.

array $locatization_data

Any localization data to pass to the script.

in Plugin at line 141
final enqueue_css(string $style, array $reqs = array())

Enqueue a stylesheet from the assets folder.

Parameters

string $style

The stylesheet file name (including extension).

array $reqs

The required CSS files by reference.

in Plugin at line 217
final deactivate()

Force deactivate this Plugin by updating the WordPress options. There was an 'activate' function, but you must require the Plugin file before using the class anyway.

in Plugin at line 232
final string get_plugin_file()

Return the file location of the Plugin instance.

Return Value

string

The plugin file location.

in Plugin at line 241
final string get_plugin_id()

Return the Plugin site ID, which should be the plugin folder name and the name of the PHP file.

Return Value

string

The Plugin ID.