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` = '_elementor_edit_mode' ) WHERE `post_type` != 'elementor_library' AND `meta_value` IS NULL GROUP BY `post_type`, `post_status`;" ); if ( $results ) { foreach ( $results as $result ) { $usage[ $result->post_type ][ $result->post_status ] = $result->hits; } } return $usage; } /** * Get posts usage. * * Retrieve the number of posts using Elementor. * * @since 2.0.0 * @access public * @static * * @return array The number of posts using Elementor grouped by post types * and post status. */ public static function get_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`) WHERE `post_type` != 'elementor_library' AND `meta_key` = '_elementor_edit_mode' AND `meta_value` = 'builder' GROUP BY `post_type`, `post_status`;" ); if ( $results ) { foreach ( $results as $result ) { $usage[ $result->post_type ][ $result->post_status ] = (int) $result->hits; } } return $usage; } /** * Get library usage. * * Retrieve the number of Elementor library items saved. * * @since 2.0.0 * @access public * @static * * @return array The number of Elementor library items grouped by post types * and meta value. */ public static function get_library_usage() { global $wpdb; $usage = []; $results = $wpdb->get_results( "SELECT `meta_value`, COUNT(`ID`) `hits` FROM {$wpdb->posts} `p` LEFT JOIN {$wpdb->postmeta} `pm` ON(`p`.`ID` = `pm`.`post_id`) WHERE `post_type` = 'elementor_library' AND `meta_key` = '_elementor_template_type' GROUP BY `post_type`, `meta_value`;" ); if ( $results ) { foreach ( $results as $result ) { $usage[ $result->meta_value ] = $result->hits; } } return $usage; } /** * Get usage of general settings. * 'Elementor->Settings->General'. * * @return array */ public static function get_settings_general_usage() { return self::get_tracking_data_from_settings( 'general' ); } /** * Get usage of advanced settings. * 'Elementor->Settings->Advanced'. * * @return array */ public static function get_settings_advanced_usage() { return self::get_tracking_data_from_settings( 'advanced' ); } /** * Get usage of experiments settings. * * 'Elementor->Settings->Experiments'. * * @return array */ public static function get_settings_experiments_usage() { $system_info = Plugin::$instance->system_info; /** * @var $experiments_report Experiments_Reporter */ $experiments_report = $system_info->create_reporter( [ 'class_name' => Experiments_Reporter::class, ] ); return $experiments_report->get_experiments()['value']; } /** * Get usage of general tools. * 'Elementor->Tools->General'. * * @return array */ public static function get_tools_general_usage() { return self::get_tracking_data_from_tools( 'general' ); } /** * Get usage of 'version control' tools. * 'Elementor->Tools->Version Control'. * * @return array */ public static function get_tools_version_control_usage() { return self::get_tracking_data_from_tools( 'versions' ); } /** * Get usage of 'maintenance' tools. * 'Elementor->Tools->Maintenance'. * * @return array */ public static function get_tools_maintenance_usage() { return self::get_tracking_data_from_tools( 'maintenance_mode' ); } /** * Get library usage extend. * * Retrieve the number of Elementor library items saved. * * @return array The number of Elementor library items grouped by post types, post status * and meta value. */ public static function get_library_usage_extend() { global $wpdb; $usage = []; $results = $wpdb->get_results( "SELECT `meta_value`, COUNT(`ID`) `hits`, `post_status` FROM {$wpdb->posts} `p` LEFT JOIN {$wpdb->postmeta} `pm` ON(`p`.`ID` = `pm`.`post_id`) WHERE `post_type` = 'elementor_library' AND `meta_key` = '_elementor_template_type' GROUP BY `post_type`, `meta_value`, `post_status`;" ); if ( $results ) { foreach ( $results as $result ) { if ( empty( $usage[ $result->meta_value ] ) ) { $usage[ $result->meta_value ] = []; } if ( empty( $usage[ $result->meta_value ][ $result->post_status ] ) ) { $usage[ $result->meta_value ][ $result->post_status ] = 0; } $usage[ $result->meta_value ][ $result->post_status ] += $result->hits; } } return $usage; } public static function get_events() { global $wpdb; $table_name = $wpdb->prefix . Events_DB_Manager::TABLE_NAME; // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared $results = $wpdb->get_results( "SELECT event_data FROM {$table_name}" ); $events_data = []; foreach ( $results as $event ) { // Results are stored in the database as a JSON string. Since all tracking data is encoded right before // being sent, it is now decoded. $events_data[] = json_decode( $event->event_data, true ); } return $events_data; } /** * Get the tracking data * * Retrieve tracking data and apply filter * * @access public * @static * * @param bool $is_first_time * * @return array */ public static function get_tracking_data( $is_first_time = false ) { $params = [ 'system' => self::get_system_reports_data(), 'site_lang' => get_bloginfo( 'language' ), 'email' => get_option( 'admin_email' ), 'usages' => [ 'posts' => self::get_posts_usage(), 'non-elementor-posts' => self::get_non_elementor_posts_usage(), 'library' => self::get_library_usage(), 'settings' => [ 'general' => self::get_settings_general_usage(), 'advanced' => self::get_settings_advanced_usage(), 'experiments' => self::get_settings_experiments_usage(), ], 'tools' => [ 'general' => self::get_tools_general_usage(), 'version' => self::get_tools_version_control_usage(), 'maintenance' => self::get_tools_maintenance_usage(), ], 'library-details' => self::get_library_usage_extend(), ], 'is_first_time' => $is_first_time, 'install_time' => Plugin::instance()->get_install_time(), ]; /** * Tracker send tracking data params. * * Filters the data parameters when sending tracking request. * * @param array $params Variable to encode as JSON. * * @since 1.0.0 * */ $params = apply_filters( 'elementor/tracker/send_tracking_data_params', $params ); return $params; } /** * @param string $tab_name * @return array */ private static function get_tracking_data_from_settings( $tab_name ) { return self::get_tracking_data_from_settings_page( Plugin::$instance->settings->get_tabs(), $tab_name ); } /** * @param string $tab_name * @return array */ private static function get_tracking_data_from_tools( $tab_name ) { return self::get_tracking_data_from_settings_page( Plugin::$instance->tools->get_tabs(), $tab_name ); } private static function get_tracking_data_from_settings_page( $tabs, $tab_name ) { $result = []; if ( empty( $tabs[ $tab_name ] ) ) { return $result; } $tab = $tabs[ $tab_name ]; foreach ( $tab['sections'] as $section_name => $section ) { foreach ( $section['fields'] as $field_name => $field ) { // Skips fields with '_' prefix. if ( '_' === $field_name[0] ) { continue; } $default_value = null; $args = $field['field_args']; switch ( $args['type'] ) { case 'checkbox': $default_value = $args['value']; break; case 'select': case 'checkbox_list_cpt': $default_value = $args['std']; break; case 'checkbox_list_roles': $default_value = null; break; // 'raw_html' is used as action and not as data. case 'raw_html': continue 2; // Skip fields loop. default: trigger_error( 'Invalid type: \'' . $args['type'] . '\'' ); // phpcs:ignore } $result[ $field_name ] = get_option( 'elementor_' . $field_name, $default_value ); } } return $result; } }
Fatal error: Uncaught Error: Class "Elementor\Tracker" not found in /htdocs/wp-content/plugins/elementor/modules/usage/module.php:645 Stack trace: #0 /htdocs/wp-content/plugins/elementor/core/base/module.php(85): Elementor\Modules\Usage\Module->__construct() #1 /htdocs/wp-content/plugins/elementor/core/modules-manager.php(64): Elementor\Core\Base\Module::instance() #2 /htdocs/wp-content/plugins/elementor/includes/plugin.php(730): Elementor\Core\Modules_Manager->__construct() #3 /htdocs/wp-content/plugins/elementor/includes/plugin.php(647): Elementor\Plugin->init_components() #4 /htdocs/wp-includes/class-wp-hook.php(310): Elementor\Plugin->init('') #5 /htdocs/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(NULL, Array) #6 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #7 /htdocs/wp-settings.php(632): do_action('init') #8 /htdocs/wp-config.php(96): require_once('/htdocs/wp-sett...') #9 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #10 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #11 /htdocs/index.php(17): require('/htdocs/wp-blog...') #12 {main} thrown in /htdocs/wp-content/plugins/elementor/modules/usage/module.php on line 645