class.jetpack-sync-module-stats.php 726 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. class Jetpack_Sync_Module_Stats extends Jetpack_Sync_Module {
  3. function name() {
  4. return 'stats';
  5. }
  6. function init_listeners( $callback ) {
  7. add_action( 'jetpack_heartbeat', array( $this, 'sync_site_stats' ), 20 );
  8. add_action( 'jetpack_sync_heartbeat_stats', $callback );
  9. }
  10. /*
  11. * This namespaces the action that we sync.
  12. * So that we can differentiate it from future actions.
  13. */
  14. public function sync_site_stats() {
  15. do_action( 'jetpack_sync_heartbeat_stats' );
  16. }
  17. public function init_before_send() {
  18. add_filter( 'jetpack_sync_before_send_jetpack_sync_heartbeat_stats', array( $this, 'add_stats' ) );
  19. }
  20. public function add_stats() {
  21. return array( Jetpack::get_stat_data( false, false ) );
  22. }
  23. }