| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\EditorEvents; |
| 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 |
public function get_name() { |
| 21 |
return 'editor-events'; |
| 22 |
} |
| 23 |
|
| 24 |
public static function get_editor_events_config() { |
| 25 |
$can_send_events = defined( 'ELEMENTOR_EDITOR_EVENTS_MIXPANEL_TOKEN' ) && |
| 26 |
Tracker::is_allow_track() && |
| 27 |
Plugin::$instance->experiments->is_feature_active( self::EXPERIMENT_NAME ); |
| 28 |
|
| 29 |
$settings = [ |
| 30 |
'can_send_events' => $can_send_events, |
| 31 |
'elementor_version' => ELEMENTOR_VERSION, |
| 32 |
'site_url' => hash( 'sha256', get_site_url() ), |
| 33 |
'wp_version' => get_bloginfo( 'version' ), |
| 34 |
'user_agent' => esc_html( Utils::get_super_global_value( $_SERVER, 'HTTP_USER_AGENT' ) ), |
| 35 |
'site_language' => get_locale(), |
| 36 |
'site_key' => get_option( Base_App::OPTION_CONNECT_SITE_KEY ), |
| 37 |
'subscription_id' => self::get_subscription_id(), |
| 38 |
'token' => defined( 'ELEMENTOR_EDITOR_EVENTS_MIXPANEL_TOKEN' ) ? ELEMENTOR_EDITOR_EVENTS_MIXPANEL_TOKEN : '', |
| 39 |
]; |
| 40 |
|
| 41 |
return $settings; |
| 42 |
} |
| 43 |
|
| 44 |
public static function get_experimental_data(): array { |
| 45 |
return [ |
| 46 |
'name' => static::EXPERIMENT_NAME, |
| 47 |
'title' => esc_html__( 'Elementor Editor Events', 'elementor' ), |
| 48 |
'description' => esc_html__( 'Editor events processing', 'elementor' ), |
| 49 |
'hidden' => true, |
| 50 |
'release_status' => Experiments_Manager::RELEASE_STATUS_ALPHA, |
| 51 |
'default' => Experiments_Manager::STATE_INACTIVE, |
| 52 |
]; |
| 53 |
} |
| 54 |
|
| 55 |
private static function get_subscription_id() { |
| 56 |
if ( ! Utils::has_pro() ) { |
| 57 |
|
| 58 |
return null; |
| 59 |
} |
| 60 |
|
| 61 |
$license_data = get_option( '_elementor_pro_license_v2_data' ); |
| 62 |
if ( isset( $license_data['value'] ) ) { |
| 63 |
$license_info = json_decode( $license_data['value'], true ); |
| 64 |
|
| 65 |
if ( isset( $license_info['subscription_id'] ) ) { |
| 66 |
$subscription_id = $license_info['subscription_id']; |
| 67 |
|
| 68 |
return $subscription_id; |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
return null; |
| 73 |
} |
| 74 |
} |
| 75 |
|