Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[WordPress] Handle PHP Version in WordPress
<?php
register_activation_hook(__FILE__, __NAMESPACE__ . '\\acme_activate');
/**
* Verifies that the user is running the proper version of WordPress for the
* plugin to execute; otherwise, displays an error message and prevents the
* plugin from being activated.
*/
function acme_activate()
{
if (version_compare(PHP_VERSION, '5.6.20', '<')) {
wp_die(
sprintf(
'Acme requires PHP 5.6.20 or higher.
Your WordPress site is using PHP %s. Please contact your hosting
provider and ask that they upgrade the version of PHP on which
your installation of WordPress is running. Click back in your
browser to your WordPress dashboard.',
PHP_VERSION
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.