| @@ -28,14 +28,12 @@ | ||
| 28 | 28 | * @access private |
| 29 | 29 | * |
| 30 | 30 | * @var string API URL. |
| 31 | 31 | */ |
| 32 | - private static $api_url = 'https://my.elementor.com/api/v1/tracker/'; | |
| 32 | + private static $_api_url = 'https://my.elementor.com/api/v1/tracker/'; | |
| 33 | 33 | |
| 34 | 34 | private static $notice_shown = false; |
| 35 | 35 | |
| 36 | - const LAST_TERMS_UPDATED = '2025-07-07'; | |
| 37 | - | |
| 38 | 36 | /** |
| 39 | 37 | * Init. |
| 40 | 38 | * |
| 41 | 39 | * Initialize Elementor tracker. |
| @@ -46,10 +44,8 @@ | ||
| 46 | 44 | */ |
| 47 | 45 | public static function init() { |
| 48 | 46 | add_action( 'elementor/tracker/send_event', [ __CLASS__, 'send_tracking_data' ] ); |
| 49 | 47 | add_action( 'admin_init', [ __CLASS__, 'handle_tracker_actions' ] ); |
| 50 | - | |
| 51 | - add_action( 'update_option_elementor_allow_tracking', [ __CLASS__, 'set_last_update_time' ] ); | |
| 52 | 48 | } |
| 53 | 49 | |
| 54 | 50 | /** |
| 55 | 51 | * Check for settings opt-in. |
| @@ -72,10 +68,8 @@ | ||
| 72 | 68 | 'opt_in_send_tracking_data', |
| 73 | 69 | ] ); |
| 74 | 70 | } |
| 75 | 71 | |
| 76 | - self::set_last_update_time(); | |
| 77 | - | |
| 78 | 72 | if ( empty( $new_value ) ) { |
| 79 | 73 | $new_value = 'no'; |
| 80 | 74 | } |
| 81 | 75 | |
| @@ -133,10 +127,13 @@ | ||
| 133 | 127 | // Send a maximum of once per week by default. |
| 134 | 128 | if ( $last_send && $last_send > $last_send_interval ) { |
| 135 | 129 | return; |
| 136 | 130 | } |
| 137 | - } elseif ( $last_send && $last_send > strtotime( '-1 hours' ) ) { | |
| 138 | - return; | |
| 131 | + } else { | |
| 132 | + // Make sure there is at least a 1 hour delay between override sends, we dont want duplicate calls due to double clicking links. | |
| 133 | + if ( $last_send && $last_send > strtotime( '-1 hours' ) ) { | |
| 134 | + return; | |
| 135 | + } | |
| 139 | 136 | } |
| 140 | 137 | |
| 141 | 138 | // Update time first before sending to ensure it is set. |
| 142 | 139 | update_option( 'elementor_tracker_last_send', time() ); |
| @@ -143,18 +140,19 @@ | ||
| 143 | 140 | |
| 144 | 141 | $params = self::get_tracking_data( empty( $last_send ) ); |
| 145 | 142 | |
| 146 | 143 | // Tracking data is used for System Info reports, and events should not be included in System Info reports, |
| 147 | - // so it is added here. | |
| 144 | + // so it is added here | |
| 148 | 145 | $params['analytics_events'] = self::get_events(); |
| 149 | 146 | |
| 150 | 147 | add_filter( 'https_ssl_verify', '__return_false' ); |
| 151 | 148 | |
| 152 | 149 | wp_safe_remote_post( |
| 153 | - self::$api_url, | |
| 150 | + self::$_api_url, | |
| 154 | 151 | [ |
| 155 | 152 | 'timeout' => 25, |
| 156 | 153 | 'blocking' => false, |
| 154 | + // 'sslverify' => false, | |
| 157 | 155 | 'body' => [ |
| 158 | 156 | 'data' => wp_json_encode( $params ), |
| 159 | 157 | ], |
| 160 | 158 | ] |
| @@ -176,31 +174,8 @@ | ||
| 176 | 174 | public static function is_allow_track() { |
| 177 | 175 | return 'yes' === get_option( 'elementor_allow_tracking', 'no' ); |
| 178 | 176 | } |
| 179 | 177 | |
| 180 | - public static function get_last_update_time() { | |
| 181 | - return get_option( 'elementor_allow_tracking_last_update', false ); | |
| 182 | - } | |
| 183 | - | |
| 184 | - public static function set_last_update_time(): void { | |
| 185 | - update_option( 'elementor_allow_tracking_last_update', gmdate( 'U' ) ); | |
| 186 | - } | |
| 187 | - | |
| 188 | - public static function has_terms_changed( $terms_updated = self::LAST_TERMS_UPDATED ): bool { | |
| 189 | - if ( ! self::is_allow_track() ) { | |
| 190 | - return false; | |
| 191 | - } | |
| 192 | - | |
| 193 | - $last_update_time = self::get_last_update_time(); | |
| 194 | - if ( $last_update_time ) { | |
| 195 | - $terms_updated_timestamp = strtotime( $terms_updated . ' UTC' ); | |
| 196 | - | |
| 197 | - return $last_update_time < $terms_updated_timestamp; | |
| 198 | - } | |
| 199 | - | |
| 200 | - return true; | |
| 201 | - } | |
| 202 | - | |
| 203 | 178 | /** |
| 204 | 179 | * Handle tracker actions. |
| 205 | 180 | * |
| 206 | 181 | * Check if the user opted-in or opted-out and update the database. |
| @@ -227,9 +202,9 @@ | ||
| 227 | 202 | |
| 228 | 203 | self::set_opt_in( false ); |
| 229 | 204 | } |
| 230 | 205 | |
| 231 | - wp_safe_redirect( remove_query_arg( 'elementor_tracker' ) ); | |
| 206 | + wp_redirect( remove_query_arg( 'elementor_tracker' ) ); | |
| 232 | 207 | exit; |
| 233 | 208 | } |
| 234 | 209 | |
| 235 | 210 | /** |
| @@ -243,10 +218,8 @@ | ||
| 243 | 218 | |
| 244 | 219 | public static function set_opt_in( $value ) { |
| 245 | 220 | if ( $value ) { |
| 246 | 221 | update_option( 'elementor_allow_tracking', 'yes' ); |
| 247 | - self::set_last_update_time(); | |
| 248 | - | |
| 249 | 222 | self::send_tracking_data( true ); |
| 250 | 223 | } else { |
| 251 | 224 | update_option( 'elementor_allow_tracking', 'no' ); |
| 252 | 225 | update_option( 'elementor_tracker_notice', '1' ); |
| @@ -324,9 +297,8 @@ | ||
| 324 | 297 | global $wpdb; |
| 325 | 298 | |
| 326 | 299 | $usage = []; |
| 327 | 300 | |
| 328 | - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery | |
| 329 | 301 | $results = $wpdb->get_results( |
| 330 | 302 | "SELECT `post_type`, `post_status`, COUNT(`ID`) `hits` |
| 331 | 303 | FROM {$wpdb->posts} `p` |
| 332 | 304 | LEFT JOIN {$wpdb->postmeta} `pm` ON(`p`.`ID` = `pm`.`post_id` AND `meta_key` = '_elementor_edit_mode' ) |
| @@ -359,9 +331,8 @@ | ||
| 359 | 331 | global $wpdb; |
| 360 | 332 | |
| 361 | 333 | $usage = []; |
| 362 | 334 | |
| 363 | - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery | |
| 364 | 335 | $results = $wpdb->get_results( |
| 365 | 336 | "SELECT `post_type`, `post_status`, COUNT(`ID`) `hits` |
| 366 | 337 | FROM {$wpdb->posts} `p` |
| 367 | 338 | LEFT JOIN {$wpdb->postmeta} `pm` ON(`p`.`ID` = `pm`.`post_id`) |
| @@ -395,9 +366,8 @@ | ||
| 395 | 366 | global $wpdb; |
| 396 | 367 | |
| 397 | 368 | $usage = []; |
| 398 | 369 | |
| 399 | - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery | |
| 400 | 370 | $results = $wpdb->get_results( |
| 401 | 371 | "SELECT `meta_value`, COUNT(`ID`) `hits` |
| 402 | 372 | FROM {$wpdb->posts} `p` |
| 403 | 373 | LEFT JOIN {$wpdb->postmeta} `pm` ON(`p`.`ID` = `pm`.`post_id`) |
| @@ -412,8 +382,9 @@ | ||
| 412 | 382 | } |
| 413 | 383 | } |
| 414 | 384 | |
| 415 | 385 | return $usage; |
| 386 | + | |
| 416 | 387 | } |
| 417 | 388 | |
| 418 | 389 | /** |
| 419 | 390 | * Get usage of general settings. |
| @@ -435,18 +406,8 @@ | ||
| 435 | 406 | return self::get_tracking_data_from_settings( 'advanced' ); |
| 436 | 407 | } |
| 437 | 408 | |
| 438 | 409 | /** |
| 439 | - * Get usage of performance settings. | |
| 440 | - * 'Elementor->Settings->Performance'. | |
| 441 | - * | |
| 442 | - * @return array | |
| 443 | - */ | |
| 444 | - public static function get_settings_performance_usage() { | |
| 445 | - return self::get_tracking_data_from_settings( 'performance' ); | |
| 446 | - } | |
| 447 | - | |
| 448 | - /** | |
| 449 | 410 | * Get usage of experiments settings. |
| 450 | 411 | * |
| 451 | 412 | * 'Elementor->Settings->Experiments'. |
| 452 | 413 | * |
| @@ -507,9 +468,8 @@ | ||
| 507 | 468 | global $wpdb; |
| 508 | 469 | |
| 509 | 470 | $usage = []; |
| 510 | 471 | |
| 511 | - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery | |
| 512 | 472 | $results = $wpdb->get_results( |
| 513 | 473 | "SELECT `meta_value`, COUNT(`ID`) `hits`, `post_status` |
| 514 | 474 | FROM {$wpdb->posts} `p` |
| 515 | 475 | LEFT JOIN {$wpdb->postmeta} `pm` ON(`p`.`ID` = `pm`.`post_id`) |
| @@ -538,9 +498,9 @@ | ||
| 538 | 498 | public static function get_events() { |
| 539 | 499 | global $wpdb; |
| 540 | 500 | $table_name = $wpdb->prefix . Events_DB_Manager::TABLE_NAME; |
| 541 | 501 | |
| 542 | - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery | |
| 502 | + // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared | |
| 543 | 503 | $results = $wpdb->get_results( "SELECT event_data FROM {$table_name}" ); |
| 544 | 504 | |
| 545 | 505 | $events_data = []; |
| 546 | 506 | |
| @@ -589,18 +549,8 @@ | ||
| 589 | 549 | 'is_first_time' => $is_first_time, |
| 590 | 550 | 'install_time' => Plugin::instance()->get_install_time(), |
| 591 | 551 | ]; |
| 592 | 552 | |
| 593 | - $site_key = Api::get_site_key(); | |
| 594 | - if ( ! empty( $site_key ) ) { | |
| 595 | - $params['site_key'] = $site_key; | |
| 596 | - } | |
| 597 | - | |
| 598 | - $allowed_usage_time = self::get_last_update_time(); | |
| 599 | - if ( ! empty( $allowed_usage_time ) ) { | |
| 600 | - $params['allowed_usage_time'] = $allowed_usage_time; | |
| 601 | - } | |
| 602 | - | |
| 603 | 553 | /** |
| 604 | 554 | * Tracker send tracking data params. |
| 605 | 555 | * |
| 606 | 556 | * Filters the data parameters when sending tracking request. |
| @@ -607,8 +557,9 @@ | ||
| 607 | 557 | * |
| 608 | 558 | * @param array $params Variable to encode as JSON. |
| 609 | 559 | * |
| 610 | 560 | * @since 1.0.0 |
| 561 | + * | |
| 611 | 562 | */ |
| 612 | 563 | $params = apply_filters( 'elementor/tracker/send_tracking_data_params', $params ); |
| 613 | 564 | |
| 614 | 565 | return $params; |