Skip to content

Instantly share code, notes, and snippets.

@eartisan-uk
Forked from alexander-young/functions.php
Created January 23, 2020 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eartisan-uk/f1985ec41e69e73714d561f4af55756c to your computer and use it in GitHub Desktop.
Save eartisan-uk/f1985ec41e69e73714d561f4af55756c 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