Completed
Push — branch-4.2 ( 0eaf06...5c7a26 )
by Jeremy
25:35 queued 16:13
created

Jetpack_Sync_Module_Updates::name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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
}