Have you ever ever discovered your self juggling a number of plugins in your WordPress web site, wishing there was a neater strategy to clear up the litter? Whether or not you’re a seasoned webmaster or a running a blog beginner, managing plugins can shortly turn into overwhelming. That’s the place the “Deactivate and Delete” plugin is available in, providing an easy resolution to streamline your WordPress expertise.
Simplify Your WordPress Administration with the “Deactivate and Delete” Plugin
Think about this: with only one click on, you possibly can deactivate and take away any pointless plugin out of your web site. No extra digging by settings or performing a number of steps. This plugin is designed to avoid wasting you effort and time, permitting you to give attention to what really issues—creating nice content material and fascinating along with your viewers.
“Deactivate and delete” WordPress plugin code
<?php
/*
Plugin Title: Deactivate and Delete
Description: Provides an choice to deactivate and delete plugins in a single click on.
Model: 1.0
Writer: WP Easy Hacks
Writer URI: https://wpsimplehacks.com
*/
add_filter('bulk_actions-plugins', 'dad_add_bulk_actions');
perform dad_add_bulk_actions($bulk_actions) {
$bulk_actions['deactivate_and_delete'] = 'Deactivate and Delete';
return $bulk_actions;
}
add_filter('handle_bulk_actions-plugins', 'dad_handle_bulk_actions', 10, 3);
perform dad_handle_bulk_actions($redirect_to, $doaction, $plugins) {
if ($doaction !== 'deactivate_and_delete') {
return $redirect_to;
}
foreach ($plugins as $plugin) {
deactivate_plugins($plugin);
delete_plugins(array($plugin));
}
$redirect_to = add_query_arg('deactivate_and_delete', '1', $redirect_to);
return $redirect_to;
}
add_action('admin_notices', 'dad_bulk_action_admin_notice');
perform dad_bulk_action_admin_notice() {
if (!empty($_REQUEST['deactivate_and_delete'])) {
echo '<div id="message" class="up to date discover notice-success is-dismissible"><p>' . __('Chosen plugin(s) deactivated and deleted.', 'deactivate-and-delete') . '</p></div>';
}
}
add_filter('plugin_action_links', 'dad_add_quick_action', 10, 4);
perform dad_add_quick_action($actions, $plugin_file, $plugin_data, $context) {
if (is_plugin_active($plugin_file)) {
$actions['deactivate_and_delete'] = '<a href="' . wp_nonce_url(admin_url('plugins.php?motion=deactivate_and_delete&plugin=' . $plugin_file), 'deactivate_and_delete_plugin_' . $plugin_file) . '" onclick="return verify('Are you positive you need to deactivate and delete this plugin?')">' . __('Deactivate and Delete', 'deactivate-and-delete') . '</a>';
}
return $actions;
}
add_action('admin_init', 'dad_handle_quick_action');
perform dad_handle_quick_action() {
if (isset($_GET['action']) && $_GET['action'] == 'deactivate_and_delete' && isset($_GET['plugin'])) {
$plugin = $_GET['plugin'];
check_admin_referer('deactivate_and_delete_plugin_' . $plugin);
// Deactivate the plugin
deactivate_plugins($plugin);
// Delete the plugin
delete_plugins(array($plugin));
// Redirect to plugins web page with successful message
wp_redirect(add_query_arg('deactivate_and_delete', '1', admin_url('plugins.php')));
exit;
}
}
Testing
1. Activate the Plugin: Go to the WordPress admin dashboard, navigate to the “Plugins” web page, and activate the Deactivate and Delete plugin.
2. Check Fast Motion: On the “Plugins” web page, search for the “Deactivate and Delete” choice subsequent to every lively plugin. Click on it and ensure the plugin is each deactivated and deleted.
This could be sure that the fast menu choice correctly deactivates and deletes the chosen plugin.