Created
October 23, 2013 22:03
-
-
Save jayseventwo/7127575 to your computer and use it in GitHub Desktop.
If you use a custom plugin to store all your theme functions, you dont want a user to deactivate it. Add this to functions.php or your custom theme plugin to hide the "deactivate" link for your selected plugin.
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
// Disable plugin deactivation | |
add_filter( 'plugin_action_links', 'slt_lock_plugins', 10, 4 ); | |
function slt_lock_plugins( $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( | |
'plugin-folder/plugin-name.php' | |
))) | |
unset( $actions['deactivate'] ); | |
return $actions; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment