Created
August 8, 2013 21:01
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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