wp-content » plugins » How to force your WordPress theme or plugin users to use PHP 8.0

How to force your WordPress theme or plugin users to use PHP 8.0

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.

image 17 - How to force your WordPress theme or plugin users to use PHP 8.0
Currently Supported PHP Versions

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.

See also  List all WordPress Blocks in the Editor

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.

Recommended