I am looking for this information as well and it would be most welcome. If I find something on other sites I will post it here as well.
Yeah, I have the same dilemma 🙂 I’ve been digging around but had no luck!
I am looking for the same thing, especially a way to detect a Network Activate and stop users from activating my plugin that way, anyone have any ideas?
Hi,
I also cannot find a way to tell wordpress whether the plugin could be activated.
However I am about to release a new version of myEASYbackup and added the following code at the beginning of the main script:
if(is_admin() && version_compare(PHP_VERSION, '5', '<')) {
/**
* @since 1.0.5.6
*/
function myeasy_min_reqs() {
echo '<div class="error">'
. '<h3>' . __( 'Warning! It is not possible to activate this plugin as it requires PHP5 and on this server the PHP version installed is: ', MEBAK_LOCALE )
. '<b>'.PHP_VERSION.'</b></h3>'
. '<h3><a href="http://www.php.net/releases/#v4" target="_blank">' . __( 'PHP4 was discontinued by the PHP development team on December, 31 2007 !!', MEBAK_LOCALE ) .'</a>'
. '</h3>'
. '<p>' . __( 'For security reasons we <b>warmly suggest</b> that you contact your hosting provider and ask to update your account to PHP5.', MEBAK_LOCALE )
. '</p>'
. '<p>' . __( 'If they refuse for whatever reason we suggest to <b>change provider as soon as possible</b>.', MEBAK_LOCALE )
. '</p>'
.'</div>'
;
$plugins = get_option('active_plugins');
$out = array();
foreach($plugins as $key => $val) {
if($val != 'myeasybackup/myeasybackup.php') {
$out[$key] = $val;
}
}
update_option('active_plugins', $out);
}
add_action('admin_head', 'myeasy_min_reqs');
return;
}
Now, every time the plugin is activated, it will show a warning message and automatically deactivate itself.
Maybe not an elegant solution but it works.
Sorry, I forgot some explanations.
The new version of my plugin requires PHP5 so,
If we are within the admin panel and the code is running on a previous PHP version:
if(is_admin() && version_compare(PHP_VERSION, '5', '<')) {
I loop into the active plugins array:
foreach($plugins as $key => $val) {
if its not my plugin:
if($val != 'myeasybackup/myeasybackup.php') {
I copy the plugin in the output array:
$out[$key] = $val;
then its simply matter to update the active_plugins option:
update_option('active_plugins', $out);
Hope it helps and, if you find a better solution, please share it!