Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/wp-rocket/inc/Engine/Tracking/Subscriber.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
declare(strict_types=1);
3
+
4
+
namespace WP_Rocket\Engine\Tracking;
5
+
6
+
use WP_Rocket\Event_Management\Subscriber_Interface;
7
+
use WP_Rocket\Engine\Admin\RocketInsights\Managers\Plan;
8
+
9
+
class Subscriber implements Subscriber_Interface {
10
+
/**
11
+
* The tracking service.
12
+
*
13
+
* @var Tracking
14
+
*/
15
+
private $tracking;
16
+
17
+
/**
18
+
* Constructor.
19
+
*
20
+
* @param Tracking $tracking The tracking service.
21
+
*/
22
+
public function __construct( Tracking $tracking ) {
23
+
$this->tracking = $tracking;
24
+
}
25
+
26
+
/**
27
+
* Returns an array of events this subscriber wants to listen to.
28
+
*
29
+
* @return array
30
+
*/
31
+
public static function get_subscribed_events(): array {
32
+
return [
33
+
'update_option_wp_rocket_settings' => [ 'track_option_change', 10, 2 ],
34
+
'wp_rocket_upgrade' => [ 'migrate_optin', 10, 2 ],
35
+
'rocket_dashboard_after_account_data' => [ 'render_optin', 8 ],
36
+
'wp_ajax_rocket_toggle_optin' => [ 'ajax_toggle_optin' ],
37
+
'admin_enqueue_scripts' => [ 'localize_optin_status', 15 ],
38
+
'admin_print_scripts' => [ 'inject_mixpanel_script' ],
39
+
'rocket_mixpanel_optin_changed' => 'track_optin_change',
40
+
'rocket_rocket_insights_job_added' => [ 'track_rocket_insights_url_added', 10, 3 ],
41
+
'admin_footer-settings_page_wprocket' => 'track_admin_visits',
42
+
'rocket_rocket_insights_job_failed' => [ 'track_rocket_insights_test', 10, 3 ],
43
+
'rocket_rocket_insights_job_completed' => [ 'track_rocket_insights_test', 10, 3 ],
44
+
];
45
+
}
46
+
47
+
/**
48
+
* Track option change.
49
+
*
50
+
* @param mixed $old_value The old value of the option.
51
+
* @param mixed $value The new value of the option.
52
+
*
53
+
* @return void
54
+
*/
55
+
public function track_option_change( $old_value, $value ): void {
56
+
$this->tracking->track_option_change( $old_value, $value );
57
+
}
58
+
59
+
/**
60
+
* Migrate opt-in to new package on upgrade
61
+
*
62
+
* @param string $new_version The new version of the plugin.
63
+
* @param string $old_version The old version of the plugin.
64
+
*
65
+
* @return void
66
+
*/
67
+
public function migrate_optin( $new_version, $old_version ): void {
68
+
$this->tracking->migrate_optin( $new_version, $old_version );
69
+
}
70
+
71
+
/**
72
+
* Render the opt-in section.
73
+
*
74
+
* @return void
75
+
*/
76
+
public function render_optin(): void {
77
+
$this->tracking->render_optin();
78
+
}
79
+
80
+
/**
81
+
* Handle AJAX request to toggle opt-in.
82
+
*
83
+
* @return void
84
+
*/
85
+
public function ajax_toggle_optin(): void {
86
+
$this->tracking->ajax_toggle_optin();
87
+
}
88
+
89
+
/**
90
+
* Localize opt-in status to JavaScript.
91
+
*
92
+
* @return void
93
+
*/
94
+
public function localize_optin_status(): void {
95
+
$this->tracking->localize_optin_status();
96
+
}
97
+
98
+
/**
99
+
* Inject Mixpanel JavaScript SDK.
100
+
*
101
+
* @since 3.19.2
102
+
* @return void
103
+
*/
104
+
public function inject_mixpanel_script(): void {
105
+
$this->tracking->inject_mixpanel_script();
106
+
}
107
+
108
+
/**
109
+
* Track opt-in change event.
110
+
*
111
+
* @param bool $status The new opt-in status.
112
+
*
113
+
* @return void
114
+
*/
115
+
public function track_optin_change( $status ): void {
116
+
$this->tracking->track_optin_change( $status );
117
+
}
118
+
119
+
/**
120
+
* Track when a URL is added to Rocket Insights (Performance Monitoring).
121
+
*
122
+
* @since 3.20
123
+
*
124
+
* @param string $url The URL that was added for monitoring.
125
+
* @param string $plan Plan name.
126
+
* @param int $urls_count The current number of URLs being monitored.
127
+
*
128
+
* @return void
129
+
*/
130
+
public function track_rocket_insights_url_added( $url, $plan, $urls_count ): void {
131
+
$this->tracking->track_rocket_insights_url_added( $url, $plan, $urls_count );
132
+
}
133
+
134
+
/**
135
+
* Tracks when a performance test is completed or failed in Rocket Insights.
136
+
*
137
+
* @since 3.20
138
+
*
139
+
* @param object $row_details Details related to the database row.
140
+
* @param array $job_details Details related to the job.
141
+
* @param string $plan Plan name.
142
+
*
143
+
* @return void
144
+
*/
145
+
public function track_rocket_insights_test( $row_details, $job_details, $plan ): void {
146
+
$this->tracking->track_rocket_insights_test( $row_details, $job_details, $plan );
147
+
}
148
+
149
+
/**
150
+
* Tracks visits to settings page
151
+
*
152
+
* @return void
153
+
*/
154
+
public function track_admin_visits(): void {
155
+
$this->tracking->track_admin_visits();
156
+
}
157
+
}
158
+