PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 1.3.1
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v1.3.1
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / classes / WpMatomo / Report / Dates.php
matomo / classes / WpMatomo / Report Last commit date
views 6 years ago Data.php 6 years ago Dates.php 6 years ago Metadata.php 6 years ago Renderer.php 6 years ago
Dates.php
82 lines
1 <?php
2 /**
3 * Matomo - free/libre analytics platform
4 *
5 * @link https://matomo.org
6 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
7 * @package matomo
8 */
9
10 namespace WpMatomo\Report;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // if accessed directly
14 }
15
16 class Dates {
17 const TODAY = 'today';
18 const YESTERDAY = 'yesterday';
19 const THIS_WEEK = 'thisweek';
20 const LAST_WEEK = 'lastweek';
21 const THIS_MONTH = 'thismonth';
22 const LAST_MONTH = 'lastmonth';
23 const THIS_YEAR = 'thisyear';
24
25 public function get_supported_dates() {
26 return array(
27 self::YESTERDAY => 'Yesterday',
28 self::TODAY => 'Today',
29 self::THIS_WEEK => 'This week',
30 self::LAST_WEEK => 'Last week',
31 self::THIS_MONTH => 'This month',
32 self::LAST_MONTH => 'Last month',
33 self::THIS_YEAR => 'This year',
34 );
35 }
36
37 public function detect_period_and_date( $report_date ) {
38 $period = 'day';
39 $date = 'yesterday';
40
41 switch ( $report_date ) {
42 case self::TODAY:
43 $period = 'day';
44 $date = 'today';
45 break;
46 case self::YESTERDAY:
47 $period = 'day';
48 $date = 'yesterday';
49 break;
50 case self::THIS_MONTH:
51 $period = 'month';
52 $date = 'today';
53 break;
54 case self::LAST_MONTH:
55 $period = 'month';
56 $date = gmdate( 'Y-m-d', strtotime( '1 month ago' ) );
57 break;
58 case self::THIS_WEEK:
59 $period = 'week';
60 $date = 'today';
61 break;
62 case self::LAST_WEEK:
63 $period = 'week';
64 $date = gmdate( 'Y-m-d', strtotime( '1 week ago' ) );
65 break;
66 case self::THIS_YEAR:
67 $period = 'year';
68 $date = 'today';
69 break;
70 default:
71 if ( preg_match( '/\d{4}-\d{2}-\d{2}/', $report_date ) ) {
72 $period = 'day';
73 $date = $report_date;
74 }
75 }
76
77 return array( $period, $date );
78 }
79
80
81 }
82