Comment on page
How it works
The main PHP lines of the module explained in plain English.
This module is by far the simplest among all of them. But it only works if a couple of things that are fulfilled:
- 1.It must be the very first thing that the plugin loads.
- 2.The other modules (and the plugin itself) must refuse to continue running if this module fails to initialize.
Luckily, the first condition is pretty simple to fulfill. The module's entry point is the
bootstrap.phpfile (just like all the other modules, actually) and it is defined in the
composer.jsonfile as an autoload target. Since every single other module also depends on the Bootstrapper module, Composer's autoloader will ensure this file is the first one to load across the entire framework.
As far as the second condition is concerned, you can rest assured that our other modules to follow it. As for your own plugin, well, that depends on you so we're probably covered again!
On a functional level, the file
bootstrap-functions.phpcontains the checker function. The main logic is handled by the very simple
If the minimum requirements are met, the namespaced constant
DWS_WP_FRAMEWORK_BOOTSTRAPPER_INITis set to true, otherwise it is set to false in
bootstrap.php. It is best to not access the constant directly, but through use of the helper function
Should the constant be set to false, the module also outputs the
requirements-error.phptemplate as an admin notice. This notice will contain the name of the module that failed to initialize and provide some more information about what went wrong.
If the Bootstrapper module fails, all subsequent framework modules will fail too. However, the admin notice will only be outputted only once and will contain the name of the first module that failed only.
Here is an example of what the notice looks like:
Default requirements error admin notice