PluginProbe
Elementor Website Builder – more than just a page builder / 3.34.2
Elementor Website Builder – more than just a page builder v3.34.2
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / core / common / modules / events-manager / module.php

module.php in Elementor Website Builder – more than just a page builder 3.34.2, at core/common/modules/events-manager/module.php

105 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Core\Common\Modules\EventsManager;
4
5 use Elementor\Core\Base\Module as BaseModule;
6 use Elementor\Core\Common\Modules\Connect\Apps\Base_App;
7 use Elementor\Core\Experiments\Manager as Experiments_Manager;
8 use Elementor\Utils;
9 use Elementor\Plugin;
10 use Elementor\Tracker;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly.
14 }
15
16 class Module extends BaseModule {
17
18 const EXPERIMENT_NAME = 'editor_events';
19
20 const REMOTE_MIXPANEL_CONFIG_URL = 'https://assets.elementor.com/mixpanel/v1/mixpanel.json';
21
22 public function get_name() {
23 return 'events-manager';
24 }
25
26 public static function get_editor_events_config() {
27 $can_send_events = ! empty( ELEMENTOR_EDITOR_EVENTS_MIXPANEL_TOKEN ) &&
28 Tracker::is_allow_track() &&
29 ! Tracker::has_terms_changed( '2025-07-07' ) &&
30 Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME );
31
32 $mixpanel_config = self::get_remote_mixpanel_config();
33 $session_replays = $mixpanel_config[0]['sessionReplays'] ?? [];
34 $is_flags_enabled = $mixpanel_config[0]['flags'] ?? false;
35
36 $settings = [
37 'can_send_events' => $can_send_events,
38 'elementor_version' => ELEMENTOR_VERSION,
39 'site_url' => hash( 'sha256', get_site_url() ),
40 'wp_version' => get_bloginfo( 'version' ),
41 'user_agent' => esc_html( Utils::get_super_global_value( $_SERVER, 'HTTP_USER_AGENT' ) ),
42 'site_language' => get_locale(),
43 'site_key' => get_option( Base_App::OPTION_CONNECT_SITE_KEY ),
44 'subscription_id' => self::get_subscription_id(),
45 'subscription' => self::get_subscription(),
46 'token' => ELEMENTOR_EDITOR_EVENTS_MIXPANEL_TOKEN,
47 'session_replays' => $session_replays,
48 'flags_enabled' => $is_flags_enabled,
49 'isEditorOneActive' => Plugin::$instance->experiments->is_feature_active( 'e_editor_one' ),
50 ];
51
52 return $settings;
53 }
54
55 public static function get_experimental_data(): array {
56 return [
57 'name' => static::EXPERIMENT_NAME,
58 'title' => esc_html__( 'Elementor Editor Events', 'elementor' ),
59 'description' => esc_html__( 'Editor events processing', 'elementor' ),
60 'hidden' => true,
61 'release_status' => Experiments_Manager::RELEASE_STATUS_ALPHA,
62 'default' => Experiments_Manager::STATE_INACTIVE,
63 'new_site' => [
64 'default_active' => true,
65 'minimum_installation_version' => '3.32.0',
66 ],
67 ];
68 }
69
70 private static function get_subscription_id() {
71 $subscription = self::get_subscription();
72
73 return $subscription['subscription_id'] ?? null;
74 }
75
76 private static function get_subscription() {
77 if ( ! Utils::has_pro() ) {
78 return null;
79 }
80
81 $license_data = get_option( '_elementor_pro_license_v2_data' );
82 if ( ! isset( $license_data['value'] ) ) {
83 return null;
84 }
85
86 return json_decode( $license_data['value'], true );
87 }
88
89 private static function get_remote_mixpanel_config() {
90 $data = wp_remote_get( static::REMOTE_MIXPANEL_CONFIG_URL );
91
92 if ( is_wp_error( $data ) ) {
93 return [];
94 }
95
96 $data = json_decode( wp_remote_retrieve_body( $data ), true );
97
98 if ( empty( $data['mixpanel'] ) || ! is_array( $data['mixpanel'] ) ) {
99 return [];
100 }
101
102 return $data['mixpanel'];
103 }
104 }
105