Completed
Push — branch-4.2 ( 88a673...dbc98d )
by
unknown
157:35 queued 148:33
created

Jetpack_Sync_Module_Stats::sync_site_stats()   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_Stats extends Jetpack_Sync_Module {
4
5
	function name() {
6
		return 'stats';
7
	}
8
9
	function init_listeners( $callback ) {
10
		add_action( 'jetpack_heartbeat', array( $this, 'sync_site_stats' ), 20 );
11
		add_action( 'jetpack_sync_heartbeat_stats', $callback );
12
	}
13
	/*
14
	 * This namespaces the action that we sync.
15
	 * So that we can differentiate it from future actions.
16
	 */
17
	public function sync_site_stats() {
18
		do_action( 'jetpack_sync_heartbeat_stats' );
19
	}
20
21
	public function init_before_send() {
22
		add_filter( 'jetpack_sync_before_send_jetpack_sync_heartbeat_stats', array( $this, 'add_stats' ) );
23
	}
24
25
	public function add_stats() {
26
		return array( Jetpack::get_stat_data( false ) );
27
	}
28
}
29