WordPress Errors & MaintenanceApr 21, 2021
How to Easily Disable Updates for Modified Plugins in WordPress
In general, plugins that are implemented in accordance with WordPress can be customized extensively using hooks and by overriding templates.
However, there are exceptions that do not offer these functionalities.
To adapt the plugin to your website, you need to modify the core files. However, these will be overwritten during an update. The update function of a plugin can be disabled.
To do this, simply add the following code to the Functions.php of your theme:
/**
* Disable updates for recent products
*/
function disable_modified_plugin_updates( $value ) {
unset( $value->response['plugin_folder/plugin_file.php'] );
return $value;
}
add_filter( 'site_transient_update_plugins', 'disable_modified_plugin_updates' );
Ideally, you should also rename the plugin in the respective PHP and README file so that you remember it is a modified version.
This also allows you to disable multiple plugins; to do this, you can extend the code as follows:
/**
* Disable updates for recent products
*/
function disable_modified_plugin_updates( $value ) {
unset( $value->response['plugin_folder/plugin_file.php'], $value->response['plugin_folder_2/plugin_file_2.php'], $value->response['plugin_folder_3/plugin_file_3.php'] );
return $value;
}
add_filter( 'site_transient_update_plugins', 'disable_modified_plugin_updates' );
Note: Ideally, you should try to convince the author of your change before this step so that it can be integrated directly by them. This may help other users and allow the plugin to be updated in the future.