jon-b
4/9/2015 - 7:24 PM

WordPress PHP Version Check

WordPress PHP Version Check

<?php

$required_php_version = '5.5';
if ( version_compare( PHP_VERSION, $required_php_version, '>') ) {
  include 'stuff.php';
} else {
  add_action( 'admin_notices', 'halt_and_catchfire' );
}

function halt_and_catchfire()
  $error_msg = 'PLUGIN_NAME requires PHP ' . $required_php_version . ' or newer. Your server is currently running PHP ' . PHP_VERSION . '.  Please contact your web host to update.' );
  return $error_msg;
}