Skip to content

Instantly share code, notes, and snippets.

@devuri
Last active June 2, 2023 15:10
Show Gist options
  • Save devuri/034ccb7c833f970192bb64317814da3b to your computer and use it in GitHub Desktop.
Save devuri/034ccb7c833f970192bb64317814da3b to your computer and use it in GitHub Desktop.
Prevent Admin users from deactivating plugins.
<?php
/**
* Prevent Admin users from deactivating plugins.
*
* While this will remove the deactivation link it does NOT prevent deactivation
* It will only hide the link to deactivate.
*/
add_filter( 'plugin_action_links', function ( $actions, $plugin_file, $plugin_data, $context ) {
if ( array_key_exists( 'deactivate', $actions ) ){
unset( $actions['deactivate'] );
}
return $actions;
}, 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment