At the time of writing this article (December 03.2022), PHP8 is no longer actively supported and will only receive security support for the next 1 year.
New PHP versions offer better optimization and security, but not all plugins, themes, or even WordPress itself is NOT fully compatible with PHP 8.0
How to force your WordPress theme or plugin users to use PHP8 ?
Here is a small check that I use in my plugins to detect if WordPress is using PHP 8:
function get_minimum_php_version() {
return '8.0.0';
}
function is_valid_php_ver() {
return 0 <= version_compare( PHP_VERSION, get_minimum_php_version() );
}
Then to load files:
if ( is_valid_php_ver() ) {
require_once 'init.php';
}
You can add notification messages to the user that this plugin (or theme) requires PHP8 and activate it only when the requirement is met.
Was this post helpful?
Let me know if you liked the post. That’s the only way I can improve. 🙂