2017 © Pedro Peláez
 

library requirements

WordPress drop-in to check requirements

image

underdev/requirements

WordPress drop-in to check requirements

  • Sunday, August 13, 2017
  • by underDEV
  • Repository
  • 2 Watchers
  • 14 Stars
  • 170 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 5 Versions
  • 10 % Grown

The README.md

Latest Stable Version Total Downloads Latest Unstable Version, (*1)

WordPress plugin requirements

A WordPress drop-in to check requirements., (*2)

Simple include the underDEV_Requirements.php file in your project or install and load it via Composer:, (*3)

composer require underdev/requirements, (*4)

Default checks: * PHP version * PHP extensions loaded * WordPress version * Active plugins and their versions * Active theme * Function collisions * Class collisions, (*5)

You can add also your own custom checks. See the example below., (*6)

It doesn't break the user action, such as activating many plugins at once. It will simply display a notice in the admin area:, (*7)

Requirements in WP Admin, (*8)

Sample usage

<?php
/*
Plugin Name: My Test Plugin
Version: 1.0
*/

/**
 * If installed by download
 */
require_once( 'underDEV_Requirements.php' );

/**
 * If installed via Composer it's included in the autoloader
 */
require_once( 'vendor/autoload.php' );

$requirements = new underDEV_Requirements( 'My Test Plugin', array(
    'php'                => '5.3',
    'php_extensions'     => array( 'soap' ),
    'wp'                 => '4.8',
    'plugins'            => array(
        'akismet/akismet.php'   => array( 'name' => 'Akismet', 'version' => '3.0' ),
        'hello-dolly/hello.php' => array( 'name' => 'Hello Dolly', 'version' => '1.5' )
    ),
    'theme'              => array(
        'slug' => 'twentysixteen',
        'name' => 'Twenty Sixteen'
    ),
    'function_collision' => array( 'my_function_name', 'some_other_potential_collision' ),
    'class_collision'    => array( 'My_Test_Plugin', 'My_Test_Plugin_Other_Class' ),
    'custom_check'       => 'thing to check', // this is not default check and will have to be registered
) );

/**
 * Add your own check
 */
function my_plugin_custom_check( $comparsion, $r ) {
    if ( $comparsion != 'thing to check' ) {
        $r->add_error( 'this thing to be that' );
    }
}

$requirements->add_check( 'custom_check', 'my_plugin_custom_check' );

/**
 * Run all the checks and check if requirements has been satisfied
 * If not - display the admin notice and exit from the file
 */
if ( ! $requirements->satisfied() ) {

    add_action( 'admin_notices', array( $requirements, 'notice' ) );
    return;

}

/**
 * Checks passed - load the plugin
 */
new My_Test_Plugin();

The Versions

13/08 2017

dev-develop

dev-develop

WordPress drop-in to check requirements

  Sources   Download

by Kuba Mikita

13/08 2017

dev-master

9999999-dev

WordPress drop-in to check requirements

  Sources   Download

by Kuba Mikita

13/08 2017

1.2.1

1.2.1.0

WordPress drop-in to check requirements

  Sources   Download

by Kuba Mikita

18/07 2017

1.2

1.2.0.0

WordPress drop-in to check requirements

  Sources   Download

by Kuba Mikita

18/07 2017

1.1

1.1.0.0

WordPress drop-in to check requirements

  Sources   Download

by Kuba Mikita