PluginProbe ʕ •ᴥ•ʔ
Tracking Code Manager / 2.2.0
Tracking Code Manager v2.2.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 3 years ago Ecommerce.php 3 years ago Language.php 3 years ago Logger.php 3 years ago MobileDetect.php 3 years ago Options.php 3 years ago Plugin.php 3 years ago Properties.php 3 years ago Tracking.php 3 years ago Utils.php 2 years ago
Tracking.php
170 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 $result['wp_admin_email'] = get_bloginfo( 'admin_email' );
88
89 $result['plugins'] = $this->getPluginData();
90 $result['theme'] = $this->getThemeData();
91
92 //to obtain for each post type its count
93 $post_types = $tcmp->utils->query( TCMP_QUERY_POST_TYPES );
94 $data = array();
95 foreach ( $post_types as $v ) {
96 $v = $v['id'];
97 $data[ $v ] = intval( wp_count_posts( $v )->publish );
98 }
99 $result['post_types'] = $data;
100
101 //plugin configuration without secret-code
102 $data = array();
103 $keys = $tcmp->manager->keys();
104 foreach ( $keys as $k ) {
105 $v = $tcmp->manager->get( $k );
106 //to allow us to receive a part of the code and to protect user privacy
107 //we use this data only to know which SaaS services are used
108 //and not to use your data
109 $v['code'] = substr( $v['code'], 0, 100 );
110 $data[] = $v;
111 }
112 $result['iwpm_plugin_name'] = TCMP_PLUGIN_SLUG;
113 $result['iwpm_plugin_version'] = TCMP_PLUGIN_VERSION;
114 $result['iwpm_plugin_data'] = $data;
115 $result['iwpm_plugin_install_date'] = $tcmp->options->getPluginInstallDate();
116 $result['iwpm_plugin_update_date'] = $tcmp->options->getPluginUpdateDate();
117
118 $result['iwpm_license_key'] = $tcmp->options->getLicenseKey();
119 $result['iwpm_license_status'] = $tcmp->options->isLicenseSuccess();
120 $result['iwpm_tracking_enable'] = $tcmp->options->isTrackingEnable();
121 $result['iwpm_logger_enable'] = $tcmp->options->isLoggerEnable();
122 $result['iwpm_feedback_email'] = $tcmp->options->getFeedbackEmail();
123
124 //var_dump($result);
125 return $result;
126 }
127
128 //send tracking data info to our server
129 public function sendTracking( $override = false ) {
130 global $tcmp;
131
132 $result = -1;
133 if ( ! $override && ! $tcmp->options->isTrackingEnable() ) {
134 return $result;
135 }
136
137 // Send a maximum of once per week
138 $last_send = $tcmp->options->getTrackingLastSend();
139 if ( ! $override && $last_send > strtotime( '-1 week' ) ) {
140 return $result;
141 }
142
143 //add_filter('https_local_ssl_verify', '__return_false');
144 //add_filter('https_ssl_verify', '__return_false');
145 //add_filter('block_local_requests', '__return_false');
146
147 $data = $tcmp->utils->remotePost( 'usage', $this->getData() );
148 if ( $data ) {
149 $result = intval( $data['id'] );
150 $tcmp->options->setTrackingLastSend( time() );
151 }
152 return $result;
153 }
154
155 public function enableTracking() {
156 global $tcmp;
157
158 $tcmp->options->setTrackingEnable( true );
159 $tcmp->options->setTrackingNotice( false );
160 $this->sendTracking( true );
161 }
162 public function disableTracking() {
163 global $tcmp;
164
165 $tcmp->options->setTrackingEnable( false );
166 $tcmp->options->setTrackingNotice( false );
167 $this->sendTracking( true );
168 }
169 }
170