mundschenk-at / check-wp-requirements
A class to allow WordPress plugins to check certain runtime requirements before activation.
Installs: 19 412
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.4.0
Requires (Dev)
- brain/monkey: ^2.2
- dealerdirect/phpcodesniffer-composer-installer: ^1.0
- mikey179/vfsstream: ~1
- paulthewalton/acf-stubs: ^5.8
- phpcompatibility/php-compatibility: ^9.0
- phpstan/extension-installer: ^1.2
- phpstan/phpstan: ^2
- phpstan/phpstan-mockery: ^2.0
- phpstan/phpstan-phpunit: ^2
- phpunit/phpunit: 5.*||6.*||7.*||8.*||9.*
- shish/safe: ^2
- squizlabs/php_codesniffer: ^3.4
- szepeviktor/phpstan-wordpress: ^2.0.0-rc.2
- wp-coding-standards/wpcs: ^3
- yoast/phpunit-polyfills: 1.*||2.*||3.*
README
A helper class for WordPress plugins to check PHP version and other requirements.
Requirements
- PHP 7.4.0 or above
- WordPress 5.2 or higher.
Installation
The best way to use this package is through Composer:
$ composer require mundschenk-at/check-wp-requirements
Basic Usage
- Create a
\Mundschenk\WP_Requirements
object and set the requirements in the constructor. - Call the
\Mundschenk\WP_Requirements::check()
method and start your plugin normally if it returnstrue
.
// Set up autoloader. require_once __DIR__ . '/vendor/autoload.php'; /** * Load the plugin after checking for the necessary PHP version. * * It's necessary to do this here because main class relies on namespaces. */ function run_your_plugin() { $requirements = new \Mundschenk\WP_Requirements( 'Your Plugin Name', __FILE__, 'your-textdomain', [ 'php' => '8.1.0', 'multibyte' => true, 'utf-8' => false, ] ); if ( $requirements->check() ) { // Autoload the rest of your classes. // Create and start the plugin. ... } } run_your_plugin();
License
check-wp-requirements is licensed under the GNU General Public License 2 or later - see the LICENSE file for details.