Skip to content

Instantly share code, notes, and snippets.

@kagg-design
Last active July 19, 2022 15:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kagg-design/db6b1396da4d397240032cf8c3cdc768 to your computer and use it in GitHub Desktop.
Save kagg-design/db6b1396da4d397240032cf8c3cdc768 to your computer and use it in GitHub Desktop.
Disable update plugins mu-plugin
<?php
/**
* Plugin Name: Disable updates plugins
* Plugin URI: https://kagg.eu/en/
* Description: Disable update of certain plugins.
* Version: 1.2
* Author: KAGG Design
* Author URI: https://kagg.eu/en/
* License: GPL2
*
* @package disable-update-plugins
*/
/**
* Filter update_plugins transient.
*
* @param mixed $value Transient value.
*
* @return mixed
*/
function filter_update_plugins( $value ) {
if ( ! isset( $value->response ) ) {
return $value;
}
// Array of plugin slugs.
$disable_update_plugins = [
'some-plugin-slug',
];
foreach ( $value->response as $name => $plugin ) {
foreach ( $disable_update_plugins as $disable_update_plugin ) {
if ( stripos( $name . '/', $disable_update_plugin ) === 0 ) {
unset( $value->response[ $name ] );
}
}
}
return $value;
}
add_filter( 'site_transient_update_plugins', 'filter_update_plugins', PHP_INT_MAX, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment