While developing a site for a client project it was required that I hack up an existing plugin’s core files. Out of the box, the plugin was very powerful, but I needed to add some additional functionality for my client. If the plugin were updated in future, all of the additions and tweaks I made to the plugins core files would be over written and the plugin would then become un-useable for my client and potentially break their site.
Sometimes you just don’t want your clients to have TOO much control over their site. This can lead to some serious issues down the road, and tons of emails and phone calls back and forth trying to figure out what the client did and then spending the time to resolve the issue. One situation that I have found my self in is when a client updates a plugin only to find out that the new version causes php or javascript errors and takes their site down.
One solution that I decided to go with in this project was including a function and adding a filter to the plugins main .php file. The function below prevents the plugin from ‘phoning home’ and checking if there is a newer version of the plugin in the repository. Using this function and filter, I was able to successfully block future update notifications to my clients dashboard.
1 2 3 4 5 6 7 8 9 10 11 12 |
// Prevent Plugin Update Notifications function dm_prevent_update_check( $r, $url ) { if ( 0 === strpos( $url, 'http://api.wordpress.org/plugins/update-check/' ) ) { $my_plugin = plugin_basename( __FILE__ ); $plugins = unserialize( $r['body']['plugins'] ); unset( $plugins->plugins[$my_plugin] ); unset( $plugins->active[array_search( $my_plugin, $plugins->active )] ); $r['body']['plugins'] = serialize( $plugins ); } return $r; } add_filter( 'http_request_args', 'dm_prevent_update_check', 10, 2 ); |
How To Use
Just copy and paste the code from above and include it in to a plugins main .php file. For example to prevent contact-form-7 from notifying you of updates you would need to open ‘/wp-content/plugins/contact-form-7/wp-contact-form-7.php’ and then scroll to the bottom and paste the code above in. Save the file, and you will no longer receive update notifications.