deleted plugin WP-Matomo Integration version 1.0.24

This commit is contained in:
2021-04-08 18:46:38 +00:00
committed by Gitium
parent ca7eb56a01
commit d1bf360aac
151 changed files with 0 additions and 55149 deletions

View File

@ -1,77 +0,0 @@
<?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-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
}
public function addHeaderLines() {
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
}
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);
}
}
}

View File

@ -1,80 +0,0 @@
<?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-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
}
public function addHeaderLines() {
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
}
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);
}
}
}

View File

@ -1,78 +0,0 @@
<?php
namespace WP_Piwik\Widget;
use WP_Piwik\Widget;
class Chart 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-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
}
public function addHeaderLines() {
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
}
public function show() {
$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;
}
if (!$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 .= '['.$count.',"'.$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);
echo '<div id="wp-piwik_stats_vistors_graph" style="height:220px;" title="'.__('The graph contains the values shown in the table below (visitors / unique / bounces). The red line shows a linear trendline (unique).', 'wp-piwik').'"></div>';
echo '<script type="text/javascript">';
echo '$j.jqplot("wp-piwik_stats_vistors_graph", [['.$values.'],['.$unique.'],['.$bounced.']],{axes:{yaxis:{min:0, tickOptions:{formatString:"%.0f"}},xaxis:{min:1,max:30,ticks:['.$labels.']}},seriesDefaults:{showMarker:false,lineWidth:1,fill:true,fillAndStroke:true,fillAlpha:0.9,trendline:{show:false,color:"#C00",lineWidth:1.5,type:"exp"}},series:[{color:"#90AAD9",fillColor:"#D4E2ED"},{color:"#A3BCEA",fillColor:"#E4F2FD",trendline:{show:true,label:"Unique visitor trend"}},{color:"#E9A0BA",fillColor:"#FDE4F2"}],});';
echo '</script>';
}
}
}

View File

@ -1,80 +0,0 @@
<?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.__('Countries', '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-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
}
public function addHeaderLines() {
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
}
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);
}
}
}

View File

@ -1,80 +0,0 @@
<?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-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
}
public function addHeaderLines() {
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
}
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);
}
}
}

View File

@ -1,45 +0,0 @@
<?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);
}
}
}

View File

@ -1,52 +0,0 @@
<?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);
}
}
}

View File

@ -1,52 +0,0 @@
<?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);
}
}
}

View File

@ -1,21 +0,0 @@
<?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';
}
}

View File

@ -1,80 +0,0 @@
<?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-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
}
public function addHeaderLines() {
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
}
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($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);
}
}
}

View File

@ -1,38 +0,0 @@
<?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);
}
}
}

View File

@ -1,31 +0,0 @@
<?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>' );
}
}

View File

@ -1,63 +0,0 @@
<?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 ($this->parameter['date'] == 'last30') {
$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').' (&#216; '.$this->value($response, 'nb_actions_per_visit').')'),
array(__('Total time spent', 'wp-piwik').':', $time.' (&#216; '.$avgTime.')'),
array(__('Bounce count', 'wp-piwik').':', $this->value($response, 'bounce_count').' ('.$this->value($response, 'bounce_rate').')')
);
if ($this->parameter['date'] != 'last30')
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);
}
}
}

View File

@ -1,21 +0,0 @@
<?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' );
}
}

View File

@ -1,38 +0,0 @@
<?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);
}
}
}

View File

@ -1,51 +0,0 @@
<?php
namespace WP_Piwik\Widget;
class Post extends \WP_Piwik\Widget {
public $className = __CLASS__;
protected function configure($prefix = '', $params = array()) {
global $post;
$this->parameter = array(
'idSite' => self::$wpPiwik->getPiwikSiteId($this->blogId),
'period' => 'range',
'date' => isset($params['range'])?$params['range']:'last30',
'key' => isset($params['key'])?$params['key']:null,
'pageUrl' => isset($params['url'])?$params['url']:urlencode(get_permalink($post->ID)),
);
$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 (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['entry_sum_visit_length'])?$this->timeFormat($response['entry_sum_visit_length']):'-';
$avgTime = isset($response['avg_time_on_page'])?$this->timeFormat($response['avg_time_on_page']):'-';
$tableHead = null;
$tableBody = array(
array(__('Visitors', 'wp-piwik').':', $this->value($response, 'nb_visits')),
array(__('Unique visitors', 'wp-piwik').':', $this->value($response, 'sum_daily_nb_uniq_visitors')),
array(__('Page views', 'wp-piwik').':', $this->value($response, 'nb_hits').' (&#216; '.$this->value($response, 'entry_nb_actions').')'),
array(__('Total time spent', 'wp-piwik').':', $time),
array(__('Time/visit', 'wp-piwik').':', $avgTime),
array(__('Bounce count', 'wp-piwik').':', $this->value($response, 'entry_bounce_count').' ('.$this->value($response, 'bounce_rate').')'),
array(__('Min. generation time', 'wp-piwik').':', $this->value($response, 'min_time_generation')),
array(__('Max. generation time', 'wp-piwik').':', $this->value($response, 'max_time_generation'))
);
$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);
}
}
}

View File

@ -1,21 +0,0 @@
<?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';
}
}

View File

@ -1,75 +0,0 @@
<?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-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
}
public function addHeaderLines() {
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
}
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);
}
}
}

View File

@ -1,38 +0,0 @@
<?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);
}
}
}

View File

@ -1,31 +0,0 @@
<?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>';
}
}
}

View File

@ -1,73 +0,0 @@
<?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-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
}
public function addHeaderLines() {
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
}
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);
}
}
}

View File

@ -1,73 +0,0 @@
<?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-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
}
public function addHeaderLines() {
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
}
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);
}
}
}

View File

@ -1,80 +0,0 @@
<?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-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
}
public function addHeaderLines() {
echo '<!--[if IE]><script language="javascript" type="text/javascript" src="'.self::$wpPiwik->getPluginURL().'js/jqplot/excanvas.min.js"></script><![endif]-->';
echo '<link rel="stylesheet" href="'.self::$wpPiwik->getPluginURL().'js/jqplot/jquery.jqplot.min.css" type="text/css"/>';
echo '<script type="text/javascript">var $j = jQuery.noConflict();</script>';
}
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) {
$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);
}
}
}

View File

@ -1,68 +0,0 @@
<?php
namespace WP_Piwik\Widget;
class Visitors 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' => '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-jqplot',self::$wpPiwik->getPluginURL().'js/jqplot/wp-piwik.jqplot.js',array('jquery'));
wp_enqueue_style('wp-piwik', self::$wpPiwik->getPluginURL().'css/wp-piwik.css',array(),self::$wpPiwik->getPluginVersion());
add_action('admin_head-index.php', array($this, 'addHeaderLines'));
}
public function show() {
$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;
}
if (!$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:[])
);
}
}
}