Matomo Analytics – Ethical Stats. Powerful Insights. - Version 1.3.2

Version Description

Download this release

Release Info

Developer matomoteam
Plugin Icon 128x128 Matomo Analytics – Ethical Stats. Powerful Insights.
Version 1.3.2
Comparing to
See all releases

Code changes from version 1.3.1 to 1.3.2

classes/WpMatomo/API.php CHANGED
@@ -10,6 +10,7 @@
10
  namespace WpMatomo;
11
 
12
  use Piwik\API\Request;
 
13
 
14
  if ( ! defined( 'ABSPATH' ) ) {
15
  exit; // if accessed directly
@@ -198,6 +199,18 @@ class API {
198
 
199
  Bootstrap::do_bootstrap();
200
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  try {
202
  $result = Request::processRequest( $api_method, $params );
203
  } catch ( \Exception $e ) {
10
  namespace WpMatomo;
11
 
12
  use Piwik\API\Request;
13
+ use Piwik\Common;
14
 
15
  if ( ! defined( 'ABSPATH' ) ) {
16
  exit; // if accessed directly
199
 
200
  Bootstrap::do_bootstrap();
201
 
202
+ // refs https://github.com/matomo-org/wp-matomo/issues/370 ensuring segment will be used from default request when
203
+ // creating new request object and not the encoded segment
204
+ if (isset($params['segment'])) {
205
+ if (isset($_GET['segment']) || isset($_POST['segment'])) {
206
+ unset($params['segment']); // matomo will read the segment from default request
207
+ } elseif (!empty($params['segment']) && is_string($params['segment'])) {
208
+ // manually unsanitize this value
209
+ $params['segment'] = Common::unsanitizeInputValue($params['segment']);
210
+ }
211
+ }
212
+
213
+
214
  try {
215
  $result = Request::processRequest( $api_method, $params );
216
  } catch ( \Exception $e ) {
classes/WpMatomo/Admin/SystemReport.php CHANGED
@@ -52,6 +52,8 @@ class SystemReport {
52
  private $not_compatible_plugins = array(
53
  'background-manager', // Uses an old version of Twig and plugin is no longer maintained.
54
  'data-tables-generator-by-supsystic', // uses an old version of twig causing some styles to go funny in the reporting and admin
 
 
55
  );
56
 
57
  private $valid_tabs = array( 'troubleshooting' );
@@ -774,7 +776,9 @@ class SystemReport {
774
  );
775
  $consts = array('WP_DEBUG', 'WP_DEBUG_DISPLAY', 'WP_DEBUG_LOG', 'DISABLE_WP_CRON', 'FORCE_SSL_ADMIN', 'WP_CACHE',
776
  'CONCATENATE_SCRIPTS', 'COMPRESS_SCRIPTS', 'COMPRESS_CSS', 'ENFORCE_GZIP', 'WP_LOCAL_DEV',
777
- 'DIEONDBERROR', 'WPLANG', 'ALTERNATE_WP_CRON', 'WP_CRON_LOCK_TIMEOUT', 'WP_DISABLE_FATAL_ERROR_HANDLER');
 
 
778
  foreach ($consts as $const) {
779
  $rows[] = array(
780
  'name' => $const,
@@ -911,7 +915,14 @@ class SystemReport {
911
  'value' => defined( 'WP_MAX_MEMORY_LIMIT' ) ? WP_MAX_MEMORY_LIMIT : '',
912
  'comment' => '',
913
  );
914
-
 
 
 
 
 
 
 
915
  $rows[] = array(
916
  'name' => 'Time',
917
  'value' => time(),
@@ -1272,10 +1283,19 @@ class SystemReport {
1272
 
1273
  $used_not_compatible = array_intersect( $active_plugins, $this->not_compatible_plugins );
1274
  if ( ! empty( $used_not_compatible ) ) {
 
 
 
 
 
 
 
 
 
1275
  $rows[] = array(
1276
  'name' => __( 'Not compatible plugins', 'matomo' ),
1277
  'value' => count( $used_not_compatible ),
1278
- 'comment' => implode( ', ', $used_not_compatible ) . '<br><br> Matomo may work fine when using these plugins but there may be some issues. For more information see<br>https://matomo.org/faq/wordpress/which-plugins-is-matomo-for-wordpress-known-to-be-not-compatible-with/',
1279
  'is_warning' => true,
1280
  );
1281
  }
52
  private $not_compatible_plugins = array(
53
  'background-manager', // Uses an old version of Twig and plugin is no longer maintained.
54
  'data-tables-generator-by-supsystic', // uses an old version of twig causing some styles to go funny in the reporting and admin
55
+ 'tweet-old-post-pro', // uses a newer version of monolog
56
+ 'secupress', // see #369 depending on setting might have issues
57
  );
58
 
59
  private $valid_tabs = array( 'troubleshooting' );
776
  );
777
  $consts = array('WP_DEBUG', 'WP_DEBUG_DISPLAY', 'WP_DEBUG_LOG', 'DISABLE_WP_CRON', 'FORCE_SSL_ADMIN', 'WP_CACHE',
778
  'CONCATENATE_SCRIPTS', 'COMPRESS_SCRIPTS', 'COMPRESS_CSS', 'ENFORCE_GZIP', 'WP_LOCAL_DEV',
779
+ 'DIEONDBERROR', 'WPLANG', 'ALTERNATE_WP_CRON', 'WP_CRON_LOCK_TIMEOUT', 'WP_DISABLE_FATAL_ERROR_HANDLER',
780
+ 'MATOMO_SUPPORT_ASYNC_ARCHIVING', 'MATOMO_TRIGGER_BROWSER_ARCHIVING', 'MATOMO_ENABLE_TAG_MANAGER', 'MATOMO_SUPPRESS_DB_ERRORS', 'MATOMO_ENABLE_AUTO_UPGRADE',
781
+ 'MATOMO_DEBUG', 'MATOMO_SAFE_MODE', 'MATOMO_GLOBAL_UPLOAD_DIR', 'MATOMO_LOGIN_REDIRECT');
782
  foreach ($consts as $const) {
783
  $rows[] = array(
784
  'name' => $const,
915
  'value' => defined( 'WP_MAX_MEMORY_LIMIT' ) ? WP_MAX_MEMORY_LIMIT : '',
916
  'comment' => '',
917
  );
918
+
919
+ if (function_exists('timezone_version_get')) {
920
+ $rows[] = array(
921
+ 'name' => 'Timezone version',
922
+ 'value' => timezone_version_get(),
923
+ );
924
+ }
925
+
926
  $rows[] = array(
927
  'name' => 'Time',
928
  'value' => time(),
1283
 
1284
  $used_not_compatible = array_intersect( $active_plugins, $this->not_compatible_plugins );
1285
  if ( ! empty( $used_not_compatible ) ) {
1286
+
1287
+ $additional_comment = '';
1288
+ if (in_array('tweet-old-post-pro', $used_not_compatible)) {
1289
+ $additional_comment .= '<br><br>A workaround for Revive Old Posts Pro may be to add the following line to your "wp-config.php". <br><code>define( \'MATOMO_SUPPORT_ASYNC_ARCHIVING\', false );</code>.';
1290
+ }
1291
+ if (in_array('secupress', $used_not_compatible)) {
1292
+ $additional_comment .= '<br><br>If reports aren\'t being generated then you may need to disable the feature "Firewall -> Block Bad Request Methods" in SecuPress (if it is enabled) or add the following line to your "wp-config.php": <br><code>define( \'MATOMO_SUPPORT_ASYNC_ARCHIVING\', false );</code>.';
1293
+ }
1294
+
1295
  $rows[] = array(
1296
  'name' => __( 'Not compatible plugins', 'matomo' ),
1297
  'value' => count( $used_not_compatible ),
1298
+ 'comment' => implode( ', ', $used_not_compatible ) . '<br><br> Matomo may work fine when using these plugins but there may be some issues. For more information see<br>https://matomo.org/faq/wordpress/which-plugins-is-matomo-for-wordpress-known-to-be-not-compatible-with/ ' . $additional_comment,
1299
  'is_warning' => true,
1300
  );
1301
  }
classes/WpMatomo/Admin/views/tracking.php CHANGED
@@ -64,6 +64,7 @@ if ( $was_updated ) {
64
  echo '<input type="checkbox" ' . ( isset( $selected_container_ids [ $container_id ] ) && $selected_container_ids [ $container_id ] ? 'checked="checked" ' : '' ) . 'value="1" name="matomo[tagmanger_container_ids][' . $container_id . ']" /> ID:' . esc_html( $container_id ) . ' Name: ' . esc_html( $container_name ) . ' &nbsp; <br />';
65
  }
66
  echo '<br /><br /><a href="' . menu_page_url( \WpMatomo\Admin\Menu::SLUG_TAGMANAGER, false ) . '" rel="noreferrer noopener" target="_blank">Edit containers <span class="dashicons-before dashicons-external"></span></a>';
 
67
  echo '</td></tr>';
68
  }
69
 
64
  echo '<input type="checkbox" ' . ( isset( $selected_container_ids [ $container_id ] ) && $selected_container_ids [ $container_id ] ? 'checked="checked" ' : '' ) . 'value="1" name="matomo[tagmanger_container_ids][' . $container_id . ']" /> ID:' . esc_html( $container_id ) . ' Name: ' . esc_html( $container_name ) . ' &nbsp; <br />';
65
  }
66
  echo '<br /><br /><a href="' . menu_page_url( \WpMatomo\Admin\Menu::SLUG_TAGMANAGER, false ) . '" rel="noreferrer noopener" target="_blank">Edit containers <span class="dashicons-before dashicons-external"></span></a>';
67
+ echo '<br /><span class="dashicons dashicons-info-outline"></span> For Matomo to track you will need to add a Matomo Tag to the container. It otherwise won\'t track automatically.';
68
  echo '</td></tr>';
69
  }
70
 
classes/WpMatomo/Ecommerce/Base.php CHANGED
@@ -91,9 +91,13 @@ class Base {
91
  'trackEcommerceCartUpdate' => 'doTrackEcommerceCartUpdate',
92
  );
93
  if ( ! empty( $call[0] ) && ! empty( $methods[ $call[0] ] ) ) {
94
- $tracker_method = $methods[ $call[0] ];
95
- array_shift( $call );
96
- call_user_func_array( array( $this->tracker, $tracker_method ), $call );
 
 
 
 
97
  }
98
  }
99
  $this->ajax_tracker_calls = array();
91
  'trackEcommerceCartUpdate' => 'doTrackEcommerceCartUpdate',
92
  );
93
  if ( ! empty( $call[0] ) && ! empty( $methods[ $call[0] ] ) ) {
94
+ try {
95
+ $tracker_method = $methods[ $call[0] ];
96
+ array_shift( $call );
97
+ call_user_func_array( array( $this->tracker, $tracker_method ), $call );
98
+ } catch (\Exception $e) {
99
+ $this->logger->log_exception($call[0], $e);
100
+ }
101
  }
102
  }
103
  $this->ajax_tracker_calls = array();
classes/WpMatomo/Ecommerce/MemberPress.php CHANGED
@@ -85,7 +85,7 @@ class MemberPress extends Base {
85
  if ( isset( $_GET['membership'] )
86
  && isset( $_GET['trans_num'] )
87
  && class_exists( '\MeprTransaction' ) ) {
88
- $txn = \MeprTransaction::get_one_by_trans_num( (int) $_GET['trans_num'] );
89
  if ( isset( $txn->id ) && $txn->id > 0 ) {
90
  if ( $this->has_order_been_tracked_already( $txn->id ) ) {
91
  return;
85
  if ( isset( $_GET['membership'] )
86
  && isset( $_GET['trans_num'] )
87
  && class_exists( '\MeprTransaction' ) ) {
88
+ $txn = \MeprTransaction::get_one_by_trans_num($_GET['trans_num'] );
89
  if ( isset( $txn->id ) && $txn->id > 0 ) {
90
  if ( $this->has_order_been_tracked_already( $txn->id ) ) {
91
  return;
classes/WpMatomo/Ecommerce/Woocommerce.php CHANGED
@@ -25,10 +25,10 @@ class Woocommerce extends Base {
25
 
26
  add_action( 'wp_head', array( $this, 'maybe_track_order_complete' ), 99999 );
27
  add_action( 'woocommerce_after_single_product', array( $this, 'on_product_view' ), 99999, $args = 0 );
28
- add_action( 'woocommerce_add_to_cart', array( $this, 'on_cart_updated' ), 99999, 0 );
29
- add_action( 'woocommerce_cart_item_removed', array( $this, 'on_cart_updated' ), 99999, 0 );
30
- add_action( 'woocommerce_cart_item_restored', array( $this, 'on_cart_updated' ), 99999, 0 );
31
- add_action( 'woocommerce_cart_item_set_quantity', array( $this, 'on_cart_updated' ), 99999, 0 );
32
  add_action('woocommerce_thankyou', array($this, 'anonymise_orderid_in_url'), 1, 1);
33
 
34
  if (!$this->is_doing_ajax()) {
@@ -36,11 +36,11 @@ class Woocommerce extends Base {
36
  // because of woocommerce_applied_coupon and then also because of woocommerce_update_cart_action_cart_updated itself
37
  // causing two tracking requests to be issues from the server. refs #215
38
  // when not ajax mode the later event will simply overwrite the first and it should be fine.
39
- add_filter( 'woocommerce_update_cart_action_cart_updated', array( $this, 'on_cart_updated' ), 99999, 1 );
40
  }
41
 
42
- add_action( 'woocommerce_applied_coupon', array( $this, 'on_cart_updated' ), 99999, 0 );
43
- add_action( 'woocommerce_removed_coupon', array( $this, 'on_cart_updated' ), 99999, 0 );
44
  }
45
 
46
  public function anonymise_orderid_in_url($order_id)
@@ -71,17 +71,43 @@ class Woocommerce extends Base {
71
  }
72
  }
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  /**
75
  * @param null $val needed for woocommerce_update_cart_action_cart_updated filter
 
76
  *
77
  * @return mixed
78
  */
79
- public function on_cart_updated( $val = null ) {
80
  global $woocommerce;
81
 
82
  /** @var \WC_Cart $cart */
83
  $cart = $woocommerce->cart;
84
- $cart->calculate_totals();
 
 
 
85
  $cart_content = $cart->get_cart();
86
 
87
  $tracking_code = '';
25
 
26
  add_action( 'wp_head', array( $this, 'maybe_track_order_complete' ), 99999 );
27
  add_action( 'woocommerce_after_single_product', array( $this, 'on_product_view' ), 99999, $args = 0 );
28
+ add_action( 'woocommerce_add_to_cart', array( $this, 'on_cart_updated_safe' ), 99999, 0 );
29
+ add_action( 'woocommerce_cart_item_removed', array( $this, 'on_cart_updated_safe' ), 99999, 0 );
30
+ add_action( 'woocommerce_cart_item_restored', array( $this, 'on_cart_updated_safe' ), 99999, 0 );
31
+ add_action( 'woocommerce_cart_item_set_quantity', array( $this, 'on_cart_updated_safe' ), 99999, 0 );
32
  add_action('woocommerce_thankyou', array($this, 'anonymise_orderid_in_url'), 1, 1);
33
 
34
  if (!$this->is_doing_ajax()) {
36
  // because of woocommerce_applied_coupon and then also because of woocommerce_update_cart_action_cart_updated itself
37
  // causing two tracking requests to be issues from the server. refs #215
38
  // when not ajax mode the later event will simply overwrite the first and it should be fine.
39
+ add_filter( 'woocommerce_update_cart_action_cart_updated', array( $this, 'on_cart_updated_safe' ), 99999, 1 );
40
  }
41
 
42
+ add_action( 'woocommerce_applied_coupon', array( $this, 'on_coupon_updated_safe' ), 99999, 0 );
43
+ add_action( 'woocommerce_removed_coupon', array( $this, 'on_coupon_updated_safe' ), 99999, 0 );
44
  }
45
 
46
  public function anonymise_orderid_in_url($order_id)
71
  }
72
  }
73
 
74
+ public function on_coupon_updated_safe( ) {
75
+
76
+ try {
77
+ $val = $this->on_cart_updated($val= null, true);
78
+ } catch (\Exception $e) {
79
+ $this->logger->log_exception('woo_on_cart_update', $e);
80
+ }
81
+
82
+ return $val;
83
+ }
84
+
85
+ public function on_cart_updated_safe( $val = null ) {
86
+
87
+ try {
88
+ $val = $this->on_cart_updated($val);
89
+ } catch (\Exception $e) {
90
+ $this->logger->log_exception('woo_on_cart_update', $e);
91
+ }
92
+
93
+ return $val;
94
+ }
95
+
96
  /**
97
  * @param null $val needed for woocommerce_update_cart_action_cart_updated filter
98
+ * @param bool $is_coupon_update set to true if cart was updated because of a coupon
99
  *
100
  * @return mixed
101
  */
102
+ public function on_cart_updated( $val = null, $is_coupon_update = false ) {
103
  global $woocommerce;
104
 
105
  /** @var \WC_Cart $cart */
106
  $cart = $woocommerce->cart;
107
+ if (!$is_coupon_update) {
108
+ // can cause cart coupon not to be applied when WooCommerce Subscriptions is used.
109
+ $cart->calculate_totals();
110
+ }
111
  $cart_content = $cart->get_cart();
112
 
113
  $tracking_code = '';
classes/WpMatomo/User/Sync.php CHANGED
@@ -23,6 +23,7 @@ use Piwik\Plugins\UsersManager;
23
  use WpMatomo\Bootstrap;
24
  use WpMatomo\Capabilities;
25
  use WpMatomo\Logger;
 
26
  use WpMatomo\Site;
27
  use WpMatomo\User;
28
 
@@ -52,7 +53,19 @@ class Sync {
52
  add_action( 'add_user_to_blog', array( $this, 'sync_current_users' ), $prio = 10, $args = 0 );
53
  add_action( 'remove_user_from_blog', array( $this, 'sync_current_users' ), $prio = 10, $args = 0 );
54
  add_action( 'user_register', array( $this, 'sync_current_users' ), $prio = 10, $args = 0 );
55
- add_action( 'profile_update', array( $this, 'sync_current_users' ), $prio = 10, $args = 0 );
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
 
58
  public function sync_all() {
@@ -83,6 +96,25 @@ class Sync {
83
  {
84
  /** @var \WP_User[] $users */
85
  $users = get_users( $options );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  if (is_multisite()) {
87
  $super_admins = get_super_admins();
88
  if (!empty($super_admins)) {
@@ -140,9 +172,6 @@ class Sync {
140
  // to prevent UI preventing randomly saying no access between deleting and adding access
141
 
142
  $mapped_matomo_login = User::get_matomo_user_login( $user_id );
143
- if ( $mapped_matomo_login ) {
144
- $user_model->deleteUserAccess( $mapped_matomo_login, array( $idsite ) );
145
- }
146
 
147
  $matomo_login = null;
148
 
@@ -152,27 +181,33 @@ class Sync {
152
  $logins_with_some_view_access[] = $matomo_login;
153
  } elseif ( user_can( $user, Capabilities::KEY_ADMIN ) ) {
154
  $matomo_login = $this->ensure_user_exists( $user );
 
155
  $user_model->addUserAccess( $matomo_login, Admin::ID, array( $idsite ) );
156
  $user_model->setSuperUserAccess( $matomo_login, false );
157
  $logins_with_some_view_access[] = $matomo_login;
158
  } elseif ( user_can( $user, Capabilities::KEY_WRITE ) ) {
159
  $matomo_login = $this->ensure_user_exists( $user );
 
160
  $user_model->addUserAccess( $matomo_login, Write::ID, array( $idsite ) );
161
  $user_model->setSuperUserAccess( $matomo_login, false );
162
  $logins_with_some_view_access[] = $matomo_login;
163
  } elseif ( user_can( $user, Capabilities::KEY_VIEW ) ) {
164
  $matomo_login = $this->ensure_user_exists( $user );
 
165
  $user_model->addUserAccess( $matomo_login, View::ID, array( $idsite ) );
166
  $user_model->setSuperUserAccess( $matomo_login, false );
167
  $logins_with_some_view_access[] = $matomo_login;
 
 
168
  }
169
 
170
  if ( $matomo_login ) {
171
  $locale = get_user_locale( $user->ID );
172
  $locale_dash = Common::mb_strtolower(str_replace('_', '-', $locale));
 
173
  if ($locale && in_array($locale_dash, ['zh-cn', 'zh-tw', 'pt-br', 'es-ar'], true)) {
174
  $parts = [$locale_dash];
175
- } else {
176
  $parts = explode( '_', $locale );
177
  }
178
 
@@ -222,6 +257,8 @@ class Sync {
222
  if ( ! in_array( $all_user['login'], $logins_with_some_view_access, true )
223
  && ! empty( $all_user['login'] ) ) {
224
  $user_model->deleteUserOnly( $all_user['login'] );
 
 
225
  }
226
  }
227
  }
23
  use WpMatomo\Bootstrap;
24
  use WpMatomo\Capabilities;
25
  use WpMatomo\Logger;
26
+ use WpMatomo\ScheduledTasks;
27
  use WpMatomo\Site;
28
  use WpMatomo\User;
29
 
53
  add_action( 'add_user_to_blog', array( $this, 'sync_current_users' ), $prio = 10, $args = 0 );
54
  add_action( 'remove_user_from_blog', array( $this, 'sync_current_users' ), $prio = 10, $args = 0 );
55
  add_action( 'user_register', array( $this, 'sync_current_users' ), $prio = 10, $args = 0 );
56
+ add_action( 'profile_update', array( $this, 'sync_maybe_background' ), $prio = 10, $args = 0 );
57
+ }
58
+
59
+ public function sync_maybe_background()
60
+ {
61
+ global $pagenow;
62
+ if ( is_admin() && $pagenow == 'users.php' ) {
63
+ // eg for profile update we don't want to sync directly see #365 as it could cause issues with other plugins
64
+ // if they eg alter `get_users` option
65
+ wp_schedule_single_event(time() + 5, ScheduledTasks::EVENT_SYNC);
66
+ } else {
67
+ $this->sync_current_users();
68
+ }
69
  }
70
 
71
  public function sync_all() {
96
  {
97
  /** @var \WP_User[] $users */
98
  $users = get_users( $options );
99
+
100
+ $current_user = wp_get_current_user();
101
+ if (!empty($current_user) && !empty($current_user->user_login)) {
102
+ // refs https://github.com/matomo-org/wp-matomo/issues/365
103
+ // some other plugins may under circumstances overwrite the get_users query and not return all users
104
+ // as a result we would delete some users in the matomo users table. this way we make sure at least the current
105
+ // user will be added and not deleted even if the list of users is not complete
106
+ $found = false;
107
+ foreach ($users as $user) {
108
+ if ($user->user_login === $current_user->user_login) {
109
+ $found = true;
110
+ break;
111
+ }
112
+ }
113
+ if (!$found) {
114
+ $users[] = $current_user;
115
+ }
116
+ }
117
+
118
  if (is_multisite()) {
119
  $super_admins = get_super_admins();
120
  if (!empty($super_admins)) {
172
  // to prevent UI preventing randomly saying no access between deleting and adding access
173
 
174
  $mapped_matomo_login = User::get_matomo_user_login( $user_id );
 
 
 
175
 
176
  $matomo_login = null;
177
 
181
  $logins_with_some_view_access[] = $matomo_login;
182
  } elseif ( user_can( $user, Capabilities::KEY_ADMIN ) ) {
183
  $matomo_login = $this->ensure_user_exists( $user );
184
+ $user_model->deleteUserAccess( $mapped_matomo_login, array( $idsite ) );
185
  $user_model->addUserAccess( $matomo_login, Admin::ID, array( $idsite ) );
186
  $user_model->setSuperUserAccess( $matomo_login, false );
187
  $logins_with_some_view_access[] = $matomo_login;
188
  } elseif ( user_can( $user, Capabilities::KEY_WRITE ) ) {
189
  $matomo_login = $this->ensure_user_exists( $user );
190
+ $user_model->deleteUserAccess( $mapped_matomo_login, array( $idsite ) );
191
  $user_model->addUserAccess( $matomo_login, Write::ID, array( $idsite ) );
192
  $user_model->setSuperUserAccess( $matomo_login, false );
193
  $logins_with_some_view_access[] = $matomo_login;
194
  } elseif ( user_can( $user, Capabilities::KEY_VIEW ) ) {
195
  $matomo_login = $this->ensure_user_exists( $user );
196
+ $user_model->deleteUserAccess( $mapped_matomo_login, array( $idsite ) );
197
  $user_model->addUserAccess( $matomo_login, View::ID, array( $idsite ) );
198
  $user_model->setSuperUserAccess( $matomo_login, false );
199
  $logins_with_some_view_access[] = $matomo_login;
200
+ } elseif ($mapped_matomo_login) {
201
+ $user_model->deleteUserAccess( $mapped_matomo_login, array( $idsite ) );
202
  }
203
 
204
  if ( $matomo_login ) {
205
  $locale = get_user_locale( $user->ID );
206
  $locale_dash = Common::mb_strtolower(str_replace('_', '-', $locale));
207
+ $parts = [];
208
  if ($locale && in_array($locale_dash, ['zh-cn', 'zh-tw', 'pt-br', 'es-ar'], true)) {
209
  $parts = [$locale_dash];
210
+ } elseif (!empty($locale) && is_string($locale)) {
211
  $parts = explode( '_', $locale );
212
  }
213
 
257
  if ( ! in_array( $all_user['login'], $logins_with_some_view_access, true )
258
  && ! empty( $all_user['login'] ) ) {
259
  $user_model->deleteUserOnly( $all_user['login'] );
260
+ $user_model->deleteUserOptions( $all_user['login'] );
261
+ $user_model->deleteUserAccess( $all_user['login'] );
262
  }
263
  }
264
  }
matomo.php CHANGED
@@ -4,7 +4,7 @@
4
  * Description: The #1 Google Analytics alternative that gives you full control over your data and protects the privacy for your users. Free, secure and open.
5
  * Author: Matomo
6
  * Author URI: https://matomo.org
7
- * Version: 1.3.1
8
  * Domain Path: /languages
9
  * WC requires at least: 2.4.0
10
  * WC tested up to: 4.6.0
4
  * Description: The #1 Google Analytics alternative that gives you full control over your data and protects the privacy for your users. Free, secure and open.
5
  * Author: Matomo
6
  * Author URI: https://matomo.org
7
+ * Version: 1.3.2
8
  * Domain Path: /languages
9
  * WC requires at least: 2.4.0
10
  * WC tested up to: 4.6.0
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: matomo,piwik,analytics,statistics,stats,tracking,ecommerce
5
  Requires at least: 4.8
6
  Tested up to: 5.5
7
- Stable tag: 1.3.1
8
  Requires PHP: 7.2
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
4
  Tags: matomo,piwik,analytics,statistics,stats,tracking,ecommerce
5
  Requires at least: 4.8
6
  Tested up to: 5.5
7
+ Stable tag: 1.3.2
8
  Requires PHP: 7.2
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html