PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.14.2
Independent Analytics – WordPress Analytics Plugin v2.14.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 5 months ago Month.php 5 months ago
Month.php
109 lines
1 <?php
2
3 namespace IAWP\Date_Picker;
4
5 use IAWP\Utils\Timezone;
6 /** @internal */
7 class Month
8 {
9 private $date;
10 private $first_month;
11 public function __construct(\DateTime $date, \DateTime $first_month)
12 {
13 $this->date = $date;
14 $this->first_month = $first_month;
15 }
16 public function name() : string
17 {
18 return \IAWPSCOPED\iawp()->date_i18n('F Y', $this->date);
19 }
20 public function date_string() : string
21 {
22 return $this->date->format('Y-m');
23 }
24 public function days() : \DatePeriod
25 {
26 $start = $this->date->modify('first day of this month');
27 $end = (clone $this->date)->modify('last day of this month');
28 $end->setTime(23, 59, 59);
29 $interval = new \DateInterval('P1D');
30 // 1 day interval
31 return new \DatePeriod($start, $interval, $end);
32 }
33 public function extra_cells() : int
34 {
35 $user_dow = \IAWPSCOPED\iawp()->get_option('iawp_dow', 0);
36 $start = $this->date->modify('first day of this month');
37 $month_dow = $start->format('w');
38 if ($month_dow >= $user_dow) {
39 return $month_dow - $user_dow;
40 } else {
41 return 7 - ($user_dow - $month_dow);
42 }
43 }
44 public function month_class() : string
45 {
46 $now = new \DateTime('now', Timezone::utc_timezone());
47 $month = clone $this->date;
48 $class = 'iawp-calendar-month';
49 if ($month->format('Y-m') === $this->first_month->format('Y-m')) {
50 $class .= ' iawp-first-month';
51 }
52 if ($now->format('Y-m') === $month->format('Y-m')) {
53 $class .= ' iawp-current iawp-last-month';
54 }
55 // Modifying $month here
56 if ($now->format('Y n') === $month->modify('first day of +1 month')->format('Y n')) {
57 $class .= ' iawp-previous';
58 }
59 return $class;
60 }
61 public function day_class(\DateTime $day, string $first_data, string $start_date, string $end_date) : string
62 {
63 $date = $day->format('Y-m-d');
64 $class = 'iawp-day iawp-cell';
65 if ($date === \date('Y-m-d')) {
66 $class .= ' iawp-today';
67 }
68 if ($day->format('j') == '1') {
69 $class .= ' first-of-month';
70 }
71 if ($date === $first_data) {
72 $class .= ' iawp-first-data';
73 }
74 if ($date < $first_data || $date > \date('Y-m-d')) {
75 $class .= ' out-of-range';
76 }
77 if ($date === $start_date) {
78 $class .= ' iawp-start';
79 if ($date === $end_date) {
80 $class .= ' iawp-end';
81 }
82 } elseif ($date === $end_date) {
83 $class .= ' iawp-end';
84 } elseif ($date > $start_date && $date < $end_date) {
85 $class .= ' in-range';
86 }
87 return $class;
88 }
89 public function days_of_week() : string
90 {
91 $days = [];
92 $html = '';
93 // Get the correct HTML
94 for ($i = 0; $i < 7; $i++) {
95 $days[] = '<span class="iawp-day-name">' . \date_i18n("D", \strtotime("Sunday +{$i} days")) . '</span>';
96 }
97 // Shift based on the user's selection
98 for ($i = 0; $i < \IAWPSCOPED\iawp()->get_option('iawp_dow', 0); $i++) {
99 $first_day = \array_shift($days);
100 \array_push($days, $first_day);
101 }
102 // Create the HTMl string
103 foreach ($days as $day) {
104 $html .= $day;
105 }
106 return $html;
107 }
108 }
109