Marian
Marian

Reputation: 1164

Prevent WordPress plugin activation on wrong versions of PHP or WP

Is there a way to prevent WordPress from activating a plugin, when I click "Activate", and PHP or WP have the wrong versions?

Upvotes: 0

Views: 850

Answers (2)

user3042036
user3042036

Reputation: 325

   <?php
   register_activation_hook( __FILE__, 'bh_proljece_boj_install' );
   function bh_proljece_boj_install() 
   {
       if ( version_compare( get_bloginfo( 'version' ), '3.3', ' < ' ) ) 
       {
           deactivate_plugins( basename( __FILE__ ) ); // Deactivate our plugin
       }
   }
   ?>

Upvotes: 1

Mario Peshev
Mario Peshev

Reputation: 1083

There is a global variable $wp_version or you could use get_bloginfo('version') to get the WordPress version. You could also use the version_compare(...) PHP function for PHP version comparison where both verifications could be evaluated in your plugin activation function.

Upvotes: -1

Related Questions