Slimstat Analytics - Version 4.7.8.1

Version Description

  • [New] The Customizer now has its own access control settings. This allows admins to control in a more granular way who can do what.
  • [Update] If you have an existing opt-in mechanism, asking your users if they want to be tracked, you can now configure Slimstat to use that cookie to determine if a given pageview should be recorded or not.
Download this release

Release Info

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

Code changes from version 4.7.8 to 4.7.8.1

admin/config/index.php CHANGED
@@ -112,8 +112,10 @@ $settings = array(
112
  'honor_dnt_header' => array( 'description' => __( 'DNT Header', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( "The <a href='https://en.wikipedia.org/wiki/Do_Not_Track' target='_blank'>Do Not Track (DNT)</a> header is the proposed HTTP header field DNT that requests that a web application disable either its tracking or cross-site user tracking (the ambiguity remains unresolved) of an individual user. You can decide to ignore this header and track any pageview regardless of the headers sent by the browser.", 'wp-slimstat' ) ),
113
  'set_tracker_cookie' => array( 'description' => __( 'Set Cookie', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( 'Disable this option if, for legal or security reasons, you do not want Slimstat to assign a <a href="https://en.wikipedia.org/wiki/HTTP_cookie" target="_blank">cookie</a> to your visitors. Please note that, by deactivating this feature, Slimstat will not keep track of returning visitors and sessions.', 'wp-slimstat' ) ),
114
  'display_opt_out' => array( 'description' => __( 'Allow Opt-out', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( "The European <a href='https://en.wikipedia.org/wiki/General_Data_Protection_Regulation' target='_blank'>General Data Protection Regulation (GDPR)</a> requires website owners to provide a way for their visitors to opt-out of tracking. If enabled, the message here below will be displayed to all users who don't have the corresponding cookie set. A notice will be recorded under Settings > Maintenance every time a pageview is ignored because the corresponding visitor has opted out of tracking.", 'wp-slimstat' ) ),
115
- 'opt_out_cookie_names' => array( 'description' => __( 'Opt-out Cookie', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "If you're already using another solution to record and track opt-out choices made by your users, and it sets its own cookie to remember their selection, you can enter the cookie names and values in this field to let Slimstat leverage that information as well. Please use the following format: <code>cookie_name=value</code>, where 'value' is what is used to remember that the user has chosen to <strong>not</strong> be tracked.", 'wp-slimstat' ) ),
116
  'opt_out_message' => array( 'description' => __( 'Opt-out Message', 'wp-slimstat' ), 'type' => 'textarea', 'rows' => 4, 'long_description' => __( "In order to provide maximum flexibility to all site owners, we decided to give you full control over the message and its layout, by allowing you to specify the exact HTML markup that should be displayed on your website. Feel free to customize this code to match your website styles and layout. Use the two placeholders <code>{{accept_url}}</code> and <code>{{deny_url}}</code> for the corresponding links, with the following meaning: Accept = allow tracking, Deny = do not allow tracking.", 'wp-slimstat' ), 'use_tag_list' => false ),
 
 
 
117
 
118
  'filters_outbound_header' => array( 'description' => __( 'Link Tracking', 'wp-slimstat' ), 'type' => 'section_header' ),
119
  'do_not_track_outbound_classes_rel_href' => array( 'description' => __( 'Do Not Track', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "Slimstat will ignore links marked with one of these class names, <em>rel</em> attributes or whose <em>href</em> attribute contains one of these strings. Please keep in mind that the class <code>noslimstat</code> is also used to avoid tracking interactive links throughout the reports. If you remove it from this list, some features might not work as expected.", 'wp-slimstat' ) ),
@@ -203,14 +205,18 @@ $settings = array(
203
  5 => array(
204
  'title' => __( 'Access Control', 'wp-slimstat' ),
205
  'rows' => array(
206
- 'permissions_reports_header' => array('description' => __('Reports','wp-slimstat'), 'type' => 'section_header'),
207
- 'restrict_authors_view' => array('description' => __('Restrict Authors','wp-slimstat'), 'type' => 'toggle', 'long_description' => __('Enable this option if you want your authors to only see stats related to their own content.','wp-slimstat')),
208
- 'capability_can_view' => array('description' => __('Capability','wp-slimstat'), 'type' => 'text', 'long_description' => __("Specify the minimum <a href='http://codex.wordpress.org/Roles_and_Capabilities' target='_new'>capability</a> needed to access the reports (default: <code>activate_plugins</code>). If this field is empty, <strong>all your users</strong> (including subscribers) will have access to the reports, unless a 'Read access' whitelist has been specified here below. In this case, the list has precedence over the capability.",'wp-slimstat')),
209
- 'can_view' => array('description' => __('Whitelist','wp-slimstat'), 'type' => 'textarea', 'long_description' => __("List all the users who should have access to the reports. Administrators are implicitly allowed, so you don't need to list them in here. Usernames are case sensitive.",'wp-slimstat'), 'skip_update' => true),
210
-
211
- 'permissions_config_header' => array('description' => __('Settings','wp-slimstat'), 'type' => 'section_header'),
212
- 'capability_can_admin' => array('description' => __('Capability','wp-slimstat'), 'type' => 'text', 'long_description' => __("Specify the minimum <a href='http://codex.wordpress.org/Roles_and_Capabilities' target='_new'>capability</a> required to configure Slimstat (default: <code>activate_plugins</code>). The whitelist here below can be used to override this option for specific users.",'wp-slimstat')),
213
- 'can_admin' => array('description' => __('Whitelist','wp-slimstat'), 'type' => 'textarea', 'long_description' => __("List all the users who can edit these options. Please be advised that admins <strong>are not</strong> implicitly allowed, so do not forget to include yourself! Usernames are case sensitive.",'wp-slimstat'), 'skip_update' => true),
 
 
 
 
214
 
215
  'rest_api_header' => array( 'description' => __( 'Rest API', 'wp-slimstat' ), 'type' => 'section_header' ),
216
  'rest_api_tokens' => array( 'description' => __( 'Tokens', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "In order to send requests to <a href='https://slimstat.freshdesk.com/support/solutions/articles/12000033661-slimstat-rest-api' target='_blank'>the Slimstat REST API</a>, you will need to pass a valid token to the endpoint (param ?token=XXX). Using the field here below, you can define as many tokens as you like, to distribute them to your API users. Please note: treat these tokens as passwords, as they will grant read access to your reports to anyone who knows them. Use a service like <a href='https://randomkeygen.com/#ci_key' target='_blank'>RandomKeyGen.com</a> to generate unique secure tokens.", 'wp-slimstat' ) )
112
  'honor_dnt_header' => array( 'description' => __( 'DNT Header', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( "The <a href='https://en.wikipedia.org/wiki/Do_Not_Track' target='_blank'>Do Not Track (DNT)</a> header is the proposed HTTP header field DNT that requests that a web application disable either its tracking or cross-site user tracking (the ambiguity remains unresolved) of an individual user. You can decide to ignore this header and track any pageview regardless of the headers sent by the browser.", 'wp-slimstat' ) ),
113
  'set_tracker_cookie' => array( 'description' => __( 'Set Cookie', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( 'Disable this option if, for legal or security reasons, you do not want Slimstat to assign a <a href="https://en.wikipedia.org/wiki/HTTP_cookie" target="_blank">cookie</a> to your visitors. Please note that, by deactivating this feature, Slimstat will not keep track of returning visitors and sessions.', 'wp-slimstat' ) ),
114
  'display_opt_out' => array( 'description' => __( 'Allow Opt-out', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( "The European <a href='https://en.wikipedia.org/wiki/General_Data_Protection_Regulation' target='_blank'>General Data Protection Regulation (GDPR)</a> requires website owners to provide a way for their visitors to opt-out of tracking. If enabled, the message here below will be displayed to all users who don't have the corresponding cookie set. A notice will be recorded under Settings > Maintenance every time a pageview is ignored because the corresponding visitor has opted out of tracking.", 'wp-slimstat' ) ),
 
115
  'opt_out_message' => array( 'description' => __( 'Opt-out Message', 'wp-slimstat' ), 'type' => 'textarea', 'rows' => 4, 'long_description' => __( "In order to provide maximum flexibility to all site owners, we decided to give you full control over the message and its layout, by allowing you to specify the exact HTML markup that should be displayed on your website. Feel free to customize this code to match your website styles and layout. Use the two placeholders <code>{{accept_url}}</code> and <code>{{deny_url}}</code> for the corresponding links, with the following meaning: Accept = allow tracking, Deny = do not allow tracking.", 'wp-slimstat' ), 'use_tag_list' => false ),
116
+ 'opt_out_cookie_names' => array( 'description' => __( 'Opt-out Cookies', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "If you're already using another solution to record and track opt-out choices made by your users, and it sets its own cookie to remember their selection, you can enter the cookie names and values in this field to let Slimstat leverage that information as well. Please use the following format: <code>cookie_name=value</code>, where 'value' is what is used to remember that the user has chosen to <strong>not</strong> be tracked.", 'wp-slimstat' ) ),
117
+ 'opt_in_cookie_names' => array( 'description' => __( 'Opt-in Cookies', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "Similarly to the option here above, you can instruct Slimstat to only track visitors that have provided their consent (opted-in). Please use the following format: <code>cookie_name=value</code>, where 'value' is what is used to remember that the user has chosen <strong>to be</strong> tracked.", 'wp-slimstat' ) ),
118
+
119
 
120
  'filters_outbound_header' => array( 'description' => __( 'Link Tracking', 'wp-slimstat' ), 'type' => 'section_header' ),
121
  'do_not_track_outbound_classes_rel_href' => array( 'description' => __( 'Do Not Track', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "Slimstat will ignore links marked with one of these class names, <em>rel</em> attributes or whose <em>href</em> attribute contains one of these strings. Please keep in mind that the class <code>noslimstat</code> is also used to avoid tracking interactive links throughout the reports. If you remove it from this list, some features might not work as expected.", 'wp-slimstat' ) ),
205
  5 => array(
206
  'title' => __( 'Access Control', 'wp-slimstat' ),
207
  'rows' => array(
208
+ 'permissions_reports_header' => array( 'description' => __( 'Reports', 'wp-slimstat' ), 'type' => 'section_header' ),
209
+ 'restrict_authors_view' => array( 'description' => __( 'Restrict Authors', 'wp-slimstat' ), 'type' => 'toggle', 'long_description' => __( 'Enable this option if you want your authors to only see stats related to their own content.', 'wp-slimstat' ) ),
210
+ 'capability_can_view' => array( 'description' => __( 'Capability', 'wp-slimstat' ), 'type' => 'text', 'long_description' => __( "Specify the minimum <a href='http://codex.wordpress.org/Roles_and_Capabilities' target='_new'>capability</a> needed to access the reports (default: <code>activate_plugins</code>). If this field is empty, <strong>all your users</strong> (including subscribers) will have access to the reports, unless a 'Read access' whitelist has been specified here below. In this case, the list has precedence over the capability.", 'wp-slimstat' ) ),
211
+ 'can_view' => array( 'description' => __( 'Whitelist', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "List all the users who should have access to the reports. Administrators are implicitly allowed, so you don't need to list them in here. Usernames are case sensitive.", 'wp-slimstat' ), 'skip_update' => true ),
212
+
213
+ 'permissions_customize_header' => array( 'description' => __( 'Customizer', 'wp-slimstat' ), 'type' => 'section_header' ),
214
+ 'capability_can_customize' => array( 'description' => __( 'Capability', 'wp-slimstat' ), 'type' => 'text', 'long_description' => __( "Specify the minimum <a href='http://codex.wordpress.org/Roles_and_Capabilities' target='_new'>capability</a> needed to be able to customize the reports layout (default: <code>activate_plugins</code>). If this field is empty, your users will be permitted to use this features.", 'wp-slimstat' ) ),
215
+ 'can_customize' => array( 'description' => __( 'Whitelist', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "List all the users who should be allowed to customize their report layout. Administrators are implicitly allowed, so you don't need to list them in here. Usernames are case sensitive.", 'wp-slimstat' ), 'skip_update' => true ),
216
+
217
+ 'permissions_config_header' => array( 'description' => __( 'Settings', 'wp-slimstat' ), 'type' => 'section_header' ),
218
+ 'capability_can_admin' => array( 'description' => __( 'Capability', 'wp-slimstat' ), 'type' => 'text', 'long_description' => __( "Specify the minimum <a href='http://codex.wordpress.org/Roles_and_Capabilities' target='_new'>capability</a> required to configure Slimstat (default: <code>activate_plugins</code>). The whitelist here below can be used to override this option for specific users.", 'wp-slimstat' ) ),
219
+ 'can_admin' => array( 'description' => __( 'Whitelist', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "List all the users who can edit these options. Please be advised that admins <strong>are not</strong> implicitly allowed, so do not forget to include yourself! Usernames are case sensitive.", 'wp-slimstat' ), 'skip_update' => true ),
220
 
221
  'rest_api_header' => array( 'description' => __( 'Rest API', 'wp-slimstat' ), 'type' => 'section_header' ),
222
  'rest_api_tokens' => array( 'description' => __( 'Tokens', 'wp-slimstat' ), 'type' => 'textarea', 'long_description' => __( "In order to send requests to <a href='https://slimstat.freshdesk.com/support/solutions/articles/12000033661-slimstat-rest-api' target='_blank'>the Slimstat REST API</a>, you will need to pass a valid token to the endpoint (param ?token=XXX). Using the field here below, you can define as many tokens as you like, to distribute them to your API users. Please note: treat these tokens as passwords, as they will grant read access to your reports to anyone who knows them. Use a service like <a href='https://randomkeygen.com/#ci_key' target='_blank'>RandomKeyGen.com</a> to generate unique secure tokens.", 'wp-slimstat' ) )
admin/wp-slimstat-admin.php CHANGED
@@ -58,15 +58,9 @@ class wp_slimstat_admin {
58
  'title' => __( 'Traffic Sources', 'wp-slimstat' ),
59
  'callback' => array( __CLASS__, 'wp_slimstat_include_view' )
60
  ),
61
- 'slimlayout' => array(
62
- 'is_report_group' => false,
63
- 'show_in_sidebar' => ( empty( $has_network_reports ) || current_user_can( 'manage_options' ) ),
64
- 'title' => __( 'Customize', 'wp-slimstat' ),
65
- 'callback' => array( __CLASS__, 'wp_slimstat_include_layout' )
66
- ),
67
  'slimaddons' => array(
68
  'is_report_group' => false,
69
- 'show_in_sidebar' => true,
70
  'title' => __( 'Add-ons', 'wp-slimstat' ),
71
  'callback' => array( __CLASS__, 'wp_slimstat_include_addons' )
72
  ),
@@ -115,13 +109,14 @@ class wp_slimstat_admin {
115
 
116
  // Add a menu to the admin bar ( this function is declared here and not in wp_slimstat_admin because the latter is only initialized if is_admin(), and not in the front-end )
117
  if ( wp_slimstat::$settings[ 'use_separate_menu' ] != 'on' && is_admin_bar_showing() ) {
118
- add_action( 'admin_bar_menu', array( __CLASS__, 'wp_slimstat_adminbar' ), 100 );
119
  }
120
 
121
  if ( function_exists( 'is_network_admin' ) && !is_network_admin() ) {
122
  // Add the appropriate entries to the admin menu, if this user can view/admin Slimstat
123
- add_action( 'admin_menu', array( __CLASS__, 'wp_slimstat_add_view_menu' ) );
124
- add_action( 'admin_menu', array( __CLASS__, 'wp_slimstat_add_config_menu' ) );
 
125
 
126
  // Display the column in the Edit Posts / Pages screen
127
  if ( wp_slimstat::$settings[ 'add_posts_column' ] == 'on' ) {
@@ -453,11 +448,14 @@ class wp_slimstat_admin {
453
  /**
454
  * Removes 'spammers' from the database when the corresponding comments are marked as spam
455
  */
456
- public static function remove_spam($_new_status = '', $_old_status = '', $_comment = ''){
457
- $my_wpdb = apply_filters('slimstat_custom_wpdb', $GLOBALS['wpdb']);
458
 
459
- if ($_new_status == 'spam' && !empty($_comment->comment_author) && !empty($_comment->comment_author_IP)){
460
- $my_wpdb->query(wp_slimstat::$wpdb->prepare("DELETE ts FROM {$GLOBALS['wpdb']->prefix}slim_stats ts WHERE username = %s OR INET_NTOA(ip) = %s", $_comment->comment_author, $_comment->comment_author_IP));
 
 
 
461
  }
462
  }
463
  // end remove_spam
@@ -515,7 +513,7 @@ class wp_slimstat_admin {
515
  /**
516
  * Adds a new entry in the admin menu, to view the stats
517
  */
518
- public static function wp_slimstat_add_view_menu( $_s = '' ) {
519
  // If this user is whitelisted, we use the minimum capability
520
  $minimum_capability = 'read';
521
  if ( is_network_admin() ) {
@@ -555,18 +553,24 @@ class wp_slimstat_admin {
555
 
556
  return $_s;
557
  }
558
- // end wp_slimstat_add_view_menu
559
 
560
  /**
561
  * Adds a new entry to the Wordpress Toolbar
562
  */
563
- public static function wp_slimstat_adminbar(){
564
  // If this user is whitelisted, we use the minimum capability
565
  $minimum_capability_view = 'read';
566
  if ( strpos( wp_slimstat::$settings[ 'can_view' ], $GLOBALS[ 'current_user' ]->user_login) === false && !empty( wp_slimstat::$settings[ 'capability_can_view' ] ) ) {
567
  $minimum_capability_view = wp_slimstat::$settings[ 'capability_can_view' ];
568
  }
569
 
 
 
 
 
 
 
570
  // If this user is whitelisted, we use the minimum capability
571
  $minimum_capability_config = 'read';
572
  if ( ( strpos( wp_slimstat::$settings[ 'can_admin' ], $GLOBALS[ 'current_user' ]->user_login ) === false) && $GLOBALS[ 'current_user' ]->user_login != 'slimstatadmin' && !empty( wp_slimstat::$settings[ 'capability_can_admin' ] ) ) {
@@ -579,9 +583,8 @@ class wp_slimstat_admin {
579
 
580
  wp_slimstat::$settings[ 'capability_can_view' ] = empty( wp_slimstat::$settings[ 'capability_can_view' ] ) ? 'read' : wp_slimstat::$settings[ 'capability_can_view' ];
581
 
582
- if (empty(wp_slimstat::$settings['can_view']) || strpos(wp_slimstat::$settings['can_view'], $GLOBALS['current_user']->user_login) !== false || current_user_can('manage_options')){
583
- $slimstat_view_url = get_admin_url($GLOBALS['blog_id'], "admin.php?page=");
584
- $slimstat_config_url = get_admin_url($GLOBALS['blog_id'], "admin.php?page=slimconfig");
585
 
586
  $page_location = ( wp_slimstat::$settings[ 'use_separate_menu' ] == 'on' ) ? 'slimstat' : 'admin';
587
  $user_reports = get_user_option( "meta-box-order_{$page_location}_page_slimlayout", $GLOBALS[ 'current_user' ]->ID );
@@ -608,8 +611,22 @@ class wp_slimstat_admin {
608
  }
609
  }
610
 
 
 
 
 
 
 
 
 
 
611
  if ( ( empty( wp_slimstat::$settings[ 'can_admin' ] ) || strpos( wp_slimstat::$settings[ 'can_admin' ], $GLOBALS[ 'current_user' ]->user_login ) !== false || $GLOBALS[ 'current_user' ]->user_login == 'slimstatadmin' ) && current_user_can( $minimum_capability_config ) ) {
612
- $GLOBALS['wp_admin_bar']->add_menu(array('id' => 'slimstat-config', 'href' => $slimstat_config_url, 'parent' => 'slimstat-header', 'title' => __('Settings', 'wp-slimstat')));
 
 
 
 
 
613
  }
614
  }
615
  }
@@ -617,7 +634,34 @@ class wp_slimstat_admin {
617
  /**
618
  * Adds a new entry in the admin menu, to manage Slimstat options
619
  */
620
- public static function wp_slimstat_add_config_menu($_s){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
621
  wp_slimstat::$settings[ 'capability_can_admin' ] = empty( wp_slimstat::$settings[ 'capability_can_admin' ] ) ? 'activate_plugins' : wp_slimstat::$settings[ 'capability_can_admin' ];
622
 
623
  // If this user is whitelisted, we use the minimum capability
@@ -636,11 +680,10 @@ class wp_slimstat_admin {
636
  // Load styles and Javascript needed to make the reports look nice and interactive
637
  add_action( 'load-' . $new_entry, array( __CLASS__, 'wp_slimstat_stylesheet' ) );
638
  add_action('load-'.$new_entry, array(__CLASS__, 'wp_slimstat_enqueue_scripts'));
639
- //add_action('load-'.$new_entry, array(__CLASS__, 'wp_slimstat_enqueue_config_scripts'));
640
 
641
  return $_s;
642
  }
643
- // end wp_slimstat_add_config_menu
644
 
645
  /**
646
  * Includes the appropriate panel to view the stats
58
  'title' => __( 'Traffic Sources', 'wp-slimstat' ),
59
  'callback' => array( __CLASS__, 'wp_slimstat_include_view' )
60
  ),
 
 
 
 
 
 
61
  'slimaddons' => array(
62
  'is_report_group' => false,
63
+ 'show_in_sidebar' => current_user_can( 'manage_options' ),
64
  'title' => __( 'Add-ons', 'wp-slimstat' ),
65
  'callback' => array( __CLASS__, 'wp_slimstat_include_addons' )
66
  ),
109
 
110
  // Add a menu to the admin bar ( this function is declared here and not in wp_slimstat_admin because the latter is only initialized if is_admin(), and not in the front-end )
111
  if ( wp_slimstat::$settings[ 'use_separate_menu' ] != 'on' && is_admin_bar_showing() ) {
112
+ add_action( 'admin_bar_menu', array( __CLASS__, 'add_menu_to_adminbar' ), 100 );
113
  }
114
 
115
  if ( function_exists( 'is_network_admin' ) && !is_network_admin() ) {
116
  // Add the appropriate entries to the admin menu, if this user can view/admin Slimstat
117
+ add_action( 'admin_menu', array( __CLASS__, 'add_view_menu' ) );
118
+ add_action( 'admin_menu', array( __CLASS__, 'add_customize_menu' ) );
119
+ add_action( 'admin_menu', array( __CLASS__, 'add_config_menu' ) );
120
 
121
  // Display the column in the Edit Posts / Pages screen
122
  if ( wp_slimstat::$settings[ 'add_posts_column' ] == 'on' ) {
448
  /**
449
  * Removes 'spammers' from the database when the corresponding comments are marked as spam
450
  */
451
+ public static function remove_spam( $_new_status = '', $_old_status = '', $_comment = '' ) {
452
+ $my_wpdb = apply_filters( 'slimstat_custom_wpdb', $GLOBALS[ 'wpdb' ] );
453
 
454
+ if ( $_new_status == 'spam' && !empty( $_comment->comment_author ) && !empty( $_comment->comment_author_IP ) ) {
455
+ $my_wpdb->query( wp_slimstat::$wpdb->prepare( "
456
+ DELETE ts
457
+ FROM {$GLOBALS['wpdb']->prefix}slim_stats ts
458
+ WHERE username = %s OR INET_NTOA(ip) = %s", $_comment->comment_author, $_comment->comment_author_IP ) );
459
  }
460
  }
461
  // end remove_spam
513
  /**
514
  * Adds a new entry in the admin menu, to view the stats
515
  */
516
+ public static function add_view_menu( $_s = '' ) {
517
  // If this user is whitelisted, we use the minimum capability
518
  $minimum_capability = 'read';
519
  if ( is_network_admin() ) {
553
 
554
  return $_s;
555
  }
556
+ // end add_view_menu
557
 
558
  /**
559
  * Adds a new entry to the Wordpress Toolbar
560
  */
561
+ public static function add_menu_to_adminbar() {
562
  // If this user is whitelisted, we use the minimum capability
563
  $minimum_capability_view = 'read';
564
  if ( strpos( wp_slimstat::$settings[ 'can_view' ], $GLOBALS[ 'current_user' ]->user_login) === false && !empty( wp_slimstat::$settings[ 'capability_can_view' ] ) ) {
565
  $minimum_capability_view = wp_slimstat::$settings[ 'capability_can_view' ];
566
  }
567
 
568
+ // If this user is whitelisted, we use the minimum capability
569
+ $minimum_capability_customize = 'read';
570
+ if ( strpos( wp_slimstat::$settings[ 'can_customize' ], $GLOBALS[ 'current_user' ]->user_login) === false && !empty( wp_slimstat::$settings[ 'capability_can_customize' ] ) ) {
571
+ $minimum_capability_customize = wp_slimstat::$settings[ 'capability_can_customize' ];
572
+ }
573
+
574
  // If this user is whitelisted, we use the minimum capability
575
  $minimum_capability_config = 'read';
576
  if ( ( strpos( wp_slimstat::$settings[ 'can_admin' ], $GLOBALS[ 'current_user' ]->user_login ) === false) && $GLOBALS[ 'current_user' ]->user_login != 'slimstatadmin' && !empty( wp_slimstat::$settings[ 'capability_can_admin' ] ) ) {
583
 
584
  wp_slimstat::$settings[ 'capability_can_view' ] = empty( wp_slimstat::$settings[ 'capability_can_view' ] ) ? 'read' : wp_slimstat::$settings[ 'capability_can_view' ];
585
 
586
+ if ( empty( wp_slimstat::$settings[ 'can_view' ]) || strpos( wp_slimstat::$settings[ 'can_view' ], $GLOBALS[ 'current_user' ]->user_login ) !== false || current_user_can( 'manage_options' ) ) {
587
+ $slimstat_view_url = get_admin_url( $GLOBALS[ 'blog_id' ], "admin.php?page=" );
 
588
 
589
  $page_location = ( wp_slimstat::$settings[ 'use_separate_menu' ] == 'on' ) ? 'slimstat' : 'admin';
590
  $user_reports = get_user_option( "meta-box-order_{$page_location}_page_slimlayout", $GLOBALS[ 'current_user' ]->ID );
611
  }
612
  }
613
 
614
+ if ( ( empty( wp_slimstat::$settings[ 'can_customize' ] ) || strpos( wp_slimstat::$settings[ 'can_customize' ], $GLOBALS[ 'current_user' ]->user_login ) !== false ) && current_user_can( $minimum_capability_customize ) ) {
615
+ $GLOBALS[ 'wp_admin_bar' ]->add_menu( array(
616
+ 'id' => 'slimstat-layout',
617
+ 'href' => get_admin_url( $GLOBALS[ 'blog_id' ], "admin.php?page=slimlayout" ),
618
+ 'parent' => 'slimstat-header',
619
+ 'title' => __( 'Customize', 'wp-slimstat' ) )
620
+ );
621
+ }
622
+
623
  if ( ( empty( wp_slimstat::$settings[ 'can_admin' ] ) || strpos( wp_slimstat::$settings[ 'can_admin' ], $GLOBALS[ 'current_user' ]->user_login ) !== false || $GLOBALS[ 'current_user' ]->user_login == 'slimstatadmin' ) && current_user_can( $minimum_capability_config ) ) {
624
+ $GLOBALS[ 'wp_admin_bar' ]->add_menu( array(
625
+ 'id' => 'slimstat-config',
626
+ 'href' => get_admin_url( $GLOBALS[ 'blog_id' ], "admin.php?page=slimconfig" ),
627
+ 'parent' => 'slimstat-header',
628
+ 'title' => __( 'Settings', 'wp-slimstat' ) )
629
+ );
630
  }
631
  }
632
  }
634
  /**
635
  * Adds a new entry in the admin menu, to manage Slimstat options
636
  */
637
+ public static function add_customize_menu( $_s ) {
638
+ wp_slimstat::$settings[ 'capability_can_customize' ] = empty( wp_slimstat::$settings[ 'capability_can_customize' ] ) ? 'activate_plugins' : wp_slimstat::$settings[ 'capability_can_customize' ];
639
+
640
+ // If this user is whitelisted, we use the minimum capability
641
+ $minimum_capability = 'read';
642
+ if ( ( strpos( wp_slimstat::$settings[ 'can_customize' ], $GLOBALS[ 'current_user' ]->user_login ) === false ) && !empty( wp_slimstat::$settings[ 'capability_can_customize' ] ) ) {
643
+ $minimum_capability = wp_slimstat::$settings[ 'capability_can_customize' ];
644
+ }
645
+
646
+ if ( wp_slimstat::$settings[ 'use_separate_menu' ] == 'on' ) {
647
+ $new_entry = add_submenu_page( 'slimview1', __( 'Customize','wp-slimstat' ), __( 'Customize','wp-slimstat' ), $minimum_capability, 'slimlayout', array( __CLASS__, 'wp_slimstat_include_layout' ) );
648
+ }
649
+ else {
650
+ $new_entry = add_submenu_page( null, __( 'Customize','wp-slimstat' ), __( 'Customize','wp-slimstat' ), $minimum_capability, 'slimlayout', array( __CLASS__, 'wp_slimstat_include_layout' ) );
651
+ }
652
+
653
+ // Load styles and Javascript needed to make the reports look nice and interactive
654
+ add_action( 'load-' . $new_entry, array( __CLASS__, 'wp_slimstat_stylesheet' ) );
655
+ add_action('load-'.$new_entry, array(__CLASS__, 'wp_slimstat_enqueue_scripts'));
656
+
657
+ return $_s;
658
+ }
659
+ // end add_customize_menu
660
+
661
+ /**
662
+ * Adds a new entry in the admin menu, to manage Slimstat options
663
+ */
664
+ public static function add_config_menu( $_s ) {
665
  wp_slimstat::$settings[ 'capability_can_admin' ] = empty( wp_slimstat::$settings[ 'capability_can_admin' ] ) ? 'activate_plugins' : wp_slimstat::$settings[ 'capability_can_admin' ];
666
 
667
  // If this user is whitelisted, we use the minimum capability
680
  // Load styles and Javascript needed to make the reports look nice and interactive
681
  add_action( 'load-' . $new_entry, array( __CLASS__, 'wp_slimstat_stylesheet' ) );
682
  add_action('load-'.$new_entry, array(__CLASS__, 'wp_slimstat_enqueue_scripts'));
 
683
 
684
  return $_s;
685
  }
686
+ // end add_config_menu
687
 
688
  /**
689
  * Includes the appropriate panel to view the stats
readme.txt CHANGED
@@ -6,7 +6,7 @@ Text Domain: wp-slimstat
6
  Requires at least: 3.8
7
  Requires PHP: 5.2
8
  Tested up to: 4.9
9
- Stable tag: 4.7.8
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.
@@ -17,6 +17,7 @@ The leading web analytics plugin for WordPress. Track returning customers and re
17
  = Main features =
18
  * Get access to real-time access log, measure server latency, track page events, keep an eye on your bounce rate and much more.
19
  * Add shortcodes to your website to display reports in widgets or directly in posts and pages.
 
20
  * Exclude users from statistics collection based on various criteria, including; user roles, common robots, IP subnets, admin pages, country, etc.
21
  * Export your reports to CSV, generate user heatmaps or get daily emails right in your mailbox (via premium add-ons).
22
  * Compatible with W3 Total Cache, WP SuperCache, CloudFlare and most caching plugins.
@@ -77,6 +78,10 @@ Our knowledge base is available on our [support center](http://docs.wp-slimstat.
77
  5. **Responsive layout** - Keep an eye on your reports on the go
78
 
79
  == Changelog ==
 
 
 
 
80
  = 4.7.8 =
81
  * [Note] A few users have reached out to us to ask if Slimstat would be compliant with the upcoming [General Data Protection Regulation (GDPR)](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation) guidelines and regulations that are about to be activated all across Europe. Based on our understanding of this new law, as long as the hosting provider where you are storing the information collected by Slimstat is GDPR compliant, then you won't have to worry about any extra layers of compliance offered by software like ours. One of our primary goals is to make sure that you and only you are the sole owner of the data collected by our plugin. This has always been what makes Slimstat stand out from the crowd: while Jetpack, Google Analytics and many other services have full unrestricted access to the data they collect on your website, we at Slimstat don't treat our users as *the product* that we sell to other companies.
82
  * [New] Our plugin now honors the [Do Not Track header](https://en.wikipedia.org/wiki/Do_Not_Track). Please note that this feature can be turned off in the settings, and will be enabled by default.
6
  Requires at least: 3.8
7
  Requires PHP: 5.2
8
  Tested up to: 4.9
9
+ Stable tag: 4.7.8.1
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.
17
  = Main features =
18
  * Get access to real-time access log, measure server latency, track page events, keep an eye on your bounce rate and much more.
19
  * Add shortcodes to your website to display reports in widgets or directly in posts and pages.
20
+ * Fully compliant with the European GDPR guidelines. You can test your website at [cookiebot.com](https://www.cookiebot.com/en/).
21
  * Exclude users from statistics collection based on various criteria, including; user roles, common robots, IP subnets, admin pages, country, etc.
22
  * Export your reports to CSV, generate user heatmaps or get daily emails right in your mailbox (via premium add-ons).
23
  * Compatible with W3 Total Cache, WP SuperCache, CloudFlare and most caching plugins.
78
  5. **Responsive layout** - Keep an eye on your reports on the go
79
 
80
  == Changelog ==
81
+ = 4.7.8.1 =
82
+ * [New] The Customizer now has its own access control settings. This allows admins to control in a more granular way who can do what.
83
+ * [Update] If you have an existing opt-in mechanism, asking your users if they want to be tracked, you can now configure Slimstat to use that cookie to determine if a given pageview should be recorded or not.
84
+
85
  = 4.7.8 =
86
  * [Note] A few users have reached out to us to ask if Slimstat would be compliant with the upcoming [General Data Protection Regulation (GDPR)](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation) guidelines and regulations that are about to be activated all across Europe. Based on our understanding of this new law, as long as the hosting provider where you are storing the information collected by Slimstat is GDPR compliant, then you won't have to worry about any extra layers of compliance offered by software like ours. One of our primary goals is to make sure that you and only you are the sole owner of the data collected by our plugin. This has always been what makes Slimstat stand out from the crowd: while Jetpack, Google Analytics and many other services have full unrestricted access to the data they collect on your website, we at Slimstat don't treat our users as *the product* that we sell to other companies.
87
  * [New] Our plugin now honors the [Do Not Track header](https://en.wikipedia.org/wiki/Do_Not_Track). Please note that this feature can be turned off in the settings, and will be enabled by default.
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.8
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.8';
19
  public static $settings = array();
20
 
21
  public static $wpdb = '';
@@ -101,7 +101,7 @@ class wp_slimstat {
101
  }
102
  }
103
  }
104
- if ( self::$settings[ 'display_opt_out' ] == 'on' && $is_cookie_empty && !isset( $_GET[ 'slimstat-opt-out' ] ) ) {
105
  add_action( 'wp_footer', array( __CLASS__, 'opt_out_box' ) );
106
  }
107
 
@@ -314,7 +314,34 @@ class wp_slimstat {
314
  if ( isset( $_COOKIE[ $a_name ] ) && $_COOKIE[ $a_name ] == $a_value ) {
315
  self::$stat[ 'id' ] = -315;
316
  self::_set_error_array( __( 'Visitor has opted out of tracking', 'wp-slimstat' ), true );
317
- return $_argument;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
  }
319
  }
320
 
@@ -1706,9 +1733,11 @@ class wp_slimstat {
1706
  'restrict_authors_view' => 'on',
1707
  'capability_can_view' => 'activate_plugins',
1708
  'can_view' => '',
1709
- 'rest_api_tokens' => wp_hash( uniqid( time() - 3600, true ) ),
 
1710
  'capability_can_admin' => 'activate_plugins',
1711
  'can_admin' => '',
 
1712
 
1713
  // Maintenance
1714
  'last_tracker_error' => array( 0, '', 0 ),
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.8.1
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.8.1';
19
  public static $settings = array();
20
 
21
  public static $wpdb = '';
101
  }
102
  }
103
  }
104
+ if ( $is_cookie_empty && self::$settings[ 'display_opt_out' ] == 'on' && !isset( $_GET[ 'slimstat-opt-out' ] ) ) {
105
  add_action( 'wp_footer', array( __CLASS__, 'opt_out_box' ) );
106
  }
107
 
314
  if ( isset( $_COOKIE[ $a_name ] ) && $_COOKIE[ $a_name ] == $a_value ) {
315
  self::$stat[ 'id' ] = -315;
316
  self::_set_error_array( __( 'Visitor has opted out of tracking', 'wp-slimstat' ), true );
317
+ return $_argument;
318
+ }
319
+ }
320
+
321
+ // Opt-in tracking via cookie (only those who have a cookie will be tracked)
322
+ if ( !empty( self::$settings[ 'opt_in_cookie_names' ] ) ) {
323
+ $cookie_names = array();
324
+ $opt_in_cookie_names = self::string_to_array( self::$settings[ 'opt_in_cookie_names' ] );
325
+
326
+ foreach ( $opt_in_cookie_names as $a_cookie_pair ) {
327
+ list( $name, $value ) = explode( '=', $a_cookie_pair );
328
+
329
+ if ( !empty( $name ) && !empty( $value ) ) {
330
+ $cookie_names[ $name ] = $value;
331
+ }
332
+ }
333
+
334
+ $cookie_found = false;
335
+ foreach ( $cookie_names as $a_name => $a_value ) {
336
+ if ( isset( $_COOKIE[ $a_name ] ) && $_COOKIE[ $a_name ] == $a_value ) {
337
+ $cookie_found = true;
338
+ }
339
+ }
340
+
341
+ if ( !$cookie_found ) {
342
+ self::$stat[ 'id' ] = -316;
343
+ self::_set_error_array( __( 'Visitor has not opted in to be tracked', 'wp-slimstat' ), true );
344
+ return $_argument;
345
  }
346
  }
347
 
1733
  'restrict_authors_view' => 'on',
1734
  'capability_can_view' => 'activate_plugins',
1735
  'can_view' => '',
1736
+ 'capability_can_customize' => 'activate_plugins',
1737
+ 'can_customize' => '',
1738
  'capability_can_admin' => 'activate_plugins',
1739
  'can_admin' => '',
1740
+ 'rest_api_tokens' => wp_hash( uniqid( time() - 3600, true ) ),
1741
 
1742
  // Maintenance
1743
  'last_tracker_error' => array( 0, '', 0 ),