If plugin is self-deactivated, ‘Plugin activated’ is still displayed. Why?
-
TL;DR I have written a test plugin. All I have added is code which self-deactivates the plugin. So when someone installs my plugin and activates it, the plugin immediately deactivates itself. But when that occurs, the message ‘Plugin activated’ is still displayed on-screen. Is that expected, or am I doing something wrong?
___
I have built a small custom plugin. In it I have added PHP which immediately self-deactivates the plugin (see code below). When a user activates my plugin, what occurs is that plugin immediately deactivates, as desired and as expected. But the page still displaysPlugin activated.at the top of the screen (screenshot). This is of course a bit misleading to the end user. My question is: given my code, is this expected? Or have I done something incorrectly/insufficiently?I believe I know how to change that message (e.g. this Stack Exchange question/answer). But before I pursue that, I just want to know if I’ve perhaps done something incorrectly to cause this issue.
The ultimate goal is for my plugin PHP code to first perform a check of the user’s installed version of WordPress. If the user’s WordPress version is too low, my plugin will immediately deactivate. If/when that occurs, I would prefer if ‘Plugin activated’ was not displayed on-screen.
In my case, do I have to maybe trigger a reload of the page, to clear that message? Just thinking out loud.
Thanks in advance.
My Code
function opn_main() { deactivate_plugins( plugin_basename( __FILE__ ) );// Self-deactivate the Outdated Plugin Notifier plugin. return; } add_action( 'load-plugins.php', 'opn_main' );
The topic ‘If plugin is self-deactivated, ‘Plugin activated’ is still displayed. Why?’ is closed to new replies.