DWS WP Framework
  • Welcome
  • Primary goals
    • Modular design
    • No 3rd-party dependencies
  • Key concepts and dev tools
    • PHP and WP requirements
    • Object-Oriented Programming
    • Semantic Versioning
    • Version Control (git / GitHub)
    • Dependency Management (Composer)
    • Automated Testing (Codeception + Github Actions)
    • Dependency Injection (PHP-DI)
    • Coding Standards (PHPCS and PHPMD)
    • Dependencies Scoping (PHP-Scoper)
    • TypeScript and Sass
    • Task Runners (Grunt)
  • Setting up your dev environment
    • Windows
  • Your first plugin
    • Multiple plugins using the framework on the same site
  • Frequently Asked Questions
  • Bootstrapper Module
    • Motivation
    • How it works
    • How to use
    • White Labeling
  • Helpers Module
    • Motivation
    • How to use
  • Foundations Module
    • Motivation and How to use
    • Actions
      • Local action traits
      • Extension action traits
      • Integration action traits
    • States
    • Utilities
      • Stores
      • Handlers and Services
        • Logging Service
  • Plugin
    • Main Plugin Instance
    • Plugin Components
  • Hierarchies
  • Helpers
  • Utilities Module
    • Motivation and How to use
    • Hooks Service
      • Scoped Handler
    • Shortcodes Service
    • Templating Service
    • Assets Service
      • Scripts Handler
      • Styles Handler
    • CRON Events Service
      • Action Scheduler Handler
    • Admin Notices Service
    • Dependencies Service
    • Validation Service
  • Core Module
    • Motivation and How to use
    • Plugin Tree
      • Plugin Root
      • Plugin Functionality
    • Plugin Components
      • Internationalization
      • Installation / Upgrade / Uninstallation
  • Settings Module
    • Motivation and How to use
    • Settings Service
      • WordPress Handler
      • MetaBox Handler
      • ACF Handler
    • Validated Settings
  • WooCommerce Module
    • Motivation and How to use
    • Extended WC Logger
    • WC Settings Handler
Powered by GitBook
On this page

Was this helpful?

  1. Bootstrapper Module

How to use

PreviousHow it worksNextWhite Labeling

Last updated 4 years ago

Was this helpful?

The module is available for free installation through . Assuming you've added the Bootstrapper module to your project using , 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 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.

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).

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 bundled as a Composer script in .

Composer
on Packagist
Composer
our example plugin's bootstrap file
Rector's PHP Downgrade rules
our wordpress-configs package