Generate a Link to Activate a Plugin in WordPress

Here’s another specialized plugin development tip!

If you want to create a link to activate a plugin, you need to know the path of the plugin file. Let’s use Akismet for this example.

$path = 'akismet/akismet.php';
$link = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$path), 'activate-plugin_'.$path);

The `$link` URL will be something like http://yoursite.com/wp-admin/plugins.php?action=activate&plugin=akismet%2Fakismet.php&_wpnonce=f97dabdf9

Author: Zack Katz

Zack Katz is the President of Katz Web Services and the developer of WordPress plugins with over 700,000 downloads. He lives in Southwest Colorado with his wife and two cats.

Leave a Reply

Your email address will not be published. Required fields are marked *