Configuration
All available configuration options for requirements.php.
Config File Location
The requirements config file should be placed at:
your-plugin/
+-- config/
| +-- requirements.php ← Here
+-- src/
+-- plugin.php
Complete Configuration Reference
<?php
declare(strict_types=1);
/**
* Requirements Configuration
*
* @package YourPlugin
*/
return [
/*
|--------------------------------------------------------------------------
| Minimum PHP Version
|--------------------------------------------------------------------------
|
| The minimum PHP version required to run this plugin.
|
| Type: string
| Example: '8.0', '8.1', '8.2'
|
*/
'min_php_version' => '8.1',
/*
|--------------------------------------------------------------------------
| Minimum WordPress Version
|--------------------------------------------------------------------------
|
| The minimum WordPress version required.
|
| Type: string
| Example: '6.0', '6.4', '6.5'
|
*/
'min_wp_version' => '6.0',
/*
|--------------------------------------------------------------------------
| Multisite Compatibility
|--------------------------------------------------------------------------
|
| Whether your plugin supports WordPress Multisite.
|
| Type: bool
| - true: Plugin is multisite compatible
| - false: Plugin should NOT run on multisite
|
*/
'is_multisite_compatible' => true,
/*
|--------------------------------------------------------------------------
| Required PHP Extensions
|--------------------------------------------------------------------------
|
| List of PHP extensions that must be loaded.
|
| Type: array<string>
| Common extensions: json, mbstring, curl, xml, zip, openssl, gd
|
*/
'php_extensions' => [
'json',
'mbstring',
'curl',
],
/*
|--------------------------------------------------------------------------
| Required Plugins
|--------------------------------------------------------------------------
|
| List of WordPress plugins that must be installed and active.
|
| Format:
| 'Display Name' => [
| 'plugin_slug' => 'folder/file.php',
| 'min_plugin_version' => '1.0.0', // optional
| ],
|
*/
'required_plugins' => [
'WooCommerce' => [
'plugin_slug' => 'woocommerce/woocommerce.php',
'min_plugin_version' => '8.0.0',
],
'Advanced Custom Fields' => [
'plugin_slug' => 'advanced-custom-fields/acf.php',
// No version requirement
],
],
];
Individual Options
min_php_version
'min_php_version' => '8.1',
Validates the current PHP version. Uses version_compare() internally.
Error message:
PHP 8.1+ is required. You are running: 7.4.33
min_wp_version
'min_wp_version' => '6.0',
Validates the WordPress version using $GLOBALS['wp_version'].
Error message:
WordPress 6.0+ is required. You are running: 5.9.3
is_multisite_compatible
'is_multisite_compatible' => true,
| Value | Behavior |
|---|---|
true | Plugin works on both single site and multisite |
false | Plugin fails on multisite installations |
| Not set | No multisite check performed |
Error message:
This plugin is not compatible with WordPress Multisite.
php_extensions
'php_extensions' => ['json', 'mbstring', 'curl'],
Checks that each listed extension is loaded using extension_loaded().
Error message:
Required PHP extension missing: mbstring
required_plugins
'required_plugins' => [
'WooCommerce' => [
'plugin_slug' => 'woocommerce/woocommerce.php',
'min_plugin_version' => '8.0.0',
],
],
| Key | Required | Description |
|---|---|---|
plugin_slug | Yes | Plugin folder and main file |
min_plugin_version | No | Minimum version required |
Error messages:
Required plugin WooCommerce is missing. Required plugin WooCommerce is not active. Required plugin WooCommerce must be version 8.0.0+ (installed: 7.9.0)
Minimal Configuration
For simple plugins:
<?php
return [
'min_php_version' => '8.0',
'min_wp_version' => '6.0',
];
Environment-Specific Config
You can use environment variables:
<?php
return [
'min_php_version' => getenv('MIN_PHP_VERSION') ?: '8.0',
'min_wp_version' => getenv('MIN_WP_VERSION') ?: '6.0',
];