Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created March 20, 2018 16:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/eab44952ef0add72eafab04332f9ef34 to your computer and use it in GitHub Desktop.
Save tommcfarlin/eab44952ef0add72eafab04332f9ef34 to your computer and use it in GitHub Desktop.
[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