wpdesk/wp-basic-requirements

There is no license information available for the latest version (3.6.3) of this package.

3.6.3 2024-04-16 08:22 UTC

README

pipeline status coverage report Latest Stable Version Total Downloads Latest Unstable Version License

WP Basic Requirements

wp-basic-requirements is a simple library for WordPress plugins allowing to verify if the target environment meets the defined requirements. If not, it can be also used to display the notice to the users containing the proper information.

The library has to be compatible with PHP 5.2.x since it's the oldest acceptable version for WordPress to be run.

Available requirements to be defined:

  • Minimal PHP version
  • Minimal WordPress version
  • Minimal WooCommerce version
  • Required PHP module
  • Required PHP setting
  • OpenSSL version

Requirements

PHP 5.2 or later.

Installation via Composer

In order to install the bindings via Composer run the following command:

composer require wpdesk/wp-basic-requirements

Example usage

Use the following code in WordPress plugin's main .php file:

<?php

$requirements_checker = ( new WPDesk_Basic_Requirement_Checker_Factory )->create_from_requirement_array(
    __FILE__,
    'Example plugin name',
    [	
        'php'     => '7.0',
        'wp'      => '6.0',
        'plugins' => [
            [
                'name'      => 'woocommerce/woocommerce.php',
                'nice_name' => 'WooCommerce',
            ],
        ],
    ]
);

if ( $requirements_checker->are_requirements_met() ) {
    // plugin stuff goes here
} else {
    $requirements_checker->render_notices();
}