← All changes
|
core/common/modules/events-manager/module.php
+17
-15
4.0.7
→
3.35.0-dev2
View file →
| @@ -4,9 +4,8 @@ | ||
| 4 | 4 | |
| 5 | 5 | use Elementor\Core\Base\Module as BaseModule; |
| 6 | 6 | use Elementor\Core\Common\Modules\Connect\Apps\Base_App; |
| 7 | 7 | use Elementor\Core\Experiments\Manager as Experiments_Manager; |
| 8 | -use Elementor\Includes\EditorAssetsAPI; | |
| 9 | 8 | use Elementor\Utils; |
| 10 | 9 | use Elementor\Plugin; |
| 11 | 10 | use Elementor\Tracker; |
| 12 | 11 | |
| @@ -29,17 +28,12 @@ | ||
| 29 | 28 | Tracker::is_allow_track() && |
| 30 | 29 | ! Tracker::has_terms_changed( '2025-07-07' ) && |
| 31 | 30 | Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME ); |
| 32 | 31 | |
| 33 | - $is_flags_enabled = false; | |
| 32 | + $mixpanel_config = self::get_remote_mixpanel_config(); | |
| 33 | + $session_replays = $mixpanel_config[0]['sessionReplays'] ?? []; | |
| 34 | + $is_flags_enabled = $mixpanel_config[0]['flags'] ?? false; | |
| 34 | 35 | |
| 35 | - if ( $can_send_events ) { | |
| 36 | - $mixpanel_config = self::get_remote_mixpanel_config(); | |
| 37 | - $is_flags_enabled = EditorAssetsAPI::has_valid_nested_array( $mixpanel_config, [ 0 ] ) | |
| 38 | - ? (bool) ( $mixpanel_config[0]['flags'] ?? false ) | |
| 39 | - : false; | |
| 40 | - } | |
| 41 | - | |
| 42 | 36 | $settings = [ |
| 43 | 37 | 'can_send_events' => $can_send_events, |
| 44 | 38 | 'elementor_version' => ELEMENTOR_VERSION, |
| 45 | 39 | 'site_url' => hash( 'sha256', get_site_url() ), |
| @@ -49,9 +43,11 @@ | ||
| 49 | 43 | 'site_key' => get_option( Base_App::OPTION_CONNECT_SITE_KEY ), |
| 50 | 44 | 'subscription_id' => self::get_subscription_id(), |
| 51 | 45 | 'subscription' => self::get_subscription(), |
| 52 | 46 | 'token' => ELEMENTOR_EDITOR_EVENTS_MIXPANEL_TOKEN, |
| 47 | + 'session_replays' => $session_replays, | |
| 53 | 48 | 'flags_enabled' => $is_flags_enabled, |
| 49 | + 'isEditorOneActive' => Plugin::$instance->experiments->is_feature_active( 'e_editor_one' ), | |
| 54 | 50 | ]; |
| 55 | 51 | |
| 56 | 52 | return $settings; |
| 57 | 53 | } |
| @@ -90,13 +86,19 @@ | ||
| 90 | 86 | return json_decode( $license_data['value'], true ); |
| 91 | 87 | } |
| 92 | 88 | |
| 93 | 89 | private static function get_remote_mixpanel_config() { |
| 94 | - $editor_assets_api = new EditorAssetsAPI( [ | |
| 95 | - EditorAssetsAPI::ASSETS_DATA_URL => static::REMOTE_MIXPANEL_CONFIG_URL, | |
| 96 | - EditorAssetsAPI::ASSETS_DATA_TRANSIENT_KEY => '_elementor_mixpanel_config', | |
| 97 | - EditorAssetsAPI::ASSETS_DATA_KEY => 'mixpanel', | |
| 98 | - ] ); | |
| 90 | + $data = wp_remote_get( static::REMOTE_MIXPANEL_CONFIG_URL ); | |
| 99 | 91 | |
| 100 | - return $editor_assets_api->get_assets_data(); | |
| 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']; | |
| 101 | 103 | } |
| 102 | 104 | } |