Skip to content

Instantly share code, notes, and snippets.

@alexander-young
Created January 15, 2020 05:27
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save alexander-young/55e60b17c77e7254cd951d32da9d5463 to your computer and use it in GitHub Desktop.
Save alexander-young/55e60b17c77e7254cd951d32da9d5463 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