Skip to content

Instantly share code, notes, and snippets.

@rniswonger
Last active January 3, 2024 15:21
Show Gist options
  • Star 55 You must be signed in to star a gist
  • Fork 22 You must be signed in to fork a gist
  • Save rniswonger/ee1b30e5fd3693bb5f92fbcfabe1654d to your computer and use it in GitHub Desktop.
Save rniswonger/ee1b30e5fd3693bb5f92fbcfabe1654d to your computer and use it in GitHub Desktop.
WordPress - Disable specific plugin update check
/**
* Prevent update notification for plugin
* http://www.thecreativedev.com/disable-updates-for-specific-plugin-in-wordpress/
* Place in theme functions.php or at bottom of wp-config.php
*/
function disable_plugin_updates( $value ) {
if ( isset($value) && is_object($value) ) {
if ( isset( $value->response['plugin-folder/plugin.php'] ) ) {
unset( $value->response['plugin-folder/plugin.php'] );
}
}
return $value;
}
add_filter( 'site_transient_update_plugins', 'disable_plugin_updates' );
@toddcavanaugh
Copy link

Thank for sharing! Worked well. If I wanted to do this for multiple plugins, what is the best way to handle that?

@artmaug
Copy link

artmaug commented Jul 4, 2018

+1

@ebetancourt
Copy link

@toddcavanaugh I created a fork that will do this for multiple plugins: https://gist.github.com/ebetancourt/89b105d7334495535415799832511938

@markandcurry
Copy link

Very helpful. Thanks!

@cliffordp
Copy link

Plugin to do this for files with version control: https://github.com/cliffordp/tk-exclude-vcs-updates

@reatlat
Copy link

reatlat commented Jun 12, 2019

Great!
Thank you!

@juliovedovatto
Copy link

Great tip! Thanks dude 👍

A dev from work decided to "extend" a plugin, without telling the whole team about.

So I had to add this hook to avoid oficial plugin updates. Not the ideal approach but it will solve the problem and avoid future problems.

@amjo
Copy link

amjo commented Nov 13, 2019

how do we actually use this after placing it in the function.php

@reatlat
Copy link

reatlat commented Nov 13, 2019

how do we actually use this after placing it in the function.php

Only hardcoded use ;)

replace plugin-folder/plugin.php to your plugin ;)

@amjo
Copy link

amjo commented Nov 13, 2019

how do we actually use this after placing it in the function.php

Only hardcoded use ;)

replace plugin-folder/plugin.php to your plugin ;)

Thank you so much

@reatlat
Copy link

reatlat commented Nov 13, 2019

how do we actually use this after placing it in the function.php

Only hardcoded use ;)
replace plugin-folder/plugin.php to your plugin ;)

Thank you so much

take a look this fork https://gist.github.com/ebetancourt/89b105d7334495535415799832511938

This for allow you push an array of plugins to disable a bunch of them ;)

@amjo
Copy link

amjo commented Nov 14, 2019

how do we actually use this after placing it in the function.php

Only hardcoded use ;)
replace plugin-folder/plugin.php to your plugin ;)

Thank you so much

take a look this fork https://gist.github.com/ebetancourt/89b105d7334495535415799832511938

This for allow you push an array of plugins to disable a bunch of them ;)

To be honest, i saw this link above, and actually went ahead with that! :) this is superb!

@HarukiOgawa22899
Copy link

Very helpful. Thanks!

@cliffordp
Copy link

https://github.com/afragen/local-development provides this functionality

@tmcmanusCW
Copy link

Works perfectly, thank you!

@inspiredearth
Copy link

Thanks very much.
Is there a relatively easy way to have some text display next to plug-ins (for which updates are disabled), indicating they are disabled?

@easyspace
Copy link

how do we actually use this after placing it in the function.php

Only hardcoded use ;)

replace plugin-folder/plugin.php to your plugin ;)

If my plugin folder is called "myfirstplugin" and has an index.php inside its folder with another file called myfirstplugin.php, which one do I choose for this to work?

@realmatrix
Copy link

work when the plugin is enabled but show the update notification when the plugin is disabled
how to hide the update notifications if the plugin is disabled?

@57daimler
Copy link

I found the easiest way to disable updates to a specific plugin is go to Plugin Editor, browse to relevant plugin and find the plugin's update php file (search through plugin files for 'update' or 'updater' in the filename). Open file, comment out all the code (/* ...code... */) and save via update file button.

@Kadigan
Copy link

Kadigan commented Mar 3, 2021

If you want, I made a small modification to build a version blacklist. This version will block the update if the update is to a blacklisted version.

add_filter('site_transient_update_plugins', function($value){
  $pluginVersionsBlacklist = [];
  // format: "folder/file.php" => ["array", "of", "versions"]
  // "contact-form-7/wp-contact-form-7.php" => ["5.4"] // will prevent the update to CF7 v5.4 from showing up
  // "contact-form-7/wp-contact-form-7.php" => []      // will prevent ALL updates to CF7 from showing up
  $pluginVersionsBlacklist["contact-form-7/wp-contact-form-7.php"] = ["5.4"];
  $pluginVersionsBlacklist["cf7-grid-layout/cf7-grid-layout.php"]  = ["4.8.2"];

  // this shouldn't change all that much, so we can keep it around
  static $blacklistedVersionsList;
  if ( $blacklistedVersionsList == null )
    $blacklistedVersionsList = array_keys($pluginVersionsBlacklist);

  // if the update list doesn't match anything we have in the blacklist, we can abort early
  $intersection = array_intersect(array_keys($value->response), $blacklistedVersionsList);
  if ( !sizeof($intersection) )
    return $value;

  if ( isset($value) && is_object($value) )
    // run through the abridged list to check for versions
    foreach($intersection as $pluginID){
      $blacklistedVersions = $pluginVersionsBlacklist[$pluginID];
      if ( sizeof($blacklistedVersions) == 0 || in_array($value->response[$pluginID]->new_version, $blacklistedVersions) )
        unset($value->response[$pluginID]);
    }

  return $value;
});

@deanoakley
Copy link

deanoakley commented Aug 9, 2021

I thought this was cool. I made a version you can place in the main plugin file with no edits. https://gist.github.com/deanoakley/e05b9a037c5afce473b26b224a62cff5

/**
 * Prevent update notification for plugin - 
 * http://www.thecreativedev.com/disable-updates-for-specific-plugin-in-wordpress/
 * Add to the core plugin file 
 */
function disable_plugin_updates( $value ) {
  if ( isset($value) && is_object($value) ) {
  $plugin_file_name = basename(__DIR__) . '/' . basename(__FILE__);
    if ( isset( $value->response[$plugin_file_name] ) ) {
      unset( $value->response[$plugin_file_name] );
    }
  }
  return $value;
}
add_filter( 'site_transient_update_plugins', 'disable_plugin_updates' );

@usmansadiq786
Copy link

+1

@emjwey
Copy link

emjwey commented Oct 12, 2021

Thanks!

@giahojnost
Copy link

Thank you very much!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment