PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.12.2
Independent Analytics – WordPress Analytics Plugin v2.12.2
2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / IAWP / Date_Picker / Month.php
independent-analytics / IAWP / Date_Picker Last commit date
Date_Picker.php 1 year ago Month.php 1 year ago
Month.php
108 lines
1 <?php
2
3 namespace IAWP\Date_Picker;
4
5 /** @internal */
6 class Month
7 {
8 private $date;
9 private $first_month;
10 public function __construct(\DateTime $date, \DateTime $first_month)
11 {
12 $this->date = $date;
13 $this->first_month = $first_month;
14 }
15 public function name() : string
16 {
17 return \IAWPSCOPED\iawp()->date_i18n('F Y', $this->date);
18 }
19 public function date_string() : string
20 {
21 return $this->date->format('Y-m');
22 }
23 public function days() : \DatePeriod
24 {
25 $start = $this->date->modify('first day of this month');
26 $end = (clone $this->date)->modify('last day of this month');
27 $end->setTime(23, 59, 59);
28 $interval = new \DateInterval('P1D');
29 // 1 day interval
30 return new \DatePeriod($start, $interval, $end);
31 }
32 public function extra_cells() : int
33 {
34 $user_dow = \IAWPSCOPED\iawp()->get_option('iawp_dow', 0);
35 $start = $this->date->modify('first day of this month');
36 $month_dow = $start->format('w');
37 if ($month_dow >= $user_dow) {
38 return $month_dow - $user_dow;
39 } else {
40 return 7 - ($user_dow - $month_dow);
41 }
42 }
43 public function month_class() : string
44 {
45 $now = new \DateTime('now');
46 $month = clone $this->date;
47 $class = 'iawp-calendar-month';
48 if ($month->format('Y-m') === $this->first_month->format('Y-m')) {
49 $class .= ' iawp-first-month';
50 }
51 if ($now->format('Y-m') === $month->format('Y-m')) {
52 $class .= ' iawp-current iawp-last-month';
53 }
54 // Modifying $month here
55 if ($now->format('Y n') === $month->modify('first day of +1 month')->format('Y n')) {
56 $class .= ' iawp-previous';
57 }
58 return $class;
59 }
60 public function day_class(\DateTime $day, string $first_data, string $start_date, string $end_date) : string
61 {
62 $date = $day->format('Y-m-d');
63 $class = 'iawp-day iawp-cell';
64 if ($date === \date('Y-m-d')) {
65 $class .= ' iawp-today';
66 }
67 if ($day->format('j') == '1') {
68 $class .= ' first-of-month';
69 }
70 if ($date === $first_data) {
71 $class .= ' iawp-first-data';
72 }
73 if ($date < $first_data || $date > \date('Y-m-d')) {
74 $class .= ' out-of-range';
75 }
76 if ($date === $start_date) {
77 $class .= ' iawp-start';
78 if ($date === $end_date) {
79 $class .= ' iawp-end';
80 }
81 } elseif ($date === $end_date) {
82 $class .= ' iawp-end';
83 } elseif ($date > $start_date && $date < $end_date) {
84 $class .= ' in-range';
85 }
86 return $class;
87 }
88 public function days_of_week() : string
89 {
90 $days = [];
91 $html = '';
92 // Get the correct HTML
93 for ($i = 0; $i < 7; $i++) {
94 $days[] = '<span class="iawp-day-name">' . \date_i18n("D", \strtotime("Sunday +{$i} days")) . '</span>';
95 }
96 // Shift based on the user's selection
97 for ($i = 0; $i < \IAWPSCOPED\iawp()->get_option('iawp_dow', 0); $i++) {
98 $first_day = \array_shift($days);
99 \array_push($days, $first_day);
100 }
101 // Create the HTMl string
102 foreach ($days as $day) {
103 $html .= $day;
104 }
105 return $html;
106 }
107 }
108