Last active
January 11, 2016 00:49
-
-
Save joelworsham/ca39eeacace703c368a4 to your computer and use it in GitHub Desktop.
PHP Version Check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
... | |
if ( version_compare( '5.3', phpversion(), '>' ) ) { | |
add_action( 'admin_notices', '_myplugin_php_notice' ); | |
// Do what you need to stop your plugin from loading | |
} | |
/** | |
* Displays an admin error about needing to update the server's PHP version. | |
* | |
* @access private | |
*/ | |
function _myplugin_php_notice() { | |
?> | |
<div class="error"> | |
<p> | |
<?php | |
sprintf( | |
__( 'MYPLUGIN is not active because your server is not running at least PHP version 5.3. Please update or contact your server administrator. (PS: PHP 5.3 is %s year\'s old!)', 'MYPLUGIN' ), | |
intval( date( 'y' ) ) - 9 | |
) | |
?> | |
</p> | |
</div> | |
<?php | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now, this won't work once enter the year 2100, but somehow I think that's okay!