|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class Jetpack_Sync_Module_Updates extends Jetpack_Sync_Module { |
|
4
|
|
|
function name() { |
|
5
|
|
|
return "updates"; |
|
6
|
|
|
} |
|
7
|
|
|
|
|
8
|
|
|
public function init_listeners( $callable ) { |
|
9
|
|
|
add_action( 'set_site_transient_update_plugins', $callable, 10, 1 ); |
|
10
|
|
|
add_action( 'set_site_transient_update_themes', $callable, 10, 1 ); |
|
11
|
|
|
add_action( 'set_site_transient_update_core', $callable, 10, 1 ); |
|
12
|
|
|
|
|
13
|
|
|
// full sync |
|
14
|
|
|
add_action( 'jetpack_full_sync_updates', $callable ); |
|
15
|
|
|
|
|
16
|
|
|
add_filter( 'jetpack_sync_before_enqueue_set_site_transient_update_plugins', array( $this, 'filter_update_keys' ), 10, 2 ); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function full_sync() { |
|
20
|
|
|
/** |
|
21
|
|
|
* Tells the client to sync all updates to the server |
|
22
|
|
|
* |
|
23
|
|
|
* @since 4.1 |
|
24
|
|
|
* |
|
25
|
|
|
* @param boolean Whether to expand updates (should always be true) |
|
26
|
|
|
*/ |
|
27
|
|
|
do_action( 'jetpack_full_sync_updates', true ); |
|
28
|
|
|
return 1; // The number of actions enqueued |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function get_all_updates() { |
|
32
|
|
|
return array( |
|
33
|
|
|
'core' => get_site_transient( 'update_core' ), |
|
34
|
|
|
'plugins' => get_site_transient( 'update_plugins' ), |
|
35
|
|
|
'themes' => get_site_transient( 'update_themes' ), |
|
36
|
|
|
); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
// removes unnecessary keys from synced updates data |
|
40
|
|
|
function filter_update_keys( $args ) { |
|
41
|
|
|
$updates = $args[0]; |
|
42
|
|
|
|
|
43
|
|
|
if ( isset( $updates->no_update ) ) { |
|
44
|
|
|
unset( $updates->no_update ); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
return $args; |
|
48
|
|
|
} |
|
49
|
|
|
} |