Skip to content

Instantly share code, notes, and snippets.

@wpsmith
Created August 21, 2020 23:02
Show Gist options
  • Save wpsmith/8d52cba17cd6f3e503658dbb2ad0ced0 to your computer and use it in GitHub Desktop.
Save wpsmith/8d52cba17cd6f3e503658dbb2ad0ced0 to your computer and use it in GitHub Desktop.
WP: Auto-update whitelisted set of plugins.
<?php
add_filter( 'auto_update_plugin', 'wps_auto_update_specific_plugins', 10, 2 );
function wps_auto_update_specific_plugins ( $update, $item ) {
// Array of plugin slugs to always auto-update
$plugins = array (
'akismet',
'enhanced-media-library',
'duplicate-page',
);
if ( in_array( $item, $plugins ) ) {
// Always update plugins in this array
return true;
} else {
// Else, use the normal API response to decide whether to update or not
return $update;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment