Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Last active March 21, 2019 14:44
Show Gist options
  • Save zackkatz/07ddc2717d9ccfd74cca to your computer and use it in GitHub Desktop.
Save zackkatz/07ddc2717d9ccfd74cca to your computer and use it in GitHub Desktop.
Functions to get plugin activation and deactivation links
<?php
/**
* Get the Activation URL for a plugin
* @param string $plugin_path Directory and file name of plugin, like: `hello-dolly/hello.php`
* @return string URL to activate the plugin
*/
function get_plugin_activation_link( $plugin_path = 'hello-dolly/hello.php' ) {
return wp_nonce_url(admin_url('plugins.php?action=activate&amp;plugin='.$plugin_path), 'activate-plugin_'.$plugin_path);
}
/**
* Get the De-Activation URL for a plugin
* @param string $plugin_path Directory and file name of plugin, like: `hello-dolly/hello.php`
* @return string URL to de-activate the plugin
*/
function get_plugin_deactivation_link( $plugin_path = 'hello-dolly/hello.php' ) {
return wp_nonce_url(admin_url('plugins.php?action=deactivate&amp;plugin='.$plugin_path), 'deactivate-plugin_'.$plugin_path);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment