Skip to content

Instantly share code, notes, and snippets.

@lloc
Created January 13, 2013 18:23
Show Gist options
  • Select an option

  • Save lloc/4525457 to your computer and use it in GitHub Desktop.

Select an option

Save lloc/4525457 to your computer and use it in GitHub Desktop.
<?php
define( 'MYPLUGIN_MIN_PHP', '5.2' );
define( 'MYPLUGIN_MIN_WP', '2.8' );
function myplugin_activate () {
$error = '';
$phpversion = phpversion();
if ( version_compare( MYPLUGIN_MIN_PHP, $phpversion, '>' ) )
$error .= sprintf( "Minimum PHP version required is %s, not %s.\n", MYPLUGIN_MIN_PHP, $phpversion );
$wpversion = get_bloginfo( 'version' );
if ( version_compare( MYPLUGIN_MIN_WP, $wpversion, '>' ) )
$error .= sprintf( "Minimum WP version required is %s, not %s.\n", MYPLUGIN_MIN_WP, $wpversion );
if ( !$error ) return;
deactivate_plugins( __FILE__ );
die( $error );
}
register_activation_hook( __FILE__, 'myplugin_activate' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment