Skip to content

Instantly share code, notes, and snippets.

@tejasbusiness
Forked from alexander-young/functions.php
Created December 4, 2020 20:23
Show Gist options
  • Save tejasbusiness/e81390b654633ce46aea061008bec0eb to your computer and use it in GitHub Desktop.
Save tejasbusiness/e81390b654633ce46aea061008bec0eb to your computer and use it in GitHub Desktop.
Cleanup WordPress plugin admin
// Removing plugin controls from admin
function remove_plugin_controls($actions, $plugin_file, $plugin_data, $context){
if (array_key_exists('edit', $actions)) {
unset($actions['edit']);
}
if (array_key_exists('deactivate', $actions)) {
unset($actions['deactivate']);
}
if (array_key_exists('activate', $actions)) {
unset($actions['activate']);
}
if (array_key_exists('delete', $actions)) {
unset($actions['delete']);
}
return $actions;
}
add_filter('plugin_action_links', 'remove_plugin_controls', 10, 4);
// Remove bulk action options for managing plugins
function disable_bulk_actions($actions){
if (array_key_exists('deactivate-selected', $actions)) {
unset($actions['deactivate-selected']);
}
if (array_key_exists('activate-selected', $actions)) {
unset($actions['activate-selected']);
}
if (array_key_exists('delete-selected', $actions)) {
unset($actions['delete-selected']);
}
if (array_key_exists('update-selected', $actions)) {
unset($actions['update-selected']);
}
}
add_filter('bulk_actions-plugins','disable_bulk_actions');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment