Statify - Version 1.5.0

Version Description

Download this release

Release Info

Developer Bueltge
Plugin Icon 128x128 Statify
Version 1.5.0
Comparing to
See all releases

Code changes from version 1.4.3 to 1.5.0

CHANGELOG.md DELETED
@@ -1,93 +0,0 @@
1
- # Changelog
2
-
3
- ### 1.4.3 / 2016-08-15 ###
4
- * Corrected tracking and display in Multisite
5
- * Minor CSS fixes in the dashboard widget
6
- * Removed deprecated links and updated URLs for donate and wiki links
7
- * Administrative updates to plugin header and README
8
- * Updated [plugin authors](https://gist.github.com/glueckpress/f058c0ab973d45a72720)
9
-
10
- ### 1.4.2 / 01.05.2015 ###
11
- * Replace `filter_has_var(INPUT_SERVER)` calls with `isset($_SERVER[])` ([why](https://github.com/wp-stream/stream/issues/254))
12
-
13
- ### 1.4.1 / 29.04.2015 ###
14
- * Renew the tracking mechanism
15
-
16
- ### 1.4.0 / 16.04.2015 ###
17
- * WordPress 4.2 support
18
- * Plugin-wide code refactoring
19
- * Translations for English and Russian
20
- * [GitHub Repository](https://github.com/pluginkollektiv/statify)
21
-
22
- ### 1.3.0 / 28.04.2014 ###
23
- * Sourcecode optimization for plugin-finalization
24
-
25
- ### 1.2.8 / 19.04.2014 ###
26
- * JavaScript-Snippet: Relative Path for HTTP(S)-calls
27
-
28
- ### 1.2.7 / 09.04.2014 ###
29
- * Support for WordPress 3.9
30
- * Correction of dashboard links (if WordPress is in subfolder)
31
-
32
- ### 1.2.6 / 12.12.2013 ###
33
- * Optimization for WordPress 3.8
34
- * Control of tracking via `statify_skip_tracking`
35
-
36
- ### 1.2.5 / 22.08.2013 ###
37
- * Migration of chart-software
38
-
39
- ### 1.2.4 / 06.08.2013 ###
40
- * Compatibility to WordPress 3.6
41
-
42
- ### 1.2.3 / 06.06.2013 ###
43
- * Additional protection of PHP classes against direct access
44
- * Replacement for Deprecated [User Levels](http://codex.wordpress.org/Roles_and_Capabilities#User_Levels)
45
-
46
- ### 1.2.2 / 14.03.2013 ###
47
- * No-Cache and No-Content Header for optional Count JavaScript
48
-
49
- ### 1.2.1 / 18.12.2012 ###
50
- * Additional periods (up to one year) for statistics
51
- * WordPress 3.4 as requirement
52
-
53
- ### 1.2 / 29.11.2012 ###
54
- * Specially for Chrome Browser developed Statify App (discontinued)
55
- * Fix for introduced XML-RPC-interface
56
-
57
- ### 1.1 / 23.11.2012 ###
58
- * WordPress 3.5 Support
59
- * Interface via XML-RPC
60
- * Refactoring of Code Base
61
- * Revision of Online Documentation
62
- * Optional Tracking via JavaScript for Caching-Plugins
63
-
64
- ### 1.0 / 12.06.2012 ###
65
- * WordPress 3.4 Support
66
- * [Official Plugin Website](http://statify.de "Statify WordPress Stats")
67
- * Uncompressed Version of Source Codes
68
-
69
- ### 0.9 / 23.12.2011 ###
70
- * Xmas Edition
71
-
72
- ### 0.8 / 14.12.2011 ###
73
- * Support für WordPress 3.3
74
- * Display of Dashboard Widgets also for authors
75
- * Direct Link to settings on dashboard
76
- * Filtering der Targets/Referrer on the current date
77
-
78
- ### 0.7 / 05.07.2011 ###
79
- * Replacement of Statistic Days
80
- * Recolouring of Statistics Mark
81
- * Ignoring XML-RPC-Requests
82
-
83
- ### 0.6 / 22.06.2011 ###
84
- * Support for WordPress 3.2
85
- * Support for WordPress Multisite
86
- * Adjustment of redundant URL parameters of target pages
87
- * Interaktive Statistics with further informations
88
-
89
- ### 0.5 / 15.05.2011 ###
90
- * Fix: query for missing referrer in dashboard widget
91
-
92
- ### 0.4 / 16.03.2011 ###
93
- * Statify goes online
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md DELETED
@@ -1,82 +0,0 @@
1
- # Statify #
2
- * Contributors: pluginkollektiv
3
- * Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LG5VC9KXMAYXJ
4
- * Tags: stats, analytics, privacy, dashboard
5
- * Requires at least: 3.9
6
- * Tested up to: 4.6
7
- * Stable tag: 1.4.3
8
- * License: GPLv3 or later
9
- * License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
-
11
- Visitor statistics for WordPress with focus on _data protection_, _transparancy_ and _clarity_. Perfect as a widget in your WordPress Dashboard.
12
-
13
- ## Description ##
14
- The free and add-free plugin [Statify](http://statify.de) pursues a simple objective: to provide a straightforward and compact access to the number of site views.
15
-
16
- No frills. No Cookies. No third party. No storage of personal data. No endless data privacy statements.
17
-
18
- An interactive chart is followed by lists of the most common reference sources and target pages. The period of statistics and length of lists can be set directly in the dashboard widget.
19
-
20
- ### Data Privacy ###
21
- In direct comparison to statistics services such as *Google Analytics*, *WordPress.com Stats* and *Piwik* *Statify* doesn't process and store personal data as e.g. IP addresses – *Statify* counts site views, not visitors.
22
- Absolute privacy compliance coupled with transparent procedures: A locally in WordPress created database table consists of only 4 fields (ID, date, source, target) and can be viewed at any time, cleaned up and cleared by the administrator.
23
-
24
- > ### Deutsch ###
25
- > Datenschutzkonformes, anonymes und kompaktes Statistik-Plugin für WordPress.
26
- Statify kommt ohne jegliche Cookies und versteckte Zähl-Pixel aus. Die Dashboard-Statistik greift auf momentane Daten der Datenbanktabelle zu (4 Minuten Zwischenspeicherung) und liefert somit den Live-Zustand der Seitenzugriffe aus. Einsatzbereit auch in WordPress-Multisite.
27
- > For German users: [Plugin-Wiki in Deutsch](https://github.com/pluginkollektiv/statify)
28
-
29
- ### Compatibility ###
30
- For compatibility with caching plugins like [Cachify](http://cachify.de) *Statify* offers an optional switchable tracking via JavaScript. This function allows reliable count of cached blog pages.
31
-
32
- ### Memory Usage ###
33
- * Backend: ~ 0.2 MB
34
- * Frontend: ~ 0.1 MB
35
-
36
- ### Credits ###
37
- * Author: [Sergej Müller](https://sergejmueller.github.io/)
38
- * Maintainers: [pluginkollektiv](http://pluginkollektiv.org/)
39
- * Contributor: [Bego Mario Garde](https://garde-medienberatung.de)
40
-
41
- ## Installation ##
42
- * If you don’t know how to install a plugin for WordPress, [here’s how](http://codex.wordpress.org/Managing_Plugins#Installing_Plugins).
43
-
44
- ### Requirements ###
45
- * PHP 5.2.4
46
- * WordPress 3.9
47
-
48
- ## Changelog ##
49
-
50
- ### 1.4.3 / 2016-08-15 ###
51
- * Corrected tracking and display in Multisite
52
- * Minor CSS fixes in the dashboard widget
53
- * Removed deprecated links and updated URLs for donate and wiki links
54
- * Administrative updates to plugin header and README
55
- * Updated [plugin authors](https://gist.github.com/glueckpress/f058c0ab973d45a72720)
56
-
57
- ### 1.4.2 / 01.05.2015 ###
58
- * Replace `filter_has_var(INPUT_SERVER)` calls with `isset($_SERVER[])` ([why](https://github.com/wp-stream/stream/issues/254))
59
-
60
- ### 1.4.1 / 29.04.2015 ###
61
- * Renew the tracking mechanism
62
-
63
- ### 1.4.0 / 16.04.2015 ###
64
- * WordPress 4.2 support
65
- * Plugin-wide code refactoring
66
- * Translations for English and Russian
67
- * [GitHub Repository](https://github.com/pluginkollektiv/statify)
68
-
69
- ### 1.3.0 / 28.04.2014 ###
70
- * Sourcecode optimization for plugin-finalization
71
-
72
- For the complete changelog, check out our [GitHub repository](https://github.com/pluginkollektiv/statify).
73
-
74
- ## Upgrade Notice ##
75
-
76
- ### 1.4.3 ###
77
-
78
- This is mainly a maintenance release ensuring compatibility with the latest version of WordPress. Works well with Multisite too!
79
-
80
- ## Screenshots ##
81
- 1. Statify dashboard widget
82
- 2. Statify dashboard widget options
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
css/dashboard.css CHANGED
@@ -57,10 +57,10 @@
57
 
58
  /* @group Back stage */
59
 
60
- #statify_dashboard .dashboard-widget-control-form {
61
- padding: 0 0 18px;
62
  }
63
- #statify_dashboard .dashboard-widget-control-form select {
64
  width: 100px;
65
  }
66
 
@@ -70,4 +70,4 @@
70
  line-height: 28px;
71
  }
72
 
73
- /* @end group */
57
 
58
  /* @group Back stage */
59
 
60
+ #statify_dashboard form {
61
+ padding: 18px 0;
62
  }
63
+ #statify_dashboard input[type="number"] {
64
  width: 100px;
65
  }
66
 
70
  line-height: 28px;
71
  }
72
 
73
+ /* @end group */
css/dashboard.min.css CHANGED
@@ -1 +1 @@
1
- #statify_chart{color:#aaa;height:140px;margin:0 -4px;text-align:center}#statify_chart_data{display:none}#statify_dashboard .inside{height:1%;margin:0;padding-bottom:0;overflow:hidden;position:relative}#statify_dashboard .table{padding-bottom:12px}#statify_dashboard .table p.sub{color:#BBB;margin:0 0 -4px}#statify_dashboard .table div{overflow:hidden}#statify_dashboard .table.referrer{float:left;width:45%}#statify_dashboard .table.target{float:right;width:55%}#statify_dashboard td{padding:8px 0 0;line-height:1.4em}#statify_dashboard td.b{text-align:right;padding-right:4px;color:#777}#statify_dashboard label{display:block;margin-bottom:1.1em!important}#statify_dashboard .dashboard-widget-control-form{padding:0 0 18px}#statify_dashboard .dashboard-widget-control-form select{width:100px}#statify_dashboard .meta-links{float:right;margin:0;line-height:28px}
1
+ #statify_chart{color:#aaa;height:140px;margin:0 -4px;text-align:center}#statify_chart_data{display:none}#statify_dashboard .inside{height:1%;margin:0;padding-bottom:0;overflow:hidden;position:relative}#statify_dashboard .table{padding-bottom:12px}#statify_dashboard .table p.sub{color:#BBB;margin:0 0 -4px}#statify_dashboard .table div{overflow:hidden}#statify_dashboard .table.referrer{float:left;width:45%}#statify_dashboard .table.target{float:right;width:55%}#statify_dashboard td{padding:8px 0 0;line-height:1.4em}#statify_dashboard td.b{text-align:right;padding-right:4px;color:#777}#statify_dashboard label{display:block;margin-bottom:1.1em !important}#statify_dashboard form{padding:18px 0}#statify_dashboard input[type="number"]{width:100px}#statify_dashboard .meta-links{float:right;margin:0;line-height:28px}
inc/statify.class.php CHANGED
@@ -1,53 +1,46 @@
1
  <?php
2
-
3
-
4
- /* Quit */
5
- defined('ABSPATH') OR exit;
6
-
7
 
8
  /**
9
- * Statify
10
- *
11
- * @since 0.1.0
12
- */
13
-
14
- class Statify
15
- {
16
 
17
 
18
  /**
19
- * Plugin options
20
- *
21
- * @since 1.4.0
22
- */
23
-
24
  public static $_options;
25
 
26
 
27
  /**
28
- * Class self initialize
29
- *
30
- * @since 0.1.0
31
- * @change 0.1.0
32
- */
 
33
 
34
- public static function instance()
35
- {
36
  new self();
37
  }
38
 
39
 
40
  /**
41
- * Class constructor
42
- *
43
- * @since 0.1.0
44
- * @change 1.4.0
45
- */
 
46
 
47
- public function __construct()
48
- {
49
  /* Skip me! */
50
- if ( (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) OR (defined('DOING_AJAX') && DOING_AJAX) ) {
51
  return;
52
  }
53
 
@@ -56,98 +49,37 @@ class Statify
56
 
57
  /* Plugin options */
58
  self::$_options = wp_parse_args(
59
- get_option('statify'),
60
  array(
61
- 'days' => 14,
62
- 'limit' => 3,
63
- 'today' => 0,
64
- 'snippet' => 0
65
- )
 
66
  );
67
 
68
  /* XMLRPC */
69
- if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST ) {
70
- add_filter(
71
- 'xmlrpc_methods',
72
- array(
73
- 'Statify_XMLRPC',
74
- 'xmlrpc_methods'
75
- )
76
- );
77
-
78
- /* Cron */
79
- } else if ( defined('DOING_CRON') && DOING_CRON ) {
80
- add_action(
81
- 'statify_cleanup',
82
- array(
83
- 'Statify_Cron',
84
- 'cleanup_data'
85
- )
86
- );
87
-
88
- /* Backend */
89
- } else if ( is_admin() ) {
90
- add_action(
91
- 'wpmu_new_blog',
92
- array(
93
- 'Statify_Install',
94
- 'init_site'
95
- )
96
- );
97
- add_action(
98
- 'delete_blog',
99
- array(
100
- 'Statify_Uninstall',
101
- 'init_site'
102
- )
103
- );
104
- add_action(
105
- 'wp_dashboard_setup',
106
- array(
107
- 'Statify_Dashboard',
108
- 'init'
109
- )
110
- );
111
- add_filter(
112
- 'plugin_row_meta',
113
- array(
114
- 'Statify_Backend',
115
- 'add_meta_link'
116
- ),
117
- 10,
118
- 2
119
- );
120
- add_filter(
121
- 'plugin_action_links_' .STATIFY_BASE,
122
- array(
123
- 'Statify_Backend',
124
- 'add_action_link'
125
- )
126
- );
127
-
128
- /* Frontend */
129
  } else {
130
- add_action(
131
- 'template_redirect',
132
- array(
133
- 'Statify_Frontend',
134
- 'track_visit'
135
- )
136
- );
137
- add_filter(
138
- 'query_vars',
139
- array(
140
- 'Statify_Frontend',
141
- 'query_vars'
142
- )
143
- );
144
- add_action(
145
- 'wp_footer',
146
- array(
147
- 'Statify_Frontend',
148
- 'wp_footer'
149
- )
150
- );
151
  }
152
  }
153
- }
1
  <?php
2
+ /** Quit */
3
+ defined( 'ABSPATH' ) || exit;
 
 
 
4
 
5
  /**
6
+ * Statify.
7
+ *
8
+ * @since 0.1.0
9
+ */
10
+ class Statify {
 
 
11
 
12
 
13
  /**
14
+ * Plugin options.
15
+ *
16
+ * @since 1.4.0
17
+ * @var array $_options
18
+ */
19
  public static $_options;
20
 
21
 
22
  /**
23
+ * Class self initialize.
24
+ *
25
+ * @since 0.1.0
26
+ * @version 0.1.0
27
+ */
28
+ public static function instance() {
29
 
 
 
30
  new self();
31
  }
32
 
33
 
34
  /**
35
+ * Class constructor
36
+ *
37
+ * @since 0.1.0
38
+ * @version 2017-01-10
39
+ */
40
+ public function __construct() {
41
 
 
 
42
  /* Skip me! */
43
+ if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
44
  return;
45
  }
46
 
49
 
50
  /* Plugin options */
51
  self::$_options = wp_parse_args(
52
+ get_option( 'statify' ),
53
  array(
54
+ 'days' => 14,
55
+ 'limit' => 3,
56
+ 'today' => 0,
57
+ 'snippet' => 0,
58
+ 'blacklist' => 0,
59
+ )
60
  );
61
 
62
  /* XMLRPC */
63
+ if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) {
64
+ add_filter( 'xmlrpc_methods', array( 'Statify_XMLRPC', 'xmlrpc_methods' ) );
65
+
66
+ /* Cron */
67
+ } elseif ( defined( 'DOING_CRON' ) && DOING_CRON ) {
68
+ add_action( 'statify_cleanup', array( 'Statify_Cron', 'cleanup_data' ) );
69
+
70
+ /* Backend */
71
+ } elseif ( is_admin() ) {
72
+ add_action( 'wpmu_new_blog', array( 'Statify_Install', 'init_site' ) );
73
+ add_action( 'delete_blog', array( 'Statify_Uninstall', 'init_site' ) );
74
+ add_action( 'wp_dashboard_setup', array( 'Statify_Dashboard', 'init' ) );
75
+ add_filter( 'plugin_row_meta', array( 'Statify_Backend', 'add_meta_link' ), 10, 2 );
76
+ add_filter( 'plugin_action_links_' . STATIFY_BASE, array( 'Statify_Backend', 'add_action_link' ) );
77
+
78
+ /* Frontend */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  } else {
80
+ add_action( 'template_redirect', array( 'Statify_Frontend', 'track_visit' ) );
81
+ add_filter( 'query_vars', array( 'Statify_Frontend', 'query_vars' ) );
82
+ add_action( 'wp_footer', array( 'Statify_Frontend', 'wp_footer' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
84
  }
85
+ }
inc/statify_backend.class.php CHANGED
@@ -1,77 +1,69 @@
1
  <?php
2
-
3
-
4
- /* Quit */
5
- defined('ABSPATH') OR exit;
6
-
7
 
8
  /**
9
- * Statify_Backend
10
- *
11
- * @since 1.4.0
12
- */
13
-
14
- class Statify_Backend
15
- {
16
-
17
 
18
  /**
19
- * Add plugin meta links
20
- *
21
- * @since 0.1.0
22
- * @change 1.4.0
23
- *
24
- * @param array $input Registered links
25
- * @param string $file Current plugin file
26
- * @return array Merged links
27
- */
 
 
28
 
29
- public static function add_meta_link($input, $file)
30
- {
31
  /* Restliche Plugins? */
32
- if ( $file !== STATIFY_BASE ) {
33
  return $input;
34
  }
35
 
36
  return array_merge(
37
  $input,
38
  array(
39
- '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LG5VC9KXMAYXJ" target="_blank">PayPal</a>'
 
40
  )
41
  );
42
  }
43
 
44
-
45
  /**
46
- * Add plugin action links
47
- *
48
- * @since 0.1.0
49
- * @change 1.4.0
50
- *
51
- * @param array $input Registered links
52
- * @return array Merged links
53
- */
 
 
54
 
55
- public static function add_action_link($input)
56
- {
57
  /* Rechte? */
58
- if ( ! current_user_can('edit_dashboard') ) {
59
  return $input;
60
  }
61
 
62
- /* Zusammenführen */
63
  return array_merge(
64
  $input,
65
  array(
66
  sprintf(
 
67
  '<a href="%s">%s</a>',
68
- add_query_arg(
69
- array(
70
- 'edit' => 'statify_dashboard#statify_dashboard'
71
- ),
72
- admin_url('/')
73
  ),
74
- __('Settings')
75
  )
76
  )
77
  );
1
  <?php
2
+ /** Quit */
3
+ defined( 'ABSPATH' ) || exit;
 
 
 
4
 
5
  /**
6
+ * Statify_Backend
7
+ *
8
+ * @since 1.4.0
9
+ */
10
+ class Statify_Backend {
 
 
 
11
 
12
  /**
13
+ * Add plugin meta links
14
+ *
15
+ * @since 0.1.0
16
+ * @version 1.4.0
17
+ *
18
+ * @param array $input Registered links.
19
+ * @param string $file Current plugin file.
20
+ *
21
+ * @return array Merged links
22
+ */
23
+ public static function add_meta_link( $input, $file ) {
24
 
 
 
25
  /* Restliche Plugins? */
26
+ if ( STATIFY_BASE !== $file ) {
27
  return $input;
28
  }
29
 
30
  return array_merge(
31
  $input,
32
  array(
33
+ '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8CH5FPR88QYML" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Donate', 'statify' ) . '</a>',
34
+ '<a href="https://wordpress.org/support/plugin/statify" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Support', 'statify' ) . '</a>',
35
  )
36
  );
37
  }
38
 
 
39
  /**
40
+ * Add plugin action links
41
+ *
42
+ * @since 0.1.0
43
+ * @version 1.4.0
44
+ *
45
+ * @param array $input Registered links.
46
+ *
47
+ * @return array Merged links
48
+ */
49
+ public static function add_action_link( $input ) {
50
 
 
 
51
  /* Rechte? */
52
+ if ( ! current_user_can( 'edit_dashboard' ) ) {
53
  return $input;
54
  }
55
 
56
+ /** Zusammenführen */
57
  return array_merge(
58
  $input,
59
  array(
60
  sprintf(
61
+ /** @lang Disable language injection for Url query argument. */
62
  '<a href="%s">%s</a>',
63
+ add_query_arg( array( 'edit' => 'statify_dashboard#statify_dashboard' ),
64
+ admin_url( '/' )
 
 
 
65
  ),
66
+ esc_html__( 'Settings', 'statify' )
67
  )
68
  )
69
  );
inc/statify_cron.class.php CHANGED
@@ -1,37 +1,30 @@
1
  <?php
2
-
3
-
4
- /* Quit */
5
- defined('ABSPATH') OR exit;
6
-
7
 
8
  /**
9
- * Statify_Cron
10
- *
11
- * @since 1.4.0
12
- */
13
-
14
- class Statify_Cron extends Statify
15
- {
16
-
17
 
18
  /**
19
- * Cleanup obsolete DB values
20
- *
21
- * @since 0.3.0
22
- * @change 1.4.0
23
- */
24
-
25
- public static function cleanup_data()
26
- {
27
- /* Global */
28
  global $wpdb;
29
 
30
  /* Remove items */
31
  $wpdb->query(
32
  $wpdb->prepare(
33
  "DELETE FROM `$wpdb->statify` WHERE created <= SUBDATE(CURDATE(), %d)",
34
- (int)self::$_options['days']
35
  )
36
  );
37
 
@@ -40,4 +33,4 @@ class Statify_Cron extends Statify
40
  "OPTIMIZE TABLE `$wpdb->statify`"
41
  );
42
  }
43
- }
1
  <?php
2
+ /** Quit */
3
+ defined( 'ABSPATH' ) || exit;
 
 
 
4
 
5
  /**
6
+ * Statify_Cron
7
+ *
8
+ * @since 1.4.0
9
+ */
10
+ class Statify_Cron extends Statify {
 
 
 
11
 
12
  /**
13
+ * Cleanup obsolete DB values
14
+ *
15
+ * @since 0.3.0
16
+ * @version 1.4.0
17
+ */
18
+ public static function cleanup_data() {
19
+
20
+ /** Global */
 
21
  global $wpdb;
22
 
23
  /* Remove items */
24
  $wpdb->query(
25
  $wpdb->prepare(
26
  "DELETE FROM `$wpdb->statify` WHERE created <= SUBDATE(CURDATE(), %d)",
27
+ (int) self::$_options['days']
28
  )
29
  );
30
 
33
  "OPTIMIZE TABLE `$wpdb->statify`"
34
  );
35
  }
36
+ }
inc/statify_dashboard.class.php CHANGED
@@ -1,146 +1,103 @@
1
  <?php
2
-
3
-
4
- /* Quit */
5
- defined('ABSPATH') OR exit;
6
-
7
 
8
  /**
9
- * Statify_Dashboard
10
- *
11
- * @since 1.1
12
- */
13
-
14
- class Statify_Dashboard extends Statify
15
- {
16
-
17
 
18
  /**
19
- * Plugin version
20
- *
21
- * @since 1.4.0
22
- */
23
-
24
  protected static $_plugin_version;
25
 
26
-
27
  /**
28
- * Dashboard widget initialize
29
- *
30
- * @since 0.1.0
31
- * @change 1.4.0
32
- *
33
- * @hook boolean statify__user_can_see_stats (https://gist.github.com/sergejmueller/1ce0482c277508d8327e)
34
- */
35
-
36
- public static function init()
37
- {
38
- /* Filter user_can_see_stats */
39
- if ( ! apply_filters('statify__user_can_see_stats', current_user_can('edit_dashboard')) ) {
40
  return;
41
  }
42
 
43
- /* Load textdomain */
44
  load_plugin_textdomain(
45
  'statify',
46
  false,
47
- wp_normalize_path(
48
- sprintf(
49
- '%s/lang',
50
- STATIFY_DIR
51
- )
52
- )
53
  );
54
 
55
- /* Plugin version */
56
  self::_get_version();
57
 
58
-
59
- /* Add dashboard widget */
60
  wp_add_dashboard_widget(
61
  'statify_dashboard',
62
  'Statify',
63
- array(
64
- __CLASS__,
65
- 'print_frontview'
66
- ),
67
- array(
68
- __CLASS__,
69
- 'print_backview'
70
- )
71
  );
72
 
73
- /* Init CSS */
74
- add_action(
75
- 'admin_print_styles',
76
- array(
77
- __CLASS__,
78
- 'add_style'
79
- )
80
- );
81
 
82
- /* Init JS */
83
- add_action(
84
- 'admin_print_scripts',
85
- array(
86
- __CLASS__,
87
- 'add_js'
88
- )
89
- );
90
  }
91
 
92
-
93
  /**
94
- * Print CSS
95
- *
96
- * @since 0.1.0
97
- * @change 1.4.0
98
- */
99
-
100
- public static function add_style()
101
- {
102
- /* Register CSS */
103
  wp_register_style(
104
  'statify',
105
- plugins_url(
106
- '/css/dashboard.min.css',
107
- STATIFY_FILE
108
- ),
109
  array(),
110
  self::$_plugin_version
111
  );
112
 
113
- /* Load CSS */
114
- wp_enqueue_style('statify');
115
  }
116
 
117
-
118
  /**
119
- * Print JavaScript
120
- *
121
- * @since 0.1.0
122
- * @change 1.4.0
123
- */
124
-
125
  public static function add_js() {
126
- /* Register JS */
 
127
  wp_register_script(
128
- 'sm_raphael_js',
129
- plugins_url(
130
- 'js/raphael.min.js',
131
- STATIFY_FILE
132
- ),
133
  array(),
134
  self::$_plugin_version,
135
  true
136
  );
137
  wp_register_script(
138
  'sm_raphael_helper',
139
- plugins_url(
140
- 'js/raphael.helper.min.js',
141
- STATIFY_FILE
142
- ),
143
- array(),
144
  self::$_plugin_version,
145
  true
146
  );
@@ -150,157 +107,159 @@ class Statify_Dashboard extends Statify
150
  'js/dashboard.min.js',
151
  STATIFY_FILE
152
  ),
153
- array('jquery'),
154
  self::$_plugin_version,
155
  true
156
  );
157
 
158
- /* Localize strings */
159
  wp_localize_script(
160
  'statify_chart_js',
161
  'statify_translations',
162
  array(
163
- 'pageview' => strip_tags( __('Pageview', 'statify') ),
164
- 'pageviews' => strip_tags( __('Pageviews', 'statify') )
165
  )
166
  );
167
  }
168
 
169
 
170
  /**
171
- * Print widget frontview
172
- *
173
- * @since 0.1.0
174
- * @change 1.4.0
175
- */
176
-
177
- public static function print_frontview()
178
- {
179
  /* Load JS */
180
- wp_enqueue_script('sm_raphael_js');
181
- wp_enqueue_script('sm_raphael_helper');
182
- wp_enqueue_script('statify_chart_js');
183
 
184
  /* Load template */
185
- load_template(
186
- wp_normalize_path(
187
- sprintf(
188
- '%s/views/widget_front.view.php',
189
- STATIFY_DIR
190
- )
191
- )
192
- );
193
  }
194
 
195
 
196
  /**
197
- * Print widget backview
198
- *
199
- * @since 0.4.0
200
- * @change 1.4.0
201
- */
202
-
203
- public static function print_backview()
204
- {
205
  /* Capability check */
206
- if ( ! current_user_can('edit_dashboard') ) {
207
  return;
208
  }
209
 
210
- /* Update plugin options */
211
- if ( ! empty($_POST['statify']) ) {
212
- self::_save_options();
213
  }
214
 
215
  /* Load view */
216
  load_template(
217
- wp_normalize_path(
218
- sprintf(
219
- '%s/views/widget_back.view.php',
220
- STATIFY_DIR
221
- )
222
- )
223
  );
224
  }
225
 
226
 
227
- /**
228
- * Save plugin options
229
- *
230
- * @since 1.4.0
231
- * @change 1.4.0
232
- */
233
-
234
- private static function _save_options()
235
- {
236
- /* Update values */
237
- update_option(
238
- 'statify',
239
- array(
240
- 'days' => (int)@$_POST['statify']['days'],
241
- 'limit' => (int)@$_POST['statify']['limit'],
242
- 'today' => (int)@$_POST['statify']['today'],
243
- 'snippet' => (int)@$_POST['statify']['snippet']
244
- )
245
- );
246
-
247
- /* Delete transient */
248
- delete_transient('statify_data');
249
-
250
- /* Clear Cachify cache */
251
- if ( has_action('cachify_flush_cache') ) {
252
- do_action('cachify_flush_cache');
253
- }
254
- }
255
-
256
-
257
- /**
258
- * Set plugin version from plugin meta data
259
- *
260
- * @since 1.4.0
261
- * @change 1.4.0
262
- */
263
-
264
- private static function _get_version()
265
- {
266
- /* Get plugin meta */
267
- $meta = get_plugin_data(STATIFY_FILE);
268
-
269
- self::$_plugin_version = $meta['Version'];
270
- }
271
 
272
 
273
  /**
274
- * Get stats from cache
275
- *
276
- * @since 0.1.0
277
- * @change 1.4.0
278
- *
279
- * @return array $data Data from cache or DB
280
- */
281
-
282
- public static function get_stats()
283
- {
284
- /* Get from cache */
285
- if ( $data = get_transient('statify_data') ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  return $data;
287
  }
288
 
289
- /* Get from DB */
290
  $data = self::_select_data();
291
 
292
- /* Prepare data */
293
- if ( ! empty($data['visits']) ) {
294
- $data['visits'] = array_reverse($data['visits']);
295
  } else {
296
- $data = NULL;
297
- }
298
 
299
- /* Make cache */
300
  set_transient(
301
- 'statify_data',
302
- $data,
303
- MINUTE_IN_SECONDS * 4
304
  );
305
 
306
  return $data;
@@ -308,46 +267,45 @@ class Statify_Dashboard extends Statify
308
 
309
 
310
  /**
311
- * Get stats from DB
312
- *
313
- * @since 0.1.0
314
- * @change 1.4.0
315
- *
316
- * @return array DB results
317
- */
318
-
319
- private static function _select_data()
320
- {
321
- /* Global */
322
  global $wpdb;
323
 
324
- /* Init values */
325
- $days = (int)self::$_options['days'];
326
- $limit = (int)self::$_options['limit'];
327
- $today = (int)self::$_options['today'];
328
 
329
  return array(
330
- 'visits' => $wpdb->get_results(
331
  $wpdb->prepare(
332
  "SELECT `created` as `date`, COUNT(`created`) as `count` FROM `$wpdb->statify` GROUP BY `created` ORDER BY `created` DESC LIMIT %d",
333
  $days
334
  ),
335
  ARRAY_A
336
  ),
337
- 'target' => $wpdb->get_results(
338
  $wpdb->prepare(
339
- "SELECT COUNT(`target`) as `count`, `target` as `url` FROM `$wpdb->statify` " .( $today ? 'WHERE created = DATE(NOW())' : '' ). " GROUP BY `target` ORDER BY `count` DESC LIMIT %d",
340
  $limit
341
  ),
342
  ARRAY_A
343
  ),
344
  'referrer' => $wpdb->get_results(
345
  $wpdb->prepare(
346
- "SELECT COUNT(`referrer`) as `count`, `referrer` as `url`, SUBSTRING_INDEX(SUBSTRING_INDEX(TRIM(LEADING 'www.' FROM(TRIM(LEADING 'https://' FROM TRIM(LEADING 'http://' FROM TRIM(`referrer`))))), '/', 1), ':', 1) as `host` FROM `$wpdb->statify` WHERE `referrer` != '' " .( $today ? 'AND created = DATE(NOW())' : '' ). " GROUP BY `host` ORDER BY `count` DESC LIMIT %d",
347
  $limit
348
  ),
349
  ARRAY_A
350
  )
351
  );
352
  }
353
- }
1
  <?php
2
+ /** Quit */
3
+ defined( 'ABSPATH' ) || exit;
 
 
 
4
 
5
  /**
6
+ * Statify_Dashboard
7
+ *
8
+ * @since 1.1
9
+ */
10
+ class Statify_Dashboard extends Statify {
 
 
 
11
 
12
  /**
13
+ * Plugin version.
14
+ *
15
+ * @since 1.4.0
16
+ * @var string
17
+ */
18
  protected static $_plugin_version;
19
 
 
20
  /**
21
+ * Dashboard widget initialize
22
+ *
23
+ * @since 0.1.0
24
+ * @version 2016-12-21
25
+ *
26
+ * @wp-hook boolean statify__user_can_see_stats
27
+ * @see https://wordpress.org/plugins/statify/
28
+ */
29
+ public static function init() {
30
+
31
+ /** Filter user_can_see_stats */
32
+ if ( ! apply_filters( 'statify__user_can_see_stats', current_user_can( 'edit_dashboard' ) ) ) {
33
  return;
34
  }
35
 
36
+ /** Load textdomain */
37
  load_plugin_textdomain(
38
  'statify',
39
  false,
40
+ wp_normalize_path( sprintf( '%s/lang', STATIFY_DIR ) )
 
 
 
 
 
41
  );
42
 
43
+ /** Plugin version */
44
  self::_get_version();
45
 
46
+ /** Add dashboard widget */
 
47
  wp_add_dashboard_widget(
48
  'statify_dashboard',
49
  'Statify',
50
+ array( __CLASS__, 'print_frontview' ),
51
+ array( __CLASS__, 'print_backview' )
 
 
 
 
 
 
52
  );
53
 
54
+ /** Init CSS */
55
+ add_action( 'admin_print_styles', array( __CLASS__, 'add_style' ) );
 
 
 
 
 
 
56
 
57
+ /** Init JS */
58
+ add_action( 'admin_print_scripts', array( __CLASS__, 'add_js' ) );
 
 
 
 
 
 
59
  }
60
 
 
61
  /**
62
+ * Print CSS
63
+ *
64
+ * @since 0.1.0
65
+ * @version 1.4.0
66
+ */
67
+ public static function add_style() {
68
+
69
+ /** Register CSS */
 
70
  wp_register_style(
71
  'statify',
72
+ plugins_url( '/css/dashboard.min.css', STATIFY_FILE ),
 
 
 
73
  array(),
74
  self::$_plugin_version
75
  );
76
 
77
+ /** Load CSS */
78
+ wp_enqueue_style( 'statify' );
79
  }
80
 
 
81
  /**
82
+ * Print JavaScript
83
+ *
84
+ * @since 0.1.0
85
+ * @version 1.4.0
86
+ */
 
87
  public static function add_js() {
88
+
89
+ /** Register JS */
90
  wp_register_script(
91
+ 'raphael',
92
+ plugins_url( 'js/raphael.min.js', STATIFY_FILE ),
 
 
 
93
  array(),
94
  self::$_plugin_version,
95
  true
96
  );
97
  wp_register_script(
98
  'sm_raphael_helper',
99
+ plugins_url( 'js/raphael.helper.min.js', STATIFY_FILE ),
100
+ array( 'raphael' ),
 
 
 
101
  self::$_plugin_version,
102
  true
103
  );
107
  'js/dashboard.min.js',
108
  STATIFY_FILE
109
  ),
110
+ array( 'jquery', 'sm_raphael_helper' ),
111
  self::$_plugin_version,
112
  true
113
  );
114
 
115
+ /** Localize strings */
116
  wp_localize_script(
117
  'statify_chart_js',
118
  'statify_translations',
119
  array(
120
+ 'pageview' => strip_tags( esc_html__( 'Pageview', 'statify' ) ),
121
+ 'pageviews' => strip_tags( esc_html__( 'Pageviews', 'statify' ) ),
122
  )
123
  );
124
  }
125
 
126
 
127
  /**
128
+ * Print widget frontview.
129
+ *
130
+ * @since 0.1.0
131
+ * @version 1.4.0
132
+ */
133
+ public static function print_frontview() {
134
+
 
135
  /* Load JS */
136
+ wp_enqueue_script( 'sm_raphael_js' );
137
+ wp_enqueue_script( 'sm_raphael_helper' );
138
+ wp_enqueue_script( 'statify_chart_js' );
139
 
140
  /* Load template */
141
+ load_template(
142
+ wp_normalize_path( sprintf( '%s/views/widget_front.view.php', STATIFY_DIR ) )
143
+ );
 
 
 
 
 
144
  }
145
 
146
 
147
  /**
148
+ * Print widget backview
149
+ *
150
+ * @since 0.4.0
151
+ * @version 1.4.0
152
+ */
153
+ public static function print_backview() {
154
+
 
155
  /* Capability check */
156
+ if ( ! current_user_can( 'edit_dashboard' ) ) {
157
  return;
158
  }
159
 
160
+ /** Update plugin options */
161
+ if ( ! empty( $_POST['statify'] ) ) {
162
+ self::_save_options();
163
  }
164
 
165
  /* Load view */
166
  load_template(
167
+ wp_normalize_path( sprintf( '%s/views/widget_back.view.php', STATIFY_DIR ) )
 
 
 
 
 
168
  );
169
  }
170
 
171
 
172
+ /**
173
+ * Save plugin options
174
+ *
175
+ * @since 1.4.0
176
+ * @version 2017-01-10
177
+ */
178
+ private static function _save_options() {
179
+ /** Check the nonce field from the dashboard form. */
180
+ if ( ! check_admin_referer( 'statify-dashboard' ) ) {
181
+ return;
182
+ }
183
+
184
+ /** Get numeric values from POST variables */
185
+ $options = array();
186
+ foreach ( array( 'days', 'limit' ) as $option_name ) {
187
+ $options[ $option_name ] = Statify::$_options[ $option_name ];
188
+ if ( isset( $_POST['statify'][ $option_name ] ) && (int) $_POST['statify'][ $option_name ] > 0 ) {
189
+ $options[ $option_name ] = (int) $_POST['statify'][ $option_name ];
190
+ }
191
+ }
192
+ if ( (int) $options['limit'] > 100 ) {
193
+ $options['limit'] = 100;
194
+ }
195
+
196
+ /** Get checkbox values from POST variables */
197
+ foreach ( array( 'today', 'snippet', 'blacklist' ) as $option_name ) {
198
+ if ( isset( $_POST['statify'][ $option_name ] ) && (int) $_POST['statify'][ $option_name ] === 1 ) {
199
+ $options[ $option_name ] = 1;
200
+ } else {
201
+ $options[ $option_name ] = 0;
202
+ }
203
+ }
204
+
205
+ /** Update values */
206
+ update_option( 'statify', $options );
207
+
208
+ /** Delete transient */
209
+ delete_transient( 'statify_data' );
210
+
211
+ /** Clear Cachify cache */
212
+ if ( has_action( 'cachify_flush_cache' ) ) {
213
+ do_action( 'cachify_flush_cache' );
214
+ }
215
+ }
216
 
217
 
218
  /**
219
+ * Set plugin version from plugin meta data
220
+ *
221
+ * @since 1.4.0
222
+ * @version 1.4.0
223
+ */
224
+ private static function _get_version() {
225
+
226
+ /* Get plugin meta */
227
+ $meta = get_plugin_data( STATIFY_FILE );
228
+
229
+ self::$_plugin_version = $meta['Version'];
230
+ }
231
+
232
+
233
+ /**
234
+ * Get stats from cache
235
+ *
236
+ * @since 0.1.0
237
+ * @version 1.4.0
238
+ *
239
+ * @return array $data Data from cache or DB
240
+ */
241
+ public static function get_stats() {
242
+
243
+ /** Get from cache */
244
+ if ( $data = get_transient( 'statify_data' ) ) {
245
  return $data;
246
  }
247
 
248
+ /** Get from DB */
249
  $data = self::_select_data();
250
 
251
+ /** Prepare data */
252
+ if ( ! empty( $data['visits'] ) ) {
253
+ $data['visits'] = array_reverse( $data['visits'] );
254
  } else {
255
+ $data = null;
256
+ }
257
 
258
+ /** Make cache */
259
  set_transient(
260
+ 'statify_data',
261
+ $data,
262
+ MINUTE_IN_SECONDS * 4
263
  );
264
 
265
  return $data;
267
 
268
 
269
  /**
270
+ * Get stats from DB
271
+ *
272
+ * @since 0.1.0
273
+ * @version 1.4.0
274
+ *
275
+ * @return array DB results
276
+ */
277
+ private static function _select_data() {
278
+
279
+ /** Global */
 
280
  global $wpdb;
281
 
282
+ /** Init values */
283
+ $days = (int) self::$_options['days'];
284
+ $limit = (int) self::$_options['limit'];
285
+ $today = (int) self::$_options['today'];
286
 
287
  return array(
288
+ 'visits' => $wpdb->get_results(
289
  $wpdb->prepare(
290
  "SELECT `created` as `date`, COUNT(`created`) as `count` FROM `$wpdb->statify` GROUP BY `created` ORDER BY `created` DESC LIMIT %d",
291
  $days
292
  ),
293
  ARRAY_A
294
  ),
295
+ 'target' => $wpdb->get_results(
296
  $wpdb->prepare(
297
+ "SELECT COUNT(`target`) as `count`, `target` as `url` FROM `$wpdb->statify` " . ( $today ? 'WHERE created = DATE(NOW())' : '' ) . " GROUP BY `target` ORDER BY `count` DESC LIMIT %d",
298
  $limit
299
  ),
300
  ARRAY_A
301
  ),
302
  'referrer' => $wpdb->get_results(
303
  $wpdb->prepare(
304
+ "SELECT COUNT(`referrer`) as `count`, `referrer` as `url`, SUBSTRING_INDEX(SUBSTRING_INDEX(TRIM(LEADING 'www.' FROM(TRIM(LEADING 'https://' FROM TRIM(LEADING 'http://' FROM TRIM(`referrer`))))), '/', 1), ':', 1) as `host` FROM `$wpdb->statify` WHERE `referrer` != '' " . ( $today ? 'AND created = DATE(NOW())' : '' ) . " GROUP BY `host` ORDER BY `count` DESC LIMIT %d",
305
  $limit
306
  ),
307
  ARRAY_A
308
  )
309
  );
310
  }
311
+ }
inc/statify_deactivate.class.php CHANGED
@@ -1,33 +1,26 @@
1
  <?php
2
-
3
-
4
- /* Quit */
5
- defined('ABSPATH') OR exit;
6
-
7
 
8
  /**
9
- * Statify_Deactivate
10
- *
11
- * @since 1.4.0
12
- */
13
-
14
- class Statify_Deactivate
15
- {
16
-
17
 
18
  /**
19
- * Plugin deactivation actions
20
- *
21
- * @since 1.4.0
22
- * @change 1.4.0
23
- */
24
-
25
- public static function init()
26
- {
27
- /* Delete transients */
28
- delete_transient('statify_data');
29
-
30
- /* Delete cron event */
31
- wp_clear_scheduled_hook('statify_cleanup');
32
  }
33
- }
1
  <?php
2
+ /** Quit */
3
+ defined( 'ABSPATH' ) || exit;
 
 
 
4
 
5
  /**
6
+ * Statify_Deactivate
7
+ *
8
+ * @since 1.4.0
9
+ */
10
+ class Statify_Deactivate {
 
 
 
11
 
12
  /**
13
+ * Plugin deactivation actions
14
+ *
15
+ * @since 1.4.0
16
+ * @version 1.4.0
17
+ */
18
+ public static function init() {
19
+
20
+ /** Delete transients */
21
+ delete_transient( 'statify_data' );
22
+
23
+ /** Delete cron event */
24
+ wp_clear_scheduled_hook( 'statify_cleanup' );
 
25
  }
26
+ }
inc/statify_frontend.class.php CHANGED
@@ -1,52 +1,45 @@
1
  <?php
2
-
3
-
4
- /* Quit */
5
- defined('ABSPATH') OR exit;
6
-
7
 
8
  /**
9
- * Statify_Frontend
10
- *
11
- * @since 1.4.0
12
- */
13
-
14
- class Statify_Frontend extends Statify
15
- {
16
 
17
 
18
  /**
19
- * Track the page view
20
- *
21
- * @since 0.1.0
22
- * @change 1.4.2
23
- */
24
-
25
- public static function track_visit()
26
- {
 
27
  /* Init vars */
28
  $use_snippet = self::$_options['snippet'];
29
- $is_snippet = $use_snippet && get_query_var('statify_target');
30
-
31
- /* Skip tracking */
32
- if ( self::_skip_tracking() ) {
33
- return self::_jump_out($is_snippet);
34
- }
35
 
36
  /* Set target & referrer */
37
  if ( $is_snippet ) {
38
- $target = urldecode( get_query_var('statify_target') );
39
- $referrer = urldecode( get_query_var('statify_referrer') );
40
- } else if ( ! $use_snippet) {
41
- $target = ( isset($_SERVER['REQUEST_URI']) ? wp_unslash($_SERVER['REQUEST_URI']) : '/' );
42
- $referrer = ( isset($_SERVER['HTTP_REFERER']) ? wp_unslash($_SERVER['HTTP_REFERER']) : '' );
 
 
43
  } else {
44
- return;
45
  }
46
 
47
  /* Invalid target? */
48
- if ( empty($target) OR ! wp_validate_redirect($target, false) ) {
49
- return self::_jump_out($is_snippet);
50
  }
51
 
52
  /* Global vars */
@@ -56,18 +49,17 @@ class Statify_Frontend extends Statify
56
  $data = array(
57
  'created' => '',
58
  'referrer' => '',
59
- 'target' => ''
60
  );
61
 
62
  /* Set request timestamp */
63
- $data['created'] = strftime(
64
- '%Y-%m-%d',
65
- current_time('timestamp')
66
- );
67
 
68
  /* Sanitize referrer url */
69
- if ( ! empty($referrer) && strpos( $referrer, home_url() ) === false ) {
70
- $data['referrer'] = esc_url_raw( $referrer, array('http', 'https') );
71
  }
72
 
73
  /* Relative target url */
@@ -75,64 +67,151 @@ class Statify_Frontend extends Statify
75
 
76
  /* Trim target url */
77
  if ( $wp_rewrite->permalink_structure ) {
78
- $data['target'] = parse_url($data['target'], PHP_URL_PATH);
79
  }
80
 
81
  /* Sanitize target url */
82
- $data['target'] = esc_url_raw($data['target']);
83
 
84
  /* Insert */
85
- $wpdb->insert(
86
- $wpdb->statify,
87
- $data
88
- );
89
 
90
  /* Jump! */
91
- return self::_jump_out($is_snippet);
92
  }
93
 
94
-
95
  /**
96
- * Rules to skip the tracking
97
- *
98
- * @since 1.2.6
99
- * @change 1.4.2
100
- *
101
- * @hook boolean statify_skip_tracking (https://gist.github.com/sergejmueller/7612368)
102
- *
103
- * @return boolean $skip_hook TRUE if NO tracking is desired
104
- */
 
 
 
 
 
 
 
 
 
105
 
 
 
 
 
 
 
 
 
 
 
 
106
  private static function _skip_tracking() {
107
- /* Skip tracking via Hook */
108
- if ( ( $skip_hook = apply_filters('statify_skip_tracking', NULL) ) !== NULL ) {
 
 
 
 
109
  return $skip_hook;
110
  }
111
 
112
- /* Skip tracking via User Agent */
113
- if ( ! isset($_SERVER['HTTP_USER_AGENT']) OR ! preg_match('/(?:Windows|Macintosh|Linux|iPhone|iPad)/', $_SERVER['HTTP_USER_AGENT']) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  return true;
115
  }
116
 
117
- /* Skip tracking via Conditional_Tags */
118
- return ( is_feed() OR is_trackback() OR is_robots() OR is_preview() OR is_user_logged_in() OR is_404() OR is_search() );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  }
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
  /**
123
- * Send JavaScript headers or return false
124
- *
125
- * @since 1.1.0
126
- * @change 1.3.1
127
- *
128
- * @param boolean $is_snippet Snippet type
129
- * @return mixed Exit or return depending on snippet type
130
- */
131
-
132
- private static function _jump_out($is_snippet) {
 
133
  if ( $is_snippet ) {
134
  nocache_headers();
135
- header('Content-type: text/javascript', true, 204);
136
  exit;
137
  }
138
 
@@ -141,16 +220,17 @@ class Statify_Frontend extends Statify
141
 
142
 
143
  /**
144
- * Declare GET variables for further use
145
- *
146
- * @since 1.1.0
147
- * @change 1.3.1
148
- *
149
- * @param array $vars Input with existing variables
150
- * @return array $vars Output with plugin variables
151
- */
152
-
153
- public static function query_vars($vars) {
 
154
  $vars[] = 'statify_referrer';
155
  $vars[] = 'statify_target';
156
 
@@ -159,14 +239,13 @@ class Statify_Frontend extends Statify
159
 
160
 
161
  /**
162
- * Print JavaScript snippet
163
- *
164
- * @since 1.1.0
165
- * @change 1.4.1
166
- */
167
-
168
- public static function wp_footer()
169
- {
170
  /* Skip by option */
171
  if ( ! self::$_options['snippet'] ) {
172
  return;
@@ -178,13 +257,13 @@ class Statify_Frontend extends Statify
178
  }
179
 
180
  /* Load template */
181
- load_template(
182
- wp_normalize_path(
183
- sprintf(
184
- '%s/views/js_snippet.view.php',
185
- STATIFY_DIR
186
- )
187
- )
188
- );
189
  }
190
- }
1
  <?php
2
+ /** Quit */
3
+ defined( 'ABSPATH' ) || exit;
 
 
 
4
 
5
  /**
6
+ * Statify_Frontend
7
+ *
8
+ * @since 1.4.0
9
+ */
10
+ class Statify_Frontend extends Statify {
 
 
11
 
12
 
13
  /**
14
+ * Track the page view
15
+ *
16
+ * @since 0.1.0
17
+ * @version 1.4.2
18
+ *
19
+ * @return bool
20
+ */
21
+ public static function track_visit() {
22
+
23
  /* Init vars */
24
  $use_snippet = self::$_options['snippet'];
25
+ $is_snippet = $use_snippet && get_query_var( 'statify_target' );
 
 
 
 
 
26
 
27
  /* Set target & referrer */
28
  if ( $is_snippet ) {
29
+ $target = urldecode( get_query_var( 'statify_target' ) );
30
+ $referrer = urldecode( get_query_var( 'statify_referrer' ) );
31
+ } elseif ( ! $use_snippet ) {
32
+ // @codingStandardsIgnoreStart The globals are checked.
33
+ $target = ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '/' );
34
+ $referrer = ( isset( $_SERVER['HTTP_REFERER'] ) ? wp_unslash( $_SERVER['HTTP_REFERER'] ) : '' );
35
+ // @codingStandardsIgnoreEnd
36
  } else {
37
+ return false;
38
  }
39
 
40
  /* Invalid target? */
41
+ if ( empty( $target ) || ! wp_validate_redirect( $target, false ) ) {
42
+ return self::_jump_out( $is_snippet );
43
  }
44
 
45
  /* Global vars */
49
  $data = array(
50
  'created' => '',
51
  'referrer' => '',
52
+ 'target' => '',
53
  );
54
 
55
  /* Set request timestamp */
56
+ $data['created'] = strftime( '%Y-%m-%d', current_time( 'timestamp' ) );
57
+
58
+ $needles = array( home_url(), network_admin_url() );
 
59
 
60
  /* Sanitize referrer url */
61
+ if ( ! empty( $referrer ) && self::strposa( $referrer, $needles ) === false ) {
62
+ $data['referrer'] = esc_url_raw( $referrer, array( 'http', 'https' ) );
63
  }
64
 
65
  /* Relative target url */
67
 
68
  /* Trim target url */
69
  if ( $wp_rewrite->permalink_structure ) {
70
+ $data['target'] = wp_parse_url( $data['target'], PHP_URL_PATH );
71
  }
72
 
73
  /* Sanitize target url */
74
+ $data['target'] = esc_url_raw( $data['target'] );
75
 
76
  /* Insert */
77
+ $wpdb->insert( $wpdb->statify, $data );
 
 
 
78
 
79
  /* Jump! */
80
+ return self::_jump_out( $is_snippet );
81
  }
82
 
 
83
  /**
84
+ * Find the position of the first occurrence of a substring in a string about a array.
85
+ *
86
+ * @param string $haystack The string to search in.
87
+ * @param array $needle The string to search for.
88
+ * @param int $offset Search will start this number of characters counted from the beginning of the string.
89
+ *
90
+ * @return bool
91
+ */
92
+ private static function strposa( $haystack, array $needle, $offset = 0 ) {
93
+
94
+ foreach ( $needle as $query ) {
95
+ if ( strpos( $haystack, $query, $offset ) !== false ) {
96
+ return true;
97
+ } // stop on first true result
98
+ }
99
+
100
+ return false;
101
+ }
102
 
103
+ /**
104
+ * Rules to skip the tracking
105
+ *
106
+ * @since 1.2.6
107
+ * @version 2016-12-21
108
+ *
109
+ * @hook boolean statify__skip_tracking
110
+ * @see https://wordpress.org/plugins/statify/
111
+ *
112
+ * @return boolean $skip_hook TRUE if NO tracking is desired
113
+ */
114
  private static function _skip_tracking() {
115
+
116
+ if ( function_exists( 'apply_filters_deprecated' ) ) {
117
+ apply_filters_deprecated( 'statify_skip_tracking', array( '' ), '1.5.0', 'statify__skip_tracking' );
118
+ }
119
+ /* Skip tracking via Hook */
120
+ if ( ( $skip_hook = apply_filters( 'statify__skip_tracking', null ) ) !== null ) {
121
  return $skip_hook;
122
  }
123
 
124
+
125
+ // Skip tracking via User Agent
126
+ // @codingStandardsIgnoreStart The globals are checked.
127
+ if ( ! isset( $_SERVER['HTTP_USER_AGENT'] )
128
+ || ! preg_match( '/(?:Windows|Macintosh|Linux|iPhone|iPad)/', $_SERVER['HTTP_USER_AGENT'] ) ) {
129
+ // @codingStandardsIgnoreEnd
130
+ return true;
131
+ }
132
+
133
+ /** Skip tracking via Referrer check and Conditional_Tags. */
134
+ return ( self::check_referrer() || is_feed() || is_trackback() || is_robots()
135
+ || is_preview() || is_user_logged_in() || is_404() || is_search()
136
+ );
137
+ }
138
+
139
+ /**
140
+ * Compare the referrer url to the blacklist data.
141
+ * De/activate this feature via settings in the Dashboard widget.
142
+ *
143
+ * @since 2016-12-21
144
+ * @version 2017-01-10
145
+ *
146
+ * @return bool
147
+ */
148
+ private static function check_referrer() {
149
+ // Return false if the blacklist filter is inactive.
150
+ $is_filter_reffer = get_option( 'statify' );
151
+
152
+ if ( ! $is_filter_reffer['blacklist'] ) {
153
+ return false;
154
+ }
155
+
156
+ // @codingStandardsIgnoreStart The globals are checked.
157
+ $referrer = ( isset( $_SERVER['HTTP_REFERER'] ) ? wp_parse_url( $_SERVER['HTTP_REFERER'], PHP_URL_HOST ) : '' );
158
+ // @codingStandardsIgnoreEnd
159
+
160
+ if ( empty( $referrer ) ) {
161
  return true;
162
  }
163
 
164
+ if ( is_array( $referrer ) && isset( $referrer['host'] ) ) {
165
+ $referrer = $referrer['host'];
166
+ }
167
+
168
+ if ( ! is_string( $referrer ) ) {
169
+ return false;
170
+ }
171
+
172
+ $blacklist = self::get_blacklist_keys();
173
+ foreach ( $blacklist as $item ) {
174
+ if ( strpos( $referrer, $item ) !== false ) {
175
+ return true;
176
+ }
177
+ }
178
+
179
+ return false;
180
  }
181
 
182
+ /**
183
+ * Get a array from the blacklist option of 'Settings' - 'Discussion' - 'Comment Blacklist'.
184
+ *
185
+ * @since 2016-12-21
186
+ *
187
+ * @return array
188
+ */
189
+ private static function get_blacklist_keys() {
190
+
191
+ $blacklist = trim( get_option( 'blacklist_keys' ) );
192
+
193
+ if ( empty( $blacklist ) ) {
194
+ return array();
195
+ }
196
+
197
+ return (array) explode( "\n", $blacklist );
198
+ }
199
 
200
  /**
201
+ * Send JavaScript headers or return false
202
+ *
203
+ * @since 1.1.0
204
+ * @version 1.3.1
205
+ *
206
+ * @param boolean $is_snippet Snippet type.
207
+ *
208
+ * @return mixed Exit or return depending on snippet type.
209
+ */
210
+ private static function _jump_out( $is_snippet ) {
211
+
212
  if ( $is_snippet ) {
213
  nocache_headers();
214
+ header( 'Content-type: text/javascript', true, 204 );
215
  exit;
216
  }
217
 
220
 
221
 
222
  /**
223
+ * Declare GET variables for further use
224
+ *
225
+ * @since 1.1.0
226
+ * @version 1.3.1
227
+ *
228
+ * @param array $vars Input with existing variables.
229
+ *
230
+ * @return array $vars Output with plugin variables
231
+ */
232
+ public static function query_vars( $vars ) {
233
+
234
  $vars[] = 'statify_referrer';
235
  $vars[] = 'statify_target';
236
 
239
 
240
 
241
  /**
242
+ * Print JavaScript snippet
243
+ *
244
+ * @since 1.1.0
245
+ * @version 1.4.1
246
+ */
247
+ public static function wp_footer() {
248
+
 
249
  /* Skip by option */
250
  if ( ! self::$_options['snippet'] ) {
251
  return;
257
  }
258
 
259
  /* Load template */
260
+ load_template(
261
+ wp_normalize_path(
262
+ sprintf(
263
+ '%s/views/js_snippet.view.php',
264
+ STATIFY_DIR
265
+ )
266
+ )
267
+ );
268
  }
269
+ }
inc/statify_install.class.php CHANGED
@@ -1,31 +1,39 @@
1
  <?php
2
-
3
- /* Quit */
4
- defined( 'ABSPATH' ) OR exit;
5
 
6
  /**
7
  * Statify_Install
8
  *
9
- * @since 0.1
 
10
  */
11
  class Statify_Install {
 
12
  /**
13
- * Plugin activaton handler.
14
  *
15
  * @since 0.1.0
16
  *
17
  * @param bool $network_wide Whether the plugin was activated network-wide or not.
18
  */
19
  public static function init( $network_wide = false ) {
20
- global $wpdb;
21
 
22
- // Create tables for each site in a network.
23
- if ( is_multisite() && $network_wide ) {
24
- // Todo: Use get_sites() in WordPress 4.6+
25
- $ids = $wpdb->get_col( "SELECT blog_id FROM `$wpdb->blogs`" );
 
 
 
 
 
 
 
 
 
26
 
27
- foreach ( $ids as $site_id ) {
28
- switch_to_blog( $site_id );
29
  self::_apply();
30
  }
31
 
@@ -43,6 +51,7 @@ class Statify_Install {
43
  * @param int $site_id Site ID.
44
  */
45
  public function init_site( $site_id ) {
 
46
  switch_to_blog( (int) $site_id );
47
 
48
  self::_apply();
@@ -53,17 +62,12 @@ class Statify_Install {
53
  /**
54
  * Creates the database tables needed for the plugin.
55
  *
56
- * @since 0.1.0
57
- * @change 1.4.0
58
  */
59
  private static function _apply() {
60
- // Todo: Remove. Use sane defaults instead.
61
- add_option(
62
- 'statify',
63
- array()
64
- );
65
 
66
- // Cleanup any leftover transients
67
  delete_transient( 'statify_data' );
68
 
69
  // Set up the cron event.
@@ -79,4 +83,4 @@ class Statify_Install {
79
  Statify_Table::init();
80
  Statify_Table::create();
81
  }
82
- }
1
  <?php
2
+ /** Quit */
3
+ defined( 'ABSPATH' ) || exit;
 
4
 
5
  /**
6
  * Statify_Install
7
  *
8
+ * @since 0.1
9
+ * @version 2016-12-20
10
  */
11
  class Statify_Install {
12
+
13
  /**
14
+ * Plugin activation handler.
15
  *
16
  * @since 0.1.0
17
  *
18
  * @param bool $network_wide Whether the plugin was activated network-wide or not.
19
  */
20
  public static function init( $network_wide = false ) {
 
21
 
22
+ if ( $network_wide && is_multisite() ) {
23
+ // @ToDo: leave only get_sites, after decision which versions of WP will we supporting.
24
+ if ( function_exists( 'get_sites' ) ) {
25
+ $sites = get_sites();
26
+ } elseif ( function_exists( 'wp_get_sites' ) ) {
27
+ $sites = wp_get_sites();
28
+ } else {
29
+ return;
30
+ }
31
+ // Create tables for each site in a network.
32
+ foreach ( $sites as $site ) {
33
+ // Convert object to array.
34
+ $site = (array) $site;
35
 
36
+ switch_to_blog( $site['blog_id'] );
 
37
  self::_apply();
38
  }
39
 
51
  * @param int $site_id Site ID.
52
  */
53
  public function init_site( $site_id ) {
54
+
55
  switch_to_blog( (int) $site_id );
56
 
57
  self::_apply();
62
  /**
63
  * Creates the database tables needed for the plugin.
64
  *
65
+ * @since 0.1.0
66
+ * @version 1.4.0
67
  */
68
  private static function _apply() {
 
 
 
 
 
69
 
70
+ // Cleanup any leftover transients.
71
  delete_transient( 'statify_data' );
72
 
73
  // Set up the cron event.
83
  Statify_Table::init();
84
  Statify_Table::create();
85
  }
86
+ }
inc/statify_table.class.php CHANGED
@@ -1,64 +1,55 @@
1
  <?php
2
-
3
-
4
- /* Quit */
5
- defined('ABSPATH') OR exit;
6
-
7
 
8
  /**
9
- * Statify Table
10
- *
11
- * @since 0.6
12
- */
13
-
14
- class Statify_Table
15
- {
16
-
17
 
18
  /**
19
- * Definition der Tabelle
20
- *
21
- * @since 0.6.0
22
- * @change 1.2.4
23
- */
24
-
25
- public static function init()
26
- {
27
- /* Global */
28
  global $wpdb;
29
 
30
- /* Name */
31
  $table = 'statify';
32
 
33
- /* Als Array */
34
  $wpdb->tables[] = $table;
35
 
36
- /* Mit Prefix */
37
  $wpdb->$table = $wpdb->get_blog_prefix() . $table;
38
  }
39
 
40
 
41
  /**
42
- * Anlegen der Tabelle
43
- *
44
- * @since 0.6.0
45
- * @change 1.2.4
46
- */
47
-
48
- public static function create()
49
- {
50
- /* Global */
51
  global $wpdb;
52
 
53
- /* Existenz prüfen */
54
- if ( $wpdb->get_var("SHOW TABLES LIKE '$wpdb->statify'") == $wpdb->statify ) {
55
  return;
56
  }
57
 
58
- /* Einbinden */
59
- require_once(ABSPATH. 'wp-admin/includes/upgrade.php');
60
 
61
- /* Anlegen */
62
  dbDelta(
63
  "CREATE TABLE `$wpdb->statify` (
64
  `id` bigint(20) unsigned NOT NULL auto_increment,
@@ -75,18 +66,16 @@ class Statify_Table
75
 
76
 
77
  /**
78
- * Löschung der Tabelle
79
- *
80
- * @since 0.6.0
81
- * @change 1.2.4
82
- */
83
-
84
- public static function drop()
85
- {
86
- /* Global */
87
  global $wpdb;
88
 
89
- /* Remove */
90
- $wpdb->query("DROP TABLE IF EXISTS `$wpdb->statify`");
91
  }
92
- }
1
  <?php
2
+ /** Quit */
3
+ defined( 'ABSPATH' ) || exit;
 
 
 
4
 
5
  /**
6
+ * Statify Table
7
+ *
8
+ * @since 0.6
9
+ */
10
+ class Statify_Table {
 
 
 
11
 
12
  /**
13
+ * Definition of the custom table.
14
+ *
15
+ * @since 0.6.0
16
+ * @version 1.2.4
17
+ */
18
+ public static function init() {
19
+
20
+ /** Global */
 
21
  global $wpdb;
22
 
23
+ /** Name */
24
  $table = 'statify';
25
 
26
+ /** Als Array */
27
  $wpdb->tables[] = $table;
28
 
29
+ /** Mit Prefix */
30
  $wpdb->$table = $wpdb->get_blog_prefix() . $table;
31
  }
32
 
33
 
34
  /**
35
+ * Create the table.
36
+ *
37
+ * @since 0.6.0
38
+ * @version 1.2.4
39
+ */
40
+ public static function create() {
41
+
 
 
42
  global $wpdb;
43
 
44
+ /** If existent. */
45
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->statify'" ) === $wpdb->statify ) {
46
  return;
47
  }
48
 
49
+ /** Include */
50
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
51
 
52
+ /** Create. */
53
  dbDelta(
54
  "CREATE TABLE `$wpdb->statify` (
55
  `id` bigint(20) unsigned NOT NULL auto_increment,
66
 
67
 
68
  /**
69
+ * Remove the custom table.
70
+ *
71
+ * @since 0.6.0
72
+ * @version 1.2.4
73
+ */
74
+ public static function drop() {
75
+
 
 
76
  global $wpdb;
77
 
78
+ /** Remove */
79
+ $wpdb->query( "DROP TABLE IF EXISTS `$wpdb->statify`" );
80
  }
81
+ }
inc/statify_uninstall.class.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
-
3
- /* Quit */
4
- defined( 'ABSPATH' ) OR exit;
5
 
6
  /**
7
  * Statify_Uninstall
@@ -9,23 +8,32 @@ defined( 'ABSPATH' ) OR exit;
9
  * @since 0.1
10
  */
11
  class Statify_Uninstall {
 
12
  /**
13
  * Plugin uninstall handler.
14
  *
15
- * @since 0.1.0
16
- * @change 0.1.0
17
  */
18
  public static function init() {
19
- global $wpdb;
20
 
21
  if ( is_multisite() ) {
22
  $old = get_current_blog_id();
 
 
 
 
 
 
 
 
 
23
 
24
- // Todo: Use get_sites() in WordPress 4.6+
25
- $ids = $wpdb->get_col( "SELECT blog_id FROM `$wpdb->blogs`" );
 
26
 
27
- foreach ( $ids as $id ) {
28
- switch_to_blog( $id );
29
  self::_apply();
30
  }
31
 
@@ -43,6 +51,7 @@ class Statify_Uninstall {
43
  * @param int $site_id Site ID.
44
  */
45
  public function init_site( $site_id ) {
 
46
  switch_to_blog( $site_id );
47
 
48
  self::_apply();
@@ -53,17 +62,18 @@ class Statify_Uninstall {
53
  /**
54
  * Deletes all plugin data.
55
  *
56
- * @since 0.1.0
57
- * @change 1.4.0
58
  */
59
  private static function _apply() {
60
- /* Delete options */
 
61
  delete_option( 'statify' );
62
 
63
- /* Init table */
64
  Statify_Table::init();
65
 
66
- /* Delete table */
67
  Statify_Table::drop();
68
  }
69
- }
1
  <?php
2
+ /** Quit */
3
+ defined( 'ABSPATH' ) || exit;
 
4
 
5
  /**
6
  * Statify_Uninstall
8
  * @since 0.1
9
  */
10
  class Statify_Uninstall {
11
+
12
  /**
13
  * Plugin uninstall handler.
14
  *
15
+ * @since 0.1.0
16
+ * @version 0.1.0
17
  */
18
  public static function init() {
 
19
 
20
  if ( is_multisite() ) {
21
  $old = get_current_blog_id();
22
+ // @ToDo: leave only get_sites, after decision which versions of WP will we supporting.
23
+ // @ToDo Redundant with Statify_Install class. We should reduce the maintenance.
24
+ if ( function_exists( 'get_sites' ) ) {
25
+ $sites = get_sites();
26
+ } elseif ( function_exists( 'wp_get_sites' ) ) {
27
+ $sites = wp_get_sites();
28
+ } else {
29
+ return;
30
+ }
31
 
32
+ foreach ( $sites as $site ) {
33
+ // Convert object to array.
34
+ $site = (array) $site;
35
 
36
+ switch_to_blog( $site['blog_id'] );
 
37
  self::_apply();
38
  }
39
 
51
  * @param int $site_id Site ID.
52
  */
53
  public function init_site( $site_id ) {
54
+
55
  switch_to_blog( $site_id );
56
 
57
  self::_apply();
62
  /**
63
  * Deletes all plugin data.
64
  *
65
+ * @since 0.1.0
66
+ * @version 1.4.0
67
  */
68
  private static function _apply() {
69
+
70
+ /** Delete options */
71
  delete_option( 'statify' );
72
 
73
+ /** Init table */
74
  Statify_Table::init();
75
 
76
+ /** Delete table */
77
  Statify_Table::drop();
78
  }
79
+ }
inc/statify_xmlrpc.class.php CHANGED
@@ -1,34 +1,29 @@
1
  <?php
2
-
3
-
4
- /* Quit */
5
- defined('ABSPATH') OR exit;
6
-
7
 
8
  /**
9
- * Statify_XMLRPC
10
- *
11
- * @since 1.1
12
- */
13
-
14
- class Statify_XMLRPC
15
- {
16
-
17
 
18
  /**
19
- * Erweiterung der XMLRPC-Methode
20
- *
21
- * @since 1.1.0
22
- * @change 1.1.0
23
- *
24
- * @return array $methods Array ohne Plugin-Callback
25
- * @return array $methods Array mit Plugin-Callback
26
- */
 
 
27
 
28
- public static function xmlrpc_methods($methods) {
29
  $methods['statify.getStats'] = array(
30
  __CLASS__,
31
- 'xmlrpc_callback'
32
  );
33
 
34
  return $methods;
@@ -36,39 +31,40 @@ class Statify_XMLRPC
36
 
37
 
38
  /**
39
- * Ausführung der XMLRPC-Anfrage
40
- *
41
- * @since 1.1.0
42
- * @change 1.2.5
43
- *
44
- * @param array $args Array mit Parametern (Zugangsdaten)
45
- * @return string String mit Ergebnissen
46
- */
47
-
48
- public static function xmlrpc_callback($args) {
49
- /* Keine Zugangsdaten? */
50
- if ( empty($args[0]) OR empty($args[1]) ) {
 
51
  return '{"error": "Empty login data"}';
52
  }
53
 
54
- /* Nutzer einloggen */
55
- $user = wp_authenticate($args[0], $args[1]);
56
 
57
- /* Falsche Zugangsdaten */
58
- if ( ! $user OR is_wp_error($user) ) {
59
  return '{"error": "Incorrect login"}';
60
  }
61
 
62
- /* Berechtigung prüfen */
63
- if ( ! user_can($user, 'edit_dashboard') ) {
64
  return '{"error": "User can check failed"}';
65
  }
66
 
67
- /* Leer? */
68
  if ( ! $data = Statify_Dashboard::get_stats() ) {
69
  return '{"error": "No data"}';
70
  }
71
 
72
- return json_encode($data['visits']);
73
  }
74
- }
1
  <?php
2
+ /** Quit */
3
+ defined( 'ABSPATH' ) || exit;
 
 
 
4
 
5
  /**
6
+ * Statify_XMLRPC
7
+ *
8
+ * @since 1.1
9
+ */
10
+ class Statify_XMLRPC {
 
 
 
11
 
12
  /**
13
+ * Enhancement from the XMLRPC-method.
14
+ *
15
+ * @since 1.1.0
16
+ * @version 1.1.0
17
+ *
18
+ * @param array $methods Array without Plugin-Callback.
19
+ *
20
+ * @return array $methods Array with Plugin-Callback.
21
+ */
22
+ public static function xmlrpc_methods( $methods ) {
23
 
 
24
  $methods['statify.getStats'] = array(
25
  __CLASS__,
26
+ 'xmlrpc_callback',
27
  );
28
 
29
  return $methods;
31
 
32
 
33
  /**
34
+ * Ausführung der XMLRPC-Anfrage
35
+ *
36
+ * @since 1.1.0
37
+ * @version 1.2.5
38
+ *
39
+ * @param array $args Array with parameters (access data).
40
+ *
41
+ * @return string String with results.
42
+ */
43
+ public static function xmlrpc_callback( $args ) {
44
+
45
+ /** No access data? */
46
+ if ( empty( $args[0] ) || empty( $args[1] ) ) {
47
  return '{"error": "Empty login data"}';
48
  }
49
 
50
+ /** Login */
51
+ $user = wp_authenticate( $args[0], $args[1] );
52
 
53
+ /** Wrong access data */
54
+ if ( ! $user || is_wp_error( $user ) ) {
55
  return '{"error": "Incorrect login"}';
56
  }
57
 
58
+ /** Check access rights. */
59
+ if ( ! user_can( $user, 'edit_dashboard' ) ) {
60
  return '{"error": "User can check failed"}';
61
  }
62
 
63
+ /** Empty? */
64
  if ( ! $data = Statify_Dashboard::get_stats() ) {
65
  return '{"error": "No data"}';
66
  }
67
 
68
+ return wp_json_encode( $data['visits'] );
69
  }
70
+ }
lang/statify-ru_RU.mo DELETED
Binary file
lang/statify-ru_RU.po DELETED
@@ -1,53 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Statify\n"
4
- "POT-Creation-Date: \n"
5
- "PO-Revision-Date: \n"
6
- "Last-Translator: Sergej Müller\n"
7
- "Language-Team: Sergej Müller\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=utf-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "X-Poedit-SourceCharset: utf-8\n"
12
- "X-Poedit-KeywordsList: __;_e\n"
13
- "X-Poedit-Basepath: .\n"
14
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
- "Language: de_DE\n"
16
- "X-Generator: Poedit 1.7.5\n"
17
- "X-Poedit-SearchPath-0: .\n"
18
-
19
- msgid "Compact, easy-to-use and privacy-compliant stats plugin for WordPress."
20
- msgstr "Компактный и простой в использовании плагин для статистики в WordPress."
21
-
22
- msgid "No data available."
23
- msgstr "Данные отсутствуют."
24
-
25
- msgid "Top targets"
26
- msgstr "Топ цели"
27
-
28
- msgid "Top referers"
29
- msgstr "Топ рефереров"
30
-
31
- msgid "Period of data saving"
32
- msgstr "Период сохранения данных"
33
-
34
- msgid "Number of entries in top lists"
35
- msgstr "Количество записей в ТОП-листах"
36
-
37
- msgid "Entries in top lists only for today"
38
- msgstr "Записи в ТОП-листах только за сегодня"
39
-
40
- msgid "Page tracking via JavaScript"
41
- msgstr "Отслеживание через JavaScript"
42
-
43
- msgid "recommended if caching is in use"
44
- msgstr "при кэширование страниц"
45
-
46
- msgid "Pageview"
47
- msgstr "Просмотр"
48
-
49
- msgid "Pageviews"
50
- msgstr "Просмотров"
51
-
52
- msgid "days"
53
- msgstr "дней"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Statify #
2
+ * Contributors: pluginkollektiv
3
+ * Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TD4AMD2D8EMZW
4
+ * Tags: analytics, dashboard, pageviews, privacy, statistics, stats, visits, web stats, widget
5
+ * Requires at least: 3.9
6
+ * Tested up to: 4.7.3
7
+ * Stable tag: 1.5.0
8
+ * License: GPLv3 or later
9
+ * License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
+
11
+ Visitor statistics for WordPress with focus on data protection, transparency and clarity. Perfect as a widget in your WordPress Dashboard.
12
+
13
+
14
+ ## Description ##
15
+ The free and ad-free plugin Statify pursues a simple objective: to provide a straightforward and compact access to the number of site views.
16
+
17
+ No frills. No Cookies. No third party. No storage of personal data. No endless data privacy statements.
18
+
19
+ An interactive chart is followed by lists of the most common reference sources and target pages. The period of statistics and length of lists can be set directly in the dashboard widget.
20
+
21
+ ### Data Privacy ###
22
+ In direct comparison to statistics services such as *Google Analytics*, *WordPress.com Stats* and *Piwik* *Statify* doesn't process and store personal data as e.g. IP addresses – *Statify* counts site views, not visitors.
23
+ Absolute privacy compliance coupled with transparent procedures: A locally in WordPress created database table consists of only four fields (ID, date, source, target) and can be viewed at any time, cleaned up and cleared by the administrator.
24
+
25
+ ### Settings and Hooks ###
26
+ The plugin configuration can be changed directly in the *Statify* Widget on the dashboard by clicking the *Configure* link.
27
+
28
+ #### Period of data saving ####
29
+ *Statify* stores the data only for a limited period (default: two weeks), longer intervals can be selected as option in the widget.
30
+ Data which is older than the selected period is deleted by a daily cron job.
31
+ An increase in the database volume can be expected because all statistic values are collected and managed in the local WordPress database (expecially if you increase the period of data saving).
32
+
33
+ #### Display of the widget ####
34
+ The amount of links shown in the *Statify* Widget can be set as well as the option to only count views from today.
35
+ Of course, older entries are not deleted when changing this setting.
36
+
37
+ The statistics for the dashboard widget are cached for four minutes.
38
+
39
+ Per default only administrators can see the widget. This can be changed with the `statify__user_can_see_stats` hook.
40
+
41
+ Example:
42
+ `
43
+ add_filter(
44
+ 'statify__user_can_see_stats',
45
+ '__return_true'
46
+ );
47
+ `
48
+
49
+ has to be added to the theme's `functions.php` and adapted to your needs. This example would allow all users to see the widget.
50
+
51
+ Editing the configuration is still limited to users with `edit_dashboard` capability.
52
+
53
+ #### JavaScript tracking for caching compatibility ####
54
+ For compatibility with caching plugins like [Cachify](http://cachify.de) *Statify* offers an optional switchable tracking via JavaScript.
55
+ This function allows reliable count of cached blog pages.
56
+
57
+ For this to work correctly, the active theme has to call `wp_footer()`, typically in a file named `footer.php`.
58
+
59
+ #### Skip tracking for spam referrers ####
60
+ The comment blacklist can be enabled to skip tracking for views with a referrer URL listed in comment blacklist, i. e. which considered as spam.
61
+
62
+ #### Skip tracking for defined users or pages ####
63
+ The conditions for tracking views can be customized according to page type and user capabilities by using the hook `statify__skip_tracking`.
64
+
65
+ Example:
66
+ `
67
+ add_filter(
68
+ 'statify__skip_tracking',
69
+ function() {
70
+ if ( condition ) {
71
+ return true;
72
+ }
73
+
74
+ return false;
75
+ }
76
+ );
77
+ `
78
+
79
+ has to be added to the theme's `functions.php`. The condition has modified such that the method returns true if and only if the view should be ignored.
80
+
81
+ ### Support ###
82
+ * Community support via the [support forums on wordpress.org](https://wordpress.org/support/plugin/statify)
83
+ * We don’t handle support via e-mail, Twitter, GitHub issues etc.
84
+
85
+ ### Contribute ###
86
+ * Active development of this plugin is handled [on GitHub](https://github.com/pluginkollektiv/statify).
87
+ * Pull requests for documented bugs are highly appreciated.
88
+ * If you think you’ve found a bug (e.g. you’re experiencing unexpected behavior), please post at the [support forums](https://wordpress.org/support/plugin/statify) first.
89
+ * If you want to help us translate this plugin you can do so [on WordPress Translate](https://translate.wordpress.org/projects/wp-plugins/statify).
90
+
91
+ ### Credits ###
92
+ * Author: [Sergej Müller](https://sergejmueller.github.io/)
93
+ * Maintainers: [pluginkollektiv](http://pluginkollektiv.org/)
94
+
95
+
96
+ ## Installation ##
97
+ * If you don’t know how to install a plugin for WordPress, [here’s how](https://codex.wordpress.org/Managing_Plugins#Installing_Plugins).
98
+
99
+ ### Requirements ###
100
+ * PHP 5.3 or greater
101
+ * WordPress 3.9 or greater
102
+
103
+
104
+ ## Frequently Asked Questions ##
105
+
106
+ ### Which areas are excluded from counting? ###
107
+ *Statify* does not count the following views:
108
+
109
+ * feeds
110
+ * trackbacks
111
+ * searches
112
+ * previews
113
+ * views by logged in users
114
+ * error pages
115
+
116
+ This behavior can be modified with the `statify__skip_tracking` hook.
117
+
118
+ ### Can further visitor data be recorded? ###
119
+ Some plugin users want to capture additional visitor data, e.g. name of the device and resolution.
120
+ *Statify* counts exclusively page views and no visitors, the desired data acquisition is not a question.
121
+
122
+
123
+ ## Changelog ##
124
+
125
+ You can find the full changelog in [our GitHub repository](https://github.com/pluginkollektiv/statify/blob/master/CHANGELOG.md).
126
+
127
+ ### 1.5.0 (2017-03-23) ###
128
+ * Switched to minimal PHP version 5.3
129
+ * Added more flexible settings for period of data saving and the number of entries shown in top lists
130
+ * Added validation of form data before saving settings
131
+ * Moved all documentation to [wordpress.org](https://wordpress.org/plugins/statify/).
132
+ * Added optional referrer spam protection (can be activated via the Statify settings).
133
+ * Improved conformance to the WordPress coding guidelines
134
+ * Bugfix for multi-site installations: Don't track network admin url.
135
+ * Changed hook name `statify_skip_tracking` to `statify__skip_tracking`.
136
+
137
+ ### 1.4.4 ###
138
+ * Renamed the handle of the Raphael JS library. This fixed a bug, where raphael couldn't work properly when also loaded with Antispam Bee.
139
+
140
+ ### 1.4.3 ###
141
+ * Corrected tracking and display in Multisite
142
+ * Minor CSS fixes in the dashboard widget
143
+ * Removed deprecated links and updated URLs for donate and wiki links
144
+ * Administrative updates to plugin header and README
145
+ * Updated [plugin authors](https://gist.github.com/glueckpress/f058c0ab973d45a72720)
146
+
147
+ ### 1.4.2 ###
148
+ * Replace `filter_has_var(INPUT_SERVER)` calls with `isset($_SERVER[])` ([why](https://github.com/wp-stream/stream/issues/254))
149
+
150
+ ### 1.4.1 ###
151
+ * Renew the tracking mechanism
152
+
153
+ ### 1.4.0 ###
154
+ * WordPress 4.2 support
155
+ * Plugin-wide code refactoring
156
+ * Translations for English and Russian
157
+ * [GitHub Repository](https://github.com/pluginkollektiv/statify)
158
+
159
+ ### 1.3.0 / 28.04.2014 ###
160
+ * Sourcecode optimization for plugin-finalization
161
+
162
+ For the complete changelog, check out our [GitHub repository](https://github.com/pluginkollektiv/statify).
163
+
164
+
165
+ ## Screenshots ##
166
+ 1. Statify dashboard widget
167
+ 2. Statify dashboard widget options
statify.php CHANGED
@@ -1,43 +1,30 @@
1
  <?php
2
- /*
3
- Plugin Name: Statify
4
- Description: Compact, easy-to-use and privacy-compliant stats plugin for WordPress.
5
- Text Domain: statify
6
- Domain Path: /lang
7
- Author: pluginkollektiv
8
- Author URI: https://pluginkollektiv.org
9
- Plugin URI: https://wordpress.org/plugins/statify
10
- License: GPLv3 or later
11
- Version: 1.4.3
12
- */
13
-
14
- /*
15
- Copyright (C) 2011-2015 Sergej Müller
16
-
17
- This program is free software; you can redistribute it and/or modify
18
- it under the terms of the GNU General Public License as published by
19
- the Free Software Foundation; either version 3 of the License, or
20
- (at your option) any later version.
21
-
22
- This program is distributed in the hope that it will be useful,
23
- but WITHOUT ANY WARRANTY; without even the implied warranty of
24
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
- GNU General Public License for more details.
26
-
27
- You should have received a copy of the GNU General Public License along
28
- with this program; if not, write to the Free Software Foundation, Inc.,
29
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30
- */
31
-
32
 
33
  /* Quit */
34
- defined('ABSPATH') OR exit;
35
 
36
 
37
  /* Constants */
38
- define('STATIFY_FILE', __FILE__);
39
- define('STATIFY_DIR', dirname(__FILE__));
40
- define('STATIFY_BASE', plugin_basename(__FILE__));
41
 
42
 
43
  /* Hooks */
@@ -45,56 +32,62 @@ add_action(
45
  'plugins_loaded',
46
  array(
47
  'Statify',
48
- 'instance'
49
  )
50
  );
51
  register_activation_hook(
52
  STATIFY_FILE,
53
  array(
54
  'Statify_Install',
55
- 'init'
56
  )
57
  );
58
  register_deactivation_hook(
59
- STATIFY_FILE,
60
- array(
61
- 'Statify_Deactivate',
62
- 'init'
63
- )
64
  );
65
  register_uninstall_hook(
66
  STATIFY_FILE,
67
  array(
68
  'Statify_Uninstall',
69
- 'init'
70
  )
71
  );
72
 
73
 
74
  /* Autoload */
75
- spl_autoload_register('statify_autoload');
 
 
 
 
 
 
 
76
 
77
- function statify_autoload($class) {
78
- $plugin_classes = array(
79
- 'Statify',
80
- 'Statify_Backend',
81
- 'Statify_Frontend',
82
- 'Statify_Dashboard',
83
- 'Statify_Install',
84
- 'Statify_Uninstall',
85
- 'Statify_Deactivate',
86
- 'Statify_Table',
87
- 'Statify_XMLRPC',
88
- 'Statify_Cron'
89
- );
90
 
91
- if ( in_array($class, $plugin_classes) ) {
92
- require_once(
93
- sprintf(
94
- '%s/inc/%s.class.php',
95
- STATIFY_DIR,
96
- strtolower($class)
97
- )
98
- );
99
- }
100
  }
1
  <?php
2
+ /**
3
+ * Plugin Name: Statify
4
+ * Description: Compact, easy-to-use and privacy-compliant stats plugin for WordPress.
5
+ * Text Domain: statify
6
+ * Domain Path: /lang
7
+ * Author: pluginkollektiv
8
+ * Author URI: http://pluginkollektiv.org
9
+ * Plugin URI: https://wordpress.org/plugins/statify
10
+ * License: GPLv3 or later
11
+ * Version: 1.5.0
12
+ *
13
+ * Copyright (C) 2011-2017 Sergej Müller, pluginkollektiv
14
+ *
15
+ * Php Version 5.6
16
+ *
17
+ * @package WordPress
18
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  /* Quit */
21
+ defined( 'ABSPATH' ) || exit;
22
 
23
 
24
  /* Constants */
25
+ define( 'STATIFY_FILE', __FILE__ );
26
+ define( 'STATIFY_DIR', __DIR__ );
27
+ define( 'STATIFY_BASE', plugin_basename( __FILE__ ) );
28
 
29
 
30
  /* Hooks */
32
  'plugins_loaded',
33
  array(
34
  'Statify',
35
+ 'instance',
36
  )
37
  );
38
  register_activation_hook(
39
  STATIFY_FILE,
40
  array(
41
  'Statify_Install',
42
+ 'init',
43
  )
44
  );
45
  register_deactivation_hook(
46
+ STATIFY_FILE,
47
+ array(
48
+ 'Statify_Deactivate',
49
+ 'init',
50
+ )
51
  );
52
  register_uninstall_hook(
53
  STATIFY_FILE,
54
  array(
55
  'Statify_Uninstall',
56
+ 'init',
57
  )
58
  );
59
 
60
 
61
  /* Autoload */
62
+ spl_autoload_register( 'statify_autoload' );
63
+
64
+ /**
65
+ * Include classes via autoload.
66
+ *
67
+ * @param string $class Name of an class-file name, without file extension.
68
+ */
69
+ function statify_autoload( $class ) {
70
 
71
+ $plugin_classes = array(
72
+ 'Statify',
73
+ 'Statify_Backend',
74
+ 'Statify_Frontend',
75
+ 'Statify_Dashboard',
76
+ 'Statify_Install',
77
+ 'Statify_Uninstall',
78
+ 'Statify_Deactivate',
79
+ 'Statify_Table',
80
+ 'Statify_XMLRPC',
81
+ 'Statify_Cron',
82
+ );
 
83
 
84
+ if ( in_array( $class, $plugin_classes, true ) ) {
85
+ require_once(
86
+ sprintf(
87
+ '%s/inc/%s.class.php',
88
+ STATIFY_DIR,
89
+ strtolower( $class )
90
+ )
91
+ );
92
+ }
93
  }
views/js_snippet.view.php CHANGED
@@ -1,26 +1,23 @@
1
  <?php
 
 
2
 
3
 
4
- /* Quit */
5
- class_exists('Statify') OR exit; ?>
 
 
 
 
 
 
6
 
 
 
 
7
 
8
- <!-- Stats by http://statify.de -->
9
- <script type="text/javascript">
10
- (function() {
11
- var e = document.createElement('script'),
12
- s = document.getElementsByTagName('script')[0],
13
- r = encodeURIComponent(document.referrer),
14
- t = encodeURIComponent(location.pathname + location.search),
15
- p = '?statify_referrer=' + r + '&statify_target=' + t;
16
 
17
- e.async = true;
18
- e.type = 'text/javascript';
19
- e.src = "<?php echo home_url('/', 'relative'); ?>" + p;
20
-
21
- s.parentNode.insertBefore(e, s);
22
- })();
23
- </script>
24
-
25
-
26
- <?php /* Markup space */ ?>
1
  <?php
2
+ /** Quit */
3
+ class_exists( 'Statify' ) || exit; ?>
4
 
5
 
6
+ <!-- Stats by http://statify.de -->
7
+ <script type="text/javascript">
8
+ (function () {
9
+ var e = document.createElement('script'),
10
+ s = document.getElementsByTagName('script')[0],
11
+ r = encodeURIComponent(document.referrer),
12
+ t = encodeURIComponent(location.pathname + location.search),
13
+ p = '?statify_referrer=' + r + '&statify_target=' + t;
14
 
15
+ e.async = true;
16
+ e.type = 'text/javascript';
17
+ e.src = "<?php echo esc_url( home_url( '/', 'relative' ) ); ?>" + p;
18
 
19
+ s.parentNode.insertBefore(e, s);
20
+ })();
21
+ </script>
 
 
 
 
 
22
 
23
+ <?php /** Markup space */ ?>
 
 
 
 
 
 
 
 
 
views/widget_back.view.php CHANGED
@@ -1,55 +1,37 @@
1
  <?php
2
-
3
-
4
- /* Quit */
5
- class_exists('Statify') OR exit; ?>
6
-
7
-
8
- <table class="form-table">
9
- <tr valign="top">
10
- <td>
11
- <fieldset>
12
- <label for="statify_days">
13
- <select name="statify[days]" id="statify_days">
14
- <?php foreach( array(7, 14, 21, 30, 84, 183, 365) as $days ) { ?>
15
- <option value="<?php echo $days ?>" <?php selected( Statify::$_options['days'], $days ); ?>>
16
- <?php echo sprintf( '%d %s', $days, esc_html__('days', 'statify') ); ?>
17
- </option>
18
- <?php } ?>
19
- </select>
20
- <?php esc_html_e('Period of data saving', 'statify'); ?>
21
- </label>
22
-
23
- <label for="statify_limit">
24
- <select name="statify[limit]" id="statify_limit">
25
- <?php foreach( range(0, 12) as $amount ) { ?>
26
- <option <?php selected( Statify::$_options['limit'], $amount ); ?>>
27
- <?php echo $amount; ?>
28
- </option>
29
- <?php } ?>
30
- </select>
31
- <?php esc_html_e('Number of entries in top lists', 'statify'); ?>
32
- </label>
33
-
34
- <label for="statify_today">
35
- <input type="checkbox" name="statify[today]" id="statify_today" value="1" <?php checked( Statify::$_options['today'], 1 ); ?> />
36
- <?php esc_html_e('Entries in top lists only for today', 'statify'); ?>
37
- </label>
38
-
39
- <label for="statify_snippet">
40
- <input type="checkbox" name="statify[snippet]" id="statify_snippet" value="1" <?php checked( Statify::$_options['snippet'], 1 ); ?> />
41
- <?php esc_html_e('Page tracking via JavaScript', 'statify'); ?>
42
- <small>(<?php esc_html_e('recommended if caching is in use', 'statify'); ?>)</small>
43
- </label>
44
- </fieldset>
45
- </td>
46
- </tr>
47
- </table>
48
-
49
 
50
  <p class="meta-links">
51
- <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LG5VC9KXMAYXJ" target="_blank">PayPal</a>
52
- <?php if ( strpos(get_locale(), 'de') !== false ) { ?>
53
- &bull; <a href="https://github.com/pluginkollektiv/statify/wiki" target="_blank">Wiki</a>
54
- <?php } ?>
55
  </p>
1
  <?php
2
+ /** Quit */
3
+ class_exists( 'Statify' ) || exit; ?>
4
+
5
+ <fieldset>
6
+ <label for="statify_days">
7
+ <input name="statify[days]" id="statify_days" type="number" min="1"
8
+ value="<?php echo esc_attr( Statify::$_options['days'] ); ?>">
9
+ <?php esc_html_e( 'days', 'statify' ); ?> -
10
+ <?php esc_html_e( 'Period of data saving', 'statify' ); ?>
11
+ </label>
12
+ <label for="statify_limit">
13
+ <input name="statify[limit]" id="statify_limit" type="number" min="1" max="100"
14
+ value="<?php echo esc_attr( Statify::$_options['limit'] ); ?>">
15
+ <?php esc_html_e( 'Number of entries in top lists', 'statify' ); ?>
16
+ </label>
17
+ <label for="statify_today">
18
+ <input type="checkbox" name="statify[today]" id="statify_today" value="1" <?php checked( Statify::$_options['today'], 1 ); ?> />
19
+ <?php esc_html_e( 'Entries in top lists only for today', 'statify' ); ?>
20
+ </label>
21
+ <label for="statify_snippet">
22
+ <input type="checkbox" name="statify[snippet]" id="statify_snippet" value="1" <?php checked( Statify::$_options['snippet'], 1 ); ?> />
23
+ <?php esc_html_e( 'Page tracking via JavaScript', 'statify' ); ?>
24
+ <small>(<?php esc_html_e( 'recommended if caching is in use', 'statify' ); ?>)</small>
25
+ </label>
26
+ <label for="statify_blacklist">
27
+ <input type="checkbox" name="statify[blacklist]" id="statify_blacklist" value="1" <?php checked( Statify::$_options['blacklist'], 1 ); ?> />
28
+ <?php esc_html_e( 'Skip tracking for referrers listed in the comment blacklist', 'statify' ); ?>
29
+ </label>
30
+ </fieldset>
31
+ <?php wp_nonce_field( 'statify-dashboard' ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
  <p class="meta-links">
34
+ <a href="<?php esc_html_e( 'https://wordpress.org/plugins/statify/', 'statify' ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Documentation', 'statify' ); ?></a>
35
+ &bull; <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8CH5FPR88QYML" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Donate', 'statify' ); ?></a>
36
+ &bull; <a href="https://wordpress.org/support/plugin/statify" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Support', 'statify' ); ?></a>
 
37
  </p>
views/widget_front.view.php CHANGED
@@ -1,79 +1,75 @@
1
  <?php
 
 
2
 
3
-
4
- /* Quit */
5
- class_exists('Statify') OR exit;
6
-
7
-
8
- /* Get stats */
9
  $stats = Statify_Dashboard::get_stats(); ?>
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- <div id="statify_chart">
13
- <?php if ( empty($stats['visits']) ) { ?>
14
- <p>
15
- <?php esc_html_e('No data available.', 'statify'); ?>
16
- </p>
17
- <?php } else { ?>
18
- <table id="statify_chart_data">
19
- <?php foreach( $stats['visits'] as $visit ) { ?>
20
- <tr>
21
- <th><?php echo date_i18n( get_option('date_format'), strtotime($visit['date']) ); ?></th>
22
- <td><?php echo intval($visit['count']); ?></td>
23
- </tr>
24
- <?php } ?>
25
- </table>
26
- <?php } ?>
27
- </div>
28
 
 
 
 
 
 
29
 
30
- <?php if ( ! empty($stats['target']) ) { ?>
31
- <div class="table target">
32
- <p class="sub">
33
- <?php esc_html_e('Top targets', 'statify'); ?>
34
- </p>
35
-
36
- <div>
37
- <table>
38
- <?php foreach( $stats['target'] as $target ) { ?>
39
- <tr>
40
- <td class="b">
41
- <?php echo intval($target['count']); ?>
42
- </td>
43
- <td class="t">
44
- <a href="<?php echo esc_url( home_url( $target['url'] ) ); ?>" target="_blank">
45
- <?php echo esc_html($target['url']); ?>
46
- </a>
47
- </td>
48
- </tr>
49
- <?php } ?>
50
- </table>
51
- </div>
52
- </div>
53
  <?php } ?>
54
 
55
 
56
- <?php if ( ! empty ($stats['referrer']) ) { ?>
57
- <div class="table referrer">
58
- <p class="sub">
59
- <?php esc_html_e('Top referers', 'statify'); ?>
60
- </p>
61
 
62
- <div>
63
- <table>
64
- <?php foreach( $stats['referrer'] as $referrer ) { ?>
65
- <tr>
66
- <td class="b">
67
- <?php echo intval($referrer['count']); ?>
68
- </td>
69
- <td class="t">
70
- <a href="<?php echo esc_url($referrer['url']); ?>" target="_blank">
71
- <?php echo esc_html($referrer['host']); ?>
72
- </a>
73
- </td>
74
- </tr>
75
- <?php } ?>
76
- </table>
77
- </div>
78
- </div>
79
- <?php } ?>
1
  <?php
2
+ /** Quit */
3
+ class_exists( 'Statify' ) || exit;
4
 
5
+ /** Get stats */
 
 
 
 
 
6
  $stats = Statify_Dashboard::get_stats(); ?>
7
 
8
+ <div id="statify_chart">
9
+ <?php if ( empty( $stats['visits'] ) ) { ?>
10
+ <p>
11
+ <?php esc_html_e( 'No data available.', 'statify' ); ?>
12
+ </p>
13
+ <?php } else { ?>
14
+ <table id="statify_chart_data">
15
+ <?php foreach ( (array) $stats['visits'] as $visit ) { ?>
16
+ <tr>
17
+ <th><?php echo date_i18n( get_option( 'date_format' ), strtotime( $visit['date'] ) ); ?></th>
18
+ <td><?php echo (int) $visit['count']; ?></td>
19
+ </tr>
20
+ <?php } ?>
21
+ </table>
22
+ <?php } ?>
23
+ </div>
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ <?php if ( ! empty( $stats['target'] ) ) { ?>
27
+ <div class="table target">
28
+ <p class="sub">
29
+ <?php esc_html_e( 'Top targets', 'statify' ); ?>
30
+ </p>
31
 
32
+ <div>
33
+ <table>
34
+ <?php foreach ( (array) $stats['target'] as $target ) { ?>
35
+ <tr>
36
+ <td class="b">
37
+ <?php echo (int) $target['count']; ?>
38
+ </td>
39
+ <td class="t">
40
+ <a href="<?php echo esc_url( home_url( $target['url'] ) ); ?>" target="_blank" rel="noopener noreferrer">
41
+ <?php echo esc_html( $target['url'] ); ?>
42
+ </a>
43
+ </td>
44
+ </tr>
45
+ <?php } ?>
46
+ </table>
47
+ </div>
48
+ </div>
 
 
 
 
 
 
49
  <?php } ?>
50
 
51
 
52
+ <?php if ( ! empty( $stats['referrer'] ) ) { ?>
53
+ <div class="table referrer">
54
+ <p class="sub">
55
+ <?php esc_html_e( 'Top referers', 'statify' ); ?>
56
+ </p>
57
 
58
+ <div>
59
+ <table>
60
+ <?php foreach ( (array) $stats['referrer'] as $referrer ) { ?>
61
+ <tr>
62
+ <td class="b">
63
+ <?php echo (int) $referrer['count']; ?>
64
+ </td>
65
+ <td class="t">
66
+ <a href="<?php echo esc_url( $referrer['url'] ); ?>" target="_blank" rel="noopener noreferrer">
67
+ <?php echo esc_html( $referrer['host'] ); ?>
68
+ </a>
69
+ </td>
70
+ </tr>
71
+ <?php } ?>
72
+ </table>
73
+ </div>
74
+ </div>
75
+ <?php } ?>