Last active
November 19, 2021 10:19
-
-
Save froger-me/d8ba0366da217e18c68953fc7036c7d7 to your computer and use it in GitHub Desktop.
WordPress auto updates for specific plugins and themes
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 | |
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