Generate activation or deactivation link of WordPress plugin

You often need an action link to activate or deactivate a plugin. How do you do that?
I have written a simple function that can help you achieve this.

How to use?
This function requires 2 parameters; first one is the plugin file name, and second one is action type.
Plugin file name is the base file resides in wp-content/plugins directory. If you have a plugin called My Super Plugin and the base file is wp-content/plugins/my-super-plugin/my-super-plugin.php, then the file name will be my-super-plugin/my-super-plugin.php

And second parameter is the action type, either activate or deactivate.

So, if you want to activate My Super Plugin, you have to write-

And to deactivate-

Need help with your WordPress tasks?