Skip to content

Instantly share code, notes, and snippets.

@mrazzari
Last active March 23, 2019 00:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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', 'remove_update_xyz');
function remove_update_xyz($value) {
$plugin = plugin_basename(__FILE__);
if (!isset($value->response[ $plugin ])){ return $value; }
add_action( "in_plugin_update_message-$plugin", "in_plugin_update_message_xyz");
unset($value->response[ $plugin ]->package); // Remove ->package to fully remove the update notice.
return $value;
}
function in_plugin_update_message_xyz($plugin_data){
echo " A customized version is being used. Please contact your developer for updates.";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment