I use code similar to this to check for the minimum requirements for a plugin:
if (is_admin()) {
// check for required versions of WP and PHP
$min_wp = '4.9.6';
$min_php = '7.2';
if (!check_requirements($min_wp, $min_php)) {
add_action('admin_init', 'my_disable_plugin');
add_action('admin_notices', 'my_show_notice_disabled_plugin');
add_action('network_admin_init', 'my_disable_plugin');
add_action('network_admin_notices', 'my_show_notice_disabled_plugin');
my_deregister();
return;
}
}
function check_requirements($min_wp, $min_php) {
// see this for how to check requirements https://www.sitepoint.com/preventing-wordpress-plugin-incompatibilities/
// set $requirements_met true if OK, false if not OK
return $requirements_met;
}
function my_disable_plugin() {
// disable the plugin
}
function my_show_notice_diabled_plugin() {
// admin notice that plugin disabled
}
function my_deregister() {
// de-register the plugin
}
So if on the admin page, the plugin minimum requirements are checked. If that fails, the plugin is disabled and de-registered, and the admin notices displayed with the alert.