overclokk / minimum-requirements
Check the minimum requirements for your WordPress theme or plugin
Installs: 1 015
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 2
Open Issues: 1
Type:wordpress-plugin
Requires
- php: >=5.2
Requires (Dev)
- lucatume/function-mocker: ^1.0
- lucatume/wp-browser: ^1.10
This package is not auto-updated.
Last update: 2023-08-19 12:40:24 UTC
README
Check the minimum requirements for your WordPress theme or plugin
Installation
To install simply require the package in the composer.json
file like
"require": { "overclokk/minimum-requirements": "*" }
and then use composer install
or composer update
to fetch the package.
CLI
Or simply run
composer require overclokk/minimum-requirements
Or
php composer.phar require overclokk/minimum-requirements
Example
/** * Require minimum-requirements class to load minimum compatibility theme/plugin */ require( dirname( __FILE__ ) . '/vendor/overclokk/minimum-requirements/minimum-requirements.php' ); /** * Instantiate the class * * @param string $php_ver The minimum PHP version. * @param string $wp_ver The minimum WP version. * @param string $name The name of the theme/plugin to check. * @param array $plugins Required plugins format plugin_path/plugin_name. * * @var Minimum_Requirements */ $requirements = new Minimum_Requirements( '5.3', '3.5', 'YOUR PLUGIN NAME', array( 'plugin-a', 'plugin-b' ) ); /** * Check compatibility on install * If is not compatible on install print an admin_notice */ register_activation_hook( __FILE__, array( $requirements, 'check_compatibility_on_install' ) ); /** * If it is already installed and activated check if example new version is compatible, if is not don't load plugin code and prin admin_notice * This part need more test */ if ( ! $requirements->is_compatible_version() ) { add_action( 'admin_notices', array( $requirements, 'load_plugin_admin_notices' ) ); return; } /** * If it is compatible load the rest of the theme/plugin code */ // Your stuff here
Credits
The original code (only the part of cheking requirements) comes from SZ-Google of Massimo della Rovere with my personal improvements and a little piece of code from WordPress-Plugin-Boilerplate-Powered of Mte90 (the part that check the plugin needed).
Thanks to Luca Tumedei for his help for improving the code and writing test with wp-browser