I’m using the code below to deactivate the plugin itself when the user’s PHP version is not sufficient. One problem is that the yellow message box appears saying that the plugin is activated although it is successfully denied by this function. So is there a way not to display the yellow message?
function Plugin_Requirements() {
global $wp_version;
$plugin = plugin_basename( __FILE__ );
$plugin_data = get_plugin_data( __FILE__, false );
$numPHPver='5.1.2';
$strMsg .= $plugin_data['Name'] . ': ' . __('requires PHP') . ' ' . $numPHPver . __(' or higher. Your PHP version is : ') . phpversion() . __('. Deactivating the plugin.') . '<br />';
if ( version_compare(phpversion(), $numPHPver, "<" ) ) {
echo '<div class="error"><p>' . $strMsg . '</p></div>';
deactivate_plugins( $plugin );
}
}
add_action( 'admin_init', 'Plugin_Requirements' );
It seems it is currently not possible to do it as a part of plugin.