When my plugin is deactivated, I want to get a confirmation from the user whether all plugin options/tables need to be deleted or left as it is. Based on the option selected, I want to proceed further. Is it possible ? If yes, how ?
2 comments
Comments are closed.
I have implemented a workaround with JavaScript. I’m loading my own JavaScript file:
which contains a script that adds following Event Listener – when user clicks on our plugin deactivate button it prevent it from performing this action and display a JavaScript popup asking what you need, if user accepts it will be deactivated, if user press
'cancel'
nothing happens:I had trouble with the
dirname(__FILE__)
for some reason, so I changed my code to this, where bkj-functions is my plugin slug.wp_enqueue_script('wp-deactivation-message', plugins_url('js/message-deactivate.js', __FILE__), array());
with the following contents for
js/message-dactivate.js
(since I only need an “Alert” and not a “Confirm”):