Last active
February 3, 2021 17:40
-
-
Save wpmu-authors/79a2c5414969291ec90cac11c38b7522 to your computer and use it in GitHub Desktop.
dependency-check.php
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
register_activation_hook( __FILE__, 'my_plugin_activation' ); | |
function my_plugin_activation() { | |
global $wp_version; | |
$php = '5.3'; | |
$wp = '3.8'; | |
if ( version_compare( PHP_VERSION, $php, '<' ) ) { | |
deactivate_plugins( basename( __FILE__ ) ); | |
wp_die( | |
'<p>' . | |
sprintf( | |
__( 'This plugin can not be activated because it requires a PHP version greater than %1$s. Your PHP version can be updated by your hosting company.', 'my_plugin' ), | |
$php | |
) | |
. '</p> <a href="' . admin_url( 'plugins.php' ) . '">' . __( 'go back', 'my_plugin' ) . '</a>' | |
); | |
} | |
if ( version_compare( $wp_version, $wp, '<' ) ) { | |
deactivate_plugins( basename( __FILE__ ) ); | |
wp_die( | |
'<p>' . | |
sprintf( | |
__( 'This plugin can not be activated because it requires a WordPress version greater than %1$s. Please go to Dashboard ▸ Updates to gran the latest version of WordPress .', 'my_plugin' ), | |
$php | |
) | |
. '</p> <a href="' . admin_url( 'plugins.php' ) . '">' . __( 'go back', 'my_plugin' ) . '</a>' | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment