How to use
The module is available for free installation through Composer on Packagist. Assuming you've added the Bootstrapper module to your project using Composer, your plugin's main file should look something like this:
<?php
/**
* Plugin Name: My Test Plugin
* Version: 1.0.0
* Requires at least: 5.7
* Requires PHP: 8.0
*/
// Load the Composer autoloader.
\is_file( __DIR__ . '/vendor/autoload.php' ) && require_once __DIR__ . '/vendor/autoload.php';
// Bootstrap the plugin (maybe)!
if ( dws_wp_framework_check_php_wp_requirements_met( '8.0', '5.7' ) ) {
// move ahead with plugin initialization
} else {
dws_wp_framework_output_requirements_error( 'My Test Plugin', '1.0.0', '8.0', '5.7', array( 'optional_argument' ) );
}
The example above is very rudimentary. You can check our example plugin's bootstrap file for a more complete example.
There is no point for the Bootstrapper module to run on all PHP versions back to 5.3 if your own bootstrap file doesn't. For example, import of functions from another namespace is only supported since PHP5.6! For brevity, that has not been included in the code example above, but it is shown in the example plugin's bootstrap file.
All the bootstrap files of the DWS Framework are backwards compatible with PHP5.3. However, we obviously can't guarantee the same thing for any 3rd-party libraries you might bundle with your plugin. We have had success ensuring this using Rector's PHP Downgrade rules bundled as a Composer script in our wordpress-configs package.

Actions

The outputted admin notice can be customized using the following actions:
  • dws_wp_framework_requirements_error_before -- called before any HTML output of the notice
  • dws_wp_framework_requirements_error_start -- called right after the opening <div>
  • dws_wp_framework_requirements_error_list_before -- called right after the opening <ul>
  • dws_wp_framework_requirements_error_list_after -- called right before the closing </ul>
  • dws_wp_framework_requirements_error_end -- called right before the closing </div>
  • dws_wp_framework_requirements_error_after -- called after the entire HTML output of the notice
All actions receive the same arguments as the dws_wp_framework_output_requirements_error function. In order, those are:
  • The name of the component triggering the requirements error output.
  • The version of the said component.
  • The minimum PHP version required by said component.
  • The minimum WP version required by said component.
  • Any optional arguments passed on (array).
Copy link