10up / wp-compat-validation-tool
Perform PHP and WP version compatibility checks in your plugin.
Installs: 2
Dependents: 1
Suggesters: 0
Security: 0
Stars: 7
Watchers: 43
Forks: 0
Open Issues: 2
Type:wordpress-plugin
pkg:composer/10up/wp-compat-validation-tool
Requires
- composer/installers: ^2.2
This package is auto-updated.
Last update: 2025-11-22 22:05:45 UTC
README
Perform PHP and WP version compatibility checks in your plugin.
Overview
This library provides API methods to perform version validation checks in WordPress plugins. Most helpful in situation where the plugin should gracefully exit on activation when system requirements aren't met.
Setup
In your project's composer.json, add the following:
{
"require": {
"10up/wp-compat-validation-tool": "dev-trunk"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/10up/wp-compat-validation-tool.git"
}
],
"scripts": {
"post-install-cmd": [
"./10up-lib/wp-compat-validation-tool/replace-namespace.sh <New_Name_Space>"
],
"post-update-cmd": [
"./10up-lib/wp-compat-validation-tool/replace-namespace.sh <New_Name_Space>"
]
},
"extra": {
"installer-paths": {
"./{$name}/": ["10up/wp-compat-validation-tool"]
}
}
}
Replace <New_Name_Space> with a unique namespace specific to your project.
The WP_Compat_Validation_Tools namespace will be replaced by <New_Name_Space> to avoid namespace collisions in situations where multiple plugins use this package as their dependencies.
Usage
if ( ! is_readable( __DIR__ . '/10up-lib/wp-compat-validation-tool/src/Validator.php' ) ) { return; } require_once '10up-lib/wp-compat-validation-tool/src/Validator.php'; $compat_checker = new \New_Name_Space\Validator(); $compat_checker ->set_plugin_name( '<Your plugin name>' ) ->set_php_min_required_version( '7.4' ); if ( ! $compat_checker->is_plugin_compatible() ) { return; }
The Validator class should be instantiated before loading the vendor/autoload.php file, and the validation checks should be done before loading or instantiating any other composer dependency.
Support Level
Beta: This project is quite new and we're not sure what our ongoing support level for this will be. Bug reports, feature requests, questions, and pull requests are welcome. If you like this project please let us know, but be cautious using this in a Production environment!
Changelog
A complete listing of all notable changes to 10up Sitemaps is documented in CHANGELOG.md.
Contributing
Please read CODE_OF_CONDUCT.md for details on our code of conduct, CONTRIBUTING.md for details on the process for submitting pull requests to us, and CREDITS.md for a listing of maintainers of, contributors to, and libraries used by 10up Sitemaps.