Currently reviewing a theme which has tracking code in its functions from a service called "PressTrends" <a href="http://presstrends.io/">http://presstrends.io/</a> This service fetches details about users to theme's author for statistical purposes, but I'm wondering is it's OK for a theme in WP repository?<br>
<br>That's how the code looks like:<br><br><span style="font-family:courier new,monospace">// Add your PressTrends and Theme API Keys</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">$api_key = '-----';</span> (deleted by me)<br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$auth = '------';</span> (deleted by me)<br style="font-family:courier new,monospace"><br><span style="font-family:courier new,monospace">$data = get_transient( 'presstrends_data' );</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">if (!$data || $data == ''){</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">$api_base = '<a href="http://api.presstrends.io/index.php/api/sites/add/auth/">http://api.presstrends.io/index.php/api/sites/add/auth/</a>';</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$url = $api_base . $auth . '/api/' . $api_key . '/';</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">$data = array();</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$count_posts = wp_count_posts();</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">$count_pages = wp_count_posts('page');</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$comments_count = wp_count_comments();</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">$theme_data = get_theme_data(get_stylesheet_directory() . '/style.css');</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$plugin_count = count(get_option('active_plugins'));</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">$all_plugins = get_plugins();</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">foreach($all_plugins as $plugin_file => $plugin_data) {</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">$plugin_name .= $plugin_data['Name'];</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$plugin_name .= '&';</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">}</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$data['url'] = stripslashes(str_replace(array('http://', '/', ':' ), '', site_url()));</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$data['posts'] = $count_posts->publish;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">$data['pages'] = $count_pages->publish;</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$data['comments'] = $comments_count->total_comments;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">$data['approved'] = $comments_count->approved;</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$data['spam'] = $comments_count->spam;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">$data['theme_version'] = $theme_data['Version'];</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$data['theme_name'] = $theme_data['Name'];</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">$data['site_name'] = str_replace( ' ', '', get_bloginfo( 'name' ));</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$data['plugins'] = $plugin_count;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">$data['plugin'] = urlencode($plugin_name);</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$data['wpversion'] = get_bloginfo('version');</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">foreach ( $data as $k => $v ) {</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$url .= $k . '/' . $v . '/';</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">}</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">$response = wp_remote_get( $url );</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">set_transient('presstrends_data', $data, 60*60*24);</span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">}}</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">add_action('admin_init', 'if_presstrends');</span><br clear="all">
<br><br>-- <br><font style="font-family:trebuchet ms,sans-serif" size="2">Yulian Yordanov<br><a href="http://post-scriptum.info/" target="_blank">post-scriptum.info</a></font><br><br>