wp-forge / wp-plugin-check
Check if a WordPress plugin is compatible with the current environment.
1.0
2020-04-20 16:55 UTC
This package is auto-updated.
Last update: 2024-11-21 20:54:00 UTC
README
Check if a WordPress plugin is compatible with the current environment. If not, it will automatically deactivate the plugin and show a message to the user letting them know what they can do about it.
Note: Only supports checking PHP 5.2+.
Installation
composer require wp-forge/wp-plugin-check
Usage
This is how the code should be used:
<?php // Plugin headers go here... require dirname( __FILE__ ) . '/vendor/autoload.php'; // Check plugin requirements global $pagenow; if ( 'plugins.php' === $pagenow ) { $plugin_check = new WP_Forge_Plugin_Check( __FILE__ ); $plugin_check->min_php_version = '5.6'; $plugin_check->min_wp_version = '5.0'; $plugin_check->req_php_extensions = array( 'json', 'SimpleXML' ); $plugin_check->check_plugin_requirements(); } require dirname( __FILE__ ) . '/includes/bootstrap.php';
Alter the WordPress version, PHP version, and required PHP extensions as needed.
Important: Don't load any other code in your main plugin file! PHP parses all code in a file before running it, so incompatible PHP code added after this check will negate the ability to properly perform compatibility checks.