installed plugin WP-Matomo Integration
version 1.0.27
This commit is contained in:
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
use WP_Piwik\Widget;
|
||||
|
||||
class BrowserDetails extends Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Browser Details', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'DevicesDetection.getBrowserVersions';
|
||||
$this->context = 'normal';
|
||||
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
||||
wp_enqueue_script ( 'wp-piwik-chartjs', self::$wpPiwik->getPluginURL () . 'js/chartjs/chart.min.js', "3.4.1" );
|
||||
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
$tableBody = array();
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(__('Browser', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
||||
if (isset($response[0]['nb_uniq_visitors'])) $unique = 'nb_uniq_visitors';
|
||||
else $unique = 'sum_daily_nb_uniq_visitors';
|
||||
$count = 0;
|
||||
$sum = 0;
|
||||
$js = array();
|
||||
$class = array();
|
||||
if (is_array($response))
|
||||
foreach ($response as $row) {
|
||||
$count++;
|
||||
$sum += isset($row[$unique])?$row[$unique]:0;
|
||||
if ($count < $this->limit)
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
elseif (!isset($tableBody['Others'])) {
|
||||
$tableBody['Others'] = array($row['label'], $row[$unique], 0);
|
||||
$class['Others'] = 'wp-piwik-hideDetails';
|
||||
$js['Others'] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
} else {
|
||||
$tableBody['Others'][1] += $row[$unique];
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
}
|
||||
}
|
||||
if ($count > $this->limit)
|
||||
$tableBody['Others'][0] = __('Others', 'wp-piwik');
|
||||
|
||||
foreach ($tableBody as $key => $row)
|
||||
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
||||
|
||||
if (!empty($tableBody)) $this->pieChart($tableBody);
|
||||
$this->table($tableHead, $tableBody, null, false, $js, $class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
use WP_Piwik\Widget;
|
||||
|
||||
class Browsers extends Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Browsers', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'DevicesDetection.getBrowsers';
|
||||
$this->context = 'normal';
|
||||
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
||||
wp_enqueue_script ( 'wp-piwik-chartjs', self::$wpPiwik->getPluginURL () . 'js/chartjs/chart.min.js', "3.4.1" );
|
||||
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
$tableBody = array();
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(__('Browser', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
||||
if (isset($response[0]['nb_uniq_visitors'])) $unique = 'nb_uniq_visitors';
|
||||
else $unique = 'sum_daily_nb_uniq_visitors';
|
||||
$count = 0;
|
||||
$sum = 0;
|
||||
$js = array();
|
||||
$class = array();
|
||||
if (is_array($response))
|
||||
foreach ($response as $row) {
|
||||
$count++;
|
||||
$sum += isset($row[$unique])?$row[$unique]:0;
|
||||
if ($count < $this->limit)
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
elseif (!isset($tableBody['Others'])) {
|
||||
$tableBody['Others'] = array($row['label'], $row[$unique], 0);
|
||||
$class['Others'] = 'wp-piwik-hideDetails';
|
||||
$js['Others'] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
} else {
|
||||
$tableBody['Others'][1] += $row[$unique];
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
}
|
||||
}
|
||||
if ($count > $this->limit)
|
||||
$tableBody['Others'][0] = __('Others', 'wp-piwik');
|
||||
elseif ($count == $this->limit) {
|
||||
$class['Others'] = $js['Others'] = '';
|
||||
}
|
||||
|
||||
foreach ($tableBody as $key => $row)
|
||||
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
||||
|
||||
if (!empty($tableBody)) $this->pieChart($tableBody);
|
||||
$this->table($tableHead, $tableBody, null, false, $js, $class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
use WP_Piwik\Widget;
|
||||
|
||||
class Chart extends Visitors
|
||||
{
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
public function show()
|
||||
{
|
||||
$result = $this->requestData();
|
||||
$response = $result["response"];
|
||||
if (!$result["success"]) {
|
||||
echo '<strong>' . __('Piwik error', 'wp-piwik') . ':</strong> ' . htmlentities($response[$method]['message'], ENT_QUOTES, 'utf-8');
|
||||
} else {
|
||||
$values = $labels = $bounced = $unique = '';
|
||||
$count = $uniqueSum = 0;
|
||||
if (is_array($response['VisitsSummary.getVisits']))
|
||||
foreach ($response['VisitsSummary.getVisits'] as $date => $value) {
|
||||
$count++;
|
||||
$values .= $value . ',';
|
||||
$unique .= $response['VisitsSummary.getUniqueVisitors'][$date] . ',';
|
||||
$bounced .= $response['VisitsSummary.getBounceCount'][$date] . ',';
|
||||
if ($this->parameter['period'] == 'week') {
|
||||
preg_match("/[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/", $date, $dateList);
|
||||
$textKey = $this->dateFormat($dateList[0], 'short_week');
|
||||
} else $textKey = substr($date, -2);
|
||||
$labels .= '["' . $textKey . '"],';
|
||||
$uniqueSum += $response['VisitsSummary.getActions'][$date];
|
||||
}
|
||||
else {
|
||||
$values = '0,';
|
||||
$labels = '[0,"-"],';
|
||||
$unique = '0,';
|
||||
$bounced = '0,';
|
||||
}
|
||||
$average = round($uniqueSum / 30, 0);
|
||||
$values = substr($values, 0, -1);
|
||||
$unique = substr($unique, 0, -1);
|
||||
$labels = substr($labels, 0, -1);
|
||||
$bounced = substr($bounced, 0, -1);
|
||||
?>
|
||||
<div>
|
||||
<canvas id="wp-piwik_stats_vistors_graph" style="height:220px;"></canvas>
|
||||
</div>
|
||||
<script>
|
||||
new Chart(
|
||||
document.getElementById('wp-piwik_stats_vistors_graph'),
|
||||
{
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: [<?php echo $labels ?>],
|
||||
datasets: [
|
||||
{
|
||||
label: 'Visitors',
|
||||
backgroundColor: '#0277bd',
|
||||
borderColor: '#0277bd',
|
||||
data: [<?php echo $values; ?>],
|
||||
borderWidth: 1
|
||||
},
|
||||
{
|
||||
label: 'Unique',
|
||||
backgroundColor: '#ff8f00',
|
||||
borderColor: '#ff8f00',
|
||||
data: [<?php echo $unique; ?>],
|
||||
borderWidth: 1
|
||||
},
|
||||
{
|
||||
label: 'Bounced',
|
||||
backgroundColor: '#ad1457',
|
||||
borderColor: '#ad1457',
|
||||
data: [<?php echo $bounced; ?>],
|
||||
borderWidth: 1
|
||||
},
|
||||
]
|
||||
},
|
||||
options: {}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
}
|
73
wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/City.php
Normal file
73
wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/City.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
use WP_Piwik\Widget;
|
||||
|
||||
class City extends Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Cities', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'UserCountry.getCity';
|
||||
$this->context = 'normal';
|
||||
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
||||
wp_enqueue_script ( 'wp-piwik-chartjs', self::$wpPiwik->getPluginURL () . 'js/chartjs/chart.min.js', "3.4.1" );
|
||||
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
$tableBody = array();
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(__('City', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
||||
if (isset($response[0]['nb_uniq_visitors'])) $unique = 'nb_uniq_visitors';
|
||||
else $unique = 'sum_daily_nb_uniq_visitors';
|
||||
$count = 0;
|
||||
$sum = 0;
|
||||
$js = array();
|
||||
$class = array();
|
||||
if (is_array($response))
|
||||
foreach ($response as $row) {
|
||||
$count++;
|
||||
$sum += isset($row[$unique])?$row[$unique]:0;
|
||||
if ($count < $this->limit)
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
elseif (!isset($tableBody['Others'])) {
|
||||
$tableBody['Others'] = array($row['label'], $row[$unique], 0);
|
||||
$class['Others'] = 'wp-piwik-hideDetails';
|
||||
$js['Others'] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
} else {
|
||||
$tableBody['Others'][1] += $row[$unique];
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
}
|
||||
}
|
||||
if ($count > $this->limit)
|
||||
$tableBody['Others'][0] = __('Others', 'wp-piwik');
|
||||
elseif ($count == $this->limit) {
|
||||
$class['Others'] = $js['Others'] = '';
|
||||
}
|
||||
|
||||
foreach ($tableBody as $key => $row)
|
||||
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
||||
|
||||
if (!empty($tableBody)) $this->pieChart($tableBody);
|
||||
$this->table($tableHead, $tableBody, null, false, $js, $class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
use WP_Piwik\Widget;
|
||||
|
||||
class Country extends Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Countries', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'UserCountry.getCountry ';
|
||||
$this->context = 'normal';
|
||||
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
||||
wp_enqueue_script ( 'wp-piwik-chartjs', self::$wpPiwik->getPluginURL () . 'js/chartjs/chart.min.js', "3.4.1" );
|
||||
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
$tableBody = array();
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(__('Country', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
||||
if (isset($response[0]['nb_uniq_visitors'])) $unique = 'nb_uniq_visitors';
|
||||
else $unique = 'sum_daily_nb_uniq_visitors';
|
||||
$count = 0;
|
||||
$sum = 0;
|
||||
$js = array();
|
||||
$class = array();
|
||||
if (is_array($response))
|
||||
foreach ($response as $row) {
|
||||
$count++;
|
||||
$sum += isset($row[$unique])?$row[$unique]:0;
|
||||
if ($count < $this->limit)
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
elseif (!isset($tableBody['Others'])) {
|
||||
$tableBody['Others'] = array($row['label'], $row[$unique], 0);
|
||||
$class['Others'] = 'wp-piwik-hideDetails';
|
||||
$js['Others'] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
} else {
|
||||
$tableBody['Others'][1] += $row[$unique];
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
}
|
||||
}
|
||||
if ($count > $this->limit)
|
||||
$tableBody['Others'][0] = __('Others', 'wp-piwik');
|
||||
elseif ($count == $this->limit) {
|
||||
$class['Others'] = $js['Others'] = '';
|
||||
}
|
||||
|
||||
foreach ($tableBody as $key => $row)
|
||||
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
||||
|
||||
if (!empty($tableBody)) $this->pieChart($tableBody);
|
||||
$this->table($tableHead, $tableBody, null, false, $js, $class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class Ecommerce extends \WP_Piwik\Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->title = $prefix.__('E-Commerce', 'wp-piwik');
|
||||
$this->method = 'Goals.get';
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = null;
|
||||
$tableBody = array(
|
||||
array(__('Conversions', 'wp-piwik').':', $this->value($response, 'nb_conversions')),
|
||||
array(__('Visits converted', 'wp-piwik').':', $this->value($response, 'nb_visits_converted')),
|
||||
array(__('Revenue', 'wp-piwik').':', number_format($this->value($response, 'revenue'),2)),
|
||||
array(__('Conversion rate', 'wp-piwik').':', $this->value($response, 'conversion_rate')),
|
||||
array(__('Conversions (new visitor)', 'wp-piwik').':', $this->value($response, 'nb_conversions_new_visit')),
|
||||
array(__('Visits converted (new visitor)', 'wp-piwik').':', $this->value($response, 'nb_visits_converted_new_visit')),
|
||||
array(__('Revenue (new visitor)', 'wp-piwik').':', number_format($this->value($response, 'revenue_new_visit'),2)),
|
||||
array(__('Conversion rate (new visitor)', 'wp-piwik').':', $this->value($response, 'conversion_rate_new_visit')),
|
||||
array(__('Conversions (returning visitor)', 'wp-piwik').':', $this->value($response, 'nb_conversions_returning_visit')),
|
||||
array(__('Visits converted (returning visitor)', 'wp-piwik').':', $this->value($response, 'nb_visits_converted_returning_visit')),
|
||||
array(__('Revenue (returning visitor)', 'wp-piwik').':', number_format($this->value($response, 'revenue_returning_visit'),2)),
|
||||
array(__('Conversion rate (returning visitor)', 'wp-piwik').':', $this->value($response, 'conversion_rate_returning_visit')),
|
||||
);
|
||||
$tableFoot = (self::$settings->getGlobalOption('piwik_shortcut')?array(__('Shortcut', 'wp-piwik').':', '<a href="'.self::$settings->getGlobalOption('piwik_url').'">Piwik</a>'.(isset($aryConf['inline']) && $aryConf['inline']?' - <a href="?page=wp-piwik_stats">WP-Piwik</a>':'')):null);
|
||||
$this->table($tableHead, $tableBody, $tableFoot);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class Items extends \WP_Piwik\Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->title = $prefix.__('E-Commerce Items', 'wp-piwik');
|
||||
$this->method = 'Goals.getItemsName';
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(
|
||||
__('Label', 'wp-piwik'),
|
||||
__('Revenue', 'wp-piwik'),
|
||||
__('Quantity', 'wp-piwik'),
|
||||
__('Orders', 'wp-piwik'),
|
||||
__('Avg. price', 'wp-piwik'),
|
||||
__('Avg. quantity', 'wp-piwik'),
|
||||
__('Conversion rate', 'wp-piwik'),
|
||||
);
|
||||
$tableBody = array();
|
||||
if (is_array($response))
|
||||
foreach ($response as $data) {
|
||||
array_push($tableBody, array(
|
||||
$data['label'],
|
||||
number_format($data['revenue'],2),
|
||||
$data['quantity'],
|
||||
$data['orders'],
|
||||
number_format($data['avg_price'],2),
|
||||
$data['avg_quantity'],
|
||||
$data['conversion_rate']
|
||||
));
|
||||
}
|
||||
$tableFoot = array();
|
||||
$this->table($tableHead, $tableBody, $tableFoot);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class ItemsCategory extends \WP_Piwik\Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->title = $prefix.__('E-Commerce Item Categories', 'wp-piwik');
|
||||
$this->method = 'Goals.getItemsCategory';
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(
|
||||
__('Label', 'wp-piwik'),
|
||||
__('Revenue', 'wp-piwik'),
|
||||
__('Quantity', 'wp-piwik'),
|
||||
__('Orders', 'wp-piwik'),
|
||||
__('Avg. price', 'wp-piwik'),
|
||||
__('Avg. quantity', 'wp-piwik'),
|
||||
__('Conversion rate', 'wp-piwik'),
|
||||
);
|
||||
$tableBody = array();
|
||||
if (is_array($response))
|
||||
foreach ($response as $data) {
|
||||
array_push($tableBody, array(
|
||||
$data['label'],
|
||||
isset($data['revenue'])?number_format($data['revenue'],2):"-.--",
|
||||
isset($data['quantity'])?$data['quantity']:'-',
|
||||
isset($data['orders'])?$data['orders']:'-',
|
||||
number_format($data['avg_price'],2),
|
||||
$data['avg_quantity'],
|
||||
$data['conversion_rate']
|
||||
));
|
||||
}
|
||||
$tableFoot = array();
|
||||
$this->table($tableHead, $tableBody, $tableFoot);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class Keywords extends \WP_Piwik\Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Keywords', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'Referrers.getKeywords';
|
||||
$this->name = 'Keyword';
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
use WP_Piwik\Widget;
|
||||
|
||||
class Models extends Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Models', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'DevicesDetection.getModel';
|
||||
$this->context = 'normal';
|
||||
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
||||
wp_enqueue_script ( 'wp-piwik-chartjs', self::$wpPiwik->getPluginURL () . 'js/chartjs/chart.min.js', "3.4.1" );
|
||||
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
$tableBody = array();
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(__('Model', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
||||
if (isset($response[0]['nb_uniq_visitors'])) $unique = 'nb_uniq_visitors';
|
||||
else $unique = 'sum_daily_nb_uniq_visitors';
|
||||
$count = 0;
|
||||
$sum = 0;
|
||||
$js = array();
|
||||
$class = array();
|
||||
if (is_array($response))
|
||||
foreach ($response as $row) {
|
||||
$count++;
|
||||
$sum += isset($row[$unique])?$row[$unique]:0;
|
||||
if ($count < $this->limit)
|
||||
$tableBody[$row['label']] = array(htmlentities($row['label']), $row[$unique], 0);
|
||||
elseif (!isset($tableBody['Others'])) {
|
||||
$tableBody['Others'] = array($row['label'], $row[$unique], 0);
|
||||
$class['Others'] = 'wp-piwik-hideDetails';
|
||||
$js['Others'] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
} else {
|
||||
$tableBody['Others'][1] += $row[$unique];
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
}
|
||||
}
|
||||
if ($count > $this->limit)
|
||||
$tableBody['Others'][0] = __('Others', 'wp-piwik');
|
||||
elseif ($count == $this->limit) {
|
||||
$class['Others'] = $js['Others'] = '';
|
||||
}
|
||||
|
||||
foreach ($tableBody as $key => $row)
|
||||
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
||||
|
||||
if (!empty($tableBody)) $this->pieChart($tableBody);
|
||||
$this->table($tableHead, $tableBody, null, false, $js, $class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class Noresult extends \WP_Piwik\Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Site Search', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'Actions.getSiteSearchNoResultKeywords';
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(__('Keyword', 'wp-piwik'), __('Requests', 'wp-piwik'), __('Bounced', 'wp-piwik'));
|
||||
$tableBody = array();
|
||||
$count = 0;
|
||||
if (is_array($response))
|
||||
foreach ($response as $row) {
|
||||
$count++;
|
||||
$tableBody[] = array($row['label'], $row['nb_visits'], $row['bounce_rate']);
|
||||
if ($count == 10) break;
|
||||
}
|
||||
$this->table($tableHead, $tableBody, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class OptOut extends \WP_Piwik\Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$this->parameter = $params;
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$protocol = (isset ( $_SERVER ['HTTPS'] ) && $_SERVER ['HTTPS'] != 'off') ? 'https' : 'http';
|
||||
switch (self::$settings->getGlobalOption ( 'piwik_mode' )) {
|
||||
case 'php' :
|
||||
$PIWIK_URL = $protocol . ':' . self::$settings->getGlobalOption ( 'proxy_url' );
|
||||
break;
|
||||
case 'cloud' :
|
||||
$PIWIK_URL = 'https://' . self::$settings->getGlobalOption ( 'piwik_user' ) . '.innocraft.cloud/';
|
||||
break;
|
||||
case 'cloud-matomo':
|
||||
$PIWIK_URL = 'https://' . self::$settings->getGlobalOption ( 'matomo_user' ) . '.matomo.cloud/';
|
||||
break;
|
||||
default :
|
||||
$PIWIK_URL = self::$settings->getGlobalOption ( 'piwik_url' );
|
||||
}
|
||||
$this->out ( '<iframe frameborder="no" width="'.(isset($this->parameter['width'])?$this->parameter['width']:'').'" height="'.(isset($this->parameter['height'])?$this->parameter['height']:'').'" src="'.$PIWIK_URL.'index.php?module=CoreAdminHome&action=optOut&'.(isset($this->parameter['idsite'])?'idsite='.$this->parameter['idsite'].'&':'').'language='.(isset($this->parameter['language'])?$this->parameter['language']:'en').'"></iframe>' );
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class Overview extends \WP_Piwik\Widget
|
||||
{
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array())
|
||||
{
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => isset($params['period']) ? $params['period'] : $timeSettings['period'],
|
||||
'date' => isset($params['date']) ? $params['date'] : $timeSettings['date'],
|
||||
'description' => $timeSettings['description']
|
||||
);
|
||||
$this->title = !$this->isShortcode ? $prefix . __('Overview', 'wp-piwik') . ' (' . __($this->pageId == 'dashboard' ? $this->rangeName() : $timeSettings['description'], 'wp-piwik') . ')' : ($params['title'] ? $params['title'] : '');
|
||||
$this->method = 'VisitsSummary.get';
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
if (!empty($response['result']) && $response['result'] = 'error')
|
||||
echo '<strong>' . __('Piwik error', 'wp-piwik') . ':</strong> ' . htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
if (in_array($this->parameter['date'], array('last30', 'last60', 'last90'))) {
|
||||
$result = array();
|
||||
if (is_array($response)) {
|
||||
foreach ($response as $data)
|
||||
foreach ($data as $key => $value)
|
||||
if (isset($result[$key]) && is_numeric($value))
|
||||
$result[$key] += $value;
|
||||
elseif (is_numeric($value))
|
||||
$result[$key] = $value;
|
||||
else
|
||||
$result[$key] = 0;
|
||||
if (isset($result['nb_visits']) && $result['nb_visits'] > 0) {
|
||||
$result['nb_actions_per_visit'] = round($result['nb_actions'] / $result['nb_visits'], 1);
|
||||
$result['bounce_rate'] = round($result['bounce_count'] / $result['nb_visits'] * 100, 1) . '%';
|
||||
$result['avg_time_on_site'] = round($result['sum_visit_length'] / $result['nb_visits'], 0);
|
||||
} else $result['nb_actions_per_visit'] = $result['bounce_rate'] = $result['avg_time_on_site'] = 0;
|
||||
}
|
||||
$response = $result;
|
||||
}
|
||||
$time = isset($response['sum_visit_length']) ? $this->timeFormat($response['sum_visit_length']) : '-';
|
||||
$avgTime = isset($response['avg_time_on_site']) ? $this->timeFormat($response['avg_time_on_site']) : '-';
|
||||
$tableHead = null;
|
||||
$tableBody = array(array(__('Visitors', 'wp-piwik') . ':', $this->value($response, 'nb_visits')));
|
||||
if ($this->value($response, 'nb_uniq_visitors') != '-')
|
||||
array_push($tableBody, array(__('Unique visitors', 'wp-piwik') . ':', $this->value($response, 'nb_uniq_visitors')));
|
||||
array_push($tableBody,
|
||||
array(__('Page views', 'wp-piwik') . ':', $this->value($response, 'nb_actions') . ' (Ø ' . $this->value($response, 'nb_actions_per_visit') . ')'),
|
||||
array(__('Total time spent', 'wp-piwik') . ':', $time . ' (Ø ' . $avgTime . ')'),
|
||||
array(__('Bounce count', 'wp-piwik') . ':', $this->value($response, 'bounce_count') . ' (' . $this->value($response, 'bounce_rate') . ')')
|
||||
);
|
||||
if (!in_array($this->parameter['date'], array('last30', 'last60', 'last90')))
|
||||
array_push($tableBody, array(__('Time/visit', 'wp-piwik') . ':', $avgTime), array(__('Max. page views in one visit', 'wp-piwik') . ':', $this->value($response, 'max_actions')));
|
||||
$tableFoot = (self::$settings->getGlobalOption('piwik_shortcut') ? array(__('Shortcut', 'wp-piwik') . ':', '<a href="' . self::$settings->getGlobalOption('piwik_url') . '" target="_BLANK">Matomo</a>' . (isset($aryConf['inline']) && $aryConf['inline'] ? ' - <a href="?page=wp-piwik_stats">WP-Piwik</a>' : '')) : null);
|
||||
$this->table($tableHead, $tableBody, $tableFoot);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class Pages extends \WP_Piwik\Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Pages', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'Actions.getPageTitles';
|
||||
$this->name = __('Page', 'wp-piwik' );
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class Plugins extends \WP_Piwik\Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Plugins', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'DevicePlugins.getPlugin';
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(__('Plugin', 'wp-piwik'), __('Visits', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
||||
$tableBody = array();
|
||||
$count = 0;
|
||||
if (is_array($response))
|
||||
foreach ($response as $row) {
|
||||
$count++;
|
||||
$tableBody[] = array($row['label'], $row['nb_visits'], $row['nb_visits_percentage']);
|
||||
if ($count == 10) break;
|
||||
}
|
||||
$this->table($tableHead, $tableBody, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
82
wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Post.php
Normal file
82
wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Post.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class Post extends \WP_Piwik\Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
global $post;
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => isset($params['period']) ? $params['period'] : $timeSettings['period'],
|
||||
'date' => isset($params['date']) ? $params['date'] : $timeSettings['date'],
|
||||
'key' => isset($params['key'])?$params['key']:null,
|
||||
'pageUrl' => isset($params['url'])?$params['url']:urlencode(get_permalink($post->ID)),
|
||||
'description' => $timeSettings['description']
|
||||
);
|
||||
$this->title = $prefix.__('Overview', 'wp-piwik').' ('.__($this->parameter['date'],'wp-piwik').')';
|
||||
$this->method = 'Actions.getPageUrl';
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
if (!empty($response['result']) && $response['result'] = 'error')
|
||||
echo '<strong>' . __('Piwik error', 'wp-piwik') . ':</strong> ' . htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
if (in_array($this->parameter['date'], array('last30', 'last60', 'last90'))) {
|
||||
$result = array();
|
||||
if (is_array($response)) {
|
||||
foreach ($response as $data) {
|
||||
if (isset($data[0])) {
|
||||
foreach ($data[0] as $key => $value)
|
||||
if (isset($result[$key]) && is_numeric($value))
|
||||
$result[$key] += $value;
|
||||
elseif (is_numeric($value))
|
||||
$result[$key] = $value;
|
||||
else
|
||||
$result[$key] = 0;
|
||||
}
|
||||
}
|
||||
if (isset($result['nb_visits']) && $result['nb_visits'] > 0) {
|
||||
$result['nb_actions_per_visit'] = round((isset( $result['nb_actions'] ) ? $result['nb_actions'] : 0) / $result['nb_visits'], 1);
|
||||
$result['bounce_rate'] = round((isset($result['bounce_count']) ? $result['bounce_count'] : 0) / $result['nb_visits'] * 100, 1) . '%';
|
||||
$result['avg_time_on_site'] = round((isset($result['sum_visit_length']) ? $result['sum_visit_length'] : 0) / $result['nb_visits'], 0);
|
||||
} else $result['nb_actions_per_visit'] = $result['bounce_rate'] = $result['avg_time_on_site'] = 0;
|
||||
}
|
||||
$response = $result;
|
||||
} else {
|
||||
if (isset($response[0]))
|
||||
$response = $response[0];
|
||||
if ($this->parameter['key']) {
|
||||
$this->out(isset($response[$this->parameter['key']])?$response[$this->parameter['key']]:'<em>not defined</em>');
|
||||
return;
|
||||
}
|
||||
}
|
||||
$time = isset($response['sum_visit_length']) ? $this->timeFormat($response['sum_visit_length']) : '-';
|
||||
$avgTime = isset($response['avg_time_on_site']) ? $this->timeFormat($response['avg_time_on_site']) : '-';
|
||||
$tableHead = null;
|
||||
$tableBody = array(array(__('Visitors', 'wp-piwik') . ':', $this->value($response, 'nb_visits')));
|
||||
if ($this->value($response, 'nb_uniq_visitors') != '-')
|
||||
array_push($tableBody, array(__('Unique visitors', 'wp-piwik') . ':', $this->value($response, 'nb_uniq_visitors')));
|
||||
elseif ($this->value($response, 'sum_daily_nb_uniq_visitors') != '-') {
|
||||
array_push($tableBody, __('Unique visitors', 'wp-piwik') . ':', $this->value($response, 'sum_daily_nb_uniq_visitors'));
|
||||
}
|
||||
array_push($tableBody,
|
||||
array(__('Page views', 'wp-piwik').':', $this->value($response, 'nb_hits').' (Ø '.$this->value($response, 'entry_nb_actions').')'),
|
||||
array(__('Total time spent', 'wp-piwik').':', $time),
|
||||
array(__('Bounce count', 'wp-piwik').':', $this->value($response, 'entry_bounce_count').' ('.$this->value($response, 'bounce_rate').')'),
|
||||
array(__('Time/visit', 'wp-piwik').':', $avgTime),
|
||||
array(__('Min. generation time', 'wp-piwik').':', $this->value($response, 'min_time_generation')),
|
||||
array(__('Max. generation time', 'wp-piwik').':', $this->value($response, 'max_time_generation'))
|
||||
);
|
||||
if (!in_array($this->parameter['date'], array('last30', 'last60', 'last90')))
|
||||
array_push($tableBody, array(__('Time/visit', 'wp-piwik') . ':', $avgTime), array(__('Max. page views in one visit', 'wp-piwik') . ':', $this->value($response, 'max_actions')));
|
||||
$tableFoot = (self::$settings->getGlobalOption('piwik_shortcut') ? array(__('Shortcut', 'wp-piwik') . ':', '<a href="' . self::$settings->getGlobalOption('piwik_url') . '">Piwik</a>' . (isset($aryConf['inline']) && $aryConf['inline'] ? ' - <a href="?page=wp-piwik_stats">WP-Piwik</a>' : '')) : null);
|
||||
$this->table($tableHead, $tableBody, $tableFoot);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class Referrers extends \WP_Piwik\Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Referrers', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'Referrers.getWebsites';
|
||||
$this->name = 'Referrer';
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class Screens extends \WP_Piwik\Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Resolutions', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'Resolution.getResolution';
|
||||
$this->context = 'normal';
|
||||
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
||||
wp_enqueue_script ( 'wp-piwik-chartjs', self::$wpPiwik->getPluginURL () . 'js/chartjs/chart.min.js', "3.4.1" );
|
||||
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
$tableBody = array();
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(__('Resolution', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
||||
if (isset($response[0]['nb_uniq_visitors'])) $unique = 'nb_uniq_visitors';
|
||||
else $unique = 'sum_daily_nb_uniq_visitors';
|
||||
$count = 0;
|
||||
$sum = 0;
|
||||
$js = array();
|
||||
$class = array();
|
||||
if (is_array($response))
|
||||
foreach ($response as $row) {
|
||||
$count++;
|
||||
$sum += isset($row[$unique])?$row[$unique]:0;
|
||||
if ($count < $this->limit)
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
elseif (!isset($tableBody['Others'])) {
|
||||
$tableBody['Others'] = array($row['label'], $row[$unique], 0);
|
||||
$class['Others'] = 'wp-piwik-hideDetails';
|
||||
$js['Others'] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
} else {
|
||||
$tableBody['Others'][1] += $row[$unique];
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
}
|
||||
}
|
||||
if ($count > $this->limit)
|
||||
$tableBody['Others'][0] = __('Others', 'wp-piwik');
|
||||
|
||||
foreach ($tableBody as $key => $row)
|
||||
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
||||
|
||||
if (!empty($tableBody)) $this->pieChart($tableBody);
|
||||
$this->table($tableHead, $tableBody, null, false, $js, $class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class Search extends \WP_Piwik\Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Site Search', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'Actions.getSiteSearchKeywords';
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(__('Keyword', 'wp-piwik'), __('Requests', 'wp-piwik'), __('Bounced', 'wp-piwik'));
|
||||
$tableBody = array();
|
||||
$count = 0;
|
||||
if (is_array($response))
|
||||
foreach ($response as $row) {
|
||||
$count++;
|
||||
$tableBody[] = array(htmlentities($row['label']), $row['nb_visits'], $row['bounce_rate']);
|
||||
if ($count == 10) break;
|
||||
}
|
||||
$this->table($tableHead, $tableBody, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
31
wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Seo.php
Normal file
31
wp-content/plugins/wp-piwik/classes/WP_Piwik/Widget/Seo.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class Seo extends \WP_Piwik\Widget {
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$this->parameter = array(
|
||||
'url' => get_bloginfo('url')
|
||||
);
|
||||
$this->title = $prefix.__('SEO', 'wp-piwik');
|
||||
$this->method = 'SEO.getRank';
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
echo '<div class="table"><table class="widefat"><tbody>';
|
||||
if (is_array($response))
|
||||
foreach ($response as $val)
|
||||
echo '<tr><td>'.(isset($val['logo_link']) && !empty($val['logo_link'])?'<a href="'.$val['logo_link'].'" title="'.$val['logo_tooltip'].'">'.$val['label'].'</a>':$val['label']).'</td><td>'.$val['rank'].'</td></tr>';
|
||||
else echo '<tr><td>SEO module currently not available.</td></tr>';
|
||||
echo '</tbody></table></div>';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class SystemDetails extends \WP_Piwik\Widget {
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Operation System Details', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'DevicesDetection.getOsVersions';
|
||||
$this->context = 'normal';
|
||||
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
||||
wp_enqueue_script ( 'wp-piwik-chartjs', self::$wpPiwik->getPluginURL () . 'js/chartjs/chart.min.js', "3.4.1" );
|
||||
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
$tableBody = array();
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(__('Operation System', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
||||
if (isset($response[0]['nb_uniq_visitors'])) $unique = 'nb_uniq_visitors';
|
||||
else $unique = 'sum_daily_nb_uniq_visitors';
|
||||
$count = 0;
|
||||
$sum = 0;
|
||||
$js = array();
|
||||
$class = array();
|
||||
if (is_array($response))
|
||||
foreach ($response as $row) {
|
||||
$count++;
|
||||
$sum += isset($row[$unique])?$row[$unique]:0;
|
||||
if ($count < $this->limit)
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
elseif (!isset($tableBody['Others'])) {
|
||||
$tableBody['Others'] = array($row['label'], $row[$unique], 0);
|
||||
$class['Others'] = 'wp-piwik-hideDetails';
|
||||
$js['Others'] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
} else {
|
||||
$tableBody['Others'][1] += $row[$unique];
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
}
|
||||
}
|
||||
if ($count > $this->limit)
|
||||
$tableBody['Others'][0] = __('Others', 'wp-piwik');
|
||||
|
||||
foreach ($tableBody as $key => $row)
|
||||
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
||||
|
||||
if (!empty($tableBody)) $this->pieChart($tableBody);
|
||||
$this->table($tableHead, $tableBody, null, false, $js, $class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
class Systems extends \WP_Piwik\Widget {
|
||||
|
||||
protected function configure($prefix = '', $params = array()) {
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix.__('Operation Systems', 'wp-piwik').' ('.__($timeSettings['description'],'wp-piwik').')';
|
||||
$this->method = 'DevicesDetection.getOsFamilies';
|
||||
$this->context = 'normal';
|
||||
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL().'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
||||
wp_enqueue_script ( 'wp-piwik-chartjs', self::$wpPiwik->getPluginURL () . 'js/chartjs/chart.min.js', "3.4.1" );
|
||||
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
|
||||
}
|
||||
|
||||
public function show() {
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
$tableBody = array();
|
||||
if (!empty($response['result']) && $response['result'] ='error')
|
||||
echo '<strong>'.__('Piwik error', 'wp-piwik').':</strong> '.htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(__('Operation System', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
||||
if (isset($response[0]['nb_uniq_visitors'])) $unique = 'nb_uniq_visitors';
|
||||
else $unique = 'sum_daily_nb_uniq_visitors';
|
||||
$count = 0;
|
||||
$sum = 0;
|
||||
$js = array();
|
||||
$class = array();
|
||||
if (is_array($response))
|
||||
foreach ($response as $row) {
|
||||
$count++;
|
||||
$sum += isset($row[$unique])?$row[$unique]:0;
|
||||
if ($count < $this->limit)
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
elseif (!isset($tableBody['Others'])) {
|
||||
$tableBody['Others'] = array($row['label'], $row[$unique], 0);
|
||||
$class['Others'] = 'wp-piwik-hideDetails';
|
||||
$js['Others'] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
} else {
|
||||
$tableBody['Others'][1] += $row[$unique];
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$unique], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j'."( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
}
|
||||
}
|
||||
if ($count > $this->limit)
|
||||
$tableBody['Others'][0] = __('Others', 'wp-piwik');
|
||||
|
||||
foreach ($tableBody as $key => $row)
|
||||
$tableBody[$key][2] = number_format($row[1]/$sum*100, 2).'%';
|
||||
|
||||
if (!empty($tableBody)) $this->pieChart($tableBody);
|
||||
$this->table($tableHead, $tableBody, null, false, $js, $class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
use WP_Piwik\Widget;
|
||||
|
||||
class Types extends Widget
|
||||
{
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array())
|
||||
{
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => $timeSettings['period'],
|
||||
'date' => $timeSettings['date']
|
||||
);
|
||||
$this->title = $prefix . __('Types', 'wp-piwik') . ' (' . __($timeSettings['description'], 'wp-piwik') . ')';
|
||||
$this->method = 'DevicesDetection.getType';
|
||||
$this->context = 'normal';
|
||||
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL() . 'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
||||
wp_enqueue_script('wp-piwik-chartjs', self::$wpPiwik->getPluginURL() . 'js/chartjs/chart.min.js', "3.4.1");
|
||||
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL() . 'css/wp-piwik.css', array(), self::$wpPiwik->getPluginVersion());
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
$response = self::$wpPiwik->request($this->apiID[$this->method]);
|
||||
$tableBody = array();
|
||||
if (!empty($response['result']) && $response['result'] = 'error')
|
||||
echo '<strong>' . __('Piwik error', 'wp-piwik') . ':</strong> ' . htmlentities($response['message'], ENT_QUOTES, 'utf-8');
|
||||
else {
|
||||
$tableHead = array(__('Type', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Percent', 'wp-piwik'));
|
||||
if (isset($response[0]['nb_uniq_visitors'])) {
|
||||
$unique = 'nb_uniq_visitors';
|
||||
} else {
|
||||
$unique = 'sum_daily_nb_uniq_visitors';
|
||||
}
|
||||
$count = 0;
|
||||
$sum = 0;
|
||||
$js = array();
|
||||
$class = array();
|
||||
if (is_array($response))
|
||||
foreach ($response as $row) {
|
||||
$key = isset($row[$unique]) ? $unique : "nb_visits";
|
||||
$count++;
|
||||
$sum += isset($row[$key]) ? $row[$key] : 0;
|
||||
if ($count < $this->limit)
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$key], 0);
|
||||
elseif (!isset($tableBody['Others'])) {
|
||||
$tableBody['Others'] = array($row['label'], $row[$key], 0);
|
||||
$class['Others'] = 'wp-piwik-hideDetails';
|
||||
$js['Others'] = '$j' . "( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$key], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j' . "( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
} else {
|
||||
$tableBody['Others'][1] += $row[$key];
|
||||
$tableBody[$row['label']] = array($row['label'], $row[$key], 0);
|
||||
$class[$row['label']] = 'wp-piwik-hideDetails hidden';
|
||||
$js[$row['label']] = '$j' . "( '.wp-piwik-hideDetails' ).toggle( 'hidden' );";
|
||||
}
|
||||
}
|
||||
if ($count > $this->limit) {
|
||||
$tableBody['Others'][0] = __('Others', 'wp-piwik');
|
||||
} elseif ($count == $this->limit) {
|
||||
$class['Others'] = $js['Others'] = '';
|
||||
}
|
||||
|
||||
foreach ($tableBody as $key => $row)
|
||||
$tableBody[$key][2] = number_format($row[1] / $sum * 100, 2) . '%';
|
||||
|
||||
if (!empty($tableBody)) $this->pieChart($tableBody);
|
||||
$this->table($tableHead, $tableBody, null, false, $js, $class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace WP_Piwik\Widget;
|
||||
|
||||
use WP_Piwik\Widget;
|
||||
|
||||
class Visitors extends Widget
|
||||
{
|
||||
|
||||
public $className = __CLASS__;
|
||||
|
||||
protected function configure($prefix = '', $params = array())
|
||||
{
|
||||
$timeSettings = $this->getTimeSettings();
|
||||
$this->parameter = array(
|
||||
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
|
||||
'period' => isset($params['period']) ? $params['period'] : $timeSettings['period'],
|
||||
'date' => 'last' . ($timeSettings['period'] == 'day' ? '30' : '12'),
|
||||
'limit' => null
|
||||
);
|
||||
$this->title = $prefix . __('Visitors', 'wp-piwik') . ' (' . __($this->rangeName(), 'wp-piwik') . ')';
|
||||
$this->method = array('VisitsSummary.getVisits', 'VisitsSummary.getUniqueVisitors', 'VisitsSummary.getBounceCount', 'VisitsSummary.getActions');
|
||||
$this->context = 'normal';
|
||||
wp_enqueue_script('wp-piwik', self::$wpPiwik->getPluginURL() . 'js/wp-piwik.js', array(), self::$wpPiwik->getPluginVersion(), true);
|
||||
wp_enqueue_script('wp-piwik-chartjs', self::$wpPiwik->getPluginURL() . 'js/chartjs/chart.min.js', "3.4.1");
|
||||
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL() . 'css/wp-piwik.css', array(), self::$wpPiwik->getPluginVersion());
|
||||
}
|
||||
|
||||
public function requestData()
|
||||
{
|
||||
$response = array();
|
||||
$success = true;
|
||||
foreach ($this->method as $method) {
|
||||
$response[$method] = self::$wpPiwik->request($this->apiID[$method]);
|
||||
if (!empty($response[$method]['result']) && $response[$method]['result'] = 'error')
|
||||
$success = false;
|
||||
}
|
||||
return array("response" => $response, "success" => $success);
|
||||
}
|
||||
|
||||
public function show()
|
||||
{
|
||||
$result = $this->requestData();
|
||||
$response = $result["response"];
|
||||
if (!$result["success"]) {
|
||||
echo '<strong>' . __('Piwik error', 'wp-piwik') . ':</strong> ' . htmlentities($response[$method]['message'], ENT_QUOTES, 'utf-8');
|
||||
} else {
|
||||
$data = array();
|
||||
if (is_array($response) && is_array($response['VisitsSummary.getVisits']))
|
||||
foreach ($response['VisitsSummary.getVisits'] as $key => $value) {
|
||||
if ($this->parameter['period'] == 'week') {
|
||||
preg_match("/[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/", $key, $dateList);
|
||||
$jsKey = $dateList[0];
|
||||
$textKey = $this->dateFormat($jsKey, 'week');
|
||||
} elseif ($this->parameter['period'] == 'month') {
|
||||
$jsKey = $key . '-01';
|
||||
$textKey = $key;
|
||||
} else $jsKey = $textKey = $key;
|
||||
$data[] = array(
|
||||
$textKey,
|
||||
$value,
|
||||
$response['VisitsSummary.getUniqueVisitors'][$key] ? $response['VisitsSummary.getUniqueVisitors'][$key] : '-',
|
||||
$response['VisitsSummary.getBounceCount'][$key] ? $response['VisitsSummary.getBounceCount'][$key] : '-',
|
||||
$response['VisitsSummary.getActions'][$key] ? $response['VisitsSummary.getActions'][$key] : '-'
|
||||
);
|
||||
$javaScript[] = 'javascript:wp_piwik_datelink(\'' . urlencode('wp-piwik_stats') . '\',\'' . str_replace('-', '', $jsKey) . '\',\'' . (isset($_GET['wpmu_show_stats']) ? (int)$_GET['wpmu_show_stats'] : '') . '\');';
|
||||
}
|
||||
$this->table(
|
||||
array(__('Date', 'wp-piwik'), __('Visits', 'wp-piwik'), __('Unique', 'wp-piwik'), __('Bounced', 'wp-piwik'), __('Page Views', 'wp-piwik')),
|
||||
array_reverse($data),
|
||||
array(),
|
||||
'clickable',
|
||||
array_reverse(isset($javaScript) ? $javaScript : [])
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user