PluginProbe ʕ •ᴥ•ʔ
Tracking Code Manager / 2.8.0
Tracking Code Manager v2.8.0
2.8.0 2.7.0 trunk 1.11.8 1.11.9 1.12.0 1.12.1 1.12.2 1.12.3 1.4 1.5 2.0.0 2.0.1 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0
tracking-code-manager / includes / classes / utils / Tracking.php
tracking-code-manager / includes / classes / utils Last commit date
Cron.php 4 years ago Ecommerce.php 4 years ago Language.php 4 years ago Logger.php 1 month ago MobileDetect.php 1 month ago Options.php 2 weeks ago Plugin.php 1 month ago Properties.php 4 years ago Tracking.php 1 month ago Utils.php 1 month ago
Tracking.php
172 lines
1 <?php
2
3 // Exit if accessed directly
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 /**
9 * Usage tracking
10 *
11 * @access public
12 * @since 1.8.2
13 * @return void
14 */
15 class TCMP_Tracking {
16
17 public function __construct() {
18 //We send once a week (while tracking is allowed) to check in which can be used
19 //to determine active sites
20 add_action( 'tcmp_weekly_scheduled_events', array( $this, 'sendTracking' ) );
21
22 //add_action('tcmp_tracking_on', array($this, 'enableTracking'));
23 //add_action('tcmp_tracking_off', array($this, 'disableTracking'));
24 //add_action('admin_notices', array($this, 'admin_notice'));
25 }
26
27 private function getThemeData() {
28 $theme_data = wp_get_theme();
29 $theme = array(
30 'name' => $theme_data->display( 'Name', false, false ),
31 'theme_uri' => $theme_data->display( 'ThemeURI', false, false ),
32 'version' => $theme_data->display( 'Version', false, false ),
33 'author' => $theme_data->display( 'Author', false, false ),
34 'author_uri' => $theme_data->display( 'AuthorURI', false, false ),
35 );
36 $theme_template = $theme_data->get_template();
37 if ( '' != $theme_template && $theme_data->parent() ) {
38 $theme['template'] = array(
39 'version' => $theme_data->parent()->display( 'Version', false, false ),
40 'name' => $theme_data->parent()->display( 'Name', false, false ),
41 'theme_uri' => $theme_data->parent()->display( 'ThemeURI', false, false ),
42 'author' => $theme_data->parent()->display( 'Author', false, false ),
43 'author_uri' => $theme_data->parent()->display( 'AuthorURI', false, false ),
44 );
45 } else {
46 $theme['template'] = '';
47 }
48 unset( $theme_template );
49 return $theme;
50 }
51 private function getPluginData() {
52 //retrieve plugins (active/inactive) list
53 if ( ! function_exists( 'get_plugins' ) ) {
54 include ABSPATH . '/wp-admin/includes/plugin.php';
55 }
56
57 $plugins = array();
58 $active_plugin = get_option( 'active_plugins' );
59 foreach ( $active_plugin as $plugin_path ) {
60 if ( ! function_exists( 'get_plugin_data' ) ) {
61 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
62 }
63
64 $plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_path );
65
66 $slug = str_replace( '/' . basename( $plugin_path ), '', $plugin_path );
67 $plugins[ $slug ] = array(
68 'version' => $plugin_info['Version'],
69 'name' => $plugin_info['Name'],
70 'plugin_uri' => $plugin_info['PluginURI'],
71 'author' => $plugin_info['AuthorName'],
72 'author_uri' => $plugin_info['AuthorURI'],
73 );
74 }
75 unset( $active_plugins, $plugin_path );
76 return $plugins;
77 }
78 //obtain tracking data into an associative array
79 public function getData() {
80 global $tcmp;
81
82 //retrieve blog info
83 $result['wp_url'] = home_url();
84 $result['wp_version'] = get_bloginfo( 'version' );
85 $result['wp_language'] = get_bloginfo( 'language' );
86 $result['wp_wpurl'] = get_bloginfo( 'wpurl' );
87 // The administrator email address is intentionally NOT transmitted: it is
88 // personal data that is not needed for the usage statistics this payload
89 // collects. (See F-08 — data minimisation.)
90
91 $result['plugins'] = $this->getPluginData();
92 $result['theme'] = $this->getThemeData();
93
94 //to obtain for each post type its count
95 $post_types = $tcmp->utils->query( TCMP_QUERY_POST_TYPES );
96 $data = array();
97 foreach ( $post_types as $v ) {
98 $v = $v['id'];
99 $data[ $v ] = intval( wp_count_posts( $v )->publish );
100 }
101 $result['post_types'] = $data;
102
103 //plugin configuration without secret-code
104 $data = array();
105 $keys = $tcmp->manager->keys();
106 foreach ( $keys as $k ) {
107 $v = $tcmp->manager->get( $k );
108 //to allow us to receive a part of the code and to protect user privacy
109 //we use this data only to know which SaaS services are used
110 //and not to use your data
111 $v['code'] = substr( $v['code'], 0, 100 );
112 $data[] = $v;
113 }
114 $result['iwpm_plugin_name'] = TCMP_PLUGIN_SLUG;
115 $result['iwpm_plugin_version'] = TCMP_PLUGIN_VERSION;
116 $result['iwpm_plugin_data'] = $data;
117 $result['iwpm_plugin_install_date'] = $tcmp->options->getPluginInstallDate();
118 $result['iwpm_plugin_update_date'] = $tcmp->options->getPluginUpdateDate();
119
120 $result['iwpm_license_key'] = $tcmp->options->getLicenseKey();
121 $result['iwpm_license_status'] = $tcmp->options->isLicenseSuccess();
122 $result['iwpm_tracking_enable'] = $tcmp->options->isTrackingEnable();
123 $result['iwpm_logger_enable'] = $tcmp->options->isLoggerEnable();
124 $result['iwpm_feedback_email'] = $tcmp->options->getFeedbackEmail();
125
126 //var_dump($result);
127 return $result;
128 }
129
130 //send tracking data info to our server
131 public function sendTracking( $override = false ) {
132 global $tcmp;
133
134 $result = -1;
135 if ( ! $override && ! $tcmp->options->isTrackingEnable() ) {
136 return $result;
137 }
138
139 // Send a maximum of once per week
140 $last_send = $tcmp->options->getTrackingLastSend();
141 if ( ! $override && $last_send > strtotime( '-1 week' ) ) {
142 return $result;
143 }
144
145 //add_filter('https_local_ssl_verify', '__return_false');
146 //add_filter('https_ssl_verify', '__return_false');
147 //add_filter('block_local_requests', '__return_false');
148
149 $data = $tcmp->utils->remotePost( 'usage', $this->getData() );
150 if ( $data ) {
151 $result = intval( $data['id'] );
152 $tcmp->options->setTrackingLastSend( time() );
153 }
154 return $result;
155 }
156
157 public function enableTracking() {
158 global $tcmp;
159
160 $tcmp->options->setTrackingEnable( true );
161 $tcmp->options->setTrackingNotice( false );
162 $this->sendTracking( true );
163 }
164 public function disableTracking() {
165 global $tcmp;
166
167 $tcmp->options->setTrackingEnable( false );
168 $tcmp->options->setTrackingNotice( false );
169 $this->sendTracking( true );
170 }
171 }
172