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

Jetpack_Sync_Module_Updates   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 47
rs 10
wmc 6
lcom 0
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 3 1
A init_listeners() 0 10 1
A full_sync() 0 11 1
A get_all_updates() 0 7 1
A filter_update_keys() 0 9 2
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
}