Quantcast
Viewing all articles
Browse latest Browse all 8245

webstan on "deactivate_plugins after version check not working"

Hello,

I am busy trying to learn more about making plugins. I want to make my plugin unable to activate if the version number of wordpress is lower then the one i give. I used the following code:

register_activation_hook( __FILE__, 'st_testplugin_install' );

function st_testplugin_install() {
	if ( version_compare( get_bloginfo( 'version' ), '4.1', '<' ) ) {
		deactivate_plugins( plugin_basename( __FILE__ ) );
	}
}

After using this code my plugin is still able to activate. It seems like it doesn't run the deactivate_plugins somehow. My wordpress version is 4.0 so lower then the 4.1 i gave in the version_compare function. I was wondering if someone could help me with this and can tell me what I am doing wrong.


Viewing all articles
Browse latest Browse all 8245

Trending Articles