a tracking, or not. * * @since 1.0.0 * @access public * @static */ public static function is_allow_track() { return 'yes' === get_option( 'elementor_allow_tracking', 'no' ); } /** * Handle tracker actions. * * Check if the user opted-in or opted-out and update the database. * * Fired by `admin_init` action. * * @since 1.0.0 * @access public * @static */ public static function handle_tracker_actions() { if ( ! isset( $_GET['elementor_tracker'] ) ) { return; } if ( 'opt_into' === $_GET['elementor_tracker'] ) { check_admin_referer( 'opt_into' ); self::set_opt_in( true ); } if ( 'opt_out' === $_GET['elementor_tracker'] ) { check_admin_referer( 'opt_out' ); self::set_opt_in( false ); } wp_redirect( remove_query_arg( 'elementor_tracker' ) ); exit; } /** * @since 2.2.0 * @access public * @static */ public static function is_notice_shown() { return self::$notice_shown; } public static function set_opt_in( $value ) { if ( $value ) { update_option( 'elementor_allow_tracking', 'yes' ); self::send_tracking_data( true ); } else { update_option( 'elementor_allow_tracking', 'no' ); update_option( 'elementor_tracker_notice', '1' ); } } /** * Get system reports data. * * Retrieve the data from system reports. * * @since 2.0.0 * @access private * @static * * @return array The data from system reports. */ private static function get_system_reports_data() { $reports = Plugin::$instance->system_info->load_reports( System_Info_Module::get_allowed_reports() ); // The log report should not be sent with the usage data - it is not used and causes bloat. if ( isset( $reports['log'] ) ) { unset( $reports['log'] ); } $system_reports = []; foreach ( $reports as $report_key => $report_details ) { $system_reports[ $report_key ] = []; foreach ( $report_details['report']->get_report() as $sub_report_key => $sub_report_details ) { $system_reports[ $report_key ][ $sub_report_key ] = $sub_report_details['value']; } } return $system_reports; } /** * Get last send time. * * Retrieve the last time tracking data was sent. * * @since 2.0.0 * @access private * @static * * @return int|false The last time tracking data was sent, or false if * tracking data never sent. */ private static function get_last_send_time() { $last_send_time = get_option( 'elementor_tracker_last_send', false ); /** * Tracker last send time. * * Filters the last time tracking data was sent. * * @since 1.0.0 * * @param int|false $last_send_time The last time tracking data was sent, * or false if tracking data never sent. */ $last_send_time = apply_filters( 'elementor/tracker/last_send_time', $last_send_time ); return $last_send_time; } /** * Get non elementor post usages. * * Retrieve the number of posts that not using elementor. * @return array The number of posts using not used by Elementor grouped by post types * and post status. */ public static function get_non_elementor_posts_usage() { global $wpdb; $usage = []; $results = $wpdb->get_results( "SELECT `post_type`, `post_status`, COUNT(`ID`) `hits` FROM {$wpdb->posts} `p` LEFT JOIN {$wpdb->postmeta} `pm` ON(`p`.`ID` = `pm`.`post_id` AND `meta_key` = '_e