Skip to content

Instantly share code, notes, and snippets.

@ctalkington
Last active October 19, 2016 00:16
Show Gist options
  • Save ctalkington/ff1d03758c12922a570d1b5a8753ced0 to your computer and use it in GitHub Desktop.
Save ctalkington/ff1d03758c12922a570d1b5a8753ced0 to your computer and use it in GitHub Desktop.
Block WordPress Plugin Updates - best placed in wp-content/mu-plugins/
<?php
/*
Plugin Name: Lock Plugin Updates
Description: Allow blocking plugins from being updated.
Version: 1.0.0
Author: Example
Author URI: https://www.example.com/
@author John Doe
*/
add_filter( 'site_transient_update_plugins', 'prefix_lock_plugin_updates' );
function prefix_lock_plugin_updates( $value ) {
if ( ! is_object( $value ) || ! isset( $value->response ) ) {
return $value;
}
// format (relative to plugins dir): plugin/main-plugin-file.php
$defaults = array();
$locked_plugins = apply_filters( 'prefix_locked_plugins', $defaults );
foreach( $locked_plugins as $plugin_basename ) {
unset( $value->response[ $plugin_basename ] );
}
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment