How to Disable Plugin Updates in WordPress

WPTurbo » Snippets » How to Disable Plugin Updates in WordPress
0

Created with:

Visibility: 

public

Creator: WPTurbo Team

Customize with WPTurbo AI
X

Add Snippet To Project

New Project
Add To Existing Project

Are you a WordPress user who wants to maintain control over which plugins get updated on your website? While automatic plugin updates can be convenient, they can also introduce compatibility issues or unwanted changes to your site. In this article, we will explore how to disable plugin updates in WordPress, allowing you to have the final say on when and how your plugins are updated.

					function wpturbo_disable_plugin_updates( $value ) {
    if ( isset( $value->response['plugin-folder/plugin-file.php'] ) ) {
        unset( $value->response['plugin-folder/plugin-file.php'] );
    }
    return $value;
}
add_filter( 'site_transient_update_plugins', 'wpturbo_disable_plugin_updates' );
				

The code snippet provided allows you to disable updates for a specific plugin in WordPress. This can be useful in situations where you want to prevent a plugin from being updated because the updated version may introduce compatibility issues or unwanted changes.

The code starts by defining a new function called wpturbo_disable_plugin_updates(). This function accepts a parameter called $value, which represents the transient data for plugin updates.

Within the function, we check if the $value contains a specific plugin that we want to disable updates for. In this example, the plugin we want to disable updates for is located in the folder plugin-folder and its main file is plugin-file.php.

if ( isset( $value->response['plugin-folder/plugin-file.php'] ) ) {
    unset( $value->response['plugin-folder/plugin-file.php'] );
}

If the plugin does exist in the $value->response array, we use the unset() function to remove it from the array. This effectively disables updates for the specified plugin.

Finally, the modified $value array is returned by the function using the return statement.

The last step is to hook the wpturbo_disable_plugin_updates() function into the site_transient_update_plugins filter. This filter is responsible for filtering the transient data for plugin updates. By hooking our function into this filter, we can manipulate the data and disable updates for the specified plugin.

add_filter( 'site_transient_update_plugins', 'wpturbo_disable_plugin_updates' );

Now, whenever WordPress checks for plugin updates, our function will be called and the specified plugin will be removed from the update list, effectively disabling updates for it.

Register an account to save your snippets or go Pro to get more features.