Skip to content

Instantly share code, notes, and snippets.

Created March 20, 2018 16:38
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
[WordPress] Handle PHP Version in WordPress
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', '<')) {
'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.',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment