Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check if current WP installation runs on server with minimum PHP 5.4
<?php
add_action('admin_notices', '_check_php_version_notif', 0);
/**
* Check if current PHP version is newer than 5.4
* @link https://gist.github.com/TweetPressFr/0cb0ef6330f054f55839
* @author Julien Maury
*/
function _check_php_version_notif(){
global $pagenow;
$error = '';
if (version_compare('5.4', phpversion(), '>')) {
$error = 'This plugin needs PHP 5.4 minimum ! Sorry !';
}
if ( empty($error) || empty($pagenow) || 'plugins.php' !== $pagenow )
return;
unset($_GET['activate']);
printf(__('<div class="error"><p>%2$s</p><p>%1$s has been deactivated.</p></div>'), 'My Plugin Name', $error);
deactivate_plugins( plugin_basename(__FILE__) );
}
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.