Skip to content

Instantly share code, notes, and snippets.

@froger-me
Last active November 19, 2021 10:19
Show Gist options
  • Save froger-me/d8ba0366da217e18c68953fc7036c7d7 to your computer and use it in GitHub Desktop.
Save froger-me/d8ba0366da217e18c68953fc7036c7d7 to your computer and use it in GitHub Desktop.
WordPress auto updates for specific plugins and themes
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
function auto_update_specific_plugins( $update, $item ) {
// Array of plugin slugs to always auto-update
$plugins = array(
'dummy-plugin',
);
if ( in_array( $item->slug, $plugins, true ) ) {
return true;
} else {
return $update;
}
}
add_filter( 'auto_update_plugin', 'auto_update_specific_plugins', 10, 2 );
function auto_update_specific_themes( $update, $item ) {
// Array of theme slugs to always auto-update
$themes = array(
'dummy-theme',
);
if ( in_array( $item->slug, $theme, true ) ) {
return true;
} else {
return $update;
}
}
add_filter( 'auto_update_theme', 'auto_update_specific_themes', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment