Skip to content

Commit db7c769

Browse files
author
André Bräkling
committed
Merge branch 'master' of https://github.com/braekling/WP-Matomo
2 parents e1951ba + 70d55c1 commit db7c769

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

classes/WP_Piwik/Widget/Post.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public function show() {
4141
}
4242
}
4343
if (isset($result['nb_visits']) && $result['nb_visits'] > 0) {
44-
$result['nb_actions_per_visit'] = round($result['nb_actions'] / $result['nb_visits'], 1);
45-
$result['bounce_rate'] = round($result['bounce_count'] / $result['nb_visits'] * 100, 1) . '%';
46-
$result['avg_time_on_site'] = round($result['sum_visit_length'] / $result['nb_visits'], 0);
44+
$result['nb_actions_per_visit'] = round((isset( $result['nb_actions'] ) ? $result['nb_actions'] : 0) / $result['nb_visits'], 1);
45+
$result['bounce_rate'] = round((isset($result['bounce_count']) ? $result['bounce_count'] : 0) / $result['nb_visits'] * 100, 1) . '%';
46+
$result['avg_time_on_site'] = round((isset($result['sum_visit_length']) ? $result['sum_visit_length'] : 0) / $result['nb_visits'], 0);
4747
} else $result['nb_actions_per_visit'] = $result['bounce_rate'] = $result['avg_time_on_site'] = 0;
4848
}
4949
$response = $result;
@@ -79,4 +79,4 @@ public function show() {
7979
}
8080
}
8181

82-
}
82+
}

proxy/proxy.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@
2121
include __DIR__ . '/config.local.php';
2222
}
2323

24+
// Config calls wp-load.php which on multisite networks redeclares and messes up $path
25+
$wp_matomo_proxy_path=$path;
26+
2427
if (file_exists(__DIR__ . '/config.php')) {
2528
include __DIR__ . '/config.php';
2629
}
2730

31+
// Restore $path
32+
$path=$wp_matomo_proxy_path;
33+
2834
// -----
2935
// Important: read the instructions in README.md or at:
3036
// https://github.com/matomo-org/tracker-proxy#matomo-tracker-proxy
@@ -370,4 +376,4 @@ function arrayValue($array, $key, $value = null)
370376
$value = $array[$key];
371377
}
372378
return $value;
373-
}
379+
}

0 commit comments

Comments
 (0)