0

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

Marian
  • 1,154
  • 2
  • 15
  • 25

2 Answers2

1
   <?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
       }
   }
   ?>
user3042036
  • 325
  • 1
  • 2
  • 14
-1

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.

Mario Peshev
  • 1,063
  • 8
  • 16
  • 1
    No no, that's not what I`m asking. I know how to verify that, but I want to know if there's a way to prevent WordPress from activating the plugin. – Marian May 28 '12 at 16:08
  • WP plugins have activation hooks - see [register_activation_hook function](http://codex.wordpress.org/Function_Reference/register_activation_hook) and you can use the function to decide if a plugin is activatable or not. – Mario Peshev May 28 '12 at 16:48
  • An how exactly do I decide if a plugin is activable or not? – Marian May 29 '12 at 15:41