class.jetpack-sync-module-stats.php
| 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, false ) ); |
| 27 | } |
| 28 | } |
| 29 |