This function deactivates plugins. It is often used by a plugin to deactivate itself if the plugin requires the presence of certain features that are missing in environment after an administrator has activated it. This is usually the last step in a dependency-checking function.
<?php deactivate_plugins( plugin_basename( __FILE__ ) ); ?>
It is recommended to use the admin_init action to call this function.
<?php class myPlugin { public function __construct() { register_activation_hook( __FILE__, array( $this , 'activate' ) ); } public function activate() { // Check PHP Version and deactivate & die if it doesn't meet minimum requirements. if ( 0 > check_version( PHP_VERSION, '5.2' ) ) { deactivate_plugins( plugin_basename( __FILE__ ) ); wp_die( 'This plugin requires PHP Version 5.2. Sorry about that.' ); } // Do activate Stuff now. } }
deactivate_plugins() is located in wp-admin/includes/plugin.php
.