Prevent Your Clients From Deactivating Plugins In WordPress

Earlier we have discussed how to prevent your client’s from changing themes on their WordPress sites and keep using the theme you have designed for them.

We have also discussed about disabling plugin and theme installation/update functionality in WordPress and customizing admin area user interface. In this lesson you will learn how to remove deactivate links on plugins list.

Simply add the following code snippet by Steve Taylor in your theme’s function.php file.

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(
‘slt-custom-fields/slt-custom-fields.php’,
‘slt-file-select/slt-file-select.php’,
‘slt-simple-events/slt-simple-events.php’,
‘slt-widgets/slt-widgets.php’
)))
unset( $actions[‘deactivate’] );
return $actions;
}

Don’t just copy-paste, you will be needing to edit the plugin list by the plugins you are using in your WordPress site. All you got to do paste this code in your theme’s function.php file and adjust the array as appropriate.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.