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.php file (just like all the other modules, actually) and it is defined in the composer.json file 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.php contains the checker function. The main logic is handled by the very simple dws_wp_framework_check_php_wp_requirements_met function.

If the minimum requirements are met, the namespaced constant DWS_WP_FRAMEWORK_BOOTSTRAPPER_INIT is 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 dws_wp_framework_get_bootstrapper_init_status defined in bootstrap-functions.php.

Should the constant be set to false, the module also outputs the requirements-error.php template 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:

Last updated