Slimstat Analytics - Version 4.7.6

Version Description

  • [Note] As we mentioned earlier, we've been working on streamlining and cleaning up our source code. It's incredible how layers of code can deposit on top of each other, until they form a thick layer that prevents developers from seeing clearly what's happening. It was time to apply some virtual citric acid to descale our code. If you're using any kind of server caching functionality, please make sure to clear your cache before opening a support request. Also, do not hesitate to reach out to us if you notice any strange or unusual behaviors.
  • [New] You can now download the geolocation map as a PDF file or PNG image. Thank you, Steve, for suggesting this feature!
  • [New] You can now exclude pageviews by content type, like 404, taxonomy, search, etc. Thank you, victor50g.
  • [Update] Deprecated the 'direction' filter, which was a leftover from over 5 years ago, when we used our old interface.
  • [Fix] The cron job to archive old records was not firing as expected under certain circumstances.
  • [Fix] Charts did not render correctly, if no data was available for that specific view.
Download this release

Release Info

Developer coolmann
Plugin Icon 128x128 Slimstat Analytics
Version 4.7.6
Comparing to
See all releases

Code changes from version 4.7.5.3 to 4.7.6

README.md ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Slimstat Analytics
2
+ **Contributors:** coolmann
3
+ **Donate link:** https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BNJR5EZNY3W38
4
+ **Tags:** analytics, statistics, counter, tracking, reports, wassup, geolocation, online users, spider, tracker, pageviews, stats, maxmind, statistics, statpress, power stats, hit
5
+ Text Domain: wp-slimstat
6
+ **Requires at least:** 3.8
7
+ **Tested up to:** 4.9
8
+ **Stable tag:** 4.7.6
9
+
10
+
11
+ ## Description
12
+ The leading web analytics plugin for WordPress. Track returning customers and registered users, monitor Javascript events, detect intrusions, analyze email campaigns. Thousands of WordPress sites are already using it.
13
+
14
+
15
+ ### Feature Spotlight
16
+ [youtube https://www.youtube.com/watch?v=zEKP9yC8x6g]
17
+
18
+
19
+ ### Main features
20
+ * Get access to real-time access log, measure server latency, track page events, keep an eye on your bounce rate and much more.
21
+ * Add shortcodes to your website to display reports in widgets or directly in posts and pages.
22
+ * Exclude users from statistics collection based on various criteria, including; user roles, common robots, IP subnets, admin pages, country, etc.
23
+ * Export your reports to CSV, generate user heatmaps or get daily emails right in your mailbox (via premium add-ons).
24
+ * Compatible with W3 Total Cache, WP SuperCache, CloudFlare and most caching plugins.
25
+ * Support for hashing IP addresses in the database to protect your users privacy.
26
+ * Accurate IP geolocation, browser and platform detection (courtesy of [MaxMind](http://www.maxmind.com/) and [Browscap](http://browscap.org)).
27
+ * World Map that works on your mobile device, too (courtesy of [amMap](http://www.ammap.com/)).
28
+
29
+
30
+ ### Premium Add-ons
31
+ Visit [our website](http://www.wp-slimstat.com/addons/) for a list of available extensions.
32
+
33
+
34
+ ### Social Media
35
+ [Like Us](https://www.facebook.com/slimstatistics/) on Facebook and [follow us](https://twitter.com/wp_stats) on Twitter to get the latest news and updates about our plugin.
36
+
37
+
38
+ ### Translations
39
+ Slimstat is available in multiple languages: English, Belarusian (UStarCash), Chinese (沐熙工作室), Farsi, French (Michael Bastin, Jean-Michel Venet, Yves Pouplard, Henrick Kac), German (TechnoViel), Indonesian ([ChameleonJohn](https://www.chameleonjohn.com/)), Italian ([Slimstat Dev Team](https://www.wp-slimstat.com)), Japanese (h_a_l_f), Portuguese, Russian (Vitaly), Spanish ([WebHostingHub](http://www.webhostinghub.com/)), Swedish (Per Soderman) and Turkish (Seyit Mehmet Çoban). Is your language missing or incomplete? [Contact us](http://support.wp-slimstat.com/) today.
40
+
41
+
42
+ ### Reviews and Feedback
43
+ * This is by far the most accurate and in-depth tracking plugin I've encountered for WordPress [MiMango](https://wordpress.org/support/topic/excellent-plugin-and-service-9)
44
+ * I have been relying on SlimStat to not only track all traffic to my sites accurately but also to present the stats in very useful graphic format [JJD3](https://wordpress.org/support/topic/an-essential-plugin-14)
45
+ * Thanks you for such an excellent plugin. I am using it to kick Jetpack out of all the wordpress installations that I manage for myself and others - [robertwagnervt](http://wordpress.org/support/topic/plugin-wp-slimstat-excellent-but-some-errors-on-activating)
46
+ * I like Slimstat very much and so I decided to use it instead of Piwik - [Joannes](http://wordpress.org/support/topic/plugin-wp-slimstat-slimstat-and-privacy)
47
+ * Read all the [reviews](http://wordpress.org/support/view/plugin-reviews/wp-slimstat) and feel free to post your own!
48
+
49
+
50
+ ### Requirements
51
+ * WordPress 3.8+
52
+ * PHP 5.2+ (or 5.5+ if you use the Browscap data file)
53
+ * MySQL 5.0.3+
54
+ * At least 20 MB of free web space
55
+ * At least 5 MB of free DB space
56
+ * At least 32 Mb of free PHP memory for the tracker (peak memory usage)
57
+ * IE9+ or any browser supporting HTML5, to access the reports
58
+
59
+
60
+ ## Installation
61
+ 1. In your WordPress admin, go to Plugins > Add New
62
+ 2. Search for WP Slimstat Analytics
63
+ 3. Click on **Install Now** under WP Slimstat Analytics and then activate the plugin
64
+ 4. Make sure your template calls `wp_footer()` or the equivalent hook somewhere (possibly just before the `</body>` tag)
65
+ 5. Go to Slimstat > Settings > Maintenance tab > MaxMind IP to Country section and click on "Install GeoLite DB" to detect your visitors' countries based on their IP addresses
66
+ 6. If your `wp-admin` folder is not publicly accessible, make sure to check the [FAQs](http://wordpress.org/extend/plugins/wp-slimstat/faq/) to see if there's anything else you need to do
67
+
68
+
69
+ ## Please note
70
+ * If you decide to uninstall Slimstat Analytics, all the stats will be **PERMANENTLY** deleted from your database. Make sure to setup a database backup (wp_slim_*) to avoid losing your data.
71
+ * If you are upgrading from a version prior to 4.0, please install version 4.0 first to upgrade the database structure and download the new Geolocation data.
72
+
73
+
74
+ ## Frequently Asked Questions
75
+ Our knowledge base is available on our [support center](http://docs.wp-slimstat.com/) website.
76
+
77
+
78
+ ## Screenshots
79
+ ### 1. **Overview** - Your website traffic at a glance
80
+ [missing image]
81
+
82
+ ### 2. **Activity Log** - A real-time view of your visitors' whereabouts
83
+ [missing image]
84
+
85
+ ### 3. **Settings** - Plenty of options to customize the plugin's behavior
86
+ [missing image]
87
+
88
+ ### 4. **Interactive World Map** - See where your visitors are coming from
89
+ [missing image]
90
+
91
+ ### 5. **Responsive layout** - Keep an eye on your reports on the go
92
+ [missing image]
93
+
94
+
95
+
96
+ ## Changelog
97
+
98
+ ### 4.7.6
99
+ * [Note] As we mentioned earlier, we've been working on streamlining and cleaning up our source code. It's incredible how layers of code can deposit on top of each other, until they form a thick layer that prevents developers from seeing clearly what's happening. It was time to apply some virtual citric acid to descale our code. If you're using any kind of server caching functionality, please make sure to clear your cache before opening a support request. Also, do not hesitate to reach out to us if you notice any strange or unusual behaviors.
100
+ * [New] You can now download the geolocation map as a PDF file or PNG image. Thank you, Steve, for suggesting this feature!
101
+ * [New] You can now exclude pageviews by content type, like 404, taxonomy, search, etc. Thank you, [victor50g](https://wordpress.org/support/topic/suggestion-enable-filtering-on-content-404/).
102
+ * [Update] Deprecated the 'direction' filter, which was a leftover from over 5 years ago, when we used our old interface.
103
+ * [Fix] The cron job to archive old records was not firing as expected under certain circumstances.
104
+ * [Fix] Charts did not render correctly, if no data was available for that specific view.
105
+
106
+
107
+ ### 4.7.5.3
108
+ * [New] For those who can't manage to automatically update their local copy of our premium add-ons, we've added a link to manually download the zip file. You'll find it under the Plugins screen, once you've entered and saved the corresponding license key under Slimstat > Add-ons.
109
+ * [Update] The [Update Checker](https://github.com/YahnisElsts/plugin-update-checker) library has been updated to version 4.4.
110
+ * [Fix] The world map was not being displayed correctly if no data points were available for the selected time range (thank you, Michel).
111
+
112
+
113
+ ### 4.7.5.2
114
+ * [Update] You can now customize the amount of dots displayed on the World Map, under Slimstat > Settings > Reports > Access Log and World Map. Thank you, [service4](https://wordpress.org/support/topic/new-geolocation-map-with-cities/).
115
+ * [Fix] A dependency error was being highlighted for one of our premium add-ons under certain circumstances. Thank you, Peter.
116
+ * [Fix] The option to not set the session cookie was not working as expected. Thank you, [Bjarne](https://wordpress.org/support/topic/disable-cookies-2/#post-9887099).
117
+
118
+
119
+ ### 4.7.5.1
120
+ * [Update] Implemented a workaround to try and fix the "Forbidden" error that a few users are experiencing when trying to download the MaxMind Geolite2 data file.
121
+ * [Fix] Updated the link to manually download the MaxMind data file from their servers, and added a new page to our knowledge base to explain how to manually install it.
122
+
123
+
124
+ ### 4.7.5
125
+ * [New] Now that Slimstat is capable of geolocating visitors at the city level, wouldn't it make sense to display those visitors on the map? Well, of course! Go check out this new feature by accessing the Geolocation tab in Slimstat.
126
+ * [New] Updated the tracking script to handle events triggered by external libraries, like the [Vimeo API](https://github.com/vimeo/player.js/#events). Thank you, Max.
127
+ * [New] Added new operator "included_in_set", which allows you to list multiple values to match against, when composing a shortcode.
128
+ * [New] Added new option to avoid that Slimstat assigns a COOKIE to your visitors. Thank you, [dragon013](https://wordpress.org/support/topic/disable-cookies-2/).
129
+ * [Fix] A bug was preventing the feature to "restrict users" to only see their reports from working as expected.
130
+
131
+
132
+ ### 4.7.4.1
133
+ * [Update] The Browscap data file is now loaded only when needed, thus removing its inherent overhead when unnecessary.
134
+ * [Update] The Browscap data file has been updated to the latest version available on their repository (ver 6026).
135
+ * [Fix] Addressed a remote XSS Vulnerability responsibly disclosed by one of our customers. Thank you, [riscybusiness](https://wordpress.org/support/topic/security-vulnerability-affecting-slimstat/).
136
+ * [Fix] Reintroduced the WHOIS pin, which has been removed by mistake because of a regression bug. Thank you, [brachialis](https://wordpress.org/support/topic/whois-location-icon-disappear/).
137
+
138
+
139
+ ### 4.7.4
140
+ * [Update] New fields added to the Email Report and Export to Excel add-ons, by extending how certain reports are defined in core.
141
+ * [Fix] The [false positive](https://www.virustotal.com/#/file/43f69d9c4028f857b5b5544ea4559c03b4d58e02d75617482db517c626164363/detection) alert related to a virus in our code was fixed by updating [AmChart](https://www.amcharts.com/) to the latest version available (thank you, Sasa).
142
+ * [Fix] Removed a PHP warning of undefined index (thank you, [slewis1000 and Sasa](https://wordpress.org/support/topic/php-notice-undefined-index-country/))
143
+ * [Fix] The MozScape report was causing connectivity issues for some users, and it is now set as "hidden" by default.
144
+ * [Fix] Regression bug related to our Export to Excel add-on.
145
+
146
+
147
+ ### 4.7.3.1
148
+ * [Fix] Apparently more people than we initially thought have issues with the MaxMind data file not being saved as expected. We are introducing a temporary fix while we try to investigate this issue further.
149
+
150
+
151
+ ### 4.7.3
152
+ * [Fix] A [few users](https://wordpress.org/support/topic/cannot-install-maxmind-geolite-db/) pointed out a weird behavior when installing the MaxMind Geolocation data file, where an empty folder would be created instead of the actual file. If you still experience issues related to this problem, please make sure to delete the empty folder "maxmind.mmdb" under `wp-content/uploads/wp-slimstat/`.
153
+ * [Fix] Apparently Microsoft Security Essentials [was not pleased with our code](https://wordpress.org/support/topic/trojandownloader097m-donoff-detected-in-archive/), and was returning a false positive alert that a virus was included with the source code (thank you, Sasa).
154
+ * [Fix] The "content_id" filter could not be used in a shortcode to reference other pages (i.e. `[slimstat f='count-all' w='id']content_id equals 2012[/slimstat]`). Thank you, Felipe.
155
+ * [Fix] Country flags were not being displayed properly under certain circumstances (thank you, [Catmaniax](https://wordpress.org/support/topic/minor-issue-missing-png-file/)).
156
+ * [Fix] Bug preventing the new Heatmap Add-on from working as expected.
157
+
158
+
159
+ ### 4.7.2.2
160
+ * [New] Added support for SCRIPT_DEBUG: by defining this constant in your `wp-config.php` will make Slimstat load the unminified version of the javascript tracker (thank you, Sasa)
161
+ * [Update] Added new parameter to make the `admin-ajax.php` URL relative, to solve issues like [this one](https://wordpress.org/support/topic/xmlhttprequest-cannot-load-wp-adminadmin-ajax-php-3/).
162
+ * [Fix] The Network Settings premium add-on was not working because of a bug in the main plugin. Thank you, Steve, for pointing us into the right direction.
163
+ * [Fix] Updated the schema (columns) for the archive table.
164
+
165
+
166
+
167
+ ### 4.7.2.1
168
+ * [Fix] The new table columns "location" and "city" were not being created on a fresh install (thank you, [nielsgoossens](https://wordpress.org/support/topic/no-data-anymore-2/#post-9491034))
169
+ * [Fix] Async mode was not working as expected (thank you, [keithgbcc](https://wordpress.org/support/topic/doesnt-work-1694/#post-9487448))
170
+
171
+
172
+ ### 4.7.2
173
+ * [New] As those who have been using Slimstat for a while know, we never stop doing our good share of research and development to improve our plugin. One feature on our wishlist was to make the geolocation functionality more accurate. Specifically, users have been asking us to track not just the Country of origin, but possibly the state and city. In order to geolocate visitors, our code has been leveraging a third-party data file provided by [MaxMind.com](https://www.maxmind.com/en/home). A while ago, they launched a new data format, which improves performance and offers a way to quickly determine the city of origin. However, the new library required a higher version of PHP, and up until now we had been hesitant to adopt it, to allow more people to use our plugin, over the chance of offering this feature. Now, after spending some time combing through their code, we found a way to get the best of both worlds: by customizing their PHP library, we were able to make it work with PHP 5.3! Which means that now Slimstat is able to tell you your visitors' city of origin (and State, when applicable) right out of the box. This information is available in the Access Log report and in a new 'Top Cities' report under the Audience tab. Please note: the MaxMind data file to enable this feature is approximately 60 Mb, and for this reason <strong>this new functionality is not enabled by default</strong>. You must go to Slimstat > Settings > Tracker and turn on the corresponding option. Then go to Slimstat > Settings > Maintenance and uninstall/install the GeoLite file to download the one that contains the city data. Please feel free to contact us if you have any questions.
174
+ * [Update] Removed backward compatibility code for those updating from a version prior to 4.2. Hopefully most of our users are using a newer version that that. If you're not, please contact our support service for instructions on how to upgrade.
175
+ * [Update] The format used to save your settings in the database has been changed. You MUST update your premium add-ons as soon as possible, and get the version compatible with this new format, or you might notice unexpected behaviors. Please contact us if you experience difficulties updating your add-ons.
176
+ * [Update] Cleaned up some old CSS code affecting the reports.
177
+
178
+
179
+ ### 4.7.1
180
+ * [Fix] The new feature introduced in version 4.6.9.1 to allow our users to customize the default time range for the reports, had introduced a regression bug. Thank you to all our users who volunteered to test the bugfix.
181
+ * [Fix] A vulnerability has been disclosed by [Pluginvulnerabilities.com](pluginvulnerabilities.com): an attacker with admin credentials could leverage the import/export mechanism for the plugin's settings to inject some malicious code. We recommend that you upgrade to the latest version of Slimstat as soon as possible.
182
+ * [Fix] The new version of the [Add-on Update Checker library](https://github.com/YahnisElsts/plugin-update-checker), bundled with the previous release, was returning a fatal error under certain circumstances (thank you, Pepe).
183
+
184
+
185
+ ## Support Our Work
186
+ Slimstat Analytics is an open source project, dependent in large parts on donations. [This page](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BNJR5EZNY3W38)
187
+ is for those who want to donate money - be it once, be it regularly, be it a small or a big amount. Everything is set up for an easy donation process.
188
+ Try it out, you'll be amazed how good it feels! If you're on a tight budget, please consider writing [a review](https://wordpress.org/support/plugin/wp-slimstat/reviews/#new-post) for Slimstat as a token of appreciation for our hard work!
admin/config/index.php CHANGED
@@ -138,24 +138,25 @@ $settings = array(
138
  3 => array(
139
  'title' => __( 'Filters', 'wp-slimstat' ),
140
  'rows' => array(
141
- 'filters_header' => array('description' => __('Do not track settings','wp-slimstat'), 'type' => 'section_header'),
142
  'track_users' => array( 'description' => __( 'Track WP Users', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( 'Enable this option to track logged in users.', 'wp-slimstat' ) ),
143
- 'ignore_users' => array( 'description' => __( 'Blacklist by Username', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "List all the usernames you don't want to track. Please be aware that spaces are <em>not</em> ignored and that usernames are case sensitive. Wildcards: <code>*</code> matches 'any string, including the empty string', <code>!</code> matches 'any character'. For example, <code>user*</code> will match user12 and userfoo, <code>u*100</code> will match user100 and uber100, <code>user!0</code> will match user10 and user90.", 'wp-slimstat' ) ),
144
- 'ignore_ip' => array('description' => __('Blacklist by IP Address','wp-slimstat'), 'type' => 'textarea', 'long_description' => __("List all the IP addresses you don't want to track. Each network <strong>must</strong> be defined using the <a href='http://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing' target='_blank'>CIDR notation</a> (i.e. <em>192.168.0.0/24</em>). This filter applies both to the public IP and the originating IP, if available.",'wp-slimstat')),
145
- 'ignore_capabilities' => array('description' => __('Blacklist by Capability','wp-slimstat'), 'type' => 'textarea', 'long_description' => __("Users having at least one of the <a href='http://codex.wordpress.org/Roles_and_Capabilities' target='_new'>capabilities</a> listed here below will not be tracked. Capabilities are case-insensitive.",'wp-slimstat'), 'skip_update' => true),
146
-
147
- 'filters_categories_header' => array('description' => __('Profiling','wp-slimstat'), 'type' => 'section_header'),
148
- 'ignore_spammers' => array('description' => __('Ignore Spammers','wp-slimstat'), 'type' => 'toggle', 'long_description' => __("Enable this option if you don't want to track visits from users identified as spammers by third-party tools like Akismet. Pageviews generated by users whose comments are later marked as spam, will also be removed from the database.",'wp-slimstat')),
149
- 'ignore_bots' => array('description' => __('Ignore Bots','wp-slimstat'), 'type' => 'toggle', 'long_description' => __("Turn on this feature if you want to have the accuracy level of server-side tracking, but not the inconvenience of getting your database clogged with pageviews generated by crawlers, spiders, search engine bots, etc. Please note that in Client mode, bots are ignored regardless of this setting.",'wp-slimstat')),
150
- 'ignore_resources' => array('description' => __('Permalinks','wp-slimstat'), 'type' => 'textarea', 'long_description' => __("List all the URLs on your website that you don't want to track. Don't include the domain name: <em>/about, ?p=1</em>, etc. Wildcards: <code>*</code> matches 'any string, including the empty string', <code>!</code> matches 'any character'. For example, <code>/abou*</code> will match /about and /abound, <code>/abo*t</code> will match /aboundant and /about, <code>/abo!t</code> will match /about and /abort. Strings are case-insensitive.",'wp-slimstat')),
151
- 'ignore_countries' => array('description' => __('Countries','wp-slimstat'), 'type' => 'textarea', 'long_description' => __("Country codes (i.e.: <code>en-us, it, es</code>) that you don't want to track.",'wp-slimstat')),
152
- 'ignore_browsers' => array('description' => __('User Agents','wp-slimstat'), 'type' => 'textarea', 'long_description' => __("Browsers (user agents) you don't want to track. You can specify the browser's version adding a slash after the name (i.e. <em>Firefox/3.6</em>). Wildcards: <code>*</code> matches 'any string, including the empty string', <code>!</code> matches 'any character'. For example, <code>Chr*</code> will match Chrome and Chromium, <code>IE/!.0</code> will match IE/7.0 and IE/8.0. Strings are case-insensitive.",'wp-slimstat')),
153
- 'ignore_platforms' => array('description' => __('Operating Systems','wp-slimstat'), 'type' => 'textarea', 'long_description' => __("Operating system codes you don't want to track. Please refer to <a href='https://slimstat.freshdesk.com/solution/articles/12000031504-what-are-the-operating-system-codes-used-by-slimstat-' target='_blank'>this page</a> in our knowledge base to learn more about what codes you can use. Usual rules for using wildcards apply (see fields here above).",'wp-slimstat')),
154
- 'ignore_referers' => array('description' => __('Referring Sites','wp-slimstat'), 'type' => 'textarea', 'long_description' => __("Referring URLs that you don't want to track: <code>http://mysite.com*</code>, <code>*/ignore-me-please</code>, etc. Wildcards: <code>*</code> matches 'any string, including the empty string', <code>!</code> matches 'any character'. Strings are case-insensitive. Please include either a wildcard or the protocol you want to filter (http://, https://).",'wp-slimstat')),
155
-
156
- 'filters_miscellaneous_header' => array('description' => __('Miscellaneous','wp-slimstat'), 'type' => 'section_header'),
157
- 'anonymize_ip' => array('description' => __('Enable Privacy Mode','wp-slimstat'), 'type' => 'toggle', 'long_description' => __("Mask your visitors' IP addresses to comply with European Privacy Laws.",'wp-slimstat')),
158
- 'ignore_prefetch' => array('description' => __('Ignore Prefetch Requests','wp-slimstat'), 'type' => 'toggle', 'long_description' => __("Prevent Slimstat from tracking pageviews generated by Firefox's <a href='https://developer.mozilla.org/en/Link_prefetching_FAQ' target='_blank'>Link Prefetching functionality</a>.",'wp-slimstat'))
 
159
  )
160
  ),
161
 
138
  3 => array(
139
  'title' => __( 'Filters', 'wp-slimstat' ),
140
  'rows' => array(
141
+ 'filters_categories_header' => array( 'description' => __( 'Profiling', 'wp-slimstat' ), 'type' => 'section_header' ),
142
  'track_users' => array( 'description' => __( 'Track WP Users', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( 'Enable this option to track logged in users.', 'wp-slimstat' ) ),
143
+ 'ignore_spammers' => array( 'description' => __( 'Ignore Spammers', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( "Enable this option if you don't want to track visits from users identified as spammers by third-party tools like Akismet. Pageviews generated by users whose comments are later marked as spam, will also be removed from the database.", 'wp-slimstat' ) ),
144
+ 'ignore_bots' => array( 'description' => __( 'Ignore Bots', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( "Turn on this feature if you want to have the accuracy level of server-side tracking, but not the inconvenience of getting your database clogged with pageviews generated by crawlers, spiders, search engine bots, etc. Please note that in Client mode, bots are ignored regardless of this setting.", 'wp-slimstat' ) ),
145
+ 'ignore_prefetch' => array( 'description' => __( 'Ignore Prefetch Requests', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( "Prevent Slimstat from tracking pageviews generated by Firefox's <a href='https://developer.mozilla.org/en/Link_prefetching_FAQ' target='_blank'>Link Prefetching functionality</a>.", 'wp-slimstat' ) ),
146
+ 'anonymize_ip' => array( 'description' => __( 'Enable Privacy Mode', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( "Mask your visitors' IP addresses to comply with European Privacy Laws.", 'wp-slimstat' ) ),
147
+
148
+ 'filters_users_header' => array( 'description' => __( 'User Properties', 'wp-slimstat' ), 'type' => 'section_header' ),
149
+ 'ignore_users' => array( 'description' => __( 'Usernames', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "List all the usernames you don't want to track. Please be aware that spaces are <em>not</em> ignored and that usernames are case sensitive. Wildcards: <code>*</code> matches 'any string, including the empty string', <code>!</code> matches 'any character'. For example, <code>user*</code> will match user12 and userfoo, <code>u*100</code> will match user100 and uber100, <code>user!0</code> will match user10 and user90.", 'wp-slimstat' ) ),
150
+ 'ignore_ip' => array( 'description' => __( 'IP Addresses', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "List all the IP addresses you don't want to track. Each subnet <strong>must</strong> be defined using the <a href='https://www.iplocation.net/subnet-mask' target='_blank'>CIDR notation</a> (i.e. <em>192.168.0.0/24</em>). This filter applies both to the public IP and the originating IP, if available. Feel free to use an online <a href='https://www.iplocation.net/subnet-calculator' target='_blank'>subnet calculator</a> to help you determine the mask you need.", 'wp-slimstat' ) ),
151
+ 'ignore_countries' => array( 'description' => __( 'Countries', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "Country codes (i.e.: <code>en-us, it, es</code>) that you don't want to track.", 'wp-slimstat' ) ),
152
+ 'ignore_browsers' => array('description' => __( 'User Agents', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "Browsers (user agents) you don't want to track. You can specify the browser's version adding a slash after the name (i.e. <em>Firefox/3.6</em>). Wildcards: <code>*</code> matches 'any string, including the empty string', <code>!</code> matches 'any character'. For example, <code>Chr*</code> will match Chrome and Chromium, <code>IE/!.0</code> will match IE/7.0 and IE/8.0. Strings are case-insensitive.", 'wp-slimstat' ) ),
153
+ 'ignore_platforms' => array( 'description' => __( 'Operating Systems', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "Operating system codes you don't want to track. Please refer to <a href='https://slimstat.freshdesk.com/solution/articles/12000031504-what-are-the-operating-system-codes-used-by-slimstat-' target='_blank'>this page</a> in our knowledge base to learn more about what codes you can use. Usual rules for using wildcards apply (see fields here above).", 'wp-slimstat' ) ),
154
+ 'ignore_capabilities' => array( 'description' => __( 'Capabilities', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "Users having at least one of the <a href='http://codex.wordpress.org/Roles_and_Capabilities' target='_new'>capabilities</a> listed here below will not be tracked. Capabilities are case-insensitive.", 'wp-slimstat' ), 'skip_update' => true ),
155
+
156
+ 'filters_pageview_header' => array( 'description' => __( 'Page Properties', 'wp-slimstat' ), 'type' => 'section_header' ),
157
+ 'ignore_resources' => array( 'description' => __( 'Permalinks', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "List all the URLs on your website that you don't want to track. Don't include the domain name: <em>/about, ?p=1</em>, etc. Wildcards: <code>*</code> matches 'any string, including the empty string', <code>!</code> matches 'any character'. For example, <code>/abou*</code> will match /about and /abound, <code>/abo*t</code> will match /aboundant and /about, <code>/abo!t</code> will match /about and /abort. Strings are case-insensitive.", 'wp-slimstat' ) ),
158
+ 'ignore_referers' => array( 'description' => __( 'Referring Sites', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "Referring URLs that you don't want to track: <code>http://mysite.com*</code>, <code>*/ignore-me-please</code>, etc. Wildcards: <code>*</code> matches 'any string, including the empty string', <code>!</code> matches 'any character'. Strings are case-insensitive. Please include either a wildcard or the protocol you want to filter (http://, https://).", 'wp-slimstat' ) ),
159
+ 'ignore_content_types' => array( 'description' => __( 'Content Types', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "Slimstat categorizes pageviews by the associated WordPress content type: post, page, attachment, tag, 404, taxonomy, author, archive, search, feed, login and others. You can use this field to avoid tracking pages whose content type matches the ones you set here below.", 'wp-slimstat' ) )
160
  )
161
  ),
162
 
admin/css/slimstat.css CHANGED
@@ -3,8 +3,8 @@
3
  outline: none;
4
  text-decoration: none;
5
  }
6
- [id^=slim_] a.slimstat-delete-entry{
7
- color: #bbb;
8
  }
9
  .slimstat-float-right{
10
  float: right;
@@ -72,7 +72,7 @@
72
  width: 450px;
73
  z-index: 120;
74
  }
75
- #slimstat-date-filters .dropdown a.slimstat-date-choice{
76
  background-color: #eee;
77
  display: block;
78
  float: left;
@@ -219,7 +219,7 @@
219
  padding: 0 !important;
220
  }
221
  .wrap.slimstat .postbox.tall .inside{
222
- height: 900px;
223
  }
224
  [id^=slim_] p {
225
  border-bottom: 1px solid #ddd;
3
  outline: none;
4
  text-decoration: none;
5
  }
6
+ [id^=slim_] a.slimstat-delete-entry:before{
7
+ color: #e22;
8
  }
9
  .slimstat-float-right{
10
  float: right;
72
  width: 450px;
73
  z-index: 120;
74
  }
75
+ #slimstat-date-filters .dropdown #slimstat-quick-filters a {
76
  background-color: #eee;
77
  display: block;
78
  float: left;
219
  padding: 0 !important;
220
  }
221
  .wrap.slimstat .postbox.tall .inside{
222
+ height: 650px;
223
  }
224
  [id^=slim_] p {
225
  border-bottom: 1px solid #ddd;
admin/images/datepicker.png CHANGED
Binary file
admin/js/slimstat.admin.js CHANGED
@@ -7,181 +7,86 @@ if ( typeof SlimStatAdminParams == 'undefined' ) {
7
  };
8
  }
9
 
10
- var SlimStatAdmin = {
11
- _refresh_timer: [0, 0],
12
-
13
- parse_url_filters: function(report_id, href){
14
- filters_parsed = [];
15
- filters_to_add = href.split('&');
16
- jQuery('#slimstat-filters-form').attr('action', filters_to_add[0]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- for (i in filters_to_add){
19
- if (filters_to_add[i].indexOf('fs\%5B') != 0) continue;
20
-
21
- filter_components = filters_to_add[i].split('=');
22
- filter_components[0] = decodeURIComponent(filter_components[0]);
23
- jQuery('input[name="'+filter_components[0]+'"]').remove();
24
 
25
- filters_parsed[filter_components[0]] = [report_id, filter_components[1].replace('+', ' ')];
26
- }
27
- return filters_parsed;
28
- },
29
 
30
- add_filters_to_form: function(filters_parsed, reset_existing_filters){
31
- if (reset_existing_filters){
32
- jQuery('.slimstat-post-filter').remove();
33
- }
34
-
35
- for (i in filters_parsed){
36
- if (jQuery.inArray(i, ['fs[minute]','fs[hour]','fs[day]','fs[month]','fs[year]','fs[interval_direction]','fs[interval]','fs[interval_hours]','fs[interval_minutes]']) == -1){
37
- jQuery('<input>').attr('type', 'hidden').attr('name', i).attr('class', 'slimstat-post-filter slimstat-temp-filter '+filters_parsed[i][0]).val(filters_parsed[i][1]).appendTo('#slimstat-filters-form');
38
- }
39
- else{
40
- field_id = i.replace('fs[', '#slimstat-filter-').replace(']', '');
41
- field_val = filters_parsed[i][1].split(' ');
42
- jQuery(field_id).val(field_val[1]);
43
  }
44
  }
45
- },
46
-
47
- remove_filters_from_form: function(filters_parsed){
48
- for (i in filters_parsed){
49
- jQuery('input[name="'+i.replace('[', '\\[').replace(']', '\\]')+'"]').remove();
50
- }
51
- },
52
 
53
- refresh_countdown: function() {
54
- SlimStatAdmin._refresh_timer[ 1 ]--;
55
- if (SlimStatAdmin._refresh_timer[ 1 ] == -1){
56
- SlimStatAdmin._refresh_timer[ 1 ] = 59;
57
- SlimStatAdmin._refresh_timer[ 0 ] = SlimStatAdmin._refresh_timer[ 0 ] - 1;
58
- }
59
- jQuery( '.refresh-timer' ).html( SlimStatAdmin._refresh_timer[ 0 ] + ':' + ( ( SlimStatAdmin._refresh_timer[ 1 ] < 10 ) ? '0' : '' ) + SlimStatAdmin._refresh_timer[ 1 ] );
60
- if ( SlimStatAdmin._refresh_timer[ 0 ] > 0 || SlimStatAdmin._refresh_timer[ 1 ] > 0 ) {
61
- refresh_handle = window.setTimeout( "SlimStatAdmin.refresh_countdown();", 1000 );
62
- }
63
- else {
64
- report_id = 'slim_p7_02';
65
- data = {action: 'slimstat_load_report', report_id: report_id, security: jQuery('#meta-box-order-nonce').val(), page: SlimStatAdmin.get_query_string_value( 'page' ) };
66
- jQuery('#'+report_id+' .inside').html('<p class="loading"><i class="slimstat-font-spin4 animate-spin"></i></p>');
67
- SlimStatAdmin.refresh_report(report_id, data);
68
-
69
- window.clearTimeout(refresh_handle);
70
- SlimStatAdmin._refresh_timer[ 0 ] = parseInt( SlimStatAdminParams.refresh_interval / 60 );
71
- SlimStatAdmin._refresh_timer[ 1 ] = SlimStatAdminParams.refresh_interval % 60;
72
- refresh_handle = window.setTimeout( "SlimStatAdmin.refresh_countdown();", 1000 );
73
- }
74
- },
75
-
76
- refresh_report: function( report_id, data ) {
77
- // Get the data from the hidden form
78
- filters_input = jQuery( '#slimstat-filters-form .slimstat-post-filter' ).toArray();
79
- for ( i in filters_input ) {
80
- data[ filters_input[ i ][ 'name' ] ] = filters_input[ i ][ 'value' ];
81
- }
82
-
83
- jQuery('#'+report_id+' .inside').html('<p class="loading"><i class="slimstat-font-spin4 animate-spin"></i></p>');
84
-
85
- jQuery.post(ajaxurl, data, function(response){
86
- if (report_id.indexOf('_01') > 0){
87
- jQuery('#'+report_id + ' .inside').html( response );
88
- }
89
- else{
90
- jQuery( '#' + report_id + ' .inside' ).fadeOut( 700, function() {
91
- jQuery( this ).html( response ).fadeIn( 700, function() {
92
- if ( jQuery( '.refresh-timer' ).length > 0 ) {
93
- if ( typeof refresh_handle !== 'undefined' ) {
94
- window.clearTimeout( refresh_handle );
95
- }
96
- SlimStatAdmin._refresh_timer[ 0 ] = parseInt( SlimStatAdminParams.refresh_interval / 60 );
97
- SlimStatAdmin._refresh_timer[ 1 ] = SlimStatAdminParams.refresh_interval % 60;
98
- refresh_handle = window.setTimeout( "SlimStatAdmin.refresh_countdown();", 1000 );
99
- }
100
- });
101
- });
102
- }
103
- });
104
 
105
- // Remove filters set by other Ajax buttons
106
- jQuery('.slimstat-temp-filter').remove();
 
 
 
107
 
108
- // if ( jQuery( '.refresh-timer' ).length > 0 ) {
109
- // SlimStatAdmin.refresh_countdown();
110
- // }
111
- },
112
-
113
- get_query_string_value: function( key ) {
114
- query_string = window.location.search.substring( 1 );
115
-
116
- // Split into key/value pairs
117
- pairs = query_string.split("&");
118
-
119
- // Convert the array of strings into an object
120
- for ( i in pairs ) {
121
- pair_array = pairs[i].split('=');
122
- if ( pair_array[ 0 ] == key ) {
123
- return pair_array[ 1 ];
124
- }
125
- }
126
-
127
- return '';
128
  }
129
- }
130
 
131
- jQuery(function(){
132
- // Refresh page every X seconds
133
- if ( SlimStatAdminParams.refresh_interval > 0 && jQuery( '.refresh-timer' ).length > 0 ) {
134
- SlimStatAdmin._refresh_timer[ 0 ] = parseInt( SlimStatAdminParams.refresh_interval / 60 );
135
- SlimStatAdmin._refresh_timer[ 1 ] = SlimStatAdminParams.refresh_interval % 60;
136
- refresh_handle = window.setTimeout( "SlimStatAdmin.refresh_countdown();", 1000 );
137
- }
138
 
139
- // Refresh report if (re)activated via the checkbox under Screen Options
140
- jQuery( 'input.hide-postbox-tog[id^=slim_]' ).bind( 'click.postboxes', function () {
141
- if ( jQuery( this ).prop( "checked" ) && jQuery( '#' + jQuery( this ).val() ).length ) {
142
- var report_id = jQuery( this ).val();
143
- var data = { action: 'slimstat_load_report', report_id: report_id, security: jQuery( '#meta-box-order-nonce' ).val() }
144
- jQuery( '#' + report_id ).removeClass( 'hidden' );
145
- jQuery( '#' + report_id + ' .inside' ).html( '<p class="loading"></p>' );
146
- SlimStatAdmin.refresh_report( report_id, data );
147
- }
148
- });
149
-
150
- // Filters: add form markup to the Dashboard
151
- if ( !jQuery( '#slimstat-filters-form' ).length && !SlimStatAdmin.get_query_string_value( 'page' ).match( /(slimconfig|slimaddons)/ ) ) {
152
- jQuery( '<form id="slimstat-filters-form" method="post"/>' ).appendTo('body');
153
- }
154
 
155
- // Filters: Lock value input field based on operator drop down selection
156
- jQuery('#slimstat-filter-operator').change(function(){
157
- if (this.value=='is_empty'||this.value=='is_not_empty'){
158
- jQuery('#slimstat-filter-value').attr('readonly', 'readonly');
159
  }
160
- else{
161
- jQuery('#slimstat-filter-value').removeAttr('readonly');
162
  }
163
- });
164
-
165
- // Filters: empty on focus
166
- jQuery('.empty-on-focus').focus(function(){
167
- if (this.value == this.defaultValue) this.value = '';
168
- });
169
- jQuery('.empty-on-focus').blur(function(){
170
- if (this.value == '') this.value = this.defaultValue;
171
- });
172
 
173
- // Show/Hide Date Dropdown Filters
174
- jQuery('#slimstat-date-filters a').click(function(e){
175
  e.preventDefault();
176
- jQuery('#slimstat-date-filters .dropdown').slideToggle(300);
177
- jQuery(this).toggleClass('open');
178
- }).children().click(function(){
179
- return false;
180
- });
181
-
182
- // Date Filters: Datepicker
183
- if (typeof jQuery('.slimstat-filter-date').datepicker == 'function'){
184
- jQuery('.slimstat-filter-date').datepicker({
185
  buttonImage: SlimStatAdminParams.datepicker_image,
186
  buttonImageOnly: true,
187
  changeMonth: true,
@@ -191,78 +96,186 @@ jQuery(function(){
191
  nextText: '&raquo;',
192
  prevText: '&laquo;',
193
  showOn: 'both',
194
-
195
- onClose: function(dateText, inst) {
196
- if (!dateText.length) return true;
197
- jQuery('#slimstat-filter-day').val( dateText.split('-')[2] );
198
- jQuery('#slimstat-filter-month').val( dateText.split('-')[1] );
199
- jQuery('#slimstat-filter-year').val( dateText.split('-')[0] );
 
200
  }
201
- });
202
  }
203
 
204
- // Filters: Remove selected when X is clicked
205
- jQuery('a.slimstat-remove-filter').click(function(e){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  e.preventDefault();
 
 
 
 
 
 
 
 
207
 
208
- filters_to_remove = SlimStatAdmin.parse_url_filters('p0', jQuery(this).attr('href'));
209
- SlimStatAdmin.remove_filters_from_form(filters_to_remove);
 
 
 
 
 
 
210
 
211
- jQuery( '#slimstat-filters-form' ).submit();
212
- jQuery( '.slimstat-temp-filter' ).remove();
213
- return false;
214
- });
 
 
 
 
 
 
 
215
 
216
- // Send filters as post requests
217
- if ( jQuery( '#slimstat-filters-form' ).length ) {
 
 
 
 
 
 
218
  jQuery( document ).on( 'click', '.slimstat-filter-link, #toplevel_page_slimview1 a, #wp-admin-bar-slimstat-header li a', function( e ) {
 
 
 
 
 
 
 
219
  e.preventDefault();
220
 
221
- filters_parsed = SlimStatAdmin.parse_url_filters( 'p0', jQuery( this ).attr( 'href' ) );
222
- SlimStatAdmin.add_filters_to_form(filters_parsed, (typeof jQuery(this).attr('data-reset-filters') != 'undefined'));
 
 
 
223
 
224
- jQuery('#slimstat-filters-form').submit();
225
- jQuery('.slimstat-temp-filter').remove();
226
  return false;
227
  });
228
  }
229
 
230
- // Behavior associated to all the 'ajax-based' buttons
231
- jQuery(document).on('click', '[id^=slim_] .button-ajax', function(e){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  e.preventDefault();
233
- report_id = jQuery(this).parents('.postbox').attr('id');
234
-
235
- if (typeof jQuery(this).attr('href') != 'undefined'){
236
- filters_parsed = SlimStatAdmin.parse_url_filters(report_id, jQuery(this).attr('href'));
237
- SlimStatAdmin.add_filters_to_form(filters_parsed);
238
-
239
- // Remember the new filter for when the report is refreshed
240
- if (typeof filters_parsed['fs[start_from]'] != 'undefined' && jQuery('#'+report_id+' .refresh').length){
241
- href = jQuery('#'+report_id+' .refresh').attr('href');
242
- href_clean = href.substring(0, href.indexOf('&fs%5Bstart_from'));
243
- if (href_clean != '') href = href_clean;
244
- jQuery('#'+report_id+' .refresh').attr('href', href+'&fs%5Bstart_from%5D='+filters_parsed['fs[start_from]']);
245
- }
246
- }
247
 
248
- data = {action: 'slimstat_load_report', report_id: report_id, security: jQuery('#meta-box-order-nonce').val(), page: SlimStatAdmin.get_query_string_value( 'page' ) };
249
- SlimStatAdmin.refresh_report(report_id, data);
250
-
251
- jQuery('#'+report_id+' .inside').slimScroll({scrollTo : '0px'});
 
 
 
 
 
 
 
 
 
 
 
252
 
253
- if ( typeof refresh_handle !== 'undefined' ) {
254
- window.clearTimeout( refresh_handle );
 
 
255
  }
 
 
 
 
 
 
256
  });
257
 
258
- // Asynchronous Reports
259
- if (SlimStatAdminParams.async_load == 'on'){
260
- jQuery('div[id^=slim_]').each(function(){
261
- report_id = jQuery(this).attr('id');
262
- data = {action: 'slimstat_load_report', report_id: report_id, security: jQuery('#meta-box-order-nonce').val(), current_tab: SlimStatAdminParams.current_tab}
263
- SlimStatAdmin.refresh_report(report_id, data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  });
265
- }
 
 
 
 
 
 
 
 
266
 
267
  // Hide a notice and send the corresponding ajax request to the server
268
  jQuery( document ).on( 'click', '[id^=slimstat-hide-]', function( e ) {
@@ -281,38 +294,21 @@ jQuery(function(){
281
  });
282
  });
283
 
284
- // Delete Pageview
285
- jQuery(document).on('click', '.slimstat-delete-entry', function(e){
286
- var target = jQuery(this);
287
 
288
- e.preventDefault();
289
- data = {action: 'slimstat_delete_pageview', security: jQuery('#meta-box-order-nonce').val(), pageview_id : target.attr('data-pageview-id')};
290
- jQuery.ajax({
291
- url: ajaxurl,
292
- type: 'post',
293
- async: true,
294
- data: data
295
- }).done(function(){
296
- target.parents('p').fadeOut(1000);
297
- });
298
- });
299
 
300
- // SlimScroll init
301
- jQuery('[id^=slim_]:not(.tall) .inside').slimScroll({
302
  distance: '2px',
303
  opacity: '0.15',
304
  size: '5px',
305
  wheelStep: 10
306
- });
307
- jQuery('[id^=slim_].tall .inside').slimScroll({
308
- distance: '2px',
309
- height: '630px',
310
- opacity: '0.15',
311
- size: '5px',
312
- wheelStep: 10
313
- });
314
 
315
- // ToolTips
316
  jQuery( document ).on( 'mouseover', '.slimstat-tooltip-trigger', function( e ) {
317
  if ( typeof jQuery( this ).attr( 'data-hasqtip' ) != 'undefined' ) {
318
  return true;
@@ -328,7 +324,7 @@ jQuery(function(){
328
  }
329
 
330
  if ( tooltip_content.length ) {
331
- jQuery(this).qtip({
332
  overwrite: false,
333
  content: {
334
  text: tooltip_content
@@ -338,155 +334,176 @@ jQuery(function(){
338
  ready: true
339
  },
340
  hide: {
341
- delay: 250,
342
- fixed: true
343
- },
344
  position: {
345
- my: 'bottom right', // Position my top left...
346
- at: 'top left',
347
  adjust: {
348
  x: 5
349
  },
350
- viewport: jQuery(window)
351
  },
352
  style: {
353
  classes: 'qtip-light'
354
  }
355
- }, e);
356
  }
357
- });
358
 
359
- // Modal Window / Overlay: Setup
360
- if (typeof jQuery('#slimstat-modal-dialog').dialog == 'function'){
361
- jQuery('#slimstat-modal-dialog').dialog({
362
  autoOpen: false,
363
  closeOnEscape: true,
364
  closeText: '',
365
  draggable: true,
366
  modal: true,
367
  open: function(){
368
- jQuery('.ui-widget-overlay,.close-dialog').bind('click',function(){
369
- jQuery('#slimstat-modal-dialog').dialog('close');
370
- });
371
  },
372
  position: { my: "top center" },
373
  resizable: false
374
- });
375
  }
376
 
377
- // Modal Window / Whois
378
- jQuery( document ).on( 'click', '.whois', function( e ) {
379
- e.preventDefault();
 
 
 
 
380
 
381
- // If admin is using HTTPS and IP lookup service is not, open a new window/tab, instead of an overlay dialog
382
- if ( document.location.href.substr( 0, document.location.href.indexOf( "://" ) ).toLowerCase() == 'https' && jQuery( this ).attr( 'href' ).substr( 0, jQuery( this ).attr( 'href' ).indexOf( "://" ) ).toLowerCase() == 'http' ) {
383
- window.open( jQuery( this ).attr( 'href' ), '_blank' );
384
- return -1;
 
 
 
 
 
 
 
 
 
 
 
 
 
385
  }
386
-
387
- jQuery('#slimstat-modal-dialog').dialog({
388
- dialogClass: 'slimstat',
389
- title: jQuery(this).attr('title')
390
- }).html('<iframe id="ip2location" src="'+jQuery(this).attr('href')+'" width="100%" height="600"></iframe>');
391
- jQuery('#slimstat-modal-dialog').dialog('open');
392
- });
393
 
394
- // Modal Window / Load & Save Filters
395
- jQuery(document).on('click', '#slimstat-load-saved-filters', function(e){
396
- e.preventDefault();
397
- var inner_html = '';
398
-
399
- data = {action: 'slimstat_manage_filters', security: jQuery('#meta-box-order-nonce').val(), type: 'load', page: SlimStatAdmin.get_query_string_value( 'page' ) };
400
- jQuery.ajax({
401
- url: ajaxurl,
402
- type: 'post',
403
- async: false,
404
- data: data,
405
- success: function(response){
406
- inner_html = response;
 
 
 
 
 
 
 
 
 
 
 
 
 
407
  }
408
- });
409
-
410
- jQuery('#slimstat-modal-dialog').dialog({
411
- dialogClass: 'slimstat',
412
- title: jQuery(this).attr('title')
413
- }).html(inner_html);
414
- jQuery('#slimstat-modal-dialog').dialog('open');
415
- });
416
 
417
- // Save Filters
418
- jQuery(document).on('click', '#slimstat-save-filter', function(e){
419
- e.preventDefault();
420
-
421
- data = {action: 'slimstat_manage_filters', security: jQuery('#meta-box-order-nonce').val(), type: 'save', filter_array: jQuery(this).attr('data-filter-array')};
422
- jQuery.ajax({
423
- url: ajaxurl,
424
- type: 'post',
425
- async: false,
426
- data: data,
427
- success: function(response){
428
- jQuery('#slimstat-save-filter').text(response).fadeOut(1500);
429
  }
430
- });
431
- });
432
 
433
- // Delete saved filters
434
- jQuery(document).on('click', '.slimstat-delete-filter', function(e){
435
- e.preventDefault();
436
 
437
- data = {action: 'slimstat_manage_filters', security: jQuery('#meta-box-order-nonce').val(), type: 'delete', filter_id: jQuery(this).attr('data-filter-id'), page: SlimStatAdmin.get_query_string_value( 'page' ) };
438
- jQuery.ajax({
439
- url: ajaxurl,
440
- type: 'post',
441
- async: false,
442
- data: data,
443
- success: function(response){
444
- jQuery('#slim_filters_overlay').parent().html(response);
 
445
  }
446
- });
447
- });
448
 
449
- // Customizer: clone and delete report placeholders
450
- jQuery( '.slimstat-layout .slimstat-header-buttons a' ).on( 'click', function() {
451
- if ( jQuery( this ).hasClass( 'slimstat-font-docs') ) {
452
- jQuery( this ).removeClass( 'slimstat-font-docs' ).addClass( 'slimstat-font-trash' ).parents( '.postbox' ).clone(true).appendTo( jQuery( this ).parents( '.meta-box-sortables' ) );
453
- jQuery( this ).removeClass( 'slimstat-font-trash' ).addClass( 'slimstat-font-docs' );
454
  }
455
- else if ( jQuery( this ).hasClass( 'slimstat-font-minus-circled' ) ) {
456
- jQuery( this ).removeClass( 'slimstat-font-minus-circled' ).parents( '.postbox' ).appendTo( jQuery( '#postbox-container-inactive .meta-box-sortables' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
457
  }
 
458
  else {
459
- jQuery( this ).parents( '.postbox' ).remove();
460
- }
461
-
462
- // Save the new groups
463
- data = { action: 'meta-box-order', _ajax_nonce: jQuery('#meta-box-order-nonce').val(), page_columns: 0, page: 'slimstat_page_slimlayout' };
464
- jQuery( '.meta-box-sortables' ).each( function() {
465
- data[ 'order[' + this.id.split("-")[0] + ']' ] = jQuery( this ).sortable( 'toArray' ).join( ',' );
466
- });
467
 
468
- jQuery.ajax({
469
- url: ajaxurl,
470
- type: 'post',
471
- async: true,
472
- data: data
473
- });
474
 
475
- return false;
476
- });
 
 
 
 
477
 
478
- // Config toggles
479
- jQuery( 'input.slimstat-checkbox-toggle' ).not( '[data-switch-no-init]' ).bootstrapSwitch();
480
- jQuery( 'label' ).click( function( e ) {
481
- target_id = '#' + jQuery( this ).attr( 'for' );
482
- if ( jQuery( target_id ).length && typeof jQuery( target_id ).attr( 'readonly' ) != 'undefined' ) {
483
- e.preventDefault();
484
  }
485
- } );
486
 
487
- // Config tag lists
488
- jQuery( 'textarea.slimstat-taglist' ).tagEditor({ forceLowercase: false });
489
- });
 
490
 
491
  /* SlimScroll v1.3.8 | http://rocha.la | Copyright (c) 2011 Piotr Rochala. Released under the MIT and GPL licenses. */
492
  !function(e){e.fn.extend({slimScroll:function(i){var s={width:"auto",size:"7px",color:"#000",position:"right",distance:"1px",start:"top",opacity:.4,alwaysVisible:!1,disableFadeOut:!1,railVisible:!1,railColor:"#333",railOpacity:.2,railDraggable:!0,railClass:"slimScrollRail",barClass:"slimScrollBar",wrapperClass:"slimScrollDiv",allowPageScroll:!1,wheelStep:20,touchScrollStep:200,borderRadius:"7px",railBorderRadius:"7px"},o=e.extend(s,i);return this.each(function(){function s(t){if(h){var t=t||window.event,i=0;t.wheelDelta&&(i=-t.wheelDelta/120),t.detail&&(i=t.detail/3);var s=t.target||t.srcTarget||t.srcElement;e(s).closest("."+o.wrapperClass).is(x.parent())&&r(i,!0),t.preventDefault&&!y&&t.preventDefault(),y||(t.returnValue=!1)}}function r(e,t,i){y=!1;var s=e,r=x.outerHeight()-D.outerHeight();if(t&&(s=parseInt(D.css("top"))+e*parseInt(o.wheelStep)/100*D.outerHeight(),s=Math.min(Math.max(s,0),r),s=e>0?Math.ceil(s):Math.floor(s),D.css({top:s+"px"})),v=parseInt(D.css("top"))/(x.outerHeight()-D.outerHeight()),s=v*(x[0].scrollHeight-x.outerHeight()),i){s=e;var a=s/x[0].scrollHeight*x.outerHeight();a=Math.min(Math.max(a,0),r),D.css({top:a+"px"})}x.scrollTop(s),x.trigger("slimscrolling",~~s),n(),c()}function a(e){window.addEventListener?(e.addEventListener("DOMMouseScroll",s,!1),e.addEventListener("mousewheel",s,!1)):document.attachEvent("onmousewheel",s)}function l(){f=Math.max(x.outerHeight()/x[0].scrollHeight*x.outerHeight(),m),D.css({height:f+"px"});var e=f==x.outerHeight()?"none":"block";D.css({display:e})}function n(){if(l(),clearTimeout(p),v==~~v){if(y=o.allowPageScroll,b!=v){var e=0==~~v?"top":"bottom";x.trigger("slimscroll",e)}}else y=!1;return b=v,f>=x.outerHeight()?void(y=!0):(D.stop(!0,!0).fadeIn("fast"),void(o.railVisible&&R.stop(!0,!0).fadeIn("fast")))}function c(){o.alwaysVisible||(p=setTimeout(function(){o.disableFadeOut&&h||u||d||(D.fadeOut("slow"),R.fadeOut("slow"))},1e3))}var h,u,d,p,g,f,v,b,w="<div></div>",m=30,y=!1,x=e(this);if(x.parent().hasClass(o.wrapperClass)){var C=x.scrollTop();if(D=x.siblings("."+o.barClass),R=x.siblings("."+o.railClass),l(),e.isPlainObject(i)){if("height"in i&&"auto"==i.height){x.parent().css("height","auto"),x.css("height","auto");var H=x.parent().parent().height();x.parent().css("height",H),x.css("height",H)}else if("height"in i){var S=i.height;x.parent().css("height",S),x.css("height",S)}if("scrollTo"in i)C=parseInt(o.scrollTo);else if("scrollBy"in i)C+=parseInt(o.scrollBy);else if("destroy"in i)return D.remove(),R.remove(),void x.unwrap();r(C,!1,!0)}}else if(!(e.isPlainObject(i)&&"destroy"in i)){o.height="auto"==o.height?x.parent().height():o.height;var E=e(w).addClass(o.wrapperClass).css({position:"relative",overflow:"hidden",width:o.width,height:o.height});x.css({overflow:"hidden",width:o.width,height:o.height});var R=e(w).addClass(o.railClass).css({width:o.size,height:"100%",position:"absolute",top:0,display:o.alwaysVisible&&o.railVisible?"block":"none","border-radius":o.railBorderRadius,background:o.railColor,opacity:o.railOpacity,zIndex:90}),D=e(w).addClass(o.barClass).css({background:o.color,width:o.size,position:"absolute",top:0,opacity:o.opacity,display:o.alwaysVisible?"block":"none","border-radius":o.borderRadius,BorderRadius:o.borderRadius,MozBorderRadius:o.borderRadius,WebkitBorderRadius:o.borderRadius,zIndex:99}),M="right"==o.position?{right:o.distance}:{left:o.distance};R.css(M),D.css(M),x.wrap(E),x.parent().append(D),x.parent().append(R),o.railDraggable&&D.bind("mousedown",function(i){var s=e(document);return d=!0,t=parseFloat(D.css("top")),pageY=i.pageY,s.bind("mousemove.slimscroll",function(e){currTop=t+e.pageY-pageY,D.css("top",currTop),r(0,D.position().top,!1)}),s.bind("mouseup.slimscroll",function(e){d=!1,c(),s.unbind(".slimscroll")}),!1}).bind("selectstart.slimscroll",function(e){return e.stopPropagation(),e.preventDefault(),!1}),R.hover(function(){n()},function(){c()}),D.hover(function(){u=!0},function(){u=!1}),x.hover(function(){h=!0,n(),c()},function(){h=!1,c()}),x.bind("touchstart",function(e,t){e.originalEvent.touches.length&&(g=e.originalEvent.touches[0].pageY)}),x.bind("touchmove",function(e){if(y||e.originalEvent.preventDefault(),e.originalEvent.touches.length){var t=(g-e.originalEvent.touches[0].pageY)/o.touchScrollStep;r(t,!0),g=e.originalEvent.touches[0].pageY}}),l(),"bottom"===o.start?(D.css({top:x.outerHeight()-D.outerHeight()}),r(0,!0)):"top"!==o.start&&(r(e(o.start).position().top,null,!0),o.alwaysVisible||D.hide()),a(this)}}),this}}),e.fn.extend({slimscroll:e.fn.slimScroll})}(jQuery);
7
  };
8
  }
9
 
10
+ // ----- TABLE OF CONTENTS -----------------------------------------------------------
11
+ //
12
+ // 1. Data refresh
13
+ // 2. Filters
14
+ // 3. Activity log
15
+ // 4. Customizer
16
+ // 5. Miscellaneous
17
+ // 6. Init third-party libraries
18
+ //
19
+ // -----------------------------------------------------------------------------------
20
+
21
+ jQuery( function() {
22
+
23
+ // ----- BEGIN: DATA REFRESH -----------------------------------------------------
24
+ //
25
+
26
+ // Reload a report's data if it is (re)activated via the checkbox under Screen Options
27
+ jQuery( 'input.hide-postbox-tog[id^=slim_p]' ).on( 'click.postboxes', function () {
28
+ if ( jQuery( this ).prop( "checked" ) && jQuery( '#' + jQuery( this ).val() ).length ) {
29
+ SlimStatAdmin.refresh_report( jQuery( this ).val() );
30
+ }
31
+ });
32
 
33
+ // Reload a report's data if the corresponding refresh/pagination button is clicked
34
+ jQuery( document ).on( 'click', '[id^=slim_] .refresh', function( e ) {
35
+ e.preventDefault();
 
 
 
36
 
37
+ var id = jQuery( this ).parents( '.postbox' ).attr( 'id' );
 
 
 
38
 
39
+ // Is this a pagination link?
40
+ if ( typeof jQuery( this ).attr( 'href' ).split( '?' )[ 1 ] == 'string' ) {
41
+ clean_filters = SlimStatAdmin.get_query_string_filters( jQuery( this ).attr( 'href' ).split( '?' )[ 1 ].substring( 1 ) );
42
+ if ( typeof clean_filters[ 'fs[start_from]' ] == 'string' ) {
43
+ jQuery( '<input type="hidden" name="fs[start_from]" class="slimstat-post-filter slimstat-temp-filter" value="' + clean_filters[ 'fs[start_from]' ] + '">' ).appendTo( '#slimstat-filters-form' );
 
 
 
 
 
 
 
 
44
  }
45
  }
 
 
 
 
 
 
 
46
 
47
+ SlimStatAdmin.refresh_report( id );
48
+
49
+ // Remove any temporary filters (pagination) set here above
50
+ jQuery( '.slimstat-temp-filter' ).remove();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
+ // Re-initialize SlimScroll on the new content
53
+ jQuery( '#' + id + ' .inside' ).slimScroll( {
54
+ scrollTo : '0px'
55
+ } );
56
+ } );
57
 
58
+ // Asynchronous reports are loaded dynamically after the page loads
59
+ if ( SlimStatAdminParams.async_load == 'on' ) {
60
+ jQuery( 'div[id^=slim_]' ).each( function() {
61
+ SlimStatAdmin.refresh_report( jQuery( this ).attr( 'id' ) );
62
+ } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
 
64
 
65
+ //
66
+ // ----- END: DATA REFRESH -------------------------------------------------------
 
 
 
 
 
67
 
68
+ // ----- BEGIN: FILTERS ----------------------------------------------------------
69
+ //
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
+ // Make input field read-only if certain operators are selected
72
+ jQuery( '#slimstat-filter-operator' ).on( 'change', function() {
73
+ if ( this.value == 'is_empty' || this.value == 'is_not_empty' ) {
74
+ jQuery( '#slimstat-filter-value' ).attr( 'readonly', 'readonly' );
75
  }
76
+ else {
77
+ jQuery( '#slimstat-filter-value' ).removeAttr( 'readonly' );
78
  }
79
+ } );
 
 
 
 
 
 
 
 
80
 
81
+ // Toggle the Date Filters dropdown menu
82
+ jQuery( '#slimstat-date-filters > a' ).on( 'click', function( e ) {
83
  e.preventDefault();
84
+ jQuery( '#slimstat-date-filters > .dropdown' ).slideToggle( 250 );
85
+ } );
86
+
87
+ // Initialize the datepicker library and button (built-in)
88
+ if ( typeof jQuery( '.slimstat-filter-date' ).datepicker == 'function' ) {
89
+ jQuery( '.slimstat-filter-date' ).datepicker( {
 
 
 
90
  buttonImage: SlimStatAdminParams.datepicker_image,
91
  buttonImageOnly: true,
92
  changeMonth: true,
96
  nextText: '&raquo;',
97
  prevText: '&laquo;',
98
  showOn: 'both',
99
+
100
+ onClose: function( dateText, inst ) {
101
+ if ( dateText.length ) {
102
+ jQuery( '#slimstat-filter-day' ).val( dateText.split( '-' )[ 2 ] );
103
+ jQuery( '#slimstat-filter-month' ).val( dateText.split( '-' )[ 1 ] );
104
+ jQuery( '#slimstat-filter-year' ).val( dateText.split( '-' )[ 0 ] );
105
+ }
106
  }
107
+ } );
108
  }
109
 
110
+ // Save filters
111
+ jQuery( document ).on( 'click', '#slimstat-save-filter', function( e ) {
112
+ e.preventDefault();
113
+
114
+ data = {
115
+ action: 'slimstat_manage_filters',
116
+ security: jQuery( '#meta-box-order-nonce' ).val(),
117
+ type: 'save',
118
+ filter_array: jQuery( this ).attr( 'data-filter-array' )
119
+ };
120
+
121
+ var element = jQuery( this );
122
+ jQuery.post( ajaxurl, data, function( response ) {
123
+ element.text( response ).fadeOut( 1500 );
124
+ } );
125
+ } );
126
+
127
+ // Load saved filters: open a dialog with a list of filters
128
+ jQuery( document ).on( 'click', '#slimstat-load-saved-filters', function( e ) {
129
  e.preventDefault();
130
+ var inner_html = '';
131
+
132
+ data = {
133
+ action: 'slimstat_manage_filters',
134
+ security: jQuery( '#meta-box-order-nonce' ).val(),
135
+ type: 'load',
136
+ page: SlimStatAdmin.get_current_tab()
137
+ };
138
 
139
+ var dialog_title = jQuery( this ).attr( 'title' ); // passed as an attribute so that it can be localized
140
+ jQuery.post( ajaxurl, data, function( response ) {
141
+ jQuery( '#slimstat-modal-dialog' ).dialog( {
142
+ dialogClass: 'slimstat',
143
+ title: dialog_title
144
+ } ).html( response ).dialog( 'open' );
145
+ } );
146
+ } );
147
 
148
+ // Delete saved filters
149
+ jQuery( document ).on( 'click', '.slimstat-delete-filter', function( e ) {
150
+ e.preventDefault();
151
+
152
+ data = {
153
+ action: 'slimstat_manage_filters',
154
+ security: jQuery( '#meta-box-order-nonce' ).val(),
155
+ page: SlimStatAdmin.get_current_tab(),
156
+ type: 'delete',
157
+ filter_id: jQuery( this ).attr( 'data-filter-id' )
158
+ };
159
 
160
+ jQuery.post( ajaxurl, data, function( response ) {
161
+ jQuery( '#slim_filters_overlay' ).parent().html( response );
162
+ } );
163
+ } );
164
+
165
+ // Certain links enable filters throughout the interface. These links trigger a form submission, where all the filters are stored.
166
+ // Using a "POST" request allows us to handle much larger filter values across the various screens
167
+ if ( jQuery( 'form#slimstat-filters-form' ).length ) {
168
  jQuery( document ).on( 'click', '.slimstat-filter-link, #toplevel_page_slimview1 a, #wp-admin-bar-slimstat-header li a', function( e ) {
169
+ url = jQuery( this ).attr( 'href' );
170
+
171
+ // If this link doesn't have a valid HREF attribute, bail
172
+ if ( typeof url != 'string' ) {
173
+ return true;
174
+ }
175
+
176
  e.preventDefault();
177
 
178
+ jQuery( 'form#slimstat-filters-form' ).attr( 'action', url.split( '?' )[ 0 ] + '?page=' + SlimStatAdmin.get_current_tab( url.split( '?' )[ 1 ] ) );
179
+
180
+ SlimStatAdmin.add_url_filters_to_form( url, typeof jQuery( this ).attr( 'data-reset-filters' ) != 'undefined' );
181
+
182
+ jQuery( '#slimstat-filters-form' ).submit();
183
 
 
 
184
  return false;
185
  });
186
  }
187
 
188
+ // Since we handle all "filter links" as POST requests (see code here above), we need to add dummy form tag to the dashboard,
189
+ // for when our reports are displayed on that page
190
+ if ( !jQuery( '#slimstat-filters-form' ).length && !SlimStatAdmin.get_current_tab().match( /(slimconfig|slimaddons)/ ) ) {
191
+ jQuery( '<form id="slimstat-filters-form" method="post"/>' ).appendTo('body');
192
+ }
193
+
194
+ //
195
+ // ----- END: FILTERS ------------------------------------------------------------
196
+
197
+ // ----- BEGIN: ACTIVITY LOG -----------------------------------------------------
198
+ //
199
+
200
+ // Reload the Activity Log every X seconds
201
+ if ( SlimStatAdminParams.refresh_interval > 0 && jQuery( '.refresh-timer' ).length > 0 ) {
202
+ SlimStatAdmin._refresh_timer = parseInt( SlimStatAdminParams.refresh_interval );
203
+ window.setTimeout( "SlimStatAdmin.refresh_countdown();", 1000 );
204
+ }
205
+
206
+ // Delete a pageview when the corresponding button is clicked.
207
+ // Since this content can be reloaded dynamically, we use the .on call with the classname
208
+ jQuery( document ).on( 'click', '.slimstat-delete-entry', function( e ) {
209
  e.preventDefault();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
 
211
+ data = {
212
+ action: 'slimstat_delete_pageview',
213
+ security: jQuery( '#meta-box-order-nonce' ).val(),
214
+ pageview_id : jQuery( this ).attr( 'data-pageview-id' )
215
+ };
216
+
217
+ var parent = jQuery( this ).parents( 'p' );
218
+ jQuery.post( ajaxurl, data, function( response ) {
219
+ parent.fadeOut( 500 );
220
+ } );
221
+ } );
222
+
223
+ // // Modal Window / Whois
224
+ jQuery( document ).on( 'click', '.whois', function( e ) {
225
+ e.preventDefault();
226
 
227
+ // If admin is using HTTPS and IP lookup service is not, open a new window/tab, instead of an overlay dialog
228
+ if ( document.location.href.substr( 0, document.location.href.indexOf( "://" ) ).toLowerCase() == 'https' && jQuery( this ).attr( 'href' ).substr( 0, jQuery( this ).attr( 'href' ).indexOf( "://" ) ).toLowerCase() == 'http' ) {
229
+ window.open( jQuery( this ).attr( 'href' ), '_blank' );
230
+ return -1;
231
  }
232
+
233
+ jQuery('#slimstat-modal-dialog').dialog({
234
+ dialogClass: 'slimstat',
235
+ title: jQuery(this).attr('title')
236
+ }).html('<iframe id="ip2location" src="'+jQuery(this).attr('href')+'" width="100%" height="630"></iframe>');
237
+ jQuery('#slimstat-modal-dialog').dialog('open');
238
  });
239
 
240
+ //
241
+ // ----- END: ACTIVITY LOG -------------------------------------------------------
242
+
243
+ // ----- BEGIN: CUSTOMIZER -------------------------------------------------------
244
+ //
245
+
246
+ // Clone and delete report placeholders
247
+ jQuery( '.slimstat-layout .slimstat-header-buttons a' ).on( 'click', function() {
248
+ if ( jQuery( this ).hasClass( 'slimstat-font-docs' ) ) {
249
+ jQuery( this ).removeClass( 'slimstat-font-docs' ).addClass( 'slimstat-font-trash' ).parents( '.postbox' ).clone( true ).appendTo( jQuery( this ).parents( '.meta-box-sortables' ) );
250
+ jQuery( this ).removeClass( 'slimstat-font-trash' ).addClass( 'slimstat-font-docs' );
251
+ }
252
+ else if ( jQuery( this ).hasClass( 'slimstat-font-minus-circled' ) ) {
253
+ jQuery( this ).removeClass( 'slimstat-font-minus-circled' ).parents( '.postbox' ).appendTo( jQuery( '#postbox-container-inactive .meta-box-sortables' ) );
254
+ }
255
+ else {
256
+ jQuery( this ).parents( '.postbox' ).remove();
257
+ }
258
+
259
+ // Save the new groups
260
+ var data = {
261
+ action: 'meta-box-order',
262
+ _ajax_nonce: jQuery( '#meta-box-order-nonce' ).val(),
263
+ page: 'slimstat_page_slimlayout',
264
+ page_columns: 0
265
+ };
266
+
267
+ jQuery( '.meta-box-sortables' ).each( function() {
268
+ data[ 'order[' + this.id.split("-")[0] + ']' ] = jQuery( this ).sortable( 'toArray' ).join( ',' );
269
  });
270
+
271
+ jQuery.post( ajaxurl, data );
272
+ } );
273
+
274
+ //
275
+ // ----- END: CUSTOMIZER ---------------------------------------------------------
276
+
277
+ // ----- BEGIN: MISCELLANEOUS ----------------------------------------------------
278
+ //
279
 
280
  // Hide a notice and send the corresponding ajax request to the server
281
  jQuery( document ).on( 'click', '[id^=slimstat-hide-]', function( e ) {
294
  });
295
  });
296
 
297
+ //
298
+ // ----- END: MISCELLANEOUS ------------------------------------------------------
 
299
 
300
+ // ----- BEGIN: INIT THIRD-PARTY LIBRARIES ---------------------------------------
301
+ //
 
 
 
 
 
 
 
 
 
302
 
303
+ // SlimScroll
304
+ jQuery( '[id^=slim_] .inside' ).slimScroll( {
305
  distance: '2px',
306
  opacity: '0.15',
307
  size: '5px',
308
  wheelStep: 10
309
+ } );
 
 
 
 
 
 
 
310
 
311
+ // QTip
312
  jQuery( document ).on( 'mouseover', '.slimstat-tooltip-trigger', function( e ) {
313
  if ( typeof jQuery( this ).attr( 'data-hasqtip' ) != 'undefined' ) {
314
  return true;
324
  }
325
 
326
  if ( tooltip_content.length ) {
327
+ jQuery(this).qtip( {
328
  overwrite: false,
329
  content: {
330
  text: tooltip_content
334
  ready: true
335
  },
336
  hide: {
337
+ delay: 250,
338
+ fixed: true
339
+ },
340
  position: {
341
+ my: 'bottom right',
342
+ at: 'top left',
343
  adjust: {
344
  x: 5
345
  },
346
+ viewport: jQuery( window )
347
  },
348
  style: {
349
  classes: 'qtip-light'
350
  }
351
+ }, e );
352
  }
353
+ } );
354
 
355
+ // Modal Window
356
+ if ( typeof jQuery( '#slimstat-modal-dialog' ).dialog == 'function' ) {
357
+ jQuery( '#slimstat-modal-dialog' ).dialog( {
358
  autoOpen: false,
359
  closeOnEscape: true,
360
  closeText: '',
361
  draggable: true,
362
  modal: true,
363
  open: function(){
364
+ jQuery( '.ui-widget-overlay, .close-dialog' ).on( 'click', function() {
365
+ jQuery( '#slimstat-modal-dialog' ).dialog( 'close' );
366
+ } );
367
  },
368
  position: { my: "top center" },
369
  resizable: false
370
+ } );
371
  }
372
 
373
+ // BootstrapSwitch (pretty checkboxes in settings)
374
+ jQuery( 'input.slimstat-checkbox-toggle' ).not( '[data-switch-no-init]' ).bootstrapSwitch();
375
+
376
+ // TagEditor
377
+ jQuery( 'textarea.slimstat-taglist' ).tagEditor( {
378
+ forceLowercase: false
379
+ } );
380
 
381
+ //
382
+ // ----- END: INIT THIRD-PARTY LIBRARIES -----------------------------------------
383
+ } );
384
+
385
+ // ----- BEGIN: SLIMSTATADMIN HELPER FUNCTIONS ---------------------------------------
386
+ var SlimStatAdmin = {
387
+ _refresh_timer: 0,
388
+
389
+ refresh_countdown: function() {
390
+ SlimStatAdmin._refresh_timer--;
391
+ minutes = parseInt( SlimStatAdmin._refresh_timer / 60 );
392
+ seconds = parseInt( SlimStatAdmin._refresh_timer % 60 );
393
+
394
+ jQuery( '.refresh-timer' ).html( minutes + ':' + ( ( seconds < 10 ) ? '0' : '' ) + seconds );
395
+
396
+ if ( SlimStatAdmin._refresh_timer > 0 ) {
397
+ window.setTimeout( SlimStatAdmin.refresh_countdown, 1000 );
398
  }
399
+ else {
400
+ // Request the data from the server
401
+ SlimStatAdmin.refresh_report( 'slim_p7_02' );
 
 
 
 
402
 
403
+ // Reset the countdown timer
404
+ SlimStatAdmin._refresh_timer = parseInt( SlimStatAdminParams.refresh_interval );
405
+ window.setTimeout( "SlimStatAdmin.refresh_countdown();", 1000 );
406
+ }
407
+ },
408
+
409
+ refresh_report: function( id ) {
410
+ var inner_content = '#' + id + ' .inside';
411
+ jQuery( inner_content ).html( '<p class="loading"><i class="slimstat-font-spin4 animate-spin"></i></p>' );
412
+ data = {
413
+ action: 'slimstat_load_report',
414
+ security: jQuery( '#meta-box-order-nonce' ).val(),
415
+ page: SlimStatAdmin.get_current_tab(),
416
+ report_id: id
417
+ };
418
+
419
+ // Append the data from the hidden form
420
+ filters_input = jQuery( '#slimstat-filters-form .slimstat-post-filter' ).toArray();
421
+ for ( i in filters_input ) {
422
+ data[ filters_input[ i ][ 'name' ] ] = filters_input[ i ][ 'value' ];
423
+ }
424
+
425
+ jQuery.post( ajaxurl, data, function( response ) {
426
+ // Charts don't play nice with the "fade" animation we have for the other reports
427
+ if ( id.indexOf( '_01' ) > 0 ) {
428
+ jQuery( inner_content ).html( response );
429
  }
430
+ else{
431
+ jQuery( inner_content ).fadeOut( 500, function() { jQuery( this ).html( response ).fadeIn( 500 ); } );
 
 
 
 
 
 
432
 
433
+ // If we are refreshing the Activity Log, let's reset the countdown timer
434
+ if ( id == 'slim_p7_02' ) {
435
+ SlimStatAdmin._refresh_timer = SlimStatAdminParams.refresh_interval;
436
+ }
 
 
 
 
 
 
 
 
437
  }
438
+ } );
439
+ },
440
 
441
+ get_query_string_filters: function( url ) {
 
 
442
 
443
+ // Parse the URL and update the form_filters object accordingly
444
+ query_string_pairs = url.substring( url.indexOf( '?' ) + 1 ).split( '&' );
445
+ clean_filters = {};
446
+
447
+ for ( i in query_string_pairs ) {
448
+ decoded_pair = decodeURIComponent( query_string_pairs[ i ].replace( /\+/g, '%20' ) );
449
+
450
+ if ( decoded_pair.indexOf( 'fs[' ) == -1 ) {
451
+ continue;
452
  }
 
 
453
 
454
+ a_pair = decoded_pair.split( '=' );
455
+ if ( a_pair[ 0 ].length ) {
456
+ clean_filters[ a_pair[ 0 ] ] = a_pair[ 1 ];
457
+ }
 
458
  }
459
+
460
+ return clean_filters;
461
+ },
462
+
463
+ add_url_filters_to_form: function( url, delete_existing_filters ) {
464
+ clean_filters = SlimStatAdmin.get_query_string_filters( url );
465
+
466
+ // Manipulate the existing list of filters (hidden input fields), if we don't want to delete them
467
+ if ( typeof delete_existing_filters == 'undefined' || !delete_existing_filters ) {
468
+
469
+ for( i in clean_filters ) {
470
+ // If value is empty (length is 1, meaning that it just has the operator but no value), delete corresponding input field
471
+ if ( clean_filters[ i ].trim().split( ' ' ).length == 1 ) {
472
+ jQuery( 'input[name="' + i + '"]' ).remove();
473
+ }
474
+ else if ( jQuery( 'input[name="' + i + '"]' ).length > 0 ) {
475
+ jQuery( 'input[name="' + i + '"]' ).attr( 'value', clean_filters[ i ] );
476
+ }
477
+ else {
478
+ jQuery( '<input type="hidden" name="' + i + '" class="slimstat-post-filter" value="' + clean_filters[ i ] + '">' ).appendTo( '#slimstat-filters-form' );
479
+ }
480
+ }
481
  }
482
+ // Start from a clean slate
483
  else {
484
+ jQuery( '.slimstat-post-filter' ).remove();
 
 
 
 
 
 
 
485
 
486
+ for( i in clean_filters ) {
487
+ jQuery( '<input type="hidden" name="' + i + '" class="slimstat-post-filter" value="' + clean_filters[ i ] + '">' ).appendTo( '#slimstat-filters-form' );
488
+ }
489
+ }
490
+ },
 
491
 
492
+ // Get the value of a given key in the query string passed via the URL
493
+ get_current_tab: function( query_string ) {
494
+ query_string = typeof query_string == 'undefined' ? window.location.search.substring( 1 ) : query_string;
495
+ var regex = new RegExp( "page(=([^&#]*)|&|#|$)" );
496
+
497
+ values = regex.exec( query_string );
498
 
499
+ if ( typeof values[ 2 ] == 'string' ) {
500
+ return decodeURIComponent( values[ 2 ].replace( /\+/g, " " ) );
 
 
 
 
501
  }
 
502
 
503
+ return '';
504
+ }
505
+ }
506
+ // ----- END: SLIMSTATADMIN HELPER FUNCTIONS -----------------------------------------
507
 
508
  /* SlimScroll v1.3.8 | http://rocha.la | Copyright (c) 2011 Piotr Rochala. Released under the MIT and GPL licenses. */
509
  !function(e){e.fn.extend({slimScroll:function(i){var s={width:"auto",size:"7px",color:"#000",position:"right",distance:"1px",start:"top",opacity:.4,alwaysVisible:!1,disableFadeOut:!1,railVisible:!1,railColor:"#333",railOpacity:.2,railDraggable:!0,railClass:"slimScrollRail",barClass:"slimScrollBar",wrapperClass:"slimScrollDiv",allowPageScroll:!1,wheelStep:20,touchScrollStep:200,borderRadius:"7px",railBorderRadius:"7px"},o=e.extend(s,i);return this.each(function(){function s(t){if(h){var t=t||window.event,i=0;t.wheelDelta&&(i=-t.wheelDelta/120),t.detail&&(i=t.detail/3);var s=t.target||t.srcTarget||t.srcElement;e(s).closest("."+o.wrapperClass).is(x.parent())&&r(i,!0),t.preventDefault&&!y&&t.preventDefault(),y||(t.returnValue=!1)}}function r(e,t,i){y=!1;var s=e,r=x.outerHeight()-D.outerHeight();if(t&&(s=parseInt(D.css("top"))+e*parseInt(o.wheelStep)/100*D.outerHeight(),s=Math.min(Math.max(s,0),r),s=e>0?Math.ceil(s):Math.floor(s),D.css({top:s+"px"})),v=parseInt(D.css("top"))/(x.outerHeight()-D.outerHeight()),s=v*(x[0].scrollHeight-x.outerHeight()),i){s=e;var a=s/x[0].scrollHeight*x.outerHeight();a=Math.min(Math.max(a,0),r),D.css({top:a+"px"})}x.scrollTop(s),x.trigger("slimscrolling",~~s),n(),c()}function a(e){window.addEventListener?(e.addEventListener("DOMMouseScroll",s,!1),e.addEventListener("mousewheel",s,!1)):document.attachEvent("onmousewheel",s)}function l(){f=Math.max(x.outerHeight()/x[0].scrollHeight*x.outerHeight(),m),D.css({height:f+"px"});var e=f==x.outerHeight()?"none":"block";D.css({display:e})}function n(){if(l(),clearTimeout(p),v==~~v){if(y=o.allowPageScroll,b!=v){var e=0==~~v?"top":"bottom";x.trigger("slimscroll",e)}}else y=!1;return b=v,f>=x.outerHeight()?void(y=!0):(D.stop(!0,!0).fadeIn("fast"),void(o.railVisible&&R.stop(!0,!0).fadeIn("fast")))}function c(){o.alwaysVisible||(p=setTimeout(function(){o.disableFadeOut&&h||u||d||(D.fadeOut("slow"),R.fadeOut("slow"))},1e3))}var h,u,d,p,g,f,v,b,w="<div></div>",m=30,y=!1,x=e(this);if(x.parent().hasClass(o.wrapperClass)){var C=x.scrollTop();if(D=x.siblings("."+o.barClass),R=x.siblings("."+o.railClass),l(),e.isPlainObject(i)){if("height"in i&&"auto"==i.height){x.parent().css("height","auto"),x.css("height","auto");var H=x.parent().parent().height();x.parent().css("height",H),x.css("height",H)}else if("height"in i){var S=i.height;x.parent().css("height",S),x.css("height",S)}if("scrollTo"in i)C=parseInt(o.scrollTo);else if("scrollBy"in i)C+=parseInt(o.scrollBy);else if("destroy"in i)return D.remove(),R.remove(),void x.unwrap();r(C,!1,!0)}}else if(!(e.isPlainObject(i)&&"destroy"in i)){o.height="auto"==o.height?x.parent().height():o.height;var E=e(w).addClass(o.wrapperClass).css({position:"relative",overflow:"hidden",width:o.width,height:o.height});x.css({overflow:"hidden",width:o.width,height:o.height});var R=e(w).addClass(o.railClass).css({width:o.size,height:"100%",position:"absolute",top:0,display:o.alwaysVisible&&o.railVisible?"block":"none","border-radius":o.railBorderRadius,background:o.railColor,opacity:o.railOpacity,zIndex:90}),D=e(w).addClass(o.barClass).css({background:o.color,width:o.size,position:"absolute",top:0,opacity:o.opacity,display:o.alwaysVisible?"block":"none","border-radius":o.borderRadius,BorderRadius:o.borderRadius,MozBorderRadius:o.borderRadius,WebkitBorderRadius:o.borderRadius,zIndex:99}),M="right"==o.position?{right:o.distance}:{left:o.distance};R.css(M),D.css(M),x.wrap(E),x.parent().append(D),x.parent().append(R),o.railDraggable&&D.bind("mousedown",function(i){var s=e(document);return d=!0,t=parseFloat(D.css("top")),pageY=i.pageY,s.bind("mousemove.slimscroll",function(e){currTop=t+e.pageY-pageY,D.css("top",currTop),r(0,D.position().top,!1)}),s.bind("mouseup.slimscroll",function(e){d=!1,c(),s.unbind(".slimscroll")}),!1}).bind("selectstart.slimscroll",function(e){return e.stopPropagation(),e.preventDefault(),!1}),R.hover(function(){n()},function(){c()}),D.hover(function(){u=!0},function(){u=!1}),x.hover(function(){h=!0,n(),c()},function(){h=!1,c()}),x.bind("touchstart",function(e,t){e.originalEvent.touches.length&&(g=e.originalEvent.touches[0].pageY)}),x.bind("touchmove",function(e){if(y||e.originalEvent.preventDefault(),e.originalEvent.touches.length){var t=(g-e.originalEvent.touches[0].pageY)/o.touchScrollStep;r(t,!0),g=e.originalEvent.touches[0].pageY}}),l(),"bottom"===o.start?(D.css({top:x.outerHeight()-D.outerHeight()}),r(0,!0)):"top"!==o.start&&(r(e(o.start).position().top,null,!0),o.alwaysVisible||D.hide()),a(this)}}),this}}),e.fn.extend({slimscroll:e.fn.slimScroll})}(jQuery);
admin/view/index.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php if (!function_exists('add_action')) exit(0); ?>
2
 
3
  <div class="wrap slimstat">
4
  <h2><?php echo wp_slimstat_admin::$screens_info[ $_GET[ 'page' ] ][ 'title' ] ?></h2>
@@ -14,7 +14,7 @@
14
  $filter_name_html .= '</select>';
15
 
16
  $filter_operator_html = '<label for="slimstat-filter-operator">Filter operator</label><select name="o" id="slimstat-filter-operator">';
17
- foreach ( wp_slimstat_db::$operator_names as $a_operator_label => $a_operator_name ){
18
  $filter_operator_html .= "<option value='$a_operator_label'>$a_operator_name</option>";
19
  }
20
  $filter_operator_html .= '</select>';
@@ -22,80 +22,71 @@
22
  $filter_value_html = '<label for="slimstat-filter-value">Filter value</label><input type="text" class="text" name="v" id="slimstat-filter-value" value="" size="20">';
23
 
24
  if ( wp_slimstat::$settings[ 'enable_sov' ] == 'on' ) {
25
- echo $filter_value_html.$filter_operator_html.$filter_name_html;
26
  }
27
- else{
28
- echo $filter_name_html.$filter_operator_html.$filter_value_html;
29
  }
30
 
31
- echo '<input type="submit" value="'.__('Apply','wp-slimstat').'" class="button-secondary">';
32
 
33
- $saved_filters = get_option('slimstat_filters', array());
34
- if (!empty($saved_filters)){
35
- echo '<a href="#" id="slimstat-load-saved-filters" class="button-secondary noslimstat" title="Saved Filters">'.__('Load','wp-slimstat').'</a>';
36
  }
37
- ?>
38
- </fieldset><!-- slimstat-filters -->
39
 
40
  <fieldset id="slimstat-date-filters" class="wp-ui-highlight">
41
  <a href="#" class="noslimstat"><?php
42
- if (!empty(wp_slimstat_db::$filters_normalized['date']['hour']) || !empty(wp_slimstat_db::$filters_normalized['date']['interval_hours'])){
43
  echo gmdate( wp_slimstat::$settings[ 'date_format' ] . ' ' . wp_slimstat::$settings[ 'time_format' ], wp_slimstat_db::$filters_normalized['utime']['start']).' - ';
44
- $end_format = (date('Ymd', wp_slimstat_db::$filters_normalized['utime']['start']) != date('Ymd', wp_slimstat_db::$filters_normalized['utime']['end']))?wp_slimstat::$settings[ 'date_format' ] . ' ' . wp_slimstat::$settings[ 'time_format' ] : wp_slimstat::$settings[ 'time_format' ];
 
45
  echo gmdate( $end_format, wp_slimstat_db::$filters_normalized[ 'utime' ][ 'end' ] );
46
  }
47
- else if (!empty(wp_slimstat_db::$filters_normalized['date']['day']) && empty(wp_slimstat_db::$filters_normalized['date']['interval'])){
48
- echo ucwords(gmdate(wp_slimstat::$settings['date_format'], wp_slimstat_db::$filters_normalized['utime']['start']));
49
- }
50
- else{
51
- echo ucwords( gmdate( wp_slimstat::$settings[ 'date_format' ], wp_slimstat_db::$filters_normalized[ 'utime' ][ 'start' ] ) . ' - ' . gmdate( wp_slimstat::$settings[ 'date_format' ], wp_slimstat_db::$filters_normalized[ 'utime' ][ 'end' ] ) );
 
 
 
 
 
52
  }
53
  ?></a>
54
  <div class="dropdown">
55
- <a class="slimstat-filter-link slimstat-date-choice noslimstat" href="<?php echo wp_slimstat_reports::fs_url('hour equals 0&&&day equals '.date_i18n('d').'&&&month equals '.date_i18n('m').'&&&year equals '.date_i18n('Y').'&&&interval equals 0') ?>"><?php _e('Today','wp-slimstat') ?></a>
56
- <a class="slimstat-filter-link slimstat-date-choice noslimstat" href="<?php echo wp_slimstat_reports::fs_url('hour equals 0&&&day equals '.date_i18n('d', mktime(0, 0, 0, date_i18n('m'), date_i18n('d')-1, date_i18n('Y'))).'&&&month equals '.date_i18n('m', mktime(0, 0, 0, date_i18n('m'), date_i18n('d')-1, date_i18n('Y'))).'&&&year equals '.date_i18n('Y', mktime(0, 0, 0, date_i18n('m'), date_i18n('d')-1, date_i18n('Y'))).'&&&interval equals 0') ?>"><?php _e('Yesterday','wp-slimstat') ?></a>
57
- <a class="slimstat-filter-link slimstat-date-choice noslimstat" href="<?php echo wp_slimstat_reports::fs_url('hour equals 0&&&day equals '.date_i18n('d').'&&&month equals '.date_i18n('m').'&&&year equals '.date_i18n('Y').'&&&interval equals 7&&&interval_direction equals 0') ?>"><?php _e('Last 7 Days','wp-slimstat') ?></a>
58
- <a class="slimstat-filter-link slimstat-date-choice noslimstat" href="<?php echo wp_slimstat_reports::fs_url( 'hour equals 0&&&day equals ' . date_i18n( 'd' ) . '&&&month equals ' . date_i18n( 'm' ) . '&&&year equals ' . date_i18n( 'Y' ) . '&&&interval equals 60&&&interval_direction equals 0' ) ?>"><?php _e( 'Last 60 Days', 'wp-slimstat' ) ?></a>
59
- <a class="slimstat-filter-link slimstat-date-choice noslimstat" href="<?php echo wp_slimstat_reports::fs_url('hour equals 0&&&day equals '.date_i18n('d').'&&&month equals '.date_i18n('m').'&&&year equals '.date_i18n('Y').'&&&interval equals 90&&&interval_direction equals minus') ?>"><?php _e('Last 90 Days','wp-slimstat') ?></a>
60
- <a class="slimstat-filter-link slimstat-date-choice noslimstat" href="<?php echo wp_slimstat_reports::fs_url('hour equals 0&&&day equals 0&&&month equals 0&&&year equals '.date_i18n('Y').'&&&interval equals 0') ?>"><?php _e('This Year So Far','wp-slimstat') ?></a>
61
- <strong><?php _e('Date Range','wp-slimstat') ?></strong>
62
-
 
 
63
  <label for="slimstat-filter-day">Day</label>
64
- <select name="day" id="slimstat-filter-day">
65
- <option value="0"><?php _e('Day','wp-slimstat') ?></option><?php
66
- for ( $i = 1; $i <= 31; $i++ ) {
67
- if ( !empty( wp_slimstat_db::$filters_normalized[ 'date' ][ 'day' ]) && wp_slimstat_db::$filters_normalized[ 'date' ][ 'day' ] == $i ) {
68
- echo "<option selected='selected'>$i</option>";
69
- }
70
- else {
71
- echo "<option>$i</option>";
72
- }
73
- }
74
- ?>
75
- </select>
76
 
77
  <label for="slimstat-filter-month">Month</label>
78
  <select name="month" id="slimstat-filter-month">
79
  <option value="0"><?php _e( 'Month', 'wp-slimstat' ) ?></option><?php
80
  for ( $i = 1; $i <= 12; $i++ ) {
81
- if ( !empty( wp_slimstat_db::$filters_normalized[ 'date' ][ 'month' ]) && wp_slimstat_db::$filters_normalized[ 'date' ][ 'month' ] == $i ) {
82
- echo "<option value='$i' selected='selected'>" . $GLOBALS[ 'wp_locale' ]->get_month_abbrev( $GLOBALS[ 'wp_locale' ]->get_month( $i ) ) . "</option>";
83
- }
84
- else{
85
- echo "<option value='$i'>" . $GLOBALS[ 'wp_locale' ]->get_month_abbrev( $GLOBALS[ 'wp_locale' ]->get_month( $i ) ) . "</option>";
86
- }
87
  }
88
  ?>
89
  </select>
90
 
91
  <label for="slimstat-filter-year">Year</label>
92
- <input type="text" name="year" id="slimstat-filter-year" placeholder="<?php _e('Year','wp-slimstat') ?>" class="empty-on-focus" value="<?php echo !empty(wp_slimstat_db::$filters_normalized['date']['year'])?wp_slimstat_db::$filters_normalized['date']['year']:'' ?>">
93
  @
94
  <label for="slimstat-filter-hour">Hour</label>
95
- <input type="text" name="hour" id="slimstat-filter-hour" placeholder="<?php _e('Hour','wp-slimstat') ?>" class="short empty-on-focus" value="<?php echo !empty(wp_slimstat_db::$filters_normalized['date']['hour'])?wp_slimstat_db::$filters_normalized['date']['hour']:'' ?>">:
96
 
97
  <label for="slimstat-filter-minute">Minute</label>
98
- <input type="text" name="minute" id="slimstat-filter-minute" placeholder="<?php _e('Min','wp-slimstat') ?>" class="short empty-on-focus" value="<?php echo !empty(wp_slimstat_db::$filters_normalized['date']['minute'])?wp_slimstat_db::$filters_normalized['date']['minute']:'' ?>">
99
  <input type="hidden" class="slimstat-filter-date" name="slimstat-filter-date" value=""/>
100
  <br/>
101
 
@@ -106,38 +97,34 @@
106
  </select>
107
 
108
  <label for="slimstat-filter-interval">Days in interval</label>
109
- <input type="text" name="interval" id="slimstat-filter-interval" placeholder="<?php _e('days', 'wp-slimstat') ?>" class="short empty-on-focus" value="<?php echo !empty(wp_slimstat_db::$filters_normalized['date']['interval'])?wp_slimstat_db::$filters_normalized['date']['interval']:'' ?>">,
110
 
111
  <label for="slimstat-filter-interval_hours">Hours in interval</label>
112
- <input type="text" name="interval_hours" id="slimstat-filter-interval_hours" placeholder="<?php _e('hours', 'wp-slimstat') ?>" class="short empty-on-focus" value="<?php echo !empty(wp_slimstat_db::$filters_normalized['date']['interval_hours'])?wp_slimstat_db::$filters_normalized['date']['interval_hours']:'' ?>">:
113
 
114
  <label for="slimstat-filter-interval_minutes">Minutes in interval</label>
115
- <input type="text" name="interval_minutes" id="slimstat-filter-interval_minutes" placeholder="<?php _e('mins', 'wp-slimstat') ?>" class="short empty-on-focus" value="<?php echo !empty(wp_slimstat_db::$filters_normalized['date']['interval_minutes'])?wp_slimstat_db::$filters_normalized['date']['interval_minutes']:'' ?>">
116
 
117
- <input type="submit" value="<?php _e('Apply','wp-slimstat') ?>" class="button-secondary noslimstat">
118
 
119
  <?php
120
- if (!empty(wp_slimstat_db::$filters_normalized['date']['day']) ||
121
- !(empty(wp_slimstat_db::$filters_normalized['date']['month']) || wp_slimstat_db::$filters_normalized['date']['month'] == date_i18n('n')) ||
122
- !empty(wp_slimstat_db::$filters_normalized['date']['year']) ||
123
- !empty(wp_slimstat_db::$filters_normalized['date']['interval']) ||
124
- !empty(wp_slimstat_db::$filters_normalized['date']['interval_hours']) ||
125
- !empty(wp_slimstat_db::$filters_normalized['date']['interval_minutes'])): ?>
126
- <a class="slimstat-filter-link button-secondary noslimstat" href="<?php echo wp_slimstat_reports::fs_url('minute equals 0&&&hour equals 0&&&day equals 0&&&month equals 0&&&year equals 0&&&interval_direction equals 1&&&interval equals 0&&&interval_hours equals 0&&&interval_minutes equals 0') ?>"><?php _e( 'Reset Filters', 'wp-slimstat' ) ?></a>
127
- <?php endif ?>
128
  </div>
129
  </fieldset><!-- .slimstat-date-filters -->
130
 
131
- <?php foreach(wp_slimstat_db::$filters_normalized['columns'] as $a_key => $a_details): ?>
132
- <input type="hidden" name="fs[<?php echo $a_key ?>]" class="slimstat-post-filter" value="<?php echo htmlspecialchars($a_details[0].' '.$a_details[1]) ?>"/>
133
  <?php endforeach ?>
134
 
135
- <?php foreach(wp_slimstat_db::$filters_normalized['date'] as $a_key => $a_value): if (!empty($a_value) && !empty(wp_slimstat_db::$filters_normalized['date'][$a_key])): ?>
136
- <input type="hidden" name="fs[<?php echo $a_key ?>]" class="slimstat-post-filter" value="equals <?php echo htmlspecialchars($a_value) ?>"/>
137
  <?php endif; endforeach; ?>
138
 
139
- <?php foreach(wp_slimstat_db::$filters_normalized['misc'] as $a_key => $a_value): if (!empty($a_value) && !empty(wp_slimstat_db::$filters_normalized['misc'][$a_key])): ?>
140
- <input type="hidden" name="fs[<?php echo $a_key ?>]" class="slimstat-post-filter" value="equals <?php echo htmlspecialchars($a_value) ?>"/>
141
  <?php endif; endforeach; ?>
142
  </form>
143
  <?php
@@ -151,11 +138,11 @@
151
 
152
  // Path to wp-content folder, used to detect caching plugins via advanced-cache.php
153
  if ( file_exists( dirname( dirname( dirname( dirname( plugin_dir_path( __FILE__ ) ) ) ) ) . '/advanced-cache.php' ) && ( empty( wp_slimstat::$settings[ 'no_caching_warning' ] ) || wp_slimstat::$settings[ 'no_caching_warning' ] != 'on' ) && ( empty( wp_slimstat::$settings[ 'javascript_mode' ] ) || wp_slimstat::$settings[ 'javascript_mode' ] != 'on' ) ) {
154
- wp_slimstat_admin::show_alert_message( sprintf( __( "A caching plugin has been detected on your website. Please <a href='%s' target='_blank' class='noslimstat'>make sure to configure</a> Slimstat Analytics accordingly, to get accurate information.", 'wp-slimstat' ), 'https://slimstat.freshdesk.com/support/solutions/articles/5000528524-i-am-using-w3-total-cache-or-wp-super-cache-hypercache-etc-and-it-looks-like-slimstat-is-not-tra' ) . '<a id="slimstat-hide-caching-notice" class="slimstat-font-cancel slimstat-float-right" title="Hide this notice" href="#"></a>', 'wp-ui-text-notification below-h2' );
155
  }
156
 
157
  $filters_html = wp_slimstat_reports::get_filters_html( wp_slimstat_db::$filters_normalized[ 'columns' ] );
158
- if (!empty($filters_html)){
159
  echo "<div id='slimstat-current-filters'>$filters_html</div>";
160
  }
161
  ?>
1
+ <?php if ( !function_exists( 'add_action' ) ) exit(); ?>
2
 
3
  <div class="wrap slimstat">
4
  <h2><?php echo wp_slimstat_admin::$screens_info[ $_GET[ 'page' ] ][ 'title' ] ?></h2>
14
  $filter_name_html .= '</select>';
15
 
16
  $filter_operator_html = '<label for="slimstat-filter-operator">Filter operator</label><select name="o" id="slimstat-filter-operator">';
17
+ foreach ( wp_slimstat_db::$operator_names as $a_operator_label => $a_operator_name ) {
18
  $filter_operator_html .= "<option value='$a_operator_label'>$a_operator_name</option>";
19
  }
20
  $filter_operator_html .= '</select>';
22
  $filter_value_html = '<label for="slimstat-filter-value">Filter value</label><input type="text" class="text" name="v" id="slimstat-filter-value" value="" size="20">';
23
 
24
  if ( wp_slimstat::$settings[ 'enable_sov' ] == 'on' ) {
25
+ echo $filter_value_html.$filter_operator_html . $filter_name_html;
26
  }
27
+ else {
28
+ echo $filter_name_html.$filter_operator_html . $filter_value_html;
29
  }
30
 
31
+ echo '<input type="submit" value="' . __( 'Apply', 'wp-slimstat' ) . '" class="button-secondary">';
32
 
33
+ $saved_filters = get_option( 'slimstat_filters', array() );
34
+ if ( !empty( $saved_filters ) ) {
35
+ echo '<a href="#" id="slimstat-load-saved-filters" class="button-secondary noslimstat" title="Saved Filters">' . __( 'Load', 'wp-slimstat' ) . '</a>';
36
  }
37
+ ?></fieldset><!-- #slimstat-filters -->
 
38
 
39
  <fieldset id="slimstat-date-filters" class="wp-ui-highlight">
40
  <a href="#" class="noslimstat"><?php
41
+ if ( !empty( wp_slimstat_db::$filters_normalized[ 'date' ][ 'hour' ] ) || !empty( wp_slimstat_db::$filters_normalized[ 'date' ][ 'interval_hours' ] ) ) {
42
  echo gmdate( wp_slimstat::$settings[ 'date_format' ] . ' ' . wp_slimstat::$settings[ 'time_format' ], wp_slimstat_db::$filters_normalized['utime']['start']).' - ';
43
+
44
+ $end_format = ( date( 'Ymd', wp_slimstat_db::$filters_normalized[ 'utime' ][ 'start' ] ) != date( 'Ymd', wp_slimstat_db::$filters_normalized[ 'utime' ][ 'end' ] ) ) ? wp_slimstat::$settings[ 'date_format' ] . ' ' . wp_slimstat::$settings[ 'time_format' ] : wp_slimstat::$settings[ 'time_format' ];
45
  echo gmdate( $end_format, wp_slimstat_db::$filters_normalized[ 'utime' ][ 'end' ] );
46
  }
47
+ else {
48
+ $start_date = gmdate( wp_slimstat::$settings[ 'date_format' ], wp_slimstat_db::$filters_normalized[ 'utime' ][ 'start' ] );
49
+ $end_date = gmdate( wp_slimstat::$settings[ 'date_format' ], wp_slimstat_db::$filters_normalized[ 'utime' ][ 'end' ] );
50
+
51
+ if ( $start_date == $end_date ) {
52
+ echo ucwords( $start_date );
53
+ }
54
+ else {
55
+ echo ucwords( $start_date ) . ' &ndash; ' . ucwords( $end_date );
56
+ }
57
  }
58
  ?></a>
59
  <div class="dropdown">
60
+ <div id="slimstat-quick-filters">
61
+ <a class="slimstat-filter-link noslimstat" href="<?php echo wp_slimstat_reports::fs_url( 'strtotime equals today&&&interval equals -1' ) ?>"><?php _e( 'Today', 'wp-slimstat' ) ?></a>
62
+ <a class="slimstat-filter-link noslimstat" href="<?php echo wp_slimstat_reports::fs_url( 'strtotime equals yesterday&&&interval equals -1' ) ?>"><?php _e( 'Yesterday', 'wp-slimstat' ) ?></a>
63
+ <a class="slimstat-filter-link noslimstat" href="<?php echo wp_slimstat_reports::fs_url( 'strtotime equals today&&&interval equals -7' ) ?>"><?php _e( 'Last 7 Days', 'wp-slimstat' ) ?></a>
64
+ <a class="slimstat-filter-link noslimstat" href="<?php echo wp_slimstat_reports::fs_url( 'strtotime equals today&&&interval equals -30' ) ?>"><?php _e( 'Last 30 Days', 'wp-slimstat' ) ?></a>
65
+ <a class="slimstat-filter-link noslimstat" href="<?php echo wp_slimstat_reports::fs_url( 'strtotime equals today&&&interval equals -90' ) ?>"><?php _e( 'Last 90 Days', 'wp-slimstat' ) ?></a>
66
+ <a class="slimstat-filter-link noslimstat" href="<?php echo wp_slimstat_reports::fs_url( 'strtotime equals today&&&interval equals -365' ) ?>"><?php _e( 'Last 365 Days', 'wp-slimstat' ) ?></a>
67
+ </div>
68
+
69
+ <strong><?php _e( 'Date Range', 'wp-slimstat' ) ?></strong>
70
  <label for="slimstat-filter-day">Day</label>
71
+ <input type="text" name="day" id="slimstat-filter-day" placeholder="<?php _e( 'Day', 'wp-slimstat' ) ?>" value="">
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  <label for="slimstat-filter-month">Month</label>
74
  <select name="month" id="slimstat-filter-month">
75
  <option value="0"><?php _e( 'Month', 'wp-slimstat' ) ?></option><?php
76
  for ( $i = 1; $i <= 12; $i++ ) {
77
+ echo "<option value='$i'>" . $GLOBALS[ 'wp_locale' ]->get_month( $i ) . "</option>";
 
 
 
 
 
78
  }
79
  ?>
80
  </select>
81
 
82
  <label for="slimstat-filter-year">Year</label>
83
+ <input type="text" name="year" id="slimstat-filter-year" placeholder="<?php _e('Year','wp-slimstat') ?>" value="">
84
  @
85
  <label for="slimstat-filter-hour">Hour</label>
86
+ <input type="text" name="hour" id="slimstat-filter-hour" placeholder="<?php _e('Hour','wp-slimstat') ?>" class="short" value="">:
87
 
88
  <label for="slimstat-filter-minute">Minute</label>
89
+ <input type="text" name="minute" id="slimstat-filter-minute" placeholder="<?php _e('Min','wp-slimstat') ?>" class="short" value="">
90
  <input type="hidden" class="slimstat-filter-date" name="slimstat-filter-date" value=""/>
91
  <br/>
92
 
97
  </select>
98
 
99
  <label for="slimstat-filter-interval">Days in interval</label>
100
+ <input type="text" name="interval" id="slimstat-filter-interval" placeholder="<?php _e('days', 'wp-slimstat') ?>" class="short" value="">,
101
 
102
  <label for="slimstat-filter-interval_hours">Hours in interval</label>
103
+ <input type="text" name="interval_hours" id="slimstat-filter-interval_hours" placeholder="<?php _e('hours', 'wp-slimstat') ?>" class="short" value="">:
104
 
105
  <label for="slimstat-filter-interval_minutes">Minutes in interval</label>
106
+ <input type="text" name="interval_minutes" id="slimstat-filter-interval_minutes" placeholder="<?php _e('mins', 'wp-slimstat') ?>" class="short" value="">
107
 
108
+ <input type="submit" value="<?php _e( 'Apply', 'wp-slimstat' ) ?>" class="button button-primary noslimstat">
109
 
110
  <?php
111
+ if ( !empty( wp_slimstat_db::$filters_normalized[ 'date' ][ 'day' ] ) || !empty( wp_slimstat_db::$filters_normalized[ 'date' ][ 'month' ] ) || !empty( wp_slimstat_db::$filters_normalized[ 'date' ][ 'year' ] ) || !empty( wp_slimstat_db::$filters_normalized[ 'date' ][ 'interval' ] ) || !empty( wp_slimstat_db::$filters_normalized[ 'date' ][ 'interval_hours' ] ) || !empty( wp_slimstat_db::$filters_normalized[ 'date' ][ 'interval_minutes' ] ) ) {
112
+ echo '<a class="slimstat-filter-link button button-secondary noslimstat" data-reset-filters="true" href="' . wp_slimstat_reports::fs_url() . '">' . __( 'Reset Filters', 'wp-slimstat' ) . '</a>';
113
+ }
114
+ ?>
 
 
 
 
115
  </div>
116
  </fieldset><!-- .slimstat-date-filters -->
117
 
118
+ <?php foreach( wp_slimstat_db::$filters_normalized[ 'columns' ] as $a_key => $a_details ): ?>
119
+ <input type="hidden" name="fs[<?php echo $a_key ?>]" class="slimstat-post-filter" value="<?php echo htmlspecialchars($a_details[0].' '.$a_details[1]) ?>"/>
120
  <?php endforeach ?>
121
 
122
+ <?php foreach ( wp_slimstat_db::$filters_normalized[ 'date' ] as $a_key => $a_value ) : if ( !empty( $a_value ) ): ?>
123
+ <input type="hidden" name="fs[<?php echo $a_key ?>]" class="slimstat-post-filter" value="equals <?php echo htmlspecialchars( $a_value ) ?>"/>
124
  <?php endif; endforeach; ?>
125
 
126
+ <?php foreach( wp_slimstat_db::$filters_normalized[ 'misc' ] as $a_key => $a_value ): if ( !empty( $a_value ) ): ?>
127
+ <input type="hidden" name="fs[<?php echo $a_key ?>]" class="slimstat-post-filter" value="equals <?php echo htmlspecialchars( $a_value ) ?>"/>
128
  <?php endif; endforeach; ?>
129
  </form>
130
  <?php
138
 
139
  // Path to wp-content folder, used to detect caching plugins via advanced-cache.php
140
  if ( file_exists( dirname( dirname( dirname( dirname( plugin_dir_path( __FILE__ ) ) ) ) ) . '/advanced-cache.php' ) && ( empty( wp_slimstat::$settings[ 'no_caching_warning' ] ) || wp_slimstat::$settings[ 'no_caching_warning' ] != 'on' ) && ( empty( wp_slimstat::$settings[ 'javascript_mode' ] ) || wp_slimstat::$settings[ 'javascript_mode' ] != 'on' ) ) {
141
+ wp_slimstat_admin::show_alert_message( sprintf( __( "A caching plugin might be enabled on your website. Please <a href='%s' target='_blank' class='noslimstat'>make sure to configure</a> Slimstat Analytics accordingly, to get accurate information.", 'wp-slimstat' ), 'https://slimstat.freshdesk.com/support/solutions/articles/5000528524-i-am-using-w3-total-cache-or-wp-super-cache-hypercache-etc-and-it-looks-like-slimstat-is-not-tra' ) . '<a id="slimstat-hide-caching-notice" class="slimstat-font-cancel slimstat-float-right" title="Hide this notice" href="#"></a>', 'wp-ui-text-notification below-h2' );
142
  }
143
 
144
  $filters_html = wp_slimstat_reports::get_filters_html( wp_slimstat_db::$filters_normalized[ 'columns' ] );
145
+ if ( !empty( $filters_html ) ) {
146
  echo "<div id='slimstat-current-filters'>$filters_html</div>";
147
  }
148
  ?>
admin/view/wp-slimstat-db.php CHANGED
@@ -121,7 +121,6 @@ class wp_slimstat_db {
121
  'event_description' => array( __( 'Event Description', 'wp-slimstat' ), 'varchar' ),
122
  'position' => array( __( 'Event Coordinates', 'wp-slimstat' ), 'int' ),
123
 
124
- 'direction' => array( __( 'Direction', 'wp-slimstat' ), 'varchar' ),
125
  'limit_results' => array( __( 'Max Results', 'wp-slimstat' ), 'int' ),
126
  'start_from' => array( __( 'Offset', 'wp-slimstat' ), 'int' ),
127
 
@@ -134,24 +133,27 @@ class wp_slimstat_db {
134
 
135
  // Filters use the following format: browser equals Firefox&&&country contains gb
136
  $filters_array = array();
137
- if ( !empty( $_REQUEST[ 'fs' ] ) && is_array( $_REQUEST[ 'fs' ] ) ) {
138
- foreach( $_REQUEST[ 'fs' ] as $a_request_filter_name => $a_request_filter_value ) {
 
 
139
  $filters_array[ htmlspecialchars( $a_request_filter_name ) ] = "$a_request_filter_name $a_request_filter_value";
140
  }
141
  }
142
 
143
- // Fields and drop downs
144
- if ( !empty( $_POST[ 'f' ] ) && !empty( $_POST[ 'o' ] ) ) {
145
- $filters_array[ htmlspecialchars( $_POST[ 'f' ] ) ] = "{$_POST[ 'f' ]} {$_POST[ 'o' ]} " . ( isset( $_POST[ 'v' ] ) ? $_POST[ 'v' ] : '' );
146
- }
147
-
148
  foreach ( array( 'minute', 'hour', 'day', 'month', 'year', 'interval_direction', 'interval', 'interval_hours', 'interval_minutes' ) as $a_date_time_filter_name ) {
149
- if ( isset( $_POST[ $a_date_time_filter_name ] ) ) {
150
  $filters_array[ $a_date_time_filter_name ] = "$a_date_time_filter_name equals " . intval( $_POST[ $a_date_time_filter_name ] );
151
  }
152
  }
153
 
154
- // Hidden Filters
 
 
 
 
 
155
  if ( wp_slimstat::$settings[ 'restrict_authors_view' ] == 'on' && !current_user_can( 'manage_options' ) && !empty( $GLOBALS[ 'current_user' ]->user_login ) ) {
156
  $filters_array[ 'author' ] = 'author equals ' . $GLOBALS[ 'current_user' ]->user_login;
157
  }
@@ -178,8 +180,7 @@ class wp_slimstat_db {
178
  $filters_raw = apply_filters( 'slimstat_db_pre_filters', $filters_raw );
179
 
180
  // Normalize the filters
181
- self::$filters_normalized = self::get_filters_normalized( $filters_raw );
182
-
183
  }
184
  // end init
185
 
@@ -357,7 +358,7 @@ class wp_slimstat_db {
357
  break;
358
  }
359
 
360
- if ( isset( $where[ 1 ] ) ) {
361
  return $GLOBALS[ 'wpdb' ]->prepare( $where[ 0 ], $where[ 1 ] );
362
  }
363
  else {
@@ -385,23 +386,14 @@ class wp_slimstat_db {
385
  return wp_slimstat::$wpdb->get_var( $_sql );
386
  }
387
 
388
- public static function get_filters_normalized( $_filters = '', $_init_misc = true ) {
389
  $filters_normalized = array(
390
  'columns' => array(),
391
- 'date' => array(),
392
- 'misc' => array(
393
- 'direction' => 'DESC',
394
- 'limit_results' => wp_slimstat::$settings[ 'limit_results' ],
395
- 'start_from' => 0
396
- ),
397
- 'utime' => array(
398
- 'start' => 0,
399
- 'end' => 0
400
- )
401
  );
402
 
403
- if ( !empty( $_filters ) ) {
404
- $matches = explode( '&&&', $_filters );
405
 
406
  foreach( $matches as $idx => $a_match ) {
407
  preg_match( '/([^\s]+)\s([^\s]+)\s(.+)?/', urldecode( $a_match ), $a_filter );
@@ -476,7 +468,6 @@ class wp_slimstat_db {
476
  $filters_normalized[ 'date' ][ $a_filter[ 1 ] ] = in_array( $a_filter[ 3 ], array( 1, 2 ) ) ? $a_filter[ 3 ] : 1;
477
  break;
478
 
479
- case 'direction':
480
  case 'limit_results':
481
  case 'start_from':
482
  $filters_normalized[ 'misc' ][ $a_filter[ 1 ] ] = str_replace( '\\', '', htmlspecialchars_decode( $a_filter[ 3 ] ) );
@@ -497,6 +488,25 @@ class wp_slimstat_db {
497
  }
498
  }
499
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
500
  // If the setting to use the last X days as default time span is enabled, we need to setup the "interval" variables
501
  if ( ( empty( wp_slimstat::$settings[ 'use_current_month_timespan' ] ) || wp_slimstat::$settings[ 'use_current_month_timespan' ] != 'on' ) ) {
502
  // Do not set the interval if another date filter has already been set
@@ -504,7 +514,7 @@ class wp_slimstat_db {
504
  if ( !empty( $filters_normalized[ 'date' ] ) ) {
505
  $filters_to_check = array_diff( $filters_normalized[ 'date' ], array( 'interval_direction' => 1 ) );
506
  foreach( $filters_to_check as $a_filter ) {
507
- if ( !empty( $a_filter ) ) {
508
  $is_date_filter_empty = false;
509
  break;
510
  }
@@ -521,7 +531,7 @@ class wp_slimstat_db {
521
  wp_slimstat::toggle_date_i18n_filters( false );
522
 
523
  // Let's calculate our time range, based on date filters
524
- if ( empty( $filters_normalized[ 'date' ][ 'interval' ] ) && empty( $filters_normalized[ 'date' ][ 'interval_hours' ] ) && empty( $filters_normalized[ 'date' ][ 'interval_minutes' ] ) ) {
525
  if ( !empty( $filters_normalized[ 'date' ][ 'minute' ] ) ) {
526
  $filters_normalized[ 'utime' ][ 'start' ] = mktime(
527
  !empty( $filters_normalized[ 'date' ][ 'hour' ] ) ? $filters_normalized[ 'date' ][ 'hour' ] : 0,
@@ -649,7 +659,7 @@ class wp_slimstat_db {
649
  wp_slimstat::toggle_date_i18n_filters( true );
650
 
651
  // Apply third-party filters
652
- $filters_normalized = apply_filters( 'slimstat_db_filters_normalized', $filters_normalized, $_filters );
653
 
654
  return $filters_normalized;
655
  }
121
  'event_description' => array( __( 'Event Description', 'wp-slimstat' ), 'varchar' ),
122
  'position' => array( __( 'Event Coordinates', 'wp-slimstat' ), 'int' ),
123
 
 
124
  'limit_results' => array( __( 'Max Results', 'wp-slimstat' ), 'int' ),
125
  'start_from' => array( __( 'Offset', 'wp-slimstat' ), 'int' ),
126
 
133
 
134
  // Filters use the following format: browser equals Firefox&&&country contains gb
135
  $filters_array = array();
136
+
137
+ // Filters are set via javascript as hidden fields and submitted as a POST request. They override anything passed through the regular input fields
138
+ if ( !empty( $_POST[ 'fs' ] ) && is_array( $_POST[ 'fs' ] ) ) {
139
+ foreach( $_POST[ 'fs' ] as $a_request_filter_name => $a_request_filter_value ) {
140
  $filters_array[ htmlspecialchars( $a_request_filter_name ) ] = "$a_request_filter_name $a_request_filter_value";
141
  }
142
  }
143
 
144
+ // Date filters (input fields)
 
 
 
 
145
  foreach ( array( 'minute', 'hour', 'day', 'month', 'year', 'interval_direction', 'interval', 'interval_hours', 'interval_minutes' ) as $a_date_time_filter_name ) {
146
+ if ( !empty( $_POST[ $a_date_time_filter_name ] ) ) {
147
  $filters_array[ $a_date_time_filter_name ] = "$a_date_time_filter_name equals " . intval( $_POST[ $a_date_time_filter_name ] );
148
  }
149
  }
150
 
151
+ // Fields and drop downs
152
+ if ( !empty( $_POST[ 'f' ] ) && !empty( $_POST[ 'o' ] ) ) {
153
+ $filters_array[ htmlspecialchars( $_POST[ 'f' ] ) ] = "{$_POST[ 'f' ]} {$_POST[ 'o' ]} " . ( isset( $_POST[ 'v' ] ) ? $_POST[ 'v' ] : '' );
154
+ }
155
+
156
+ // Filters set via the plugin options
157
  if ( wp_slimstat::$settings[ 'restrict_authors_view' ] == 'on' && !current_user_can( 'manage_options' ) && !empty( $GLOBALS[ 'current_user' ]->user_login ) ) {
158
  $filters_array[ 'author' ] = 'author equals ' . $GLOBALS[ 'current_user' ]->user_login;
159
  }
180
  $filters_raw = apply_filters( 'slimstat_db_pre_filters', $filters_raw );
181
 
182
  // Normalize the filters
183
+ self::$filters_normalized = self::init_filters( $filters_raw );
 
184
  }
185
  // end init
186
 
358
  break;
359
  }
360
 
361
+ if ( isset( $where[ 1 ] ) && $where[ 1 ] != '' ) {
362
  return $GLOBALS[ 'wpdb' ]->prepare( $where[ 0 ], $where[ 1 ] );
363
  }
364
  else {
386
  return wp_slimstat::$wpdb->get_var( $_sql );
387
  }
388
 
389
+ public static function parse_filters( $_filters_raw ) {
390
  $filters_normalized = array(
391
  'columns' => array(),
392
+ 'date' => array()
 
 
 
 
 
 
 
 
 
393
  );
394
 
395
+ if ( !empty( $_filters_raw ) ) {
396
+ $matches = explode( '&&&', $_filters_raw );
397
 
398
  foreach( $matches as $idx => $a_match ) {
399
  preg_match( '/([^\s]+)\s([^\s]+)\s(.+)?/', urldecode( $a_match ), $a_filter );
468
  $filters_normalized[ 'date' ][ $a_filter[ 1 ] ] = in_array( $a_filter[ 3 ], array( 1, 2 ) ) ? $a_filter[ 3 ] : 1;
469
  break;
470
 
 
471
  case 'limit_results':
472
  case 'start_from':
473
  $filters_normalized[ 'misc' ][ $a_filter[ 1 ] ] = str_replace( '\\', '', htmlspecialchars_decode( $a_filter[ 3 ] ) );
488
  }
489
  }
490
 
491
+ return $filters_normalized;
492
+ }
493
+
494
+ public static function init_filters( $_filters_raw = '' ) {
495
+ $filters_normalized = self::parse_filters( $_filters_raw );
496
+
497
+ // Initialize default values
498
+ if ( empty( $filters_normalized[ 'misc' ][ 'limit_results' ] ) ) {
499
+ $filters_normalized[ 'misc' ][ 'limit_results' ] = wp_slimstat::$settings[ 'limit_results' ];
500
+ }
501
+ if ( empty( $filters_normalized[ 'misc' ][ 'start_from' ] ) ) {
502
+ $filters_normalized[ 'misc' ][ 'start_from' ] = 0;
503
+ }
504
+
505
+ $filters_normalized[ 'utime' ] = array(
506
+ 'start' => 0,
507
+ 'end' => 0
508
+ );
509
+
510
  // If the setting to use the last X days as default time span is enabled, we need to setup the "interval" variables
511
  if ( ( empty( wp_slimstat::$settings[ 'use_current_month_timespan' ] ) || wp_slimstat::$settings[ 'use_current_month_timespan' ] != 'on' ) ) {
512
  // Do not set the interval if another date filter has already been set
514
  if ( !empty( $filters_normalized[ 'date' ] ) ) {
515
  $filters_to_check = array_diff( $filters_normalized[ 'date' ], array( 'interval_direction' => 1 ) );
516
  foreach( $filters_to_check as $a_filter ) {
517
+ if ( isset( $a_filter ) ) {
518
  $is_date_filter_empty = false;
519
  break;
520
  }
531
  wp_slimstat::toggle_date_i18n_filters( false );
532
 
533
  // Let's calculate our time range, based on date filters
534
+ if ( !isset( $filters_normalized[ 'date' ][ 'interval' ] ) && !isset( $filters_normalized[ 'date' ][ 'interval_hours' ] ) && !isset( $filters_normalized[ 'date' ][ 'interval_minutes' ] ) ) {
535
  if ( !empty( $filters_normalized[ 'date' ][ 'minute' ] ) ) {
536
  $filters_normalized[ 'utime' ][ 'start' ] = mktime(
537
  !empty( $filters_normalized[ 'date' ][ 'hour' ] ) ? $filters_normalized[ 'date' ][ 'hour' ] : 0,
659
  wp_slimstat::toggle_date_i18n_filters( true );
660
 
661
  // Apply third-party filters
662
+ $filters_normalized = apply_filters( 'slimstat_db_filters_normalized', $filters_normalized, $_filters_raw );
663
 
664
  return $filters_normalized;
665
  }
admin/view/wp-slimstat-reports.php CHANGED
@@ -920,7 +920,7 @@ class wp_slimstat_reports {
920
  if ( is_admin() ) {
921
  // Show the refresh button only if the time range is not in the past
922
  if ( wp_slimstat_db::$filters_normalized[ 'utime' ][ 'end' ] >= date_i18n( 'U' ) - 300 ) {
923
- $header_buttons = '<a class="button-ajax noslimstat refresh slimstat-font-arrows-cw" title="'.__('Refresh','wp-slimstat').'" href="'.self::fs_url().'"></a>';
924
  }
925
 
926
  // Allow third-party code to add more buttons
@@ -929,7 +929,7 @@ class wp_slimstat_reports {
929
  $header_tooltip = !empty( self::$reports_info[ $_report_id ][ 'tooltip' ] ) ? '<i class="slimstat-tooltip-trigger corner"><span class="slimstat-tooltip-content">' . self::$reports_info[ $_report_id ][ 'tooltip' ] . '</span></i>' : '';
930
  }
931
 
932
- echo "<div class='postbox $header_classes' id='$_report_id'>{$header_buttons} <h3 data-report-id='{$_report_id}'>" . self::$reports_info[ $_report_id ][ 'title' ] . " {$header_tooltip}</h3><div class='inside' id='{$_report_id}_inside'>";
933
  }
934
 
935
  public static function report_footer(){
@@ -953,18 +953,18 @@ class wp_slimstat_reports {
953
  if ( $startpoint == $_count_all_results ) {
954
  $startpoint -= $_results_per_page;
955
  }
956
- $pagination_buttons .= '<a class="button-ajax slimstat-font-angle-double-' . $direction_next . '" href="' . wp_slimstat_reports::fs_url( 'start_from equals ' . $startpoint ) . '"></a> ';
957
  }
958
  if ($endpoint < $_count_all_results && $_count_page_results > 0){
959
  $startpoint = wp_slimstat_db::$filters_normalized['misc']['start_from'] + $_results_per_page;
960
- $pagination_buttons .= '<a class="button-ajax slimstat-font-angle-'.$direction_next.'" href="' . wp_slimstat_reports::fs_url( 'start_from equals ' . $startpoint ) . '"></a> ';
961
  }
962
  if (wp_slimstat_db::$filters_normalized['misc']['start_from'] > 0){
963
  $startpoint = (wp_slimstat_db::$filters_normalized['misc']['start_from'] > $_results_per_page)?wp_slimstat_db::$filters_normalized['misc']['start_from'] - $_results_per_page : 0;
964
- $pagination_buttons .= '<a class="button-ajax slimstat-font-angle-'.$direction_prev.'" href="'.wp_slimstat_reports::fs_url('start_from equals '.$startpoint).'"></a> ';
965
  }
966
  if (wp_slimstat_db::$filters_normalized['misc']['start_from'] - $_results_per_page > 0){
967
- $pagination_buttons .= '<a class="button-ajax slimstat-font-angle-double-'.$direction_prev.'" href="'.wp_slimstat_reports::fs_url('start_from equals 0').'"></a> ';
968
  }
969
 
970
  $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::$settings[ 'limit_results' ] ) ? '+' : '') );
@@ -1023,7 +1023,7 @@ class wp_slimstat_reports {
1023
  $count_page_results = count( $results );
1024
 
1025
  if ($count_page_results == 0){
1026
- echo '<p class="nodata">'.__('No data to display','wp-slimstat').'</p>';
1027
 
1028
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
1029
  die();
@@ -1228,8 +1228,15 @@ class wp_slimstat_reports {
1228
  }
1229
 
1230
  public static function show_chart( $_args = array() ) {
1231
- if ( empty( $_args ) ) {
1232
- echo 'No data found';
 
 
 
 
 
 
 
1233
 
1234
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
1235
  die();
@@ -1239,12 +1246,6 @@ class wp_slimstat_reports {
1239
  }
1240
  }
1241
 
1242
-
1243
- //<div class="one-third"></div>
1244
- //<div class="one-third"></div>
1245
- //<div class="one-third"></div>
1246
- // return 0;
1247
-
1248
  // Enqueue all the Javascript and styles
1249
  $path_slimstat = dirname( dirname( __FILE__ ) );
1250
  wp_enqueue_script( 'slimstat_amcharts', plugins_url( '/admin/js/amcharts/amcharts.js', $path_slimstat ), array(), null, false );
@@ -1255,17 +1256,17 @@ class wp_slimstat_reports {
1255
  wp_enqueue_style( 'slimstat_amcharts_plugins_export_css', plugins_url( '/admin/js/amcharts/plugins/export/export.css', $path_slimstat ) );
1256
 
1257
  // Pre-calculate all the values needed to render the charts
1258
- $chart_data = wp_slimstat_db::get_data_for_chart( $_args[ 'chart_data' ] );
1259
  $chart_colors = !empty( wp_slimstat::$settings[ 'chart_colors' ] ) ? wp_slimstat::string_to_array( wp_slimstat::$settings[ 'chart_colors' ] ) : array( '#bbcc44', '#21759b', '#ccc', '#999' );
1260
 
1261
  ?>
1262
- <div class="chart-placeholder" id="slim_chart_<?php echo $_args[ 'id' ]; ?>" style="min-height: 280px"></div>
1263
 
1264
  <script type="text/javascript">
1265
  <?php if ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ): ?>
1266
  jQuery(function() {
1267
  <?php endif; ?>
1268
- var chart_<?php echo $_args[ 'id' ]; ?> = AmCharts.makeChart("slim_chart_<?php echo $_args[ 'id' ]; ?>", {
1269
  "type": "serial",
1270
  "zoomOutButtonPadding": 25,
1271
  "theme": "light",
@@ -1795,7 +1796,7 @@ class wp_slimstat_reports {
1795
  $count_page_results = count( $results );
1796
 
1797
  if ($count_page_results == 0){
1798
- echo '<p class="nodata">'.__('No data to display','wp-slimstat').'</p>';
1799
 
1800
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
1801
  die();
@@ -1828,11 +1829,12 @@ class wp_slimstat_reports {
1828
  }
1829
 
1830
  public static function show_world_map() {
1831
- $countries = wp_slimstat_db::get_top('country');
1832
- $recent_visits = wp_slimstat_db::get_recent('location', '', '', true, '', 'city');
 
 
1833
  if ( !empty( $recent_visits ) ) {
1834
  $recent_visits = array_slice( $recent_visits, 0, wp_slimstat::$settings[ 'max_dots_on_map' ] );
1835
- $data_points = array();
1836
 
1837
  foreach ( $recent_visits as $a_recent_visit ) {
1838
  if ( !empty( $a_recent_visit[ 'city' ] ) && !empty( $a_recent_visit[ 'location' ] ) ) {
@@ -1845,82 +1847,107 @@ class wp_slimstat_reports {
1845
  }
1846
 
1847
  $data_areas = array('xx'=>'{id:"XX",balloonText:"'.__('c-xx','wp-slimstat').': 0",value:0,color:"#ededed"}','af'=>'{id:"AF",balloonText:"'.__('c-af','wp-slimstat').': 0",value:0,color:"#ededed"}','ax'=>'{id:"AX",balloonText:"'.__('c-ax','wp-slimstat').': 0",value:0,color:"#ededed"}','al'=>'{id:"AL",balloonText:"'.__('c-al','wp-slimstat').': 0",value:0,color:"#ededed"}','dz'=>'{id:"DZ",balloonText:"'.__('c-dz','wp-slimstat').': 0",value:0,color:"#ededed"}','ad'=>'{id:"AD",balloonText:"'.__('c-ad','wp-slimstat').': 0",value:0,color:"#ededed"}','ao'=>'{id:"AO",balloonText:"'.__('c-ao','wp-slimstat').': 0",value:0,color:"#ededed"}','ai'=>'{id:"AI",balloonText:"'.__('c-ai','wp-slimstat').': 0",value:0,color:"#ededed"}','ag'=>'{id:"AG",balloonText:"'.__('c-ag','wp-slimstat').': 0",value:0,color:"#ededed"}','ar'=>'{id:"AR",balloonText:"'.__('c-ar','wp-slimstat').': 0",value:0,color:"#ededed"}','am'=>'{id:"AM",balloonText:"'.__('c-am','wp-slimstat').': 0",value:0,color:"#ededed"}','aw'=>'{id:"AW",balloonText:"'.__('c-aw','wp-slimstat').': 0",value:0,color:"#ededed"}','au'=>'{id:"AU",balloonText:"'.__('c-au','wp-slimstat').': 0",value:0,color:"#ededed"}','at'=>'{id:"AT",balloonText:"'.__('c-at','wp-slimstat').': 0",value:0,color:"#ededed"}','az'=>'{id:"AZ",balloonText:"'.__('c-az','wp-slimstat').': 0",value:0,color:"#ededed"}','bs'=>'{id:"BS",balloonText:"'.__('c-bs','wp-slimstat').': 0",value:0,color:"#ededed"}','bh'=>'{id:"BH",balloonText:"'.__('c-bh','wp-slimstat').': 0",value:0,color:"#ededed"}','bd'=>'{id:"BD",balloonText:"'.__('c-bd','wp-slimstat').': 0",value:0,color:"#ededed"}','bb'=>'{id:"BB",balloonText:"'.__('c-bb','wp-slimstat').': 0",value:0,color:"#ededed"}','by'=>'{id:"BY",balloonText:"'.__('c-by','wp-slimstat').': 0",value:0,color:"#ededed"}','be'=>'{id:"BE",balloonText:"'.__('c-be','wp-slimstat').': 0",value:0,color:"#ededed"}','bz'=>'{id:"BZ",balloonText:"'.__('c-bz','wp-slimstat').': 0",value:0,color:"#ededed"}','bj'=>'{id:"BJ",balloonText:"'.__('c-bj','wp-slimstat').': 0",value:0,color:"#ededed"}','bm'=>'{id:"BM",balloonText:"'.__('c-bm','wp-slimstat').': 0",value:0,color:"#ededed"}','bt'=>'{id:"BT",balloonText:"'.__('c-bt','wp-slimstat').': 0",value:0,color:"#ededed"}','bo'=>'{id:"BO",balloonText:"'.__('c-bo','wp-slimstat').': 0",value:0,color:"#ededed"}','ba'=>'{id:"BA",balloonText:"'.__('c-ba','wp-slimstat').': 0",value:0,color:"#ededed"}','bw'=>'{id:"BW",balloonText:"'.__('c-bw','wp-slimstat').': 0",value:0,color:"#ededed"}','br'=>'{id:"BR",balloonText:"'.__('c-br','wp-slimstat').': 0",value:0,color:"#ededed"}','bn'=>'{id:"BN",balloonText:"'.__('c-bn','wp-slimstat').': 0",value:0,color:"#ededed"}','bg'=>'{id:"BG",balloonText:"'.__('c-bg','wp-slimstat').': 0",value:0,color:"#ededed"}','bf'=>'{id:"BF",balloonText:"'.__('c-bf','wp-slimstat').': 0",value:0,color:"#ededed"}','bi'=>'{id:"BI",balloonText:"'.__('c-bi','wp-slimstat').': 0",value:0,color:"#ededed"}','kh'=>'{id:"KH",balloonText:"'.__('c-kh','wp-slimstat').': 0",value:0,color:"#ededed"}','cm'=>'{id:"CM",balloonText:"'.__('c-cm','wp-slimstat').': 0",value:0,color:"#ededed"}','ca'=>'{id:"CA",balloonText:"'.__('c-ca','wp-slimstat').': 0",value:0,color:"#ededed"}','cv'=>'{id:"CV",balloonText:"'.__('c-cv','wp-slimstat').': 0",value:0,color:"#ededed"}','ky'=>'{id:"KY",balloonText:"'.__('c-ky','wp-slimstat').': 0",value:0,color:"#ededed"}','cf'=>'{id:"CF",balloonText:"'.__('c-cf','wp-slimstat').': 0",value:0,color:"#ededed"}','td'=>'{id:"TD",balloonText:"'.__('c-td','wp-slimstat').': 0",value:0,color:"#ededed"}','cl'=>'{id:"CL",balloonText:"'.__('c-cl','wp-slimstat').': 0",value:0,color:"#ededed"}','cn'=>'{id:"CN",balloonText:"'.__('c-cn','wp-slimstat').': 0",value:0,color:"#ededed"}','co'=>'{id:"CO",balloonText:"'.__('c-co','wp-slimstat').': 0",value:0,color:"#ededed"}','km'=>'{id:"KM",balloonText:"'.__('c-km','wp-slimstat').': 0",value:0,color:"#ededed"}','cg'=>'{id:"CG",balloonText:"'.__('c-cg','wp-slimstat').': 0",value:0,color:"#ededed"}','cd'=>'{id:"CD",balloonText:"'.__('c-cd','wp-slimstat').': 0",value:0,color:"#ededed"}','cr'=>'{id:"CR",balloonText:"'.__('c-cr','wp-slimstat').': 0",value:0,color:"#ededed"}','ci'=>'{id:"CI",balloonText:"'.__('c-ci','wp-slimstat').': 0",value:0,color:"#ededed"}','hr'=>'{id:"HR",balloonText:"'.__('c-hr','wp-slimstat').': 0",value:0,color:"#ededed"}','cu'=>'{id:"CU",balloonText:"'.__('c-cu','wp-slimstat').': 0",value:0,color:"#ededed"}','cy'=>'{id:"CY",balloonText:"'.__('c-cy','wp-slimstat').': 0",value:0,color:"#ededed"}','cz'=>'{id:"CZ",balloonText:"'.__('c-cz','wp-slimstat').': 0",value:0,color:"#ededed"}','dk'=>'{id:"DK",balloonText:"'.__('c-dk','wp-slimstat').': 0",value:0,color:"#ededed"}','dj'=>'{id:"DJ",balloonText:"'.__('c-dj','wp-slimstat').': 0",value:0,color:"#ededed"}','dm'=>'{id:"DM",balloonText:"'.__('c-dm','wp-slimstat').': 0",value:0,color:"#ededed"}','do'=>'{id:"DO",balloonText:"'.__('c-do','wp-slimstat').': 0",value:0,color:"#ededed"}','ec'=>'{id:"EC",balloonText:"'.__('c-ec','wp-slimstat').': 0",value:0,color:"#ededed"}','eg'=>'{id:"EG",balloonText:"'.__('c-eg','wp-slimstat').': 0",value:0,color:"#ededed"}','sv'=>'{id:"SV",balloonText:"'.__('c-sv','wp-slimstat').': 0",value:0,color:"#ededed"}','gq'=>'{id:"GQ",balloonText:"'.__('c-gq','wp-slimstat').': 0",value:0,color:"#ededed"}','er'=>'{id:"ER",balloonText:"'.__('c-er','wp-slimstat').': 0",value:0,color:"#ededed"}','ee'=>'{id:"EE",balloonText:"'.__('c-ee','wp-slimstat').': 0",value:0,color:"#ededed"}','et'=>'{id:"ET",balloonText:"'.__('c-et','wp-slimstat').': 0",value:0,color:"#ededed"}','fo'=>'{id:"FO",balloonText:"'.__('c-fo','wp-slimstat').': 0",value:0,color:"#ededed"}','fk'=>'{id:"FK",balloonText:"'.__('c-fk','wp-slimstat').': 0",value:0,color:"#ededed"}','fj'=>'{id:"FJ",balloonText:"'.__('c-fj','wp-slimstat').': 0",value:0,color:"#ededed"}','fi'=>'{id:"FI",balloonText:"'.__('c-fi','wp-slimstat').': 0",value:0,color:"#ededed"}','fr'=>'{id:"FR",balloonText:"'.__('c-fr','wp-slimstat').': 0",value:0,color:"#ededed"}','gf'=>'{id:"GF",balloonText:"'.__('c-gf','wp-slimstat').': 0",value:0,color:"#ededed"}','ga'=>'{id:"GA",balloonText:"'.__('c-ga','wp-slimstat').': 0",value:0,color:"#ededed"}','gm'=>'{id:"GM",balloonText:"'.__('c-gm','wp-slimstat').': 0",value:0,color:"#ededed"}','ge'=>'{id:"GE",balloonText:"'.__('c-ge','wp-slimstat').': 0",value:0,color:"#ededed"}','de'=>'{id:"DE",balloonText:"'.__('c-de','wp-slimstat').': 0",value:0,color:"#ededed"}','gh'=>'{id:"GH",balloonText:"'.__('c-gh','wp-slimstat').': 0",value:0,color:"#ededed"}','gr'=>'{id:"GR",balloonText:"'.__('c-gr','wp-slimstat').': 0",value:0,color:"#ededed"}','gl'=>'{id:"GL",balloonText:"'.__('c-gl','wp-slimstat').': 0",value:0,color:"#ededed"}','gd'=>'{id:"GD",balloonText:"'.__('c-gd','wp-slimstat').': 0",value:0,color:"#ededed"}','gp'=>'{id:"GP",balloonText:"'.__('c-gp','wp-slimstat').': 0",value:0,color:"#ededed"}','gt'=>'{id:"GT",balloonText:"'.__('c-gt','wp-slimstat').': 0",value:0,color:"#ededed"}','gn'=>'{id:"GN",balloonText:"'.__('c-gn','wp-slimstat').': 0",value:0,color:"#ededed"}','gw'=>'{id:"GW",balloonText:"'.__('c-gw','wp-slimstat').': 0",value:0,color:"#ededed"}','gy'=>'{id:"GY",balloonText:"'.__('c-gy','wp-slimstat').': 0",value:0,color:"#ededed"}','ht'=>'{id:"HT",balloonText:"'.__('c-ht','wp-slimstat').': 0",value:0,color:"#ededed"}','hn'=>'{id:"HN",balloonText:"'.__('c-hn','wp-slimstat').': 0",value:0,color:"#ededed"}','hk'=>'{id:"HK",balloonText:"'.__('c-hk','wp-slimstat').': 0",value:0,color:"#ededed"}','hu'=>'{id:"HU",balloonText:"'.__('c-hu','wp-slimstat').': 0",value:0,color:"#ededed"}','is'=>'{id:"IS",balloonText:"'.__('c-is','wp-slimstat').': 0",value:0,color:"#ededed"}','in'=>'{id:"IN",balloonText:"'.__('c-in','wp-slimstat').': 0",value:0,color:"#ededed"}','id'=>'{id:"ID",balloonText:"'.__('c-id','wp-slimstat').': 0",value:0,color:"#ededed"}','ir'=>'{id:"IR",balloonText:"'.__('c-ir','wp-slimstat').': 0",value:0,color:"#ededed"}','iq'=>'{id:"IQ",balloonText:"'.__('c-iq','wp-slimstat').': 0",value:0,color:"#ededed"}','ie'=>'{id:"IE",balloonText:"'.__('c-ie','wp-slimstat').': 0",value:0,color:"#ededed"}','il'=>'{id:"IL",balloonText:"'.__('c-il','wp-slimstat').': 0",value:0,color:"#ededed"}','it'=>'{id:"IT",balloonText:"'.__('c-it','wp-slimstat').': 0",value:0,color:"#ededed"}','jm'=>'{id:"JM",balloonText:"'.__('c-jm','wp-slimstat').': 0",value:0,color:"#ededed"}','jp'=>'{id:"JP",balloonText:"'.__('c-jp','wp-slimstat').': 0",value:0,color:"#ededed"}','jo'=>'{id:"JO",balloonText:"'.__('c-jo','wp-slimstat').': 0",value:0,color:"#ededed"}','kz'=>'{id:"KZ",balloonText:"'.__('c-kz','wp-slimstat').': 0",value:0,color:"#ededed"}','ke'=>'{id:"KE",balloonText:"'.__('c-ke','wp-slimstat').': 0",value:0,color:"#ededed"}','nr'=>'{id:"NR",balloonText:"'.__('c-nr','wp-slimstat').': 0",value:0,color:"#ededed"}','kp'=>'{id:"KP",balloonText:"'.__('c-kp','wp-slimstat').': 0",value:0,color:"#ededed"}','kr'=>'{id:"KR",balloonText:"'.__('c-kr','wp-slimstat').': 0",value:0,color:"#ededed"}','kv'=>'{id:"KV",balloonText:"'.__('c-kv','wp-slimstat').': 0",value:0,color:"#ededed"}','kw'=>'{id:"KW",balloonText:"'.__('c-kw','wp-slimstat').': 0",value:0,color:"#ededed"}','kg'=>'{id:"KG",balloonText:"'.__('c-kg','wp-slimstat').': 0",value:0,color:"#ededed"}','la'=>'{id:"LA",balloonText:"'.__('c-la','wp-slimstat').': 0",value:0,color:"#ededed"}','lv'=>'{id:"LV",balloonText:"'.__('c-lv','wp-slimstat').': 0",value:0,color:"#ededed"}','lb'=>'{id:"LB",balloonText:"'.__('c-lb','wp-slimstat').': 0",value:0,color:"#ededed"}','ls'=>'{id:"LS",balloonText:"'.__('c-ls','wp-slimstat').': 0",value:0,color:"#ededed"}','lr'=>'{id:"LR",balloonText:"'.__('c-lr','wp-slimstat').': 0",value:0,color:"#ededed"}','ly'=>'{id:"LY",balloonText:"'.__('c-ly','wp-slimstat').': 0",value:0,color:"#ededed"}','li'=>'{id:"LI",balloonText:"'.__('c-li','wp-slimstat').': 0",value:0,color:"#ededed"}','lt'=>'{id:"LT",balloonText:"'.__('c-lt','wp-slimstat').': 0",value:0,color:"#ededed"}','lu'=>'{id:"LU",balloonText:"'.__('c-lu','wp-slimstat').': 0",value:0,color:"#ededed"}','mk'=>'{id:"MK",balloonText:"'.__('c-mk','wp-slimstat').': 0",value:0,color:"#ededed"}','mg'=>'{id:"MG",balloonText:"'.__('c-mg','wp-slimstat').': 0",value:0,color:"#ededed"}','mw'=>'{id:"MW",balloonText:"'.__('c-mw','wp-slimstat').': 0",value:0,color:"#ededed"}','my'=>'{id:"MY",balloonText:"'.__('c-my','wp-slimstat').': 0",value:0,color:"#ededed"}','ml'=>'{id:"ML",balloonText:"'.__('c-ml','wp-slimstat').': 0",value:0,color:"#ededed"}','mt'=>'{id:"MT",balloonText:"'.__('c-mt','wp-slimstat').': 0",value:0,color:"#ededed"}','mq'=>'{id:"MQ",balloonText:"'.__('c-mq','wp-slimstat').': 0",value:0,color:"#ededed"}','mr'=>'{id:"MR",balloonText:"'.__('c-mr','wp-slimstat').': 0",value:0,color:"#ededed"}','mu'=>'{id:"MU",balloonText:"'.__('c-mu','wp-slimstat').': 0",value:0,color:"#ededed"}','mx'=>'{id:"MX",balloonText:"'.__('c-mx','wp-slimstat').': 0",value:0,color:"#ededed"}','md'=>'{id:"MD",balloonText:"'.__('c-md','wp-slimstat').': 0",value:0,color:"#ededed"}','mn'=>'{id:"MN",balloonText:"'.__('c-mn','wp-slimstat').': 0",value:0,color:"#ededed"}','me'=>'{id:"ME",balloonText:"'.__('c-me','wp-slimstat').': 0",value:0,color:"#ededed"}','ms'=>'{id:"MS",balloonText:"'.__('c-ms','wp-slimstat').': 0",value:0,color:"#ededed"}','ma'=>'{id:"MA",balloonText:"'.__('c-ma','wp-slimstat').': 0",value:0,color:"#ededed"}','mz'=>'{id:"MZ",balloonText:"'.__('c-mz','wp-slimstat').': 0",value:0,color:"#ededed"}','mm'=>'{id:"MM",balloonText:"'.__('c-mm','wp-slimstat').': 0",value:0,color:"#ededed"}','na'=>'{id:"NA",balloonText:"'.__('c-na','wp-slimstat').': 0",value:0,color:"#ededed"}','np'=>'{id:"NP",balloonText:"'.__('c-np','wp-slimstat').': 0",value:0,color:"#ededed"}','nl'=>'{id:"NL",balloonText:"'.__('c-nl','wp-slimstat').': 0",value:0,color:"#ededed"}','nc'=>'{id:"NC",balloonText:"'.__('c-nc','wp-slimstat').': 0",value:0,color:"#ededed"}','nz'=>'{id:"NZ",balloonText:"'.__('c-nz','wp-slimstat').': 0",value:0,color:"#ededed"}','ni'=>'{id:"NI",balloonText:"'.__('c-ni','wp-slimstat').': 0",value:0,color:"#ededed"}','ne'=>'{id:"NE",balloonText:"'.__('c-ne','wp-slimstat').': 0",value:0,color:"#ededed"}','ng'=>'{id:"NG",balloonText:"'.__('c-ng','wp-slimstat').': 0",value:0,color:"#ededed"}','no'=>'{id:"NO",balloonText:"'.__('c-no','wp-slimstat').': 0",value:0,color:"#ededed"}','om'=>'{id:"OM",balloonText:"'.__('c-om','wp-slimstat').': 0",value:0,color:"#ededed"}','pk'=>'{id:"PK",balloonText:"'.__('c-pk','wp-slimstat').': 0",value:0,color:"#ededed"}','pw'=>'{id:"PW",balloonText:"'.__('c-pw','wp-slimstat').': 0",value:0,color:"#ededed"}','ps'=>'{id:"PS",balloonText:"'.__('c-ps','wp-slimstat').': 0",value:0,color:"#ededed"}','pa'=>'{id:"PA",balloonText:"'.__('c-pa','wp-slimstat').': 0",value:0,color:"#ededed"}','pg'=>'{id:"PG",balloonText:"'.__('c-pg','wp-slimstat').': 0",value:0,color:"#ededed"}','py'=>'{id:"PY",balloonText:"'.__('c-py','wp-slimstat').': 0",value:0,color:"#ededed"}','pe'=>'{id:"PE",balloonText:"'.__('c-pe','wp-slimstat').': 0",value:0,color:"#ededed"}','ph'=>'{id:"PH",balloonText:"'.__('c-ph','wp-slimstat').': 0",value:0,color:"#ededed"}','pl'=>'{id:"PL",balloonText:"'.__('c-pl','wp-slimstat').': 0",value:0,color:"#ededed"}','pt'=>'{id:"PT",balloonText:"'.__('c-pt','wp-slimstat').': 0",value:0,color:"#ededed"}','pr'=>'{id:"PR",balloonText:"'.__('c-pr','wp-slimstat').': 0",value:0,color:"#ededed"}','qa'=>'{id:"QA",balloonText:"'.__('c-qa','wp-slimstat').': 0",value:0,color:"#ededed"}','re'=>'{id:"RE",balloonText:"'.__('c-re','wp-slimstat').': 0",value:0,color:"#ededed"}','ro'=>'{id:"RO",balloonText:"'.__('c-ro','wp-slimstat').': 0",value:0,color:"#ededed"}','ru'=>'{id:"RU",balloonText:"'.__('c-ru','wp-slimstat').': 0",value:0,color:"#ededed"}','rw'=>'{id:"RW",balloonText:"'.__('c-rw','wp-slimstat').': 0",value:0,color:"#ededed"}','kn'=>'{id:"KN",balloonText:"'.__('c-kn','wp-slimstat').': 0",value:0,color:"#ededed"}','lc'=>'{id:"LC",balloonText:"'.__('c-lc','wp-slimstat').': 0",value:0,color:"#ededed"}','mf'=>'{id:"MF",balloonText:"'.__('c-mf','wp-slimstat').': 0",value:0,color:"#ededed"}','vc'=>'{id:"VC",balloonText:"'.__('c-vc','wp-slimstat').': 0",value:0,color:"#ededed"}','ws'=>'{id:"WS",balloonText:"'.__('c-ws','wp-slimstat').': 0",value:0,color:"#ededed"}','st'=>'{id:"ST",balloonText:"'.__('c-st','wp-slimstat').': 0",value:0,color:"#ededed"}','sa'=>'{id:"SA",balloonText:"'.__('c-sa','wp-slimstat').': 0",value:0,color:"#ededed"}','sn'=>'{id:"SN",balloonText:"'.__('c-sn','wp-slimstat').': 0",value:0,color:"#ededed"}','rs'=>'{id:"RS",balloonText:"'.__('c-rs','wp-slimstat').': 0",value:0,color:"#ededed"}','sl'=>'{id:"SL",balloonText:"'.__('c-sl','wp-slimstat').': 0",value:0,color:"#ededed"}','sg'=>'{id:"SG",balloonText:"'.__('c-sg','wp-slimstat').': 0",value:0,color:"#ededed"}','sk'=>'{id:"SK",balloonText:"'.__('c-sk','wp-slimstat').': 0",value:0,color:"#ededed"}','si'=>'{id:"SI",balloonText:"'.__('c-si','wp-slimstat').': 0",value:0,color:"#ededed"}','sb'=>'{id:"SB",balloonText:"'.__('c-sb','wp-slimstat').': 0",value:0,color:"#ededed"}','so'=>'{id:"SO",balloonText:"'.__('c-so','wp-slimstat').': 0",value:0,color:"#ededed"}','za'=>'{id:"ZA",balloonText:"'.__('c-za','wp-slimstat').': 0",value:0,color:"#ededed"}','gs'=>'{id:"GS",balloonText:"'.__('c-gs','wp-slimstat').': 0",value:0,color:"#ededed"}','es'=>'{id:"ES",balloonText:"'.__('c-es','wp-slimstat').': 0",value:0,color:"#ededed"}','lk'=>'{id:"LK",balloonText:"'.__('c-lk','wp-slimstat').': 0",value:0,color:"#ededed"}','sc'=>'{id:"SC",balloonText:"'.__('c-sc','wp-slimstat').': 0",value:0,color:"#ededed"}','sd'=>'{id:"SD",balloonText:"'.__('c-sd','wp-slimstat').': 0",value:0,color:"#ededed"}','ss'=>'{id:"SS",balloonText:"'.__('c-ss','wp-slimstat').': 0",value:0,color:"#ededed"}','sr'=>'{id:"SR",balloonText:"'.__('c-sr','wp-slimstat').': 0",value:0,color:"#ededed"}','sj'=>'{id:"SJ",balloonText:"'.__('c-sj','wp-slimstat').': 0",value:0,color:"#ededed"}','sz'=>'{id:"SZ",balloonText:"'.__('c-sz','wp-slimstat').': 0",value:0,color:"#ededed"}','se'=>'{id:"SE",balloonText:"'.__('c-se','wp-slimstat').': 0",value:0,color:"#ededed"}','ch'=>'{id:"CH",balloonText:"'.__('c-ch','wp-slimstat').': 0",value:0,color:"#ededed"}','sy'=>'{id:"SY",balloonText:"'.__('c-sy','wp-slimstat').': 0",value:0,color:"#ededed"}','tw'=>'{id:"TW",balloonText:"'.__('c-tw','wp-slimstat').': 0",value:0,color:"#ededed"}','tj'=>'{id:"TJ",balloonText:"'.__('c-tj','wp-slimstat').': 0",value:0,color:"#ededed"}','tz'=>'{id:"TZ",balloonText:"'.__('c-tz','wp-slimstat').': 0",value:0,color:"#ededed"}','th'=>'{id:"TH",balloonText:"'.__('c-th','wp-slimstat').': 0",value:0,color:"#ededed"}','tl'=>'{id:"TL",balloonText:"'.__('c-tl','wp-slimstat').': 0",value:0,color:"#ededed"}','tg'=>'{id:"TG",balloonText:"'.__('c-tg','wp-slimstat').': 0",value:0,color:"#ededed"}','to'=>'{id:"TO",balloonText:"'.__('c-to','wp-slimstat').': 0",value:0,color:"#ededed"}','tt'=>'{id:"TT",balloonText:"'.__('c-tt','wp-slimstat').': 0",value:0,color:"#ededed"}','tn'=>'{id:"TN",balloonText:"'.__('c-tn','wp-slimstat').': 0",value:0,color:"#ededed"}','tr'=>'{id:"TR",balloonText:"'.__('c-tr','wp-slimstat').': 0",value:0,color:"#ededed"}','tm'=>'{id:"TM",balloonText:"'.__('c-tm','wp-slimstat').': 0",value:0,color:"#ededed"}','tc'=>'{id:"TC",balloonText:"'.__('c-tc','wp-slimstat').': 0",value:0,color:"#ededed"}','ug'=>'{id:"UG",balloonText:"'.__('c-ug','wp-slimstat').': 0",value:0,color:"#ededed"}','ua'=>'{id:"UA",balloonText:"'.__('c-ua','wp-slimstat').': 0",value:0,color:"#ededed"}','ae'=>'{id:"AE",balloonText:"'.__('c-ae','wp-slimstat').': 0",value:0,color:"#ededed"}','gb'=>'{id:"GB",balloonText:"'.__('c-gb','wp-slimstat').': 0",value:0,color:"#ededed"}','us'=>'{id:"US",balloonText:"'.__('c-us','wp-slimstat').': 0",value:0,color:"#ededed"}','uy'=>'{id:"UY",balloonText:"'.__('c-uy','wp-slimstat').': 0",value:0,color:"#ededed"}','uz'=>'{id:"UZ",balloonText:"'.__('c-uz','wp-slimstat').': 0",value:0,color:"#ededed"}','vu'=>'{id:"VU",balloonText:"'.__('c-vu','wp-slimstat').': 0",value:0,color:"#ededed"}','ve'=>'{id:"VE",balloonText:"'.__('c-ve','wp-slimstat').': 0",value:0,color:"#ededed"}','vn'=>'{id:"VN",balloonText:"'.__('c-vn','wp-slimstat').': 0",value:0,color:"#ededed"}','vg'=>'{id:"VG",balloonText:"'.__('c-vg','wp-slimstat').': 0",value:0,color:"#ededed"}','vi'=>'{id:"VI",balloonText:"'.__('c-vi','wp-slimstat').': 0",value:0,color:"#ededed"}','eh'=>'{id:"EH",balloonText:"'.__('c-eh','wp-slimstat').': 0",value:0,color:"#ededed"}','ye'=>'{id:"YE",balloonText:"'.__('c-ye','wp-slimstat').': 0",value:0,color:"#ededed"}','zm'=>'{id:"ZM",balloonText:"'.__('c-zm','wp-slimstat').': 0",value:0,color:"#ededed"}','zw'=>'{id:"ZW",balloonText:"'.__('c-zw','wp-slimstat').': 0",value:0,color:"#ededed"}','gg'=>'{id:"GG",balloonText:"'.__('c-gg','wp-slimstat').': 0",value:0,color:"#ededed"}','je'=>'{id:"JE",balloonText:"'.__('c-je','wp-slimstat').': 0",value:0,color:"#ededed"}','im'=>'{id:"IM",balloonText:"'.__('c-im','wp-slimstat').': 0",value:0,color:"#ededed"}','mv'=>'{id:"MV",balloonText:"'.__('c-mv','wp-slimstat').': 0",value:0,color:"#ededed"}');
1848
- $countries_not_represented = array( __('c-eu','wp-slimstat') );
1849
  $max = 0;
1850
 
1851
- foreach($countries as $a_country){
1852
- if (!array_key_exists($a_country['country'], $data_areas)) continue;
 
 
1853
 
1854
- $percentage = (self::$pageviews > 0)?sprintf("%01.2f", (100*$a_country['counthits']/self::$pageviews)) : 0;
1855
- $percentage_format = number_format($percentage, 2, wp_slimstat_db::$formats['decimal'], wp_slimstat_db::$formats['thousand']);
1856
- $balloon_text = __('c-'.$a_country['country'], 'wp-slimstat').': '.$percentage_format.'% ('.number_format($a_country['counthits'], 0, wp_slimstat_db::$formats['decimal'], wp_slimstat_db::$formats['thousand']).')';
1857
- $data_areas[$a_country['country']] = '{id:"'.strtoupper($a_country['country']).'",balloonText:"'.$balloon_text.'",value:'.$percentage.'}';
1858
 
1859
  if ( $percentage > $max ) {
1860
  $max = $percentage;
1861
  }
1862
  }
 
 
 
 
 
 
 
 
 
1863
  ?>
1864
 
1865
- <script src="<?php echo plugins_url('/js/ammap/ammap.js', dirname(__FILE__)) ?>" type="text/javascript"></script>
1866
- <script src="<?php echo plugins_url('/js/ammap/world.js', dirname(__FILE__)) ?>" type="text/javascript"></script>
1867
 
1868
  <script type="text/javascript">
1869
- var targetSVG = "M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z";
1870
-
1871
- var dataProvider = {
1872
- map: "worldLow",
1873
- getAreasFromMap: true,
1874
- areas:[ <?php echo implode( ',', $data_areas ) ?> ],
1875
- images: [ <?php if ( !empty( $data_points ) ) echo implode( ',', $data_points ) ?> ]
1876
- };
1877
-
1878
- // Create AmMap object
1879
- var map = new AmCharts.AmMap();
1880
-
1881
- <?php if ($max != 0): ?>
1882
- var legend = new AmCharts.ValueLegend();
1883
- legend.height = 20;
1884
- legend.minValue = "0.01";
1885
- legend.maxValue = "<?php echo $max ?>%";
1886
- legend.right = 20;
1887
- legend.showAsGradient = true;
1888
- legend.width = 300;
1889
- map.valueLegend = legend;
1890
- <?php endif; ?>
1891
-
1892
- // Configuration
1893
- map.areasSettings = {
1894
- autoZoom: false,
1895
- color: "#9dff98",
1896
- colorSolid: "#fa8a50",
1897
- outlineColor: "#888888",
1898
- selectedColor: "#ffb739"
1899
- };
1900
- map.imagesSettings = {
1901
- rollOverColor: "#089282",
1902
- rollOverScale: 2,
1903
- selectedScale: 2,
1904
- selectedColor: "#089282",
1905
- color: "#13564e"
1906
- };
1907
- map.zoomControl = {
1908
- zoomControlEnabled: true,
1909
- zoomFactor: 3
1910
- };
1911
- map.backgroundAlpha = .9;
1912
- map.backgroundColor = "#7adafd";
1913
- map.backgroundZoomsToTop = false;
1914
- map.balloon.color = "#000000";
1915
- map.colorSteps = 5;
1916
- map.mouseWheelZoomEnabled = true;
1917
- map.pathToImages = "<?php echo plugins_url('/js/ammap/images/', dirname(__FILE__)) ?>";
1918
-
1919
- // Init Data
1920
- map.dataProvider = dataProvider;
1921
-
1922
- // Display Map
1923
- map.write("slim_p6_01_inside");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1924
  </script><?php
1925
 
1926
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
@@ -1965,7 +1992,7 @@ class wp_slimstat_reports {
1965
  }
1966
 
1967
  $a_filter_value_no_slashes = htmlentities( str_replace( '\\','', $a_filter_details[ 1 ] ), ENT_QUOTES, 'UTF-8' );
1968
- $filters_html .= '<li>' . strtolower( wp_slimstat_db::$columns_names[ $a_filter_label ][ 0 ] ) . ' ' . __( str_replace( '_', ' ', $a_filter_details[ 0 ] ), 'wp-slimstat' ) . " $a_filter_value_no_slashes <a class='slimstat-remove-filter slimstat-font-cancel' title='" . htmlentities( __( 'Remove filter for', 'wp-slimstat' ), ENT_QUOTES, 'UTF-8' ) . ' ' . wp_slimstat_db::$columns_names[ $a_filter_label ][ 0 ] . "' href='" . self::fs_url( "$a_filter_label equals " ) . "'></a></li>";
1969
  }
1970
  }
1971
 
@@ -1980,28 +2007,26 @@ class wp_slimstat_reports {
1980
  return $filters_html;
1981
  }
1982
 
1983
- public static function fs_url( $_filters = '' ) {
1984
-
1985
  // Allow only legitimate requests
1986
- $request_uri = htmlspecialchars( $_SERVER[ 'REQUEST_URI' ], ENT_QUOTES, 'UTF-8' );
1987
- $request_page = 'slimview1';
1988
-
1989
  if ( !is_admin() ) {
1990
  return '';
1991
  }
1992
 
1993
- // Are we on the Dashboard?
1994
- if ( empty( $_REQUEST[ 'page' ] ) ) {
1995
- $request_uri = str_replace( 'index.php', 'admin.php', $request_uri );
1996
- }
1997
- else if ( array_key_exists( $_REQUEST[ 'page' ], wp_slimstat_admin::$screens_info ) ) {
 
 
 
1998
  $request_page = $_REQUEST[ 'page' ];
1999
  }
2000
- else {
2001
- return '';
2002
- }
2003
 
2004
- // Avoid XSS attacks (why would the owner attack him/herself?)
 
 
2005
  if ( !empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
2006
  $parsed_referer = parse_url( $_SERVER[ 'HTTP_REFERER' ] );
2007
  if ( !$parsed_referer || ( !empty( $parsed_referer[ 'scheme' ] ) && !in_array( strtolower( $parsed_referer[ 'scheme' ] ), array( 'http', 'https' ) ) ) ) {
@@ -2009,38 +2034,33 @@ class wp_slimstat_reports {
2009
  }
2010
  }
2011
 
2012
- $filtered_url = explode( '?', ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? $_SERVER[ 'HTTP_REFERER' ] : $request_uri );
2013
- $filtered_url = $filtered_url[ 0 ] . '?page=' . $request_page;
2014
 
2015
  // Columns
2016
- $url_filters = wp_slimstat_db::get_filters_normalized( $_filters, false );
2017
-
2018
- if ( !empty( $url_filters[ 'columns' ] ) ) {
2019
- foreach ( $url_filters[ 'columns' ] as $a_key => $a_filter ) {
2020
  $a_key = str_replace( '_calculated', '', $a_key );
2021
- $filtered_url .= "&amp;fs%5B$a_key%5D=" . urlencode( $a_filter[ 0 ] . ' ' . $a_filter[ 1 ] );
2022
  }
2023
  }
2024
 
2025
  // Date ranges
2026
- if ( !empty( $url_filters[ 'date' ] ) ) {
2027
- foreach ( $url_filters[ 'date' ] as $a_key => $a_filter ) {
2028
  if ( isset( $a_filter ) ) {
2029
- $filtered_url .= "&amp;fs%5B$a_key%5D=" . urlencode( 'equals ' . $a_filter );
2030
  }
2031
  }
2032
  }
2033
 
2034
  // Misc filters
2035
- if ( !empty( $url_filters[ 'misc' ] ) ) {
2036
- foreach ( $url_filters[ 'misc' ] as $a_key => $a_filter ) {
2037
- if ( strpos( $_filters, "$a_key equals" ) !== false ) {
2038
- $filtered_url .= "&amp;fs%5B$a_key%5D=" . urlencode( 'equals ' . $a_filter );
2039
- }
2040
  }
2041
  }
2042
 
2043
- return $filtered_url;
2044
  }
2045
 
2046
  /**
920
  if ( is_admin() ) {
921
  // Show the refresh button only if the time range is not in the past
922
  if ( wp_slimstat_db::$filters_normalized[ 'utime' ][ 'end' ] >= date_i18n( 'U' ) - 300 ) {
923
+ $header_buttons = '<a class="noslimstat refresh slimstat-font-arrows-cw" title="'.__('Refresh','wp-slimstat').'" href="'.self::fs_url().'"></a>';
924
  }
925
 
926
  // Allow third-party code to add more buttons
929
  $header_tooltip = !empty( self::$reports_info[ $_report_id ][ 'tooltip' ] ) ? '<i class="slimstat-tooltip-trigger corner"><span class="slimstat-tooltip-content">' . self::$reports_info[ $_report_id ][ 'tooltip' ] . '</span></i>' : '';
930
  }
931
 
932
+ echo "<div class='postbox $header_classes' id='$_report_id'>{$header_buttons} <h3 data-report-id='{$_report_id}'>" . self::$reports_info[ $_report_id ][ 'title' ] . " {$header_tooltip}</h3><div class='inside'>";
933
  }
934
 
935
  public static function report_footer(){
953
  if ( $startpoint == $_count_all_results ) {
954
  $startpoint -= $_results_per_page;
955
  }
956
+ $pagination_buttons .= '<a class="refresh slimstat-font-angle-double-' . $direction_next . '" href="' . wp_slimstat_reports::fs_url( 'start_from equals ' . $startpoint ) . '"></a> ';
957
  }
958
  if ($endpoint < $_count_all_results && $_count_page_results > 0){
959
  $startpoint = wp_slimstat_db::$filters_normalized['misc']['start_from'] + $_results_per_page;
960
+ $pagination_buttons .= '<a class="refresh slimstat-font-angle-'.$direction_next.'" href="' . wp_slimstat_reports::fs_url( 'start_from equals ' . $startpoint ) . '"></a> ';
961
  }
962
  if (wp_slimstat_db::$filters_normalized['misc']['start_from'] > 0){
963
  $startpoint = (wp_slimstat_db::$filters_normalized['misc']['start_from'] > $_results_per_page)?wp_slimstat_db::$filters_normalized['misc']['start_from'] - $_results_per_page : 0;
964
+ $pagination_buttons .= '<a class="refresh slimstat-font-angle-'.$direction_prev.'" href="'.wp_slimstat_reports::fs_url('start_from equals '.$startpoint).'"></a> ';
965
  }
966
  if (wp_slimstat_db::$filters_normalized['misc']['start_from'] - $_results_per_page > 0){
967
+ $pagination_buttons .= '<a class="refresh slimstat-font-angle-double-'.$direction_prev.'" href="'.wp_slimstat_reports::fs_url('start_from equals 0').'"></a> ';
968
  }
969
 
970
  $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::$settings[ 'limit_results' ] ) ? '+' : '') );
1023
  $count_page_results = count( $results );
1024
 
1025
  if ($count_page_results == 0){
1026
+ echo '<p class="nodata">' . __( 'No data to display', 'wp-slimstat' ) . '</p>';
1027
 
1028
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
1029
  die();
1228
  }
1229
 
1230
  public static function show_chart( $_args = array() ) {
1231
+ $chart_data = wp_slimstat_db::get_data_for_chart( $_args[ 'chart_data' ] );
1232
+
1233
+ if ( empty( $chart_data[ 'json_count' ] ) ) {
1234
+ if ( !empty( wp_slimstat_db::$filters_normalized[ 'date' ][ 'interval' ] ) && wp_slimstat_db::$filters_normalized[ 'date' ][ 'interval' ] == 1 ) {
1235
+ echo '<p class="nodata">' . __( 'Chart is not displayed when the selected time range is comprised of a single day', 'wp-slimstat') . '</p>';
1236
+ }
1237
+ else {
1238
+ echo '<p class="nodata">' . __( 'No data to display', 'wp-slimstat') . '</p>';
1239
+ }
1240
 
1241
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
1242
  die();
1246
  }
1247
  }
1248
 
 
 
 
 
 
 
1249
  // Enqueue all the Javascript and styles
1250
  $path_slimstat = dirname( dirname( __FILE__ ) );
1251
  wp_enqueue_script( 'slimstat_amcharts', plugins_url( '/admin/js/amcharts/amcharts.js', $path_slimstat ), array(), null, false );
1256
  wp_enqueue_style( 'slimstat_amcharts_plugins_export_css', plugins_url( '/admin/js/amcharts/plugins/export/export.css', $path_slimstat ) );
1257
 
1258
  // Pre-calculate all the values needed to render the charts
1259
+
1260
  $chart_colors = !empty( wp_slimstat::$settings[ 'chart_colors' ] ) ? wp_slimstat::string_to_array( wp_slimstat::$settings[ 'chart_colors' ] ) : array( '#bbcc44', '#21759b', '#ccc', '#999' );
1261
 
1262
  ?>
1263
+ <div class="chart-placeholder" id="chart_<?php echo $_args[ 'id' ]; ?>" style="min-height: 280px"></div>
1264
 
1265
  <script type="text/javascript">
1266
  <?php if ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ): ?>
1267
  jQuery(function() {
1268
  <?php endif; ?>
1269
+ var chart_<?php echo $_args[ 'id' ]; ?> = AmCharts.makeChart("chart_<?php echo $_args[ 'id' ]; ?>", {
1270
  "type": "serial",
1271
  "zoomOutButtonPadding": 25,
1272
  "theme": "light",
1796
  $count_page_results = count( $results );
1797
 
1798
  if ($count_page_results == 0){
1799
+ echo '<p class="nodata">' . __( 'No data to display', 'wp-slimstat' ) . '</p>';
1800
 
1801
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
1802
  die();
1829
  }
1830
 
1831
  public static function show_world_map() {
1832
+ $countries = wp_slimstat_db::get_top( 'country' );
1833
+ $recent_visits = wp_slimstat_db::get_recent( 'location', '', '', true, '', 'city' );
1834
+
1835
+ $data_points = array();
1836
  if ( !empty( $recent_visits ) ) {
1837
  $recent_visits = array_slice( $recent_visits, 0, wp_slimstat::$settings[ 'max_dots_on_map' ] );
 
1838
 
1839
  foreach ( $recent_visits as $a_recent_visit ) {
1840
  if ( !empty( $a_recent_visit[ 'city' ] ) && !empty( $a_recent_visit[ 'location' ] ) ) {
1847
  }
1848
 
1849
  $data_areas = array('xx'=>'{id:"XX",balloonText:"'.__('c-xx','wp-slimstat').': 0",value:0,color:"#ededed"}','af'=>'{id:"AF",balloonText:"'.__('c-af','wp-slimstat').': 0",value:0,color:"#ededed"}','ax'=>'{id:"AX",balloonText:"'.__('c-ax','wp-slimstat').': 0",value:0,color:"#ededed"}','al'=>'{id:"AL",balloonText:"'.__('c-al','wp-slimstat').': 0",value:0,color:"#ededed"}','dz'=>'{id:"DZ",balloonText:"'.__('c-dz','wp-slimstat').': 0",value:0,color:"#ededed"}','ad'=>'{id:"AD",balloonText:"'.__('c-ad','wp-slimstat').': 0",value:0,color:"#ededed"}','ao'=>'{id:"AO",balloonText:"'.__('c-ao','wp-slimstat').': 0",value:0,color:"#ededed"}','ai'=>'{id:"AI",balloonText:"'.__('c-ai','wp-slimstat').': 0",value:0,color:"#ededed"}','ag'=>'{id:"AG",balloonText:"'.__('c-ag','wp-slimstat').': 0",value:0,color:"#ededed"}','ar'=>'{id:"AR",balloonText:"'.__('c-ar','wp-slimstat').': 0",value:0,color:"#ededed"}','am'=>'{id:"AM",balloonText:"'.__('c-am','wp-slimstat').': 0",value:0,color:"#ededed"}','aw'=>'{id:"AW",balloonText:"'.__('c-aw','wp-slimstat').': 0",value:0,color:"#ededed"}','au'=>'{id:"AU",balloonText:"'.__('c-au','wp-slimstat').': 0",value:0,color:"#ededed"}','at'=>'{id:"AT",balloonText:"'.__('c-at','wp-slimstat').': 0",value:0,color:"#ededed"}','az'=>'{id:"AZ",balloonText:"'.__('c-az','wp-slimstat').': 0",value:0,color:"#ededed"}','bs'=>'{id:"BS",balloonText:"'.__('c-bs','wp-slimstat').': 0",value:0,color:"#ededed"}','bh'=>'{id:"BH",balloonText:"'.__('c-bh','wp-slimstat').': 0",value:0,color:"#ededed"}','bd'=>'{id:"BD",balloonText:"'.__('c-bd','wp-slimstat').': 0",value:0,color:"#ededed"}','bb'=>'{id:"BB",balloonText:"'.__('c-bb','wp-slimstat').': 0",value:0,color:"#ededed"}','by'=>'{id:"BY",balloonText:"'.__('c-by','wp-slimstat').': 0",value:0,color:"#ededed"}','be'=>'{id:"BE",balloonText:"'.__('c-be','wp-slimstat').': 0",value:0,color:"#ededed"}','bz'=>'{id:"BZ",balloonText:"'.__('c-bz','wp-slimstat').': 0",value:0,color:"#ededed"}','bj'=>'{id:"BJ",balloonText:"'.__('c-bj','wp-slimstat').': 0",value:0,color:"#ededed"}','bm'=>'{id:"BM",balloonText:"'.__('c-bm','wp-slimstat').': 0",value:0,color:"#ededed"}','bt'=>'{id:"BT",balloonText:"'.__('c-bt','wp-slimstat').': 0",value:0,color:"#ededed"}','bo'=>'{id:"BO",balloonText:"'.__('c-bo','wp-slimstat').': 0",value:0,color:"#ededed"}','ba'=>'{id:"BA",balloonText:"'.__('c-ba','wp-slimstat').': 0",value:0,color:"#ededed"}','bw'=>'{id:"BW",balloonText:"'.__('c-bw','wp-slimstat').': 0",value:0,color:"#ededed"}','br'=>'{id:"BR",balloonText:"'.__('c-br','wp-slimstat').': 0",value:0,color:"#ededed"}','bn'=>'{id:"BN",balloonText:"'.__('c-bn','wp-slimstat').': 0",value:0,color:"#ededed"}','bg'=>'{id:"BG",balloonText:"'.__('c-bg','wp-slimstat').': 0",value:0,color:"#ededed"}','bf'=>'{id:"BF",balloonText:"'.__('c-bf','wp-slimstat').': 0",value:0,color:"#ededed"}','bi'=>'{id:"BI",balloonText:"'.__('c-bi','wp-slimstat').': 0",value:0,color:"#ededed"}','kh'=>'{id:"KH",balloonText:"'.__('c-kh','wp-slimstat').': 0",value:0,color:"#ededed"}','cm'=>'{id:"CM",balloonText:"'.__('c-cm','wp-slimstat').': 0",value:0,color:"#ededed"}','ca'=>'{id:"CA",balloonText:"'.__('c-ca','wp-slimstat').': 0",value:0,color:"#ededed"}','cv'=>'{id:"CV",balloonText:"'.__('c-cv','wp-slimstat').': 0",value:0,color:"#ededed"}','ky'=>'{id:"KY",balloonText:"'.__('c-ky','wp-slimstat').': 0",value:0,color:"#ededed"}','cf'=>'{id:"CF",balloonText:"'.__('c-cf','wp-slimstat').': 0",value:0,color:"#ededed"}','td'=>'{id:"TD",balloonText:"'.__('c-td','wp-slimstat').': 0",value:0,color:"#ededed"}','cl'=>'{id:"CL",balloonText:"'.__('c-cl','wp-slimstat').': 0",value:0,color:"#ededed"}','cn'=>'{id:"CN",balloonText:"'.__('c-cn','wp-slimstat').': 0",value:0,color:"#ededed"}','co'=>'{id:"CO",balloonText:"'.__('c-co','wp-slimstat').': 0",value:0,color:"#ededed"}','km'=>'{id:"KM",balloonText:"'.__('c-km','wp-slimstat').': 0",value:0,color:"#ededed"}','cg'=>'{id:"CG",balloonText:"'.__('c-cg','wp-slimstat').': 0",value:0,color:"#ededed"}','cd'=>'{id:"CD",balloonText:"'.__('c-cd','wp-slimstat').': 0",value:0,color:"#ededed"}','cr'=>'{id:"CR",balloonText:"'.__('c-cr','wp-slimstat').': 0",value:0,color:"#ededed"}','ci'=>'{id:"CI",balloonText:"'.__('c-ci','wp-slimstat').': 0",value:0,color:"#ededed"}','hr'=>'{id:"HR",balloonText:"'.__('c-hr','wp-slimstat').': 0",value:0,color:"#ededed"}','cu'=>'{id:"CU",balloonText:"'.__('c-cu','wp-slimstat').': 0",value:0,color:"#ededed"}','cy'=>'{id:"CY",balloonText:"'.__('c-cy','wp-slimstat').': 0",value:0,color:"#ededed"}','cz'=>'{id:"CZ",balloonText:"'.__('c-cz','wp-slimstat').': 0",value:0,color:"#ededed"}','dk'=>'{id:"DK",balloonText:"'.__('c-dk','wp-slimstat').': 0",value:0,color:"#ededed"}','dj'=>'{id:"DJ",balloonText:"'.__('c-dj','wp-slimstat').': 0",value:0,color:"#ededed"}','dm'=>'{id:"DM",balloonText:"'.__('c-dm','wp-slimstat').': 0",value:0,color:"#ededed"}','do'=>'{id:"DO",balloonText:"'.__('c-do','wp-slimstat').': 0",value:0,color:"#ededed"}','ec'=>'{id:"EC",balloonText:"'.__('c-ec','wp-slimstat').': 0",value:0,color:"#ededed"}','eg'=>'{id:"EG",balloonText:"'.__('c-eg','wp-slimstat').': 0",value:0,color:"#ededed"}','sv'=>'{id:"SV",balloonText:"'.__('c-sv','wp-slimstat').': 0",value:0,color:"#ededed"}','gq'=>'{id:"GQ",balloonText:"'.__('c-gq','wp-slimstat').': 0",value:0,color:"#ededed"}','er'=>'{id:"ER",balloonText:"'.__('c-er','wp-slimstat').': 0",value:0,color:"#ededed"}','ee'=>'{id:"EE",balloonText:"'.__('c-ee','wp-slimstat').': 0",value:0,color:"#ededed"}','et'=>'{id:"ET",balloonText:"'.__('c-et','wp-slimstat').': 0",value:0,color:"#ededed"}','fo'=>'{id:"FO",balloonText:"'.__('c-fo','wp-slimstat').': 0",value:0,color:"#ededed"}','fk'=>'{id:"FK",balloonText:"'.__('c-fk','wp-slimstat').': 0",value:0,color:"#ededed"}','fj'=>'{id:"FJ",balloonText:"'.__('c-fj','wp-slimstat').': 0",value:0,color:"#ededed"}','fi'=>'{id:"FI",balloonText:"'.__('c-fi','wp-slimstat').': 0",value:0,color:"#ededed"}','fr'=>'{id:"FR",balloonText:"'.__('c-fr','wp-slimstat').': 0",value:0,color:"#ededed"}','gf'=>'{id:"GF",balloonText:"'.__('c-gf','wp-slimstat').': 0",value:0,color:"#ededed"}','ga'=>'{id:"GA",balloonText:"'.__('c-ga','wp-slimstat').': 0",value:0,color:"#ededed"}','gm'=>'{id:"GM",balloonText:"'.__('c-gm','wp-slimstat').': 0",value:0,color:"#ededed"}','ge'=>'{id:"GE",balloonText:"'.__('c-ge','wp-slimstat').': 0",value:0,color:"#ededed"}','de'=>'{id:"DE",balloonText:"'.__('c-de','wp-slimstat').': 0",value:0,color:"#ededed"}','gh'=>'{id:"GH",balloonText:"'.__('c-gh','wp-slimstat').': 0",value:0,color:"#ededed"}','gr'=>'{id:"GR",balloonText:"'.__('c-gr','wp-slimstat').': 0",value:0,color:"#ededed"}','gl'=>'{id:"GL",balloonText:"'.__('c-gl','wp-slimstat').': 0",value:0,color:"#ededed"}','gd'=>'{id:"GD",balloonText:"'.__('c-gd','wp-slimstat').': 0",value:0,color:"#ededed"}','gp'=>'{id:"GP",balloonText:"'.__('c-gp','wp-slimstat').': 0",value:0,color:"#ededed"}','gt'=>'{id:"GT",balloonText:"'.__('c-gt','wp-slimstat').': 0",value:0,color:"#ededed"}','gn'=>'{id:"GN",balloonText:"'.__('c-gn','wp-slimstat').': 0",value:0,color:"#ededed"}','gw'=>'{id:"GW",balloonText:"'.__('c-gw','wp-slimstat').': 0",value:0,color:"#ededed"}','gy'=>'{id:"GY",balloonText:"'.__('c-gy','wp-slimstat').': 0",value:0,color:"#ededed"}','ht'=>'{id:"HT",balloonText:"'.__('c-ht','wp-slimstat').': 0",value:0,color:"#ededed"}','hn'=>'{id:"HN",balloonText:"'.__('c-hn','wp-slimstat').': 0",value:0,color:"#ededed"}','hk'=>'{id:"HK",balloonText:"'.__('c-hk','wp-slimstat').': 0",value:0,color:"#ededed"}','hu'=>'{id:"HU",balloonText:"'.__('c-hu','wp-slimstat').': 0",value:0,color:"#ededed"}','is'=>'{id:"IS",balloonText:"'.__('c-is','wp-slimstat').': 0",value:0,color:"#ededed"}','in'=>'{id:"IN",balloonText:"'.__('c-in','wp-slimstat').': 0",value:0,color:"#ededed"}','id'=>'{id:"ID",balloonText:"'.__('c-id','wp-slimstat').': 0",value:0,color:"#ededed"}','ir'=>'{id:"IR",balloonText:"'.__('c-ir','wp-slimstat').': 0",value:0,color:"#ededed"}','iq'=>'{id:"IQ",balloonText:"'.__('c-iq','wp-slimstat').': 0",value:0,color:"#ededed"}','ie'=>'{id:"IE",balloonText:"'.__('c-ie','wp-slimstat').': 0",value:0,color:"#ededed"}','il'=>'{id:"IL",balloonText:"'.__('c-il','wp-slimstat').': 0",value:0,color:"#ededed"}','it'=>'{id:"IT",balloonText:"'.__('c-it','wp-slimstat').': 0",value:0,color:"#ededed"}','jm'=>'{id:"JM",balloonText:"'.__('c-jm','wp-slimstat').': 0",value:0,color:"#ededed"}','jp'=>'{id:"JP",balloonText:"'.__('c-jp','wp-slimstat').': 0",value:0,color:"#ededed"}','jo'=>'{id:"JO",balloonText:"'.__('c-jo','wp-slimstat').': 0",value:0,color:"#ededed"}','kz'=>'{id:"KZ",balloonText:"'.__('c-kz','wp-slimstat').': 0",value:0,color:"#ededed"}','ke'=>'{id:"KE",balloonText:"'.__('c-ke','wp-slimstat').': 0",value:0,color:"#ededed"}','nr'=>'{id:"NR",balloonText:"'.__('c-nr','wp-slimstat').': 0",value:0,color:"#ededed"}','kp'=>'{id:"KP",balloonText:"'.__('c-kp','wp-slimstat').': 0",value:0,color:"#ededed"}','kr'=>'{id:"KR",balloonText:"'.__('c-kr','wp-slimstat').': 0",value:0,color:"#ededed"}','kv'=>'{id:"KV",balloonText:"'.__('c-kv','wp-slimstat').': 0",value:0,color:"#ededed"}','kw'=>'{id:"KW",balloonText:"'.__('c-kw','wp-slimstat').': 0",value:0,color:"#ededed"}','kg'=>'{id:"KG",balloonText:"'.__('c-kg','wp-slimstat').': 0",value:0,color:"#ededed"}','la'=>'{id:"LA",balloonText:"'.__('c-la','wp-slimstat').': 0",value:0,color:"#ededed"}','lv'=>'{id:"LV",balloonText:"'.__('c-lv','wp-slimstat').': 0",value:0,color:"#ededed"}','lb'=>'{id:"LB",balloonText:"'.__('c-lb','wp-slimstat').': 0",value:0,color:"#ededed"}','ls'=>'{id:"LS",balloonText:"'.__('c-ls','wp-slimstat').': 0",value:0,color:"#ededed"}','lr'=>'{id:"LR",balloonText:"'.__('c-lr','wp-slimstat').': 0",value:0,color:"#ededed"}','ly'=>'{id:"LY",balloonText:"'.__('c-ly','wp-slimstat').': 0",value:0,color:"#ededed"}','li'=>'{id:"LI",balloonText:"'.__('c-li','wp-slimstat').': 0",value:0,color:"#ededed"}','lt'=>'{id:"LT",balloonText:"'.__('c-lt','wp-slimstat').': 0",value:0,color:"#ededed"}','lu'=>'{id:"LU",balloonText:"'.__('c-lu','wp-slimstat').': 0",value:0,color:"#ededed"}','mk'=>'{id:"MK",balloonText:"'.__('c-mk','wp-slimstat').': 0",value:0,color:"#ededed"}','mg'=>'{id:"MG",balloonText:"'.__('c-mg','wp-slimstat').': 0",value:0,color:"#ededed"}','mw'=>'{id:"MW",balloonText:"'.__('c-mw','wp-slimstat').': 0",value:0,color:"#ededed"}','my'=>'{id:"MY",balloonText:"'.__('c-my','wp-slimstat').': 0",value:0,color:"#ededed"}','ml'=>'{id:"ML",balloonText:"'.__('c-ml','wp-slimstat').': 0",value:0,color:"#ededed"}','mt'=>'{id:"MT",balloonText:"'.__('c-mt','wp-slimstat').': 0",value:0,color:"#ededed"}','mq'=>'{id:"MQ",balloonText:"'.__('c-mq','wp-slimstat').': 0",value:0,color:"#ededed"}','mr'=>'{id:"MR",balloonText:"'.__('c-mr','wp-slimstat').': 0",value:0,color:"#ededed"}','mu'=>'{id:"MU",balloonText:"'.__('c-mu','wp-slimstat').': 0",value:0,color:"#ededed"}','mx'=>'{id:"MX",balloonText:"'.__('c-mx','wp-slimstat').': 0",value:0,color:"#ededed"}','md'=>'{id:"MD",balloonText:"'.__('c-md','wp-slimstat').': 0",value:0,color:"#ededed"}','mn'=>'{id:"MN",balloonText:"'.__('c-mn','wp-slimstat').': 0",value:0,color:"#ededed"}','me'=>'{id:"ME",balloonText:"'.__('c-me','wp-slimstat').': 0",value:0,color:"#ededed"}','ms'=>'{id:"MS",balloonText:"'.__('c-ms','wp-slimstat').': 0",value:0,color:"#ededed"}','ma'=>'{id:"MA",balloonText:"'.__('c-ma','wp-slimstat').': 0",value:0,color:"#ededed"}','mz'=>'{id:"MZ",balloonText:"'.__('c-mz','wp-slimstat').': 0",value:0,color:"#ededed"}','mm'=>'{id:"MM",balloonText:"'.__('c-mm','wp-slimstat').': 0",value:0,color:"#ededed"}','na'=>'{id:"NA",balloonText:"'.__('c-na','wp-slimstat').': 0",value:0,color:"#ededed"}','np'=>'{id:"NP",balloonText:"'.__('c-np','wp-slimstat').': 0",value:0,color:"#ededed"}','nl'=>'{id:"NL",balloonText:"'.__('c-nl','wp-slimstat').': 0",value:0,color:"#ededed"}','nc'=>'{id:"NC",balloonText:"'.__('c-nc','wp-slimstat').': 0",value:0,color:"#ededed"}','nz'=>'{id:"NZ",balloonText:"'.__('c-nz','wp-slimstat').': 0",value:0,color:"#ededed"}','ni'=>'{id:"NI",balloonText:"'.__('c-ni','wp-slimstat').': 0",value:0,color:"#ededed"}','ne'=>'{id:"NE",balloonText:"'.__('c-ne','wp-slimstat').': 0",value:0,color:"#ededed"}','ng'=>'{id:"NG",balloonText:"'.__('c-ng','wp-slimstat').': 0",value:0,color:"#ededed"}','no'=>'{id:"NO",balloonText:"'.__('c-no','wp-slimstat').': 0",value:0,color:"#ededed"}','om'=>'{id:"OM",balloonText:"'.__('c-om','wp-slimstat').': 0",value:0,color:"#ededed"}','pk'=>'{id:"PK",balloonText:"'.__('c-pk','wp-slimstat').': 0",value:0,color:"#ededed"}','pw'=>'{id:"PW",balloonText:"'.__('c-pw','wp-slimstat').': 0",value:0,color:"#ededed"}','ps'=>'{id:"PS",balloonText:"'.__('c-ps','wp-slimstat').': 0",value:0,color:"#ededed"}','pa'=>'{id:"PA",balloonText:"'.__('c-pa','wp-slimstat').': 0",value:0,color:"#ededed"}','pg'=>'{id:"PG",balloonText:"'.__('c-pg','wp-slimstat').': 0",value:0,color:"#ededed"}','py'=>'{id:"PY",balloonText:"'.__('c-py','wp-slimstat').': 0",value:0,color:"#ededed"}','pe'=>'{id:"PE",balloonText:"'.__('c-pe','wp-slimstat').': 0",value:0,color:"#ededed"}','ph'=>'{id:"PH",balloonText:"'.__('c-ph','wp-slimstat').': 0",value:0,color:"#ededed"}','pl'=>'{id:"PL",balloonText:"'.__('c-pl','wp-slimstat').': 0",value:0,color:"#ededed"}','pt'=>'{id:"PT",balloonText:"'.__('c-pt','wp-slimstat').': 0",value:0,color:"#ededed"}','pr'=>'{id:"PR",balloonText:"'.__('c-pr','wp-slimstat').': 0",value:0,color:"#ededed"}','qa'=>'{id:"QA",balloonText:"'.__('c-qa','wp-slimstat').': 0",value:0,color:"#ededed"}','re'=>'{id:"RE",balloonText:"'.__('c-re','wp-slimstat').': 0",value:0,color:"#ededed"}','ro'=>'{id:"RO",balloonText:"'.__('c-ro','wp-slimstat').': 0",value:0,color:"#ededed"}','ru'=>'{id:"RU",balloonText:"'.__('c-ru','wp-slimstat').': 0",value:0,color:"#ededed"}','rw'=>'{id:"RW",balloonText:"'.__('c-rw','wp-slimstat').': 0",value:0,color:"#ededed"}','kn'=>'{id:"KN",balloonText:"'.__('c-kn','wp-slimstat').': 0",value:0,color:"#ededed"}','lc'=>'{id:"LC",balloonText:"'.__('c-lc','wp-slimstat').': 0",value:0,color:"#ededed"}','mf'=>'{id:"MF",balloonText:"'.__('c-mf','wp-slimstat').': 0",value:0,color:"#ededed"}','vc'=>'{id:"VC",balloonText:"'.__('c-vc','wp-slimstat').': 0",value:0,color:"#ededed"}','ws'=>'{id:"WS",balloonText:"'.__('c-ws','wp-slimstat').': 0",value:0,color:"#ededed"}','st'=>'{id:"ST",balloonText:"'.__('c-st','wp-slimstat').': 0",value:0,color:"#ededed"}','sa'=>'{id:"SA",balloonText:"'.__('c-sa','wp-slimstat').': 0",value:0,color:"#ededed"}','sn'=>'{id:"SN",balloonText:"'.__('c-sn','wp-slimstat').': 0",value:0,color:"#ededed"}','rs'=>'{id:"RS",balloonText:"'.__('c-rs','wp-slimstat').': 0",value:0,color:"#ededed"}','sl'=>'{id:"SL",balloonText:"'.__('c-sl','wp-slimstat').': 0",value:0,color:"#ededed"}','sg'=>'{id:"SG",balloonText:"'.__('c-sg','wp-slimstat').': 0",value:0,color:"#ededed"}','sk'=>'{id:"SK",balloonText:"'.__('c-sk','wp-slimstat').': 0",value:0,color:"#ededed"}','si'=>'{id:"SI",balloonText:"'.__('c-si','wp-slimstat').': 0",value:0,color:"#ededed"}','sb'=>'{id:"SB",balloonText:"'.__('c-sb','wp-slimstat').': 0",value:0,color:"#ededed"}','so'=>'{id:"SO",balloonText:"'.__('c-so','wp-slimstat').': 0",value:0,color:"#ededed"}','za'=>'{id:"ZA",balloonText:"'.__('c-za','wp-slimstat').': 0",value:0,color:"#ededed"}','gs'=>'{id:"GS",balloonText:"'.__('c-gs','wp-slimstat').': 0",value:0,color:"#ededed"}','es'=>'{id:"ES",balloonText:"'.__('c-es','wp-slimstat').': 0",value:0,color:"#ededed"}','lk'=>'{id:"LK",balloonText:"'.__('c-lk','wp-slimstat').': 0",value:0,color:"#ededed"}','sc'=>'{id:"SC",balloonText:"'.__('c-sc','wp-slimstat').': 0",value:0,color:"#ededed"}','sd'=>'{id:"SD",balloonText:"'.__('c-sd','wp-slimstat').': 0",value:0,color:"#ededed"}','ss'=>'{id:"SS",balloonText:"'.__('c-ss','wp-slimstat').': 0",value:0,color:"#ededed"}','sr'=>'{id:"SR",balloonText:"'.__('c-sr','wp-slimstat').': 0",value:0,color:"#ededed"}','sj'=>'{id:"SJ",balloonText:"'.__('c-sj','wp-slimstat').': 0",value:0,color:"#ededed"}','sz'=>'{id:"SZ",balloonText:"'.__('c-sz','wp-slimstat').': 0",value:0,color:"#ededed"}','se'=>'{id:"SE",balloonText:"'.__('c-se','wp-slimstat').': 0",value:0,color:"#ededed"}','ch'=>'{id:"CH",balloonText:"'.__('c-ch','wp-slimstat').': 0",value:0,color:"#ededed"}','sy'=>'{id:"SY",balloonText:"'.__('c-sy','wp-slimstat').': 0",value:0,color:"#ededed"}','tw'=>'{id:"TW",balloonText:"'.__('c-tw','wp-slimstat').': 0",value:0,color:"#ededed"}','tj'=>'{id:"TJ",balloonText:"'.__('c-tj','wp-slimstat').': 0",value:0,color:"#ededed"}','tz'=>'{id:"TZ",balloonText:"'.__('c-tz','wp-slimstat').': 0",value:0,color:"#ededed"}','th'=>'{id:"TH",balloonText:"'.__('c-th','wp-slimstat').': 0",value:0,color:"#ededed"}','tl'=>'{id:"TL",balloonText:"'.__('c-tl','wp-slimstat').': 0",value:0,color:"#ededed"}','tg'=>'{id:"TG",balloonText:"'.__('c-tg','wp-slimstat').': 0",value:0,color:"#ededed"}','to'=>'{id:"TO",balloonText:"'.__('c-to','wp-slimstat').': 0",value:0,color:"#ededed"}','tt'=>'{id:"TT",balloonText:"'.__('c-tt','wp-slimstat').': 0",value:0,color:"#ededed"}','tn'=>'{id:"TN",balloonText:"'.__('c-tn','wp-slimstat').': 0",value:0,color:"#ededed"}','tr'=>'{id:"TR",balloonText:"'.__('c-tr','wp-slimstat').': 0",value:0,color:"#ededed"}','tm'=>'{id:"TM",balloonText:"'.__('c-tm','wp-slimstat').': 0",value:0,color:"#ededed"}','tc'=>'{id:"TC",balloonText:"'.__('c-tc','wp-slimstat').': 0",value:0,color:"#ededed"}','ug'=>'{id:"UG",balloonText:"'.__('c-ug','wp-slimstat').': 0",value:0,color:"#ededed"}','ua'=>'{id:"UA",balloonText:"'.__('c-ua','wp-slimstat').': 0",value:0,color:"#ededed"}','ae'=>'{id:"AE",balloonText:"'.__('c-ae','wp-slimstat').': 0",value:0,color:"#ededed"}','gb'=>'{id:"GB",balloonText:"'.__('c-gb','wp-slimstat').': 0",value:0,color:"#ededed"}','us'=>'{id:"US",balloonText:"'.__('c-us','wp-slimstat').': 0",value:0,color:"#ededed"}','uy'=>'{id:"UY",balloonText:"'.__('c-uy','wp-slimstat').': 0",value:0,color:"#ededed"}','uz'=>'{id:"UZ",balloonText:"'.__('c-uz','wp-slimstat').': 0",value:0,color:"#ededed"}','vu'=>'{id:"VU",balloonText:"'.__('c-vu','wp-slimstat').': 0",value:0,color:"#ededed"}','ve'=>'{id:"VE",balloonText:"'.__('c-ve','wp-slimstat').': 0",value:0,color:"#ededed"}','vn'=>'{id:"VN",balloonText:"'.__('c-vn','wp-slimstat').': 0",value:0,color:"#ededed"}','vg'=>'{id:"VG",balloonText:"'.__('c-vg','wp-slimstat').': 0",value:0,color:"#ededed"}','vi'=>'{id:"VI",balloonText:"'.__('c-vi','wp-slimstat').': 0",value:0,color:"#ededed"}','eh'=>'{id:"EH",balloonText:"'.__('c-eh','wp-slimstat').': 0",value:0,color:"#ededed"}','ye'=>'{id:"YE",balloonText:"'.__('c-ye','wp-slimstat').': 0",value:0,color:"#ededed"}','zm'=>'{id:"ZM",balloonText:"'.__('c-zm','wp-slimstat').': 0",value:0,color:"#ededed"}','zw'=>'{id:"ZW",balloonText:"'.__('c-zw','wp-slimstat').': 0",value:0,color:"#ededed"}','gg'=>'{id:"GG",balloonText:"'.__('c-gg','wp-slimstat').': 0",value:0,color:"#ededed"}','je'=>'{id:"JE",balloonText:"'.__('c-je','wp-slimstat').': 0",value:0,color:"#ededed"}','im'=>'{id:"IM",balloonText:"'.__('c-im','wp-slimstat').': 0",value:0,color:"#ededed"}','mv'=>'{id:"MV",balloonText:"'.__('c-mv','wp-slimstat').': 0",value:0,color:"#ededed"}');
1850
+ $countries_not_represented = array( __( 'c-eu', 'wp-slimstat' ) );
1851
  $max = 0;
1852
 
1853
+ foreach ( $countries as $a_country ) {
1854
+ if ( !array_key_exists( $a_country[ 'country' ], $data_areas ) ) {
1855
+ continue;
1856
+ }
1857
 
1858
+ $percentage = ( self::$pageviews > 0 ) ? sprintf( "%01.2f", ( 100 * $a_country[ 'counthits' ] / self::$pageviews ) ) : 0;
1859
+ $percentage_format = number_format( $percentage, 2, wp_slimstat_db::$formats[ 'decimal' ], wp_slimstat_db::$formats[ 'thousand' ] );
1860
+ $balloon_text = __( 'c-' . $a_country[ 'country' ], 'wp-slimstat' ) . ': ' . $percentage_format . '% (' . number_format( $a_country[ 'counthits' ], 0, wp_slimstat_db::$formats[ 'decimal' ], wp_slimstat_db::$formats[ 'thousand' ] ) . ')';
1861
+ $data_areas[ $a_country[ 'country' ] ] = '{id:"' . strtoupper( $a_country[ 'country' ] ) . '",balloonText:"' . $balloon_text . '",value:' . $percentage . '}';
1862
 
1863
  if ( $percentage > $max ) {
1864
  $max = $percentage;
1865
  }
1866
  }
1867
+
1868
+ $path_slimstat = dirname( dirname( __FILE__ ) );
1869
+ wp_enqueue_script( 'slimstat_ammap', plugins_url( '/admin/js/ammap/ammap.js', $path_slimstat ), array(), null, false );
1870
+ wp_enqueue_script( 'slimstat_ammap_world', plugins_url( '/admin/js/ammap/world.js', $path_slimstat ), array(), null, false );
1871
+ wp_enqueue_script( 'slimstat_amcharts_plugins_export', plugins_url( '/admin/js/amcharts/plugins/export/export.min.js', $path_slimstat ), array( 'slimstat_ammap' ), null, false );
1872
+ wp_enqueue_script( 'slimstat_amcharts_theme_light', plugins_url( '/admin/js/amcharts/themes/light.js', $path_slimstat ), array( 'slimstat_ammap' ), null, false );
1873
+
1874
+ wp_enqueue_style( 'slimstat_amcharts_plugins_export_css', plugins_url( '/admin/js/amcharts/plugins/export/export.css', $path_slimstat ) );
1875
+
1876
  ?>
1877
 
1878
+ <div id="map_slim_p6_01" style="height: 100%"></div>
 
1879
 
1880
  <script type="text/javascript">
1881
+ jQuery( function() {
1882
+ var targetSVG = "M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z";
1883
+
1884
+ var dataProvider = {
1885
+ map: "worldLow",
1886
+ getAreasFromMap: true,
1887
+ areas:[ <?php echo implode( ',', $data_areas ) ?> ],
1888
+ images: [ <?php if ( !empty( $data_points ) ) echo implode( ',', $data_points ) ?> ]
1889
+ };
1890
+
1891
+ // Create AmMap object
1892
+ var map = new AmCharts.AmMap();
1893
+
1894
+ <?php if ($max != 0): ?>
1895
+ var legend = new AmCharts.ValueLegend();
1896
+ legend.height = 20;
1897
+ legend.minValue = "0.01";
1898
+ legend.maxValue = "<?php echo $max ?>%";
1899
+ legend.right = 20;
1900
+ legend.showAsGradient = true;
1901
+ legend.width = 300;
1902
+ map.valueLegend = legend;
1903
+ <?php endif; ?>
1904
+
1905
+ // Configuration
1906
+ map.areasSettings = {
1907
+ autoZoom: false,
1908
+ color: "#9dff98",
1909
+ colorSolid: "#fa8a50",
1910
+ outlineColor: "#888888",
1911
+ selectedColor: "#ffb739"
1912
+ };
1913
+ map.imagesSettings = {
1914
+ rollOverColor: "#089282",
1915
+ rollOverScale: 2,
1916
+ selectedScale: 2,
1917
+ selectedColor: "#089282",
1918
+ color: "#13564e"
1919
+ };
1920
+ map.zoomControl = {
1921
+ zoomControlEnabled: true,
1922
+ zoomFactor: 3
1923
+ };
1924
+ map.export = {
1925
+ "enabled": true,
1926
+ "libs": {
1927
+ "path": "<?php echo plugins_url('/js/amcharts/plugins/export/libs/', dirname(__FILE__)) ?>"
1928
+ },
1929
+ "menu": [ {
1930
+ "class": "export-main",
1931
+ "menu": [ {
1932
+ "label": "Download as...",
1933
+ "menu": [ "PNG", "PDF" ]
1934
+ } ]
1935
+ } ]
1936
+ };
1937
+ map.backgroundAlpha = .9;
1938
+ map.backgroundColor = "#7adafd";
1939
+ map.backgroundZoomsToTop = false;
1940
+ map.balloon.color = "#000000";
1941
+ map.colorSteps = 5;
1942
+ map.mouseWheelZoomEnabled = true;
1943
+ map.pathToImages = "<?php echo plugins_url('/js/ammap/images/', dirname(__FILE__)) ?>";
1944
+
1945
+ // Init Data
1946
+ map.dataProvider = dataProvider;
1947
+
1948
+ // Display Map
1949
+ map.write( "map_slim_p6_01" );
1950
+ });
1951
  </script><?php
1952
 
1953
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
1992
  }
1993
 
1994
  $a_filter_value_no_slashes = htmlentities( str_replace( '\\','', $a_filter_details[ 1 ] ), ENT_QUOTES, 'UTF-8' );
1995
+ $filters_html .= '<li>' . strtolower( wp_slimstat_db::$columns_names[ $a_filter_label ][ 0 ] ) . ' ' . __( str_replace( '_', ' ', $a_filter_details[ 0 ] ), 'wp-slimstat' ) . " $a_filter_value_no_slashes <a class='slimstat-filter-link slimstat-font-cancel' title='" . htmlentities( __( 'Remove filter for', 'wp-slimstat' ), ENT_QUOTES, 'UTF-8' ) . ' ' . wp_slimstat_db::$columns_names[ $a_filter_label ][ 0 ] . "' href='" . self::fs_url( "$a_filter_label equals " ) . "'></a></li>";
1996
  }
1997
  }
1998
 
2007
  return $filters_html;
2008
  }
2009
 
2010
+ public static function fs_url( $_filters_string = '' ) {
 
2011
  // Allow only legitimate requests
 
 
 
2012
  if ( !is_admin() ) {
2013
  return '';
2014
  }
2015
 
2016
+ $request_uri = admin_url( 'admin.php' );
2017
+
2018
+ $request_page = 'slimview1';
2019
+ if ( !empty( $_REQUEST[ 'page' ] ) ) {
2020
+ if ( !array_key_exists( $_REQUEST[ 'page' ], wp_slimstat_admin::$screens_info ) ) {
2021
+ return '';
2022
+ }
2023
+
2024
  $request_page = $_REQUEST[ 'page' ];
2025
  }
 
 
 
2026
 
2027
+ $request_uri .= '?page=' . $request_page;
2028
+
2029
+ // Avoid XSS attacks ( why would the owner try to hack into his/her own website though? )
2030
  if ( !empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
2031
  $parsed_referer = parse_url( $_SERVER[ 'HTTP_REFERER' ] );
2032
  if ( !$parsed_referer || ( !empty( $parsed_referer[ 'scheme' ] ) && !in_array( strtolower( $parsed_referer[ 'scheme' ] ), array( 'http', 'https' ) ) ) ) {
2034
  }
2035
  }
2036
 
2037
+ $filters_normalized = wp_slimstat_db::parse_filters( $_filters_string );
 
2038
 
2039
  // Columns
2040
+ if ( !empty( $filters_normalized[ 'columns' ] ) ) {
2041
+ foreach ( $filters_normalized[ 'columns' ] as $a_key => $a_filter ) {
 
 
2042
  $a_key = str_replace( '_calculated', '', $a_key );
2043
+ $request_uri .= "&amp;fs%5B$a_key%5D=" . urlencode( $a_filter[ 0 ] . ' ' . $a_filter[ 1 ] );
2044
  }
2045
  }
2046
 
2047
  // Date ranges
2048
+ if ( !empty( $filters_normalized[ 'date' ] ) ) {
2049
+ foreach ( $filters_normalized[ 'date' ] as $a_key => $a_filter ) {
2050
  if ( isset( $a_filter ) ) {
2051
+ $request_uri .= "&amp;fs%5B$a_key%5D=" . urlencode( 'equals ' . $a_filter );
2052
  }
2053
  }
2054
  }
2055
 
2056
  // Misc filters
2057
+ if ( !empty( $filters_normalized[ 'misc' ] ) ) {
2058
+ foreach ( $filters_normalized[ 'misc' ] as $a_key => $a_filter ) {
2059
+ $request_uri .= "&amp;fs%5B$a_key%5D=" . urlencode( 'equals ' . $a_filter );
 
 
2060
  }
2061
  }
2062
 
2063
+ return $request_uri;
2064
  }
2065
 
2066
  /**
admin/wp-slimstat-admin.php CHANGED
@@ -11,7 +11,7 @@ class wp_slimstat_admin {
11
  * Init -- Sets things up.
12
  */
13
  public static function init() {
14
- self::$admin_notice = "We just launched our <a href='https://www.wp-slimstat.com' target='_blank'>redesigned website</a>, to promote our plugin in a cleaner and simpler way. And we are also looking for <strong>sponsors</strong>: if you can donate your time, your talent or your money to support the development of Slimstat, please <a href='http://support.wp-slimstat.com/' target='_blank'>contact our support team</a> today to learn more.";
15
  self::$admin_notice .= '<br/><br/><a id="slimstat-hide-admin-notice" href="#" class="button-secondary">Got it, thanks</a>';
16
 
17
  // Load language files
@@ -176,9 +176,6 @@ class wp_slimstat_admin {
176
  add_action( 'wp_dashboard_setup', array( __CLASS__, 'add_dashboard_widgets' ) );
177
  }
178
 
179
- // WordPress Widget
180
- // FIX ME: To be implemented
181
-
182
  // AJAX Handlers
183
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
184
  add_action( 'wp_ajax_slimstat_hide_admin_notice', array( __CLASS__, 'notices_handler' ) );
@@ -194,6 +191,11 @@ class wp_slimstat_admin {
194
  if ( wp_slimstat::$settings[ 'hide_addons' ] == 'on' ) {
195
  add_filter( 'all_plugins', array( __CLASS__, 'hide_addons' ) );
196
  }
 
 
 
 
 
197
  }
198
  // end init
199
 
@@ -319,7 +321,6 @@ class wp_slimstat_admin {
319
  CREATE TABLE IF NOT EXISTS {$GLOBALS['wpdb']->prefix}slim_stats_archive
320
  LIKE {$GLOBALS['wpdb']->prefix}slim_stats";
321
 
322
- // This table will track outbound links (clicks on links to external sites)
323
  $events_archive_table_sql = "
324
  CREATE TABLE IF NOT EXISTS {$GLOBALS['wpdb']->prefix}slim_events_archive (
325
  event_id INT(10) NOT NULL AUTO_INCREMENT,
@@ -348,75 +349,10 @@ class wp_slimstat_admin {
348
  // end init_tables
349
 
350
  /**
351
- * Updates the DB schema as needed
352
  */
353
- public static function update_tables_and_options(){
354
- $my_wpdb = apply_filters('slimstat_custom_wpdb', $GLOBALS['wpdb']);
355
-
356
- // --- Updates for version 4.2 ---
357
- if ( version_compare( wp_slimstat::$settings[ 'version' ], '4.2', '<' ) ) {
358
- // Report arrangements are now stored as a global usermeta value. Migrate old values to new variable
359
- $current_user = wp_get_current_user();
360
- $page_location = ( wp_slimstat::$settings[ 'use_separate_menu' ] == 'on' ) ? 'slimstat' : 'admin';
361
- $new_user_reports = array();
362
-
363
- for ( $i = 2; $i <= 5; $i++ ) {
364
- $user_reports = get_user_option( "meta-box-order_{$page_location}_page_wp-slim-view-$i", $current_user->ID );
365
-
366
- if ( !empty( $user_reports ) ) {
367
- $new_user_reports[ "slimview$i" ] = $user_reports[ 0 ];
368
- delete_user_option( $current_user->ID, "meta-box-order_{$page_location}_page_wp-slim-view-$i", true );
369
- }
370
- }
371
-
372
- if ( !empty( $new_user_reports ) ) {
373
- update_user_option( $current_user->ID, "meta-box-order_{$page_location}_page_slimlayout", $new_user_reports, true );
374
- }
375
- }
376
- // --- END: Updates for version 4.2 ---
377
-
378
- // --- Updates for version 4.2.1 ---
379
- if ( version_compare( wp_slimstat::$settings[ 'version' ], '4.2.1', '<' ) ) {
380
- // Remove old unused columns, if still there.
381
- $my_wpdb->query( "ALTER TABLE {$GLOBALS['wpdb']->prefix}slim_stats DROP COLUMN ip_temp, DROP COLUMN other_ip_temp, DROP COLUMN ip_num, DROP COLUMN other_ip_num" );
382
- $my_wpdb->query( "ALTER TABLE {$GLOBALS['wpdb']->prefix}slim_stats_archive DROP COLUMN ip_temp, DROP COLUMN other_ip_temp, DROP COLUMN ip_num, DROP COLUMN other_ip_num" );
383
- }
384
- // --- END: Updates for version 4.2.1 ---
385
-
386
- // --- Updates for version 4.2.6 ---
387
- if ( version_compare( wp_slimstat::$settings[ 'version' ], '4.2.6', '<' ) ) {
388
- wp_slimstat::$settings[ 'auto_purge_delete' ] = ( wp_slimstat::$settings[ 'auto_purge_delete' ] == 'on' ) ? 'no' : 'on';
389
- }
390
- // --- END: Updates for version 4.2.6 ---
391
-
392
- // --- Updates for version 4.3.5 ---
393
- if ( version_compare( wp_slimstat::$settings[ 'version' ], '4.3.5', '<' ) ) {
394
- $use_innodb = ( !empty( $have_innodb[ 0 ] ) && $have_innodb[ 0 ][ 'Value' ] == 'YES' ) ? 'ENGINE=InnoDB' : '';
395
- $events_archive_table_sql = "
396
- CREATE TABLE IF NOT EXISTS {$GLOBALS['wpdb']->prefix}slim_events_archive (
397
- event_id INT(10) NOT NULL AUTO_INCREMENT,
398
- type TINYINT UNSIGNED DEFAULT 0,
399
- event_description VARCHAR(64) DEFAULT NULL,
400
- notes VARCHAR(256) DEFAULT NULL,
401
- position VARCHAR(32) DEFAULT NULL,
402
- id INT UNSIGNED NOT NULL DEFAULT 0,
403
- dt INT(10) UNSIGNED DEFAULT 0,
404
-
405
- CONSTRAINT PRIMARY KEY (event_id),
406
- INDEX idx_{$GLOBALS['wpdb']->prefix}slim_stat_events_archive (dt)
407
- ) COLLATE utf8_general_ci $use_innodb";
408
-
409
- self::_create_table( $events_archive_table_sql, $GLOBALS[ 'wpdb' ]->prefix . 'slim_events_archive', $my_wpdb );
410
- }
411
- // --- END: Updates for version 4.3.5 ---
412
-
413
- // --- Updates for version 4.3.7 ---
414
- if ( version_compare( wp_slimstat::$settings[ 'version' ], '4.3.7', '<' ) ) {
415
-
416
- // Previous versions of Slimstat were scheduling multiple purges in some cases, let's clean this up
417
- wp_clear_scheduled_hook( 'wp_slimstat_purge' );
418
- }
419
- // --- END: Updates for version 4.3.7 ---
420
 
421
  // --- Updates for version 4.4.5 ---
422
  if ( version_compare( wp_slimstat::$settings[ 'version' ], '4.4.5', '<' ) ) {
@@ -875,14 +811,13 @@ class wp_slimstat_admin {
875
  /**
876
  * Handles the Ajax requests to load, save or delete existing filters
877
  */
878
- public static function manage_filters(){
879
  check_ajax_referer( 'meta-box-order', 'security' );
880
 
881
  include_once( dirname( __FILE__ ) . '/view/wp-slimstat-reports.php' );
882
  wp_slimstat_reports::init();
883
 
884
  $saved_filters = get_option( 'slimstat_filters', array() );
885
- $filter_found = 0;
886
 
887
  switch( $_POST[ 'type' ] ) {
888
  case 'save':
@@ -897,17 +832,17 @@ class wp_slimstat_admin {
897
  continue;
898
  }
899
 
900
- foreach ($a_saved_filter as $a_key => $a_value){
901
- $filter_found += ($a_value == $new_filter[$a_key])?0:1;
902
  }
903
 
904
- if ($filter_found == 0){
905
- echo __('Already saved','wp-slimstat');
906
  break;
907
  }
908
  }
909
 
910
- if ( empty( $saved_filters) || $filter_found > 0 ) {
911
  $saved_filters[] = $new_filter;
912
  update_option( 'slimstat_filters', $saved_filters );
913
  echo __( 'Saved', 'wp-slimstat' );
@@ -922,15 +857,15 @@ class wp_slimstat_admin {
922
 
923
  default:
924
  echo '<div id="slim_filters_overlay">';
925
- foreach ($saved_filters as $a_filter_id => $a_filter_data){
926
 
927
  $filter_html = $filter_strings = array();
928
- foreach ($a_filter_data as $a_filter_label => $a_filter_details){
929
- $filter_value_no_slashes = htmlentities(str_replace('\\','', $a_filter_details[1]), ENT_QUOTES, 'UTF-8');
930
- $filter_html[] = strtolower(wp_slimstat_db::$columns_names[$a_filter_label][0]).' '.__(str_replace('_', ' ', $a_filter_details[0]),'wp-slimstat').' '.$filter_value_no_slashes;
931
  $filter_strings[] = "$a_filter_label {$a_filter_details[0]} $filter_value_no_slashes";
932
  }
933
- echo '<p><a class="slimstat-font-cancel slimstat-delete-filter" data-filter-id="'.$a_filter_id.'" title="'.__('Delete this filter','wp-slimstat').'" href="#"></a> <a class="slimstat-filter-link" data-reset-filters="true" href="' . wp_slimstat_reports::fs_url( implode( '&&&', $filter_strings ) ).'">'.implode(', ', $filter_html).'</a> <a href="#"></a></p>';
934
  }
935
  echo '</div>';
936
  break;
11
  * Init -- Sets things up.
12
  */
13
  public static function init() {
14
+ self::$admin_notice = "We would like to thank all of those who replied to our appeal for help. It really meant a lot to us. In order to provide a way to contribute updates and bugfixes, we setup a <a href='https://github.com/slimstat/wp-slimstat' target='_blank'>public Github repository</a>, where you can submit your pull requests and point out bugs and other issues. If you would like Slimstat to speak your language (or to extend any existing partial localization), please do not hesitate to submit your language files either via Github or directly to our support team. In the meanwhile, we will keep working on our documentation, videos and on polishing our code even more. For example, this release includes a completely rewritten Javascript library to handle all the features available in the admin, from the Filter Bar to the Customizer. Let us know if you notice anything out of the ordinary, and feel free to submit a pull request to fix any bugs you might find.";
15
  self::$admin_notice .= '<br/><br/><a id="slimstat-hide-admin-notice" href="#" class="button-secondary">Got it, thanks</a>';
16
 
17
  // Load language files
176
  add_action( 'wp_dashboard_setup', array( __CLASS__, 'add_dashboard_widgets' ) );
177
  }
178
 
 
 
 
179
  // AJAX Handlers
180
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
181
  add_action( 'wp_ajax_slimstat_hide_admin_notice', array( __CLASS__, 'notices_handler' ) );
191
  if ( wp_slimstat::$settings[ 'hide_addons' ] == 'on' ) {
192
  add_filter( 'all_plugins', array( __CLASS__, 'hide_addons' ) );
193
  }
194
+
195
+ // Schedule a daily cron job to purge the data
196
+ if ( !wp_next_scheduled( 'wp_slimstat_purge' ) ) {
197
+ wp_schedule_event( time(), 'twicedaily', 'wp_slimstat_purge' );
198
+ }
199
  }
200
  // end init
201
 
321
  CREATE TABLE IF NOT EXISTS {$GLOBALS['wpdb']->prefix}slim_stats_archive
322
  LIKE {$GLOBALS['wpdb']->prefix}slim_stats";
323
 
 
324
  $events_archive_table_sql = "
325
  CREATE TABLE IF NOT EXISTS {$GLOBALS['wpdb']->prefix}slim_events_archive (
326
  event_id INT(10) NOT NULL AUTO_INCREMENT,
349
  // end init_tables
350
 
351
  /**
352
+ * Updates stuff around as needed (table schema, options, settings, files, etc)
353
  */
354
+ public static function update_tables_and_options() {
355
+ $my_wpdb = apply_filters( 'slimstat_custom_wpdb', $GLOBALS[ 'wpdb' ] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
 
357
  // --- Updates for version 4.4.5 ---
358
  if ( version_compare( wp_slimstat::$settings[ 'version' ], '4.4.5', '<' ) ) {
811
  /**
812
  * Handles the Ajax requests to load, save or delete existing filters
813
  */
814
+ public static function manage_filters() {
815
  check_ajax_referer( 'meta-box-order', 'security' );
816
 
817
  include_once( dirname( __FILE__ ) . '/view/wp-slimstat-reports.php' );
818
  wp_slimstat_reports::init();
819
 
820
  $saved_filters = get_option( 'slimstat_filters', array() );
 
821
 
822
  switch( $_POST[ 'type' ] ) {
823
  case 'save':
832
  continue;
833
  }
834
 
835
+ foreach ( $a_saved_filter as $a_key => $a_value ) {
836
+ $filter_found += ( $a_value == $new_filter[ $a_key ] ) ? 0 : 1;
837
  }
838
 
839
+ if ( $filter_found == 0 ) {
840
+ echo __( 'Already saved', 'wp-slimstat' );
841
  break;
842
  }
843
  }
844
 
845
+ if ( empty( $saved_filters ) || $filter_found > 0 ) {
846
  $saved_filters[] = $new_filter;
847
  update_option( 'slimstat_filters', $saved_filters );
848
  echo __( 'Saved', 'wp-slimstat' );
857
 
858
  default:
859
  echo '<div id="slim_filters_overlay">';
860
+ foreach ( $saved_filters as $a_filter_id => $a_filter_data ) {
861
 
862
  $filter_html = $filter_strings = array();
863
+ foreach ( $a_filter_data as $a_filter_label => $a_filter_details ) {
864
+ $filter_value_no_slashes = htmlentities( str_replace( '\\', '', $a_filter_details[ 1 ] ), ENT_QUOTES, 'UTF-8' );
865
+ $filter_html[] = strtolower( wp_slimstat_db::$columns_names[ $a_filter_label ][ 0 ] ) . ' ' . __( str_replace( '_', ' ', $a_filter_details[ 0 ] ), 'wp-slimstat' ) . ' ' . $filter_value_no_slashes;
866
  $filter_strings[] = "$a_filter_label {$a_filter_details[0]} $filter_value_no_slashes";
867
  }
868
+ echo '<p><a class="slimstat-font-cancel slimstat-delete-filter" data-filter-id="' . $a_filter_id . '" title="' . __( 'Delete this filter', 'wp-slimstat' ) . '" href="#"></a> <a class="slimstat-filter-link" data-reset-filters="true" href="' . wp_slimstat_reports::fs_url( implode( '&&&', $filter_strings ) ).'">' . implode( ', ', $filter_html ) . '</a></p>';
869
  }
870
  echo '</div>';
871
  break;
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: analytics, statistics, counter, tracking, reports, wassup, geolocation, on
5
  Text Domain: wp-slimstat
6
  Requires at least: 3.8
7
  Tested up to: 4.9
8
- Stable tag: 4.7.5.3
9
 
10
  == Description ==
11
  The leading web analytics plugin for WordPress. Track returning customers and registered users, monitor Javascript events, detect intrusions, analyze email campaigns. Thousands of WordPress sites are already using it.
@@ -71,6 +71,14 @@ Our knowledge base is available on our [support center](http://docs.wp-slimstat.
71
  5. **Responsive layout** - Keep an eye on your reports on the go
72
 
73
  == Changelog ==
 
 
 
 
 
 
 
 
74
  = 4.7.5.3 =
75
  * [New] For those who can't manage to automatically update their local copy of our premium add-ons, we've added a link to manually download the zip file. You'll find it under the Plugins screen, once you've entered and saved the corresponding license key under Slimstat > Add-ons.
76
  * [Update] The [Update Checker](https://github.com/YahnisElsts/plugin-update-checker) library has been updated to version 4.4.
@@ -137,14 +145,6 @@ Our knowledge base is available on our [support center](http://docs.wp-slimstat.
137
  * [Fix] A vulnerability has been disclosed by [Pluginvulnerabilities.com](pluginvulnerabilities.com): an attacker with admin credentials could leverage the import/export mechanism for the plugin's settings to inject some malicious code. We recommend that you upgrade to the latest version of Slimstat as soon as possible.
138
  * [Fix] The new version of the [Add-on Update Checker library](https://github.com/YahnisElsts/plugin-update-checker), bundled with the previous release, was returning a fatal error under certain circumstances (thank you, Pepe).
139
 
140
- = 4.7 =
141
- * [New] After receiving a few requests to implement a REST API within Slimstat, and given that WordPress now offers a mature and stable interface for extending its built-in REST API, we decided to finally move forward and implement this feature. Please refer to our [online knowledge base](https://slimstat.freshdesk.com/solution/articles/12000033661-slimstat-rest-api) to learn more about how to use it.
142
- * [Update] The [Add-on Update Checker library](https://github.com/YahnisElsts/plugin-update-checker) has been updated to version 4.2, to solve an incompatibility issue with PHP 7.0 (thank you, [Sasa](https://wordpress.org/support/topic/possible-incompatibility-with-php-7-0/) and Per).
143
- * [Update] Bootstrap Switch (which we use on our Settings panels) has been updated to version 3.3.4.
144
- * [Fix] Apparently, there was an issue where our XMLHttpRequest didn't send the cookie for Cross-Origin URLs (thank you, Sasa).
145
- * [Fix] Solved issue with pagination, triggered when certain long time ranges were being selected.
146
- * [Fix] The autorefresh countdown timer was not working as expected if Async Mode was enabled (thank you, [scruffy1 and service4](https://wordpress.org/support/topic/odd-visitors-activity-heading)).
147
-
148
  == Support Our Work ==
149
  Slimstat Analytics is an open source project, dependent in large parts on donations. [This page](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BNJR5EZNY3W38)
150
  is for those who want to donate money - be it once, be it regularly, be it a small or a big amount. Everything is set up for an easy donation process.
5
  Text Domain: wp-slimstat
6
  Requires at least: 3.8
7
  Tested up to: 4.9
8
+ Stable tag: 4.7.6
9
 
10
  == Description ==
11
  The leading web analytics plugin for WordPress. Track returning customers and registered users, monitor Javascript events, detect intrusions, analyze email campaigns. Thousands of WordPress sites are already using it.
71
  5. **Responsive layout** - Keep an eye on your reports on the go
72
 
73
  == Changelog ==
74
+ = 4.7.6 =
75
+ * [Note] As we mentioned earlier, we've been working on streamlining and cleaning up our source code. It's incredible how layers of code can deposit on top of each other, until they form a thick layer that prevents developers from seeing clearly what's happening. It was time to apply some virtual citric acid to descale our code. If you're using any kind of server caching functionality, please make sure to clear your cache before opening a support request. Also, do not hesitate to reach out to us if you notice any strange or unusual behaviors.
76
+ * [New] You can now download the geolocation map as a PDF file or PNG image. Thank you, Steve, for suggesting this feature!
77
+ * [New] You can now exclude pageviews by content type, like 404, taxonomy, search, etc. Thank you, [victor50g](https://wordpress.org/support/topic/suggestion-enable-filtering-on-content-404/).
78
+ * [Update] Deprecated the 'direction' filter, which was a leftover from over 5 years ago, when we used our old interface.
79
+ * [Fix] The cron job to archive old records was not firing as expected under certain circumstances.
80
+ * [Fix] Charts did not render correctly, if no data was available for that specific view.
81
+
82
  = 4.7.5.3 =
83
  * [New] For those who can't manage to automatically update their local copy of our premium add-ons, we've added a link to manually download the zip file. You'll find it under the Plugins screen, once you've entered and saved the corresponding license key under Slimstat > Add-ons.
84
  * [Update] The [Update Checker](https://github.com/YahnisElsts/plugin-update-checker) library has been updated to version 4.4.
145
  * [Fix] A vulnerability has been disclosed by [Pluginvulnerabilities.com](pluginvulnerabilities.com): an attacker with admin credentials could leverage the import/export mechanism for the plugin's settings to inject some malicious code. We recommend that you upgrade to the latest version of Slimstat as soon as possible.
146
  * [Fix] The new version of the [Add-on Update Checker library](https://github.com/YahnisElsts/plugin-update-checker), bundled with the previous release, was returning a fatal error under certain circumstances (thank you, Pepe).
147
 
 
 
 
 
 
 
 
 
148
  == Support Our Work ==
149
  Slimstat Analytics is an open source project, dependent in large parts on donations. [This page](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BNJR5EZNY3W38)
150
  is for those who want to donate money - be it once, be it regularly, be it a small or a big amount. Everything is set up for an easy donation process.
uninstall.php CHANGED
@@ -36,29 +36,28 @@ $slimstat_wpdb->query( "DROP TABLE IF EXISTS {$GLOBALS[ 'wpdb' ]->base_prefix}sl
36
 
37
  function slimstat_uninstall($_wpdb = '', $_options = array()){
38
  // Bye bye data...
39
- $_wpdb->query("DROP TABLE IF EXISTS {$GLOBALS['wpdb']->prefix}slim_outbound");
40
- $_wpdb->query("DROP TABLE IF EXISTS {$GLOBALS['wpdb']->prefix}slim_events");
41
- $_wpdb->query("DROP TABLE IF EXISTS {$GLOBALS['wpdb']->prefix}slim_stats");
42
- $_wpdb->query("DROP TABLE IF EXISTS {$GLOBALS['wpdb']->prefix}slim_events_archive");
43
- $_wpdb->query("DROP TABLE IF EXISTS {$GLOBALS['wpdb']->prefix}slim_stats_archive");
44
- $_wpdb->query("DROP TABLE IF EXISTS {$GLOBALS['wpdb']->prefix}slim_stats_3");
45
- $_wpdb->query("DROP TABLE IF EXISTS {$GLOBALS['wpdb']->prefix}slim_stats_archive_3");
46
 
47
  // Bye bye options...
48
- delete_option('slimstat_options');
49
- delete_option('slimstat_visit_id');
50
- delete_option('slimstat_filters');
51
 
52
- $GLOBALS['wpdb']->query("DELETE FROM {$GLOBALS['wpdb']->prefix}usermeta WHERE meta_key LIKE '%meta-box-order_slimstat%'");
53
- $GLOBALS['wpdb']->query("DELETE FROM {$GLOBALS['wpdb']->prefix}usermeta WHERE meta_key LIKE '%metaboxhidden_slimstat%'");
54
- $GLOBALS['wpdb']->query("DELETE FROM {$GLOBALS['wpdb']->prefix}usermeta WHERE meta_key LIKE '%closedpostboxes_slimstat%'");
55
 
56
  // Remove scheduled autopurge events
57
- wp_clear_scheduled_hook('wp_slimstat_purge');
58
 
59
- // Delete the Browscap and MaxMind data files if they exist
60
  $upload_path = wp_upload_dir();
61
  $upload_path = $upload_path[ 'basedir' ] . '/wp-slimstat/';
62
  @unlink( $upload_path . 'maxmind.mmdb' );
63
- @unlink( $upload_path . 'browscap-db.php' );
64
  }
36
 
37
  function slimstat_uninstall($_wpdb = '', $_options = array()){
38
  // Bye bye data...
39
+ $_wpdb->query( "DROP TABLE IF EXISTS {$GLOBALS[ 'wpdb' ]->prefix}slim_outbound" );
40
+ $_wpdb->query( "DROP TABLE IF EXISTS {$GLOBALS[ 'wpdb' ]->prefix}slim_events" );
41
+ $_wpdb->query( "DROP TABLE IF EXISTS {$GLOBALS[ 'wpdb' ]->prefix}slim_stats" );
42
+ $_wpdb->query( "DROP TABLE IF EXISTS {$GLOBALS[ 'wpdb' ]->prefix}slim_events_archive" );
43
+ $_wpdb->query( "DROP TABLE IF EXISTS {$GLOBALS[ 'wpdb' ]->prefix}slim_stats_archive" );
44
+ $_wpdb->query( "DROP TABLE IF EXISTS {$GLOBALS[ 'wpdb' ]->prefix}slim_stats_3" );
45
+ $_wpdb->query( "DROP TABLE IF EXISTS {$GLOBALS[ 'wpdb' ]->prefix}slim_stats_archive_3" );
46
 
47
  // Bye bye options...
48
+ delete_option( 'slimstat_options' );
49
+ delete_option( 'slimstat_visit_id' );
50
+ delete_option( 'slimstat_filters' );
51
 
52
+ $GLOBALS[ 'wpdb' ]->query( "DELETE FROM {$GLOBALS[ 'wpdb' ]->prefix}usermeta WHERE meta_key LIKE '%meta-box-order_slimstat%'" );
53
+ $GLOBALS[ 'wpdb' ]->query( "DELETE FROM {$GLOBALS[ 'wpdb' ]->prefix}usermeta WHERE meta_key LIKE '%metaboxhidden_slimstat%'" );
54
+ $GLOBALS[ 'wpdb' ]->query( "DELETE FROM {$GLOBALS[ 'wpdb' ]->prefix}usermeta WHERE meta_key LIKE '%closedpostboxes_slimstat%'" );
55
 
56
  // Remove scheduled autopurge events
57
+ wp_clear_scheduled_hook( 'wp_slimstat_purge' );
58
 
59
+ // Delete the MaxMind data file
60
  $upload_path = wp_upload_dir();
61
  $upload_path = $upload_path[ 'basedir' ] . '/wp-slimstat/';
62
  @unlink( $upload_path . 'maxmind.mmdb' );
 
63
  }
wp-slimstat.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Slimstat Analytics
4
  Plugin URI: http://wordpress.org/plugins/wp-slimstat/
5
  Description: The leading web analytics plugin for WordPress
6
- Version: 4.7.5.3
7
  Author: Jason Crouse
8
  Author URI: http://www.wp-slimstat.com/
9
  Text Domain: wp-slimstat
@@ -15,7 +15,7 @@ if ( !empty( wp_slimstat::$settings ) ) {
15
  }
16
 
17
  class wp_slimstat {
18
- public static $version = '4.7.5.3';
19
  public static $settings = array();
20
 
21
  public static $wpdb = '';
@@ -57,7 +57,7 @@ class wp_slimstat {
57
  self::$wpdb = apply_filters( 'slimstat_custom_wpdb', $GLOBALS[ 'wpdb' ] );
58
 
59
  // Hook a DB clean-up routine to the daily cronjob
60
- add_action( 'wp_update_plugins', array( __CLASS__, 'wp_slimstat_purge' ) );
61
 
62
  // Allow external domains on CORS requests
63
  add_filter( 'allowed_http_origins', array(__CLASS__, 'open_cors_admin_ajax' ) );
@@ -328,6 +328,18 @@ class wp_slimstat {
328
 
329
  $content_info = self::_get_content_info();
330
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  // Did we receive data from an Ajax request?
332
  if ( !empty( self::$data_js[ 'id' ] ) ) {
333
 
@@ -1581,7 +1593,6 @@ class wp_slimstat {
1581
  'extensions_to_track' => 'pdf,doc,xls,zip',
1582
  'track_same_domain_referers' => 'on',
1583
  'geolocation_country' => 'on',
1584
- 'track_users' => 'on',
1585
  'session_duration' => 1800,
1586
  'extend_session' => 'no',
1587
  'set_tracker_cookie' => 'on',
@@ -1590,18 +1601,22 @@ class wp_slimstat {
1590
  'external_domains' => '',
1591
 
1592
  // Filters
1593
-
1594
- 'ignore_users' => '',
1595
- 'ignore_ip' => '',
1596
- 'ignore_capabilities' => '',
1597
  'ignore_spammers' => 'on',
1598
  'ignore_bots' => 'no',
1599
- 'ignore_resources' => '',
 
 
 
 
1600
  'ignore_countries' => '',
1601
  'ignore_browsers' => '',
 
 
 
 
1602
  'ignore_referers' => '',
1603
- 'anonymize_ip' => 'no',
1604
- 'ignore_prefetch' => 'on',
1605
 
1606
  // Reports
1607
  'use_european_separators' => 'on',
@@ -1671,23 +1686,15 @@ class wp_slimstat {
1671
  * Enqueue a javascript to track users' screen resolution and other browser-based information
1672
  */
1673
  public static function wp_slimstat_enqueue_tracking_script() {
1674
- // Register the script in WordPress
1675
- $jstracker_suffix = ( defined( 'SCRIPT_DEBUG' ) && is_bool( SCRIPT_DEBUG ) && SCRIPT_DEBUG ) ? '' : '.min';
1676
-
1677
- if ( self::$settings[ 'enable_cdn' ] == 'on' ) {
1678
- $schema = is_ssl() ? 'https' : 'http';
1679
- wp_register_script( 'wp_slimstat', $schema . '://cdn.jsdelivr.net/wp/wp-slimstat/tags/' . self::$version . '/wp-slimstat.min.js', array(), null, true );
1680
- }
1681
- else{
1682
- wp_register_script( 'wp_slimstat', plugins_url( "/wp-slimstat{$jstracker_suffix}.js", __FILE__ ), array(), null, true );
1683
- }
1684
-
1685
  // Do not enqueue the script if the corresponding options are turned off
1686
  $is_tracking_filter_js = apply_filters( 'slimstat_filter_pre_tracking_js', true );
1687
  if ( ( self::$settings[ 'enable_javascript' ] != 'on' && self::$settings[ 'javascript_mode' ] != 'on' ) || self::$settings[ 'is_tracking' ] != 'on' || !$is_tracking_filter_js ) {
1688
  return 0;
1689
  }
1690
 
 
 
 
1691
  // Pass some information to the tracker
1692
  $params = array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) );
1693
 
@@ -1728,6 +1735,14 @@ class wp_slimstat {
1728
 
1729
  $params = apply_filters( 'slimstat_js_params', $params );
1730
 
 
 
 
 
 
 
 
 
1731
  wp_enqueue_script( 'wp_slimstat' );
1732
  wp_localize_script( 'wp_slimstat', 'SlimStatParams', $params );
1733
  }
@@ -1737,6 +1752,7 @@ class wp_slimstat {
1737
  */
1738
  public static function wp_slimstat_purge() {
1739
  $autopurge_interval = intval( self::$settings[ 'auto_purge' ] );
 
1740
  if ( $autopurge_interval <= 0 ) {
1741
  return;
1742
  }
@@ -1748,8 +1764,8 @@ class wp_slimstat {
1748
  // Copy entries to the archive table, if needed
1749
  if ( self::$settings[ 'auto_purge_delete' ] != 'no' ) {
1750
  $is_copy_done = self::$wpdb->query("
1751
- INSERT INTO {$GLOBALS['wpdb']->prefix}slim_stats_archive (id, ip, other_ip, username, country, referer, resource, searchterms, plugins, notes, visit_id, server_latency, page_performance, browser, browser_version, browser_type, platform, language, user_agent, resolution, screen_width, screen_height, content_type, category, author, content_id, outbound_resource, dt_out, dt)
1752
- SELECT id, ip, other_ip, username, country, referer, resource, searchterms, plugins, notes, visit_id, server_latency, page_performance, browser, browser_version, browser_type, platform, language, user_agent, resolution, screen_width, screen_height, content_type, category, author, content_id, outbound_resource, dt_out, dt
1753
  FROM {$GLOBALS[ 'wpdb' ]->prefix}slim_stats
1754
  WHERE dt < $days_ago");
1755
 
3
  Plugin Name: Slimstat Analytics
4
  Plugin URI: http://wordpress.org/plugins/wp-slimstat/
5
  Description: The leading web analytics plugin for WordPress
6
+ Version: 4.7.6
7
  Author: Jason Crouse
8
  Author URI: http://www.wp-slimstat.com/
9
  Text Domain: wp-slimstat
15
  }
16
 
17
  class wp_slimstat {
18
+ public static $version = '4.7.6';
19
  public static $settings = array();
20
 
21
  public static $wpdb = '';
57
  self::$wpdb = apply_filters( 'slimstat_custom_wpdb', $GLOBALS[ 'wpdb' ] );
58
 
59
  // Hook a DB clean-up routine to the daily cronjob
60
+ add_action( 'wp_slimstat_purge', array( __CLASS__, 'wp_slimstat_purge' ) );
61
 
62
  // Allow external domains on CORS requests
63
  add_filter( 'allowed_http_origins', array(__CLASS__, 'open_cors_admin_ajax' ) );
328
 
329
  $content_info = self::_get_content_info();
330
 
331
+ // Is this content type blacklisted?
332
+ if ( !empty( self::$settings[ 'ignore_content_types' ] ) ) {
333
+ $return_error_code = array(
334
+ -313,
335
+ sprintf( __( 'Content Type %s is blacklisted', 'wp-slimstat' ), $content_info[ 'content_type' ] ),
336
+ true
337
+ );
338
+ if ( self::_is_blacklisted( $content_info[ 'content_type' ], self::$settings[ 'ignore_content_types' ], $return_error_code ) ) {
339
+ return $_argument;
340
+ }
341
+ }
342
+
343
  // Did we receive data from an Ajax request?
344
  if ( !empty( self::$data_js[ 'id' ] ) ) {
345
 
1593
  'extensions_to_track' => 'pdf,doc,xls,zip',
1594
  'track_same_domain_referers' => 'on',
1595
  'geolocation_country' => 'on',
 
1596
  'session_duration' => 1800,
1597
  'extend_session' => 'no',
1598
  'set_tracker_cookie' => 'on',
1601
  'external_domains' => '',
1602
 
1603
  // Filters
1604
+ 'track_users' => 'on',
 
 
 
1605
  'ignore_spammers' => 'on',
1606
  'ignore_bots' => 'no',
1607
+ 'ignore_prefetch' => 'on',
1608
+ 'anonymize_ip' => 'no',
1609
+
1610
+ 'ignore_users' => '',
1611
+ 'ignore_ip' => '',
1612
  'ignore_countries' => '',
1613
  'ignore_browsers' => '',
1614
+ 'ignore_platforms' => '',
1615
+ 'ignore_capabilities' => '',
1616
+
1617
+ 'ignore_resources' => '',
1618
  'ignore_referers' => '',
1619
+ 'ignore_content_types' => '',
 
1620
 
1621
  // Reports
1622
  'use_european_separators' => 'on',
1686
  * Enqueue a javascript to track users' screen resolution and other browser-based information
1687
  */
1688
  public static function wp_slimstat_enqueue_tracking_script() {
 
 
 
 
 
 
 
 
 
 
 
1689
  // Do not enqueue the script if the corresponding options are turned off
1690
  $is_tracking_filter_js = apply_filters( 'slimstat_filter_pre_tracking_js', true );
1691
  if ( ( self::$settings[ 'enable_javascript' ] != 'on' && self::$settings[ 'javascript_mode' ] != 'on' ) || self::$settings[ 'is_tracking' ] != 'on' || !$is_tracking_filter_js ) {
1692
  return 0;
1693
  }
1694
 
1695
+ // Register the script in WordPress
1696
+ $jstracker_suffix = ( defined( 'SCRIPT_DEBUG' ) && is_bool( SCRIPT_DEBUG ) && SCRIPT_DEBUG ) ? '' : '.min';
1697
+
1698
  // Pass some information to the tracker
1699
  $params = array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) );
1700
 
1735
 
1736
  $params = apply_filters( 'slimstat_js_params', $params );
1737
 
1738
+ if ( self::$settings[ 'enable_cdn' ] == 'on' ) {
1739
+ $schema = is_ssl() ? 'https' : 'http';
1740
+ wp_register_script( 'wp_slimstat', $schema . '://cdn.jsdelivr.net/wp/wp-slimstat/tags/' . self::$version . '/wp-slimstat.min.js', array(), null, true );
1741
+ }
1742
+ else{
1743
+ wp_register_script( 'wp_slimstat', plugins_url( "/wp-slimstat{$jstracker_suffix}.js", __FILE__ ), array(), null, true );
1744
+ }
1745
+
1746
  wp_enqueue_script( 'wp_slimstat' );
1747
  wp_localize_script( 'wp_slimstat', 'SlimStatParams', $params );
1748
  }
1752
  */
1753
  public static function wp_slimstat_purge() {
1754
  $autopurge_interval = intval( self::$settings[ 'auto_purge' ] );
1755
+
1756
  if ( $autopurge_interval <= 0 ) {
1757
  return;
1758
  }
1764
  // Copy entries to the archive table, if needed
1765
  if ( self::$settings[ 'auto_purge_delete' ] != 'no' ) {
1766
  $is_copy_done = self::$wpdb->query("
1767
+ INSERT INTO {$GLOBALS['wpdb']->prefix}slim_stats_archive (id, ip, other_ip, username, country, location, city, referer, resource, searchterms, plugins, notes, visit_id, server_latency, page_performance, browser, browser_version, browser_type, platform, language, user_agent, resolution, screen_width, screen_height, content_type, category, author, content_id, outbound_resource, dt_out, dt)
1768
+ SELECT id, ip, other_ip, username, country, location, city, referer, resource, searchterms, plugins, notes, visit_id, server_latency, page_performance, browser, browser_version, browser_type, platform, language, user_agent, resolution, screen_width, screen_height, content_type, category, author, content_id, outbound_resource, dt_out, dt
1769
  FROM {$GLOBALS[ 'wpdb' ]->prefix}slim_stats
1770
  WHERE dt < $days_ago");
1771