6

I made some custom modifications to a plugin. When we get a notice that there is an official upgrade for this plugin in WP, a dev needs to manually do the upgrade because the changed files have to be integrated with the new version.

We don't want a staff member to accidentally click the upgrade button on this plugin while going through a series of upgrades.

However, we still want to see the upgrade notification, so that a dev can schedule the update. So increasing the version number in the header to some really high value is not a solution, because it blocks that visibility.

How can I block WP from being able to upgrade and the plugin still be valid?

  • 2
    to customise a plugin, it's better to not modify the files directly and to create another plugin which corrects the hooks of the original plugin. – mmm May 25 '18 at 8:28
  • @mmm yeah, I tried going that route, but it always broke the licensing somehow. – eComEvo May 25 '18 at 8:31
  • You can also put the version number to 999. Most plugins work with the version number to detect updates. – Wilco May 25 '18 at 8:48
  • @eComEvo I don't understand what can be broken then if you want that I help you in this way, you can edit your question to give more details. – mmm May 25 '18 at 8:49
  • @Wilco but it will disable updates at all. The solution with disabling only the update link is pretty good idea. And it can be done apparently :D – Krzysiek Dróżdż May 25 '18 at 9:31
1

First of all... It is a really bad idea to modify existing plugin.

But if you really have to do this, then you can hide update link with this code (this one works for Yoast SEO):

function remove_update_notification_link($value) {
    if ( array_key_exists('wordpress-seo/wp-seo.php', $value->response) ) {
        $value->response[ 'wordpress-seo/wp-seo.php' ]->package = '';
    }
    return $value;
}
add_filter('site_transient_update_plugins', 'remove_update_notification_link');

The notice will be shown, but instead of the link to update there will be info: "Automatic update is unavailable for this plugin."

If you put this code right in the plugin, then you can use more automatic way:

function remove_update_notification_link($value) {
    if ( array_key_exists(plugin_basename(__FILE__), $value->response) ) {
        $value->response[ plugin_basename(__FILE__) ]->package = '';
    }

    return $value;
} 
add_filter('site_transient_update_plugins', 'remove_update_notification_link');
  • Unfortunately, this didn't work. The the plugin basename shows up in the $value->checked list but never in $value->response. – eComEvo May 29 '18 at 17:17
  • And what is that plugin? Does it come from WP plugins repo? – Krzysiek Dróżdż May 29 '18 at 17:20
  • Yes, it does. It's the 1-Click Upsells plugin by WooCurve – eComEvo May 29 '18 at 21:47
  • @eComEvo could you paste a link for it? Also... just take a look at plugin update transient in options table - you’ll find the plugins update slug in there... if it comes from WP repo, it has to be in there. If it has some custom update plugin, then you’ll have to find the proper priority to hook in. – Krzysiek Dróżdż May 29 '18 at 21:51
  • This plugin: woocurve.com/one-click-upsells-for-woocommerce – eComEvo Jun 1 '18 at 19:46
1

The answer of @Core92 is correct, except that throws a warning when enabling/disabling other plugins so better:

function filter_plugin_updates( $value ) {
    $toAvoid='path_to_plugin/plugin_name.php';
    if( isset( $value->response[$toAvoid]) )
        unset( $value->response[$toAvoid] );
    return $value;
}
add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );
  • It would be better if you checked array_key_exists than isset - isset can still cause notices ;) – Krzysiek Dróżdż May 25 '18 at 9:21
1

In the file functions.php of the active theme add this lines

function filter_plugin_updates( $value ) {
    unset( $value->response['path_to_plugin/plugin_name.php'] ); // one plugin by line
}

add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );

This will completly hide update requirement. You will have to check yourself if there is an update available by commentating the code.

  • It's not a solution, since you will hide notices, not only link. Also it makes no sense to add this code to functions.php of active theme. If you already modified the plugin, it's much better idea to add this code to that plugin... – Krzysiek Dróżdż May 25 '18 at 9:38
-1

There is a plugin that allows you to choose which plugins you don't want to receive update notices for:

Block Plugin Update https://wordpress.org/plugins/block-specific-plugin-updates/

It has not been updated for a while, but I can tell you it works fine with the current version of WP (4.9.6)

  • But OP wants to see the notices... "However, we still want to see the upgrade notification" and this plugin will hide them... – Krzysiek Dróżdż May 31 '18 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.