Admin_Module
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
A protected constructor to ensure only singleton instances exist.
Maybe initialize singleton instance and return the instance.
A short one-liner tool to get a ReflectionClass so we can get runtime info for the static class instance and not this abstract.
An empty, placeholder function for overriding, this is where the module "starts" it's WordPress code.
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.
The function which gets called if this module is being imported as a submodule.
Our special function for searching for submodule folders, loading them into the current module and PHP environment.
Loop through all loaded modules and run their initialization functions.
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 }
Load a class from a file and return the full class name.
Check if the Upgraders need to be run, then run them and update the current version if so.
Check if the Plugin version is newer than the currently stored version.
Update the current Plugin version in the database.
Sort Schema actions by version.
Loop through and execute all Schema actions.
A function to retrieve a template file from the templates directory.
Enqueue a script from the assets folder.
Enqueue a stylesheet from the assets folder.
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.
Return the Plugin site ID, which should be the plugin folder name and the name of the PHP file.
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.
in
Singleton at line 63
final static array
get_instances()
Return a copy of the instances array.
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.
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 }
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.
in
Module at line 225
final array
get_loaded_modules()
Get the currently loaded modules.
in
Plugin_Upgrader_Trait at line 34
final
init_upgrader()
Check if the Upgraders need to be run, then run them and update the current version if so.
in
Plugin_Upgrader_Trait at line 46
final bool
requires_version_upgrade()
Check if the Plugin version is newer than the currently stored version.
in
Plugin_Upgrader_Trait at line 63
final
run_upgrades()
Find all upgrade Schemas and run them.
in
Plugin_Upgrader_Trait at line 103
final
update_current_version()
Update the current Plugin version in the database.
in
Plugin_Upgrader_Trait at line 115
final static array
sort_upgrade_schemas(array $upgrade_schemas)
Sort Schema actions by version.
in
Plugin_Upgrader_Trait at line 142
final static
execute_schemas(string $current_version, array $upgrade_schemas)
Loop through and execute all Schema actions.
in
Plugin at line 52
final null|Admin_Module
get_admin_module()
Get 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.
in
Plugin at line 122
final
enqueue_js(string $script, array $reqs = array(), array $locatization_data = array())
Enqueue a script from the assets folder.
in
Plugin at line 141
final
enqueue_css(string $style, array $reqs = array())
Enqueue a stylesheet from the assets folder.
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.
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.