Skip to content

Instantly share code, notes, and snippets.

@sambody
Created August 8, 2013 21:01
Show Gist options
  • Save sambody/6188682 to your computer and use it in GitHub Desktop.
Save sambody/6188682 to your computer and use it in GitHub Desktop.
Prevent one or more plugins to be deactivated by admin link. For clients sites. (or hide it completely with other snippet)
add_filter( 'plugin_action_links', 'disable_plugin_deactivation', 10, 4 );
function disable_plugin_deactivation( $actions, $plugin_file, $plugin_data, $context ) {
// Remove edit link for all
if ( array_key_exists( 'edit', $actions ) )
unset( $actions['edit'] );
// Remove deactivate link for crucial plugins
if ( array_key_exists( 'deactivate', $actions ) && in_array( $plugin_file, array(
'akismet/akismet.php',
'better-author-bio/better-author-bio.php'
)))
unset( $actions['deactivate'] );
return $actions;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment