| 1 |
<?php |
| 2 |
/** |
| 3 |
* Telemetry: Telemetry activation and event registration for PHP events |
| 4 |
* |
| 5 |
* @package Parsely\Telemetry |
| 6 |
* @since 3.12.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
declare(strict_types=1); |
| 10 |
|
| 11 |
use Parsely\Telemetry\Telemetry_System; |
| 12 |
use Parsely\Telemetry\Tracks; |
| 13 |
|
| 14 |
require_once __DIR__ . '/class-telemetry-system.php'; |
| 15 |
|
| 16 |
// If in a VIP environment, disable the existing Telemetry implementation. |
| 17 |
// This avoids duplicate events being sent to Tracks. |
| 18 |
if ( defined( 'VIP_GO_APP_ENVIRONMENT' ) ) { |
| 19 |
add_filter( 'wp_parsely_enable_telemetry_backend', '__return_false' ); |
| 20 |
} |
| 21 |
|
| 22 |
add_action( |
| 23 |
'init', |
| 24 |
function (): void { |
| 25 |
// Initialize the JS tracking. It will handle if telemetry is enabled or not by itself. |
| 26 |
Telemetry_System::init_js_tracking(); |
| 27 |
|
| 28 |
// Bail if wp-admin telemetry is not allowed. |
| 29 |
if ( false === Telemetry_System::is_wpadmin_telemetry_allowed() ) { |
| 30 |
return; |
| 31 |
} |
| 32 |
|
| 33 |
require_once __DIR__ . '/Events/recommended-widget.php'; |
| 34 |
require_once __DIR__ . '/Events/settings.php'; |
| 35 |
require_once __DIR__ . '/Tracks/class-tracks-event.php'; |
| 36 |
require_once __DIR__ . '/Tracks/class-tracks-pixel.php'; |
| 37 |
require_once __DIR__ . '/Tracks/class-tracks.php'; |
| 38 |
|
| 39 |
$tracks = new Tracks(); |
| 40 |
|
| 41 |
$tracks->register_events( |
| 42 |
// Recommended Widget events. |
| 43 |
array( |
| 44 |
'action_hook' => 'delete_widget', |
| 45 |
'callable' => 'Parsely\Telemetry\record_widget_deleted', |
| 46 |
'accepted_args' => 3, |
| 47 |
), |
| 48 |
array( |
| 49 |
'action_hook' => 'widget_update_callback', |
| 50 |
'callable' => 'Parsely\Telemetry\record_widget_updated', |
| 51 |
'accepted_args' => 4, |
| 52 |
), |
| 53 |
// Setting events. |
| 54 |
array( |
| 55 |
'action_hook' => 'load-settings_page_parsely', |
| 56 |
'callable' => 'Parsely\Telemetry\record_settings_page_loaded', |
| 57 |
), |
| 58 |
array( |
| 59 |
'action_hook' => 'update_option_parsely', |
| 60 |
'callable' => 'Parsely\Telemetry\record_parsely_option_updated', |
| 61 |
'accepted_args' => 2, |
| 62 |
) |
| 63 |
); |
| 64 |
|
| 65 |
$tracks->run(); |
| 66 |
} |
| 67 |
); |
| 68 |
|