Last active
July 19, 2022 15:46
-
-
Save kagg-design/db6b1396da4d397240032cf8c3cdc768 to your computer and use it in GitHub Desktop.
Disable update plugins mu-plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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