forked from Automattic/jetpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.jetpack-autoupdate.php
52 lines (43 loc) · 1.44 KB
/
class.jetpack-autoupdate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
// Update any plugins that have been flagged for automatic updates
// TODO: update themes and core
class Jetpack_Autoupdate {
private static $instance = null;
protected $updates_allowed;
static function init() {
if ( is_null( self::$instance ) ) {
self::$instance = new Jetpack_Autoupdate;
}
return self::$instance;
}
private function __construct() {
$this->updates_allowed = Jetpack_Options::get_option( 'json_api_full_management', false );
if ( $this->updates_allowed ) {
add_filter( 'auto_update_plugin', array( $this, 'autoupdate_plugin' ), 10, 2 );
add_filter( 'auto_update_theme', array( $this, 'autoupdate_theme' ), 10, 2 );
add_filter( 'auto_update_core', array( $this, 'autoupdate_core' ), 10, 2 );
}
}
function autoupdate_plugin( $update, $item ) {
$autoupdate_plugin_list = Jetpack_Options::get_option( 'autoupdate_plugins', array() );
if ( in_array( $item->plugin, $autoupdate_plugin_list ) ) {
return true;
}
return $update;
}
function autoupdate_theme( $update, $item ) {
$autoupdate_theme_list = Jetpack_Options::get_option( 'autoupdate_themes', array() );
if ( in_array( $item->theme , $autoupdate_theme_list) ) {
return true;
}
return $update;
}
function autoupdate_core( $update, $item ) {
$autoupdate_core = Jetpack_Options::get_option( 'autoupdate_core', false );
if ( $autoupdate_core ) {
return $autoupdate_core;
}
return $update;
}
}
Jetpack_Autoupdate::init();