📅  最后修改于: 2022-03-11 15:00:19.636000             🧑  作者: Mango
/**
* Deactivate plugin example class.
*/
class WPDocs_Deactivate_Plugin {
/**
* Constructor.
*/
public function __construct() {
register_activation_hook( __FILE__, array( $this , 'activate' ) );
}
/**
* Attempts to activate the plugin if at least PHP 5.4.
*/
public function activate() {
// Check PHP Version and deactivate & die if it doesn't meet minimum requirements.
if ( version_compare( PHP_VERSION, '5.4', '<=' ) ) {
deactivate_plugins( plugin_basename( __FILE__ ) );
wp_die( __( 'This plugin requires PHP Version 5.4 or greater. Sorry about that.', 'textdomain' ) );
}
// Do activate Stuff now.
}
}
new WPDocs_Deactivate_Plugin();