← All changes
|
jetpack_vendor/automattic/jetpack-sync/src/modules/class-stats.php
+8
-14
12.7.3
→
16.3-a.5
View file →
| @@ -8,8 +8,12 @@ | ||
| 8 | 8 | namespace Automattic\Jetpack\Sync\Modules; |
| 9 | 9 | |
| 10 | 10 | use Automattic\Jetpack\Heartbeat; |
| 11 | 11 | |
| 12 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 13 | + exit( 0 ); | |
| 14 | +} | |
| 15 | + | |
| 12 | 16 | /** |
| 13 | 17 | * Class to handle sync for stats. |
| 14 | 18 | */ |
| 15 | 19 | class Stats extends Module { |
| @@ -28,32 +32,22 @@ | ||
| 28 | 32 | * Initialize stats action listeners. |
| 29 | 33 | * |
| 30 | 34 | * @access public |
| 31 | 35 | * |
| 32 | - * @param callable $callback Action handler callable. | |
| 36 | + * @param callable $callback Unused - required for parent class compatibility. | |
| 33 | 37 | */ |
| 34 | - public function init_listeners( $callback ) { | |
| 38 | + public function init_listeners( $callback ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable | |
| 35 | 39 | add_action( 'jetpack_heartbeat', array( $this, 'sync_site_stats' ), 20 ); |
| 36 | - add_action( 'jetpack_sync_heartbeat_stats', $callback ); | |
| 37 | 40 | } |
| 38 | 41 | |
| 39 | 42 | /** |
| 40 | - * This namespaces the action that we sync. | |
| 41 | - * So that we can differentiate it from future actions. | |
| 43 | + * Send Heartbeat stats immediately. | |
| 42 | 44 | * |
| 43 | 45 | * @access public |
| 44 | 46 | */ |
| 45 | 47 | public function sync_site_stats() { |
| 46 | - do_action( 'jetpack_sync_heartbeat_stats' ); | |
| 47 | - } | |
| 48 | 48 | |
| 49 | - /** | |
| 50 | - * Initialize the module in the sender. | |
| 51 | - * | |
| 52 | - * @access public | |
| 53 | - */ | |
| 54 | - public function init_before_send() { | |
| 55 | - add_filter( 'jetpack_sync_before_send_jetpack_sync_heartbeat_stats', array( $this, 'add_stats' ) ); | |
| 49 | + $this->send_action( 'jetpack_sync_heartbeat_stats', $this->add_stats() ); | |
| 56 | 50 | } |
| 57 | 51 | |
| 58 | 52 | /** |
| 59 | 53 | * Retrieve the stats data for the site. |