Skip to content

Instantly share code, notes, and snippets.

@mrazzari
Last active May 29, 2025 18:09
Show Gist options
  • Save mrazzari/8602311 to your computer and use it in GitHub Desktop.
Save mrazzari/8602311 to your computer and use it in GitHub Desktop.
WP - Prevent plugin updates

Useful when you modify a plugin, and don't want another WP admin to update it, discarding your changes.

  1. Add this snippet at the top of your plugin's main file.
  2. Replace xyz for some short version of your plugin's name
  3. That's it. See screenshot:

Screenshot

<?php
// Block the admin from updating this plugin, as we've modified it.
add_filter('site_transient_update_plugins', function ($value) {
$plugin = plugin_basename(__FILE__);
if (!isset($value->response[ $plugin ])){ return $value; }
add_action( "in_plugin_update_message-$plugin", function ($plugin_data){
echo " A customized version is being used. Please contact your developer for updates.";
});
unset($value->response[ $plugin ]->package); // Remove ->package to fully remove the update notice.
return $value;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment