PluginProbe ʕ •ᴥ•ʔ
Daily Prayer Time / 2026.05.04
Daily Prayer Time v2026.05.04
2026.05.20 2026.05.11 2026.05.09 2026.05.05 2026.05.04 2026.05.03 2026.04.28 2026.04.28.1 trunk 2019.10.16 2019.11.19 2019.2.16 2019.3.1 2019.4.1 2019.4.5 2019.5.12 2019.5.13 2019.5.14 2019.5.19 2019.5.19.1 2019.5.21 2019.5.30 2019.5.5 2019.5.6 2019.5.7 2019.5.8 2019.5.9 2019.6.10 2019.6.2 2019.6.22 2019.7.10 2019.7.25 2019.8.1 2019.8.4 2019.9.16 2020.04.25 2020.04.26 2020.05.01 2020.05.04 2020.05.08 2020.05.17 2020.07.03 2021.01.10 2021.03.28 2021.07.20 2021.07.23 2021.07.24 2021.07.28 2021.08.01 2021.08.06 2021.08.07 2021.08.10 2021.09.12 2021.09.18 2021.09.23 2021.09.24 2021.10.01 2021.10.02 2021.10.10 2021.10.11 2021.10.15 2021.10.21 2021.10.27 2021.10.29 2022.03.24 2022.04.04 2022.04.14 2022.04.15 2022.04.21 2022.04.22 2022.05.04 2022.09.19 2022.11.14 2022.11.16 2022.12.18 2022.12.20 2023.01.27 2023.02.04 2023.02.09 2023.02.21 2023.03.08 2023.03.17 2023.03.18 2023.03.20 2023.05.04 2023.08.03 2023.08.08.16 2023.08.19 2023.08.19.1 2023.10.13 2023.10.21 2023.11.26 2023.12.28 2023.12.31 2024.03.28 2024.03.29 2024.03.30 2024.04.18 2024.04.20 2024.04.22 2024.04.26 2024.08.26 2024.09.12 2024.09.14 2024.09.17 2024.12.29 2024.12.30 2025.01.02 2025.01.17 2025.02.02 2025.03.04 2025.03.06 2025.03.08 2025.03.15 2025.03.20 2025.03.26 2025.03.27 2025.04.03 2025.06.16 2025.06.29 2025.07.15 2025.08.09 2025.10.26 2026.04.26
daily-prayer-time-for-mosques / Models / UpdateStyles.php
daily-prayer-time-for-mosques / Models Last commit date
Hijri 3 years ago Processors 1 month ago QuranADay 2 months ago StartTime 1 year ago design 1 month ago AdminMenu.php 2 years ago AssetsLoader.php 1 year ago CustomPluginSettings.php 4 years ago DPTAjaxHandler.php 4 years ago DPTHelper.php 1 month ago DSTemplateLoader.php 2 years ago DailyShortCode.php 2 months ago DigitalScreen.php 1 month ago HijriDate.php 3 years ago Init.php 4 years ago MonthlyShortCode.php 2 years ago MonthlyTimeTable.php 3 years ago Shortcodes.php 2 months ago Translator.php 4 years ago UpdateStyles.php 1 month ago Validator.php 3 years ago db.php 2 months ago dptWidget.php 4 years ago
UpdateStyles.php
268 lines
1 <?php
2 class UpdateStyles
3 {
4 /** @var string */
5 private $handle;
6
7 /** @var array */
8 private $options;
9
10 public function __construct($handle)
11 {
12 $this->handle = $handle;
13 $this->loadOptions();
14 $this->setScript();
15 $this->setStyles();
16 }
17
18 private function loadOptions()
19 {
20 $this->options = [
21 'tableBackground' => get_option('tableBackground'),
22 'tableHeading' => get_option('tableHeading'),
23 'tableHeadingFont' => get_option('tableHeadingFont'),
24 'notificationBackground' => get_option('notificationBackground'),
25 'notificationFont' => get_option('notificationFont'),
26 'evenRow' => get_option('evenRow'),
27 'fontColor' => get_option('fontColor'),
28 'prayerName' => get_option('prayerName'),
29 'prayerNameFont' => get_option('prayerNameFont'),
30 'highlight' => get_option('highlight') ?? 'red',
31 'highlightFont' => get_option('highlightFont') ?? 'white',
32 'digitalScreenRed' => get_option('digitalScreenRed'),
33 'digitalScreenLightRed' => get_option('digitalScreenLightRed'),
34 'digitalScreenGreen' => get_option('digitalScreenGreen'),
35 'digitalScreenPrayerName' => get_option('digitalScreenPrayerName')
36 ];
37 }
38
39 private function setScript()
40 {
41 add_action('admin_enqueue_scripts', [$this, 'enqueueColorPicker']);
42 }
43
44 public function enqueueColorPicker()
45 {
46 if (!is_admin()) {
47 return;
48 }
49
50 wp_enqueue_style('wp-color-picker');
51 wp_enqueue_script(
52 'custom-script-handle',
53 plugins_url('/../Assets/js/wp-color-picker.js', __FILE__),
54 ['wp-color-picker'],
55 '4.0.0'
56 );
57 }
58
59 private function setStyles()
60 {
61 $css = '';
62 $css .= $this->getTableBackgroundStyles();
63 $css .= $this->getTableHeadingStyles();
64 $css .= $this->getNotificationStyles();
65 $css .= $this->getPrayerNameStyles();
66 $css .= $this->getHighlightStyles();
67 $css .= $this->getDigitalScreenStyles();
68
69 wp_add_inline_style($this->handle, $this->minifyCss($css));
70 }
71
72 private function getTableBackgroundStyles()
73 {
74 if (empty($this->options['tableBackground'])) {
75 return '';
76 }
77
78 return "
79 .x-board-modern #time-table-section,
80 .x-board-modern .date-english-arabic {
81 background: {$this->options['tableBackground'] } !important
82 }
83 .green,
84 .x-board-modern .mosque-name h2,
85 .x-board-modern .clock {
86 color: {$this->options['tableBackground']}
87 }
88 .dpt-horizontal-wrapper.customStyles {
89 background-color: {$this->options['tableBackground']} !important
90 }
91 ";
92 }
93
94 private function getTableHeadingStyles()
95 {
96 if (empty($this->options['tableHeading'])) {
97 return '';
98 }
99
100 return "
101 table.customStyles th.tableHeading {
102 background: {$this->options['tableHeading']};
103 color: {$this->options['tableHeadingFont']}
104 }
105 ";
106 }
107
108 private function getNotificationStyles()
109 {
110 $styles = '';
111
112 if (!empty($this->options['notificationBackground'])) {
113 $styles .= "
114 table.customStyles th.notificationBackground,
115 .notificationBackground {
116 background: {$this->options['notificationBackground']};
117 color: {$this->options['notificationFont']}
118 }
119 ";
120 }
121
122 if (!empty($this->options['notificationFont'])) {
123 $styles .= "
124 table.customStyles th.notificationFont,
125 .notificationFont {
126 color: {$this->options['notificationFont']}
127 }
128 ";
129 }
130
131 if (!empty($this->options['evenRow'])) {
132 $styles .= "
133 table.customStyles tr:nth-child(even) {
134 background: {$this->options['evenRow']}
135 }
136 ";
137 }
138
139 if (!empty($this->options['fontColor'])) {
140 $styles .= "
141 table.customStyles {
142 color: {$this->options['fontColor']}
143 }
144 ";
145 }
146
147 return $styles;
148 }
149
150 private function getPrayerNameStyles()
151 {
152 $styles = '';
153
154 if (!empty($this->options['prayerName'])) {
155 $styles .= "
156 table.customStyles th.prayerName {
157 background: {$this->options['prayerName']}
158 }
159 ";
160 }
161
162 if (!empty($this->options['prayerNameFont'])) {
163 $styles .= "
164 table.customStyles th.prayerName {
165 color: {$this->options['prayerNameFont']}
166 }
167 .x-board-modern #time-table-section h4 {
168 color: {$this->options['prayerNameFont']}
169 }
170 ";
171 }
172
173 return $styles;
174 }
175
176 private function getHighlightStyles()
177 {
178 return "
179 table.customStyles tr.highlight, th.highlight, td.highlight {
180 font-weight: bold;
181 background: {$this->options['highlight']} !important;
182 color: {$this->options['highlightFont']} !important;
183 }
184 span.nextPrayer {
185 font-weight: bold;
186 color: {$this->options['highlight']}
187 }
188 .x-board tr.nextPrayer td {
189 background-color: {$this->options['highlight']} !important;
190 color: {$this->options['highlightFont']} !important;
191 }
192 .x-board-modern h4.nextPrayer, p.nextPrayer {
193 background: {$this->options['highlight']} !important;
194 color: {$this->options['highlightFont']} !important;
195 }
196 .d-masjid-e-usman .nextPrayer h3,
197 .nextPrayer .title,
198 tr.nextPrayer,
199 td span.nextPrayer,
200 .dpt-wrapper-container .prayer-time.highlight {
201 background: {$this->options['highlight']} !important;
202 color: {$this->options['highlightFont']} !important;
203 }
204 .d-masjid-e-usman .left-main-col-sun-times h4,
205 .left-main-col-sun-times p {
206 color: {$this->options['highlight']} !important;
207 }
208 .dptPrayerIcon {
209 color: {$this->options['highlightFont']} !important;
210 }
211 span.nextPrayer {
212 color: {$this->options['highlightFont']} !important;
213 }
214 .d-masjid-e-usman .nextPrayer h3, .nextPrayer .title, .d-masjid-e-usman .nextPrayer .dsJumuah {
215 color: {$this->options['highlightFont']} !important;
216 }
217 ";
218 }
219
220 private function getDigitalScreenStyles()
221 {
222 $styles = '';
223
224 if (!empty($this->options['digitalScreenRed'])) {
225 $styles .= "
226 .x-board .bg-red {
227 background: {$this->options['digitalScreenRed']} !important
228 }
229 ";
230 }
231
232 if (!empty($this->options['digitalScreenLightRed'])) {
233 $styles .= "
234 .x-board .l-red {
235 background: {$this->options['digitalScreenLightRed']} !important
236 }
237 ";
238 }
239
240 if (!empty($this->options['digitalScreenGreen'])) {
241 $styles .= "
242 .x-board .bg-green {
243 background: {$this->options['digitalScreenGreen']} !important
244 }
245 ";
246 }
247
248 if (!empty($this->options['digitalScreenPrayerName'])) {
249 $styles .= "
250 .x-board td.prayerName {
251 background: {$this->options['digitalScreenPrayerName']} !important
252 }
253 ";
254 }
255
256 return $styles;
257 }
258
259 private function minifyCss($css)
260 {
261 // Remove comments
262 $css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css);
263 // Remove space after colons and unnecessary whitespace
264 $css = str_replace([': ', "\r\n", "\r", "\n", "\t", ' ', ' '], [':', ' '], $css);
265 return trim($css);
266 }
267 }
268