If you use WordPress to build websites for others, then when you hand over the completed website to the client, if the client accidentally disables essential plugins, it will inevitably cause you some unnecessary trouble. Therefore, we can disable the deactivation function for certain plugins. Below is how to use code to disable the deactivation function for specific plugins.
Remove the deactivation function for specific plugins
Similar to the method from the previous „
WordPress Disable Update Notifications for Specific Plugins", add the following code to the theme's functions file. Friends who don't know how to add it are advised to use:
Safe Method to Add Code to the functions.php File: Code Snippets//删除特定插件的禁用功能
add_filter( 'plugin_action_links', 'wpkj_disable_plugin_deactivation', 10, 4 );
function wpkj_disable_plugin_deactivation( $actions, $plugin_file, $plugin_data, $context ) {
if ( array_key_exists( 'deactivate', $actions ) && in_array( $plugin_file, array(
'wpforms/wpforms.php',
'woocommerce/woocommerce.php'
)))
unset( $actions['deactivate'] );
return $actions;
}In the above code,
'wpforms/wpforms.php',
'woocommerce/woocommerce.php'
These two lines indicate the plugin location for which to remove the deactivation code. You can find each plugin's folder in the server plugin directory (wp-content/plugins). After entering the plugin folder, the file usually with the same name as the plugin is the one. After adding, the website plugins will have no deactivation button, so you don't have to worry about clients messing around and increasing your workload. Method source:
WP University
Comments are closed
The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.