If you are using WordPress to build websites for others, then after building the website and handing it over to the client, if the client accidentally disables a necessary plugin, it will inevitably cause you some unnecessary trouble. Therefore, we can disable the deactivation function for certain plugins. The following explains how to use code to disable the deactivation function for specific plugins.
Remove Deactivation Function for Specific Plugins
and the previous „
Disable update notifications for specific WordPress pluginsThe method is the same as before, add the following code to the theme's functions file. If you're unsure how to add it, it's recommended 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 code above,
'wpforms/wpforms.php',
'woocommerce/woocommerce.php'
These two lines indicate the location of the plugin whose deactivation code you want to remove. You can find each plugin's folder in the server's plugin directory (wp-content/plugins). After entering the plugin folder, the file usually named the same as the plugin is the one. After adding the code, the deactivation button for the plugin will be gone from the website's admin, so you don't have to worry about clients messing things up and creating extra work for you. Source of the method:
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.