PluginProbe ʕ •ᴥ•ʔ
Daily Prayer Time / 2026.05.20
Daily Prayer Time v2026.05.20
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 1 month 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
307 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 'digitalScreenGreenFont' => get_option('digitalScreenGreenFont') ?? 'white',
36 'digitalScreenPrayerName' => get_option('digitalScreenPrayerName'),
37 'digitalScreenSlideBg' => get_option('digitalScreenSlideBg')
38 ];
39 }
40
41 private function setScript()
42 {
43 add_action('admin_enqueue_scripts', [$this, 'enqueueColorPicker']);
44 }
45
46 public function enqueueColorPicker()
47 {
48 if (!is_admin()) {
49 return;
50 }
51
52 wp_enqueue_style('wp-color-picker');
53 wp_enqueue_script(
54 'custom-script-handle',
55 plugins_url('/../Assets/js/wp-color-picker.js', __FILE__),
56 ['wp-color-picker'],
57 '4.0.0'
58 );
59 }
60
61 private function setStyles()
62 {
63 $css = '';
64 $css .= $this->getTableBackgroundStyles();
65 $css .= $this->getTableHeadingStyles();
66 $css .= $this->getNotificationStyles();
67 $css .= $this->getPrayerNameStyles();
68 $css .= $this->getHighlightStyles();
69 $css .= $this->getDigitalScreenStyles();
70
71 wp_add_inline_style($this->handle, $this->minifyCss($css));
72 }
73
74 private function getTableBackgroundStyles()
75 {
76 if (empty($this->options['tableBackground'])) {
77 return '';
78 }
79
80 $color = $this->options['tableBackground'];
81
82 return "
83 .x-board-modern #time-table-section,
84 .x-board-modern .date-english-arabic,
85 .x-board-my-masjid .prayer-table-section,
86 .x-board-my-masjid .next-banner {
87 background: {$color} !important
88 }
89 .green,
90 .x-board-modern .mosque-name h2,
91 .x-board-modern .clock,
92 .x-board-my-masjid .highlight-text {
93 color: {$color}
94 }
95 .dpt-horizontal-wrapper.customStyles {
96 background-color: {$color} !important
97 }
98 ";
99 }
100
101 private function getTableHeadingStyles()
102 {
103 if (empty($this->options['tableHeading'])) {
104 return '';
105 }
106
107 return "
108 table.customStyles th.tableHeading {
109 background: {$this->options['tableHeading']};
110 color: {$this->options['tableHeadingFont']}
111 }
112 ";
113 }
114
115 private function getNotificationStyles()
116 {
117 $styles = '';
118
119 if (!empty($this->options['notificationBackground'])) {
120 $styles .= "
121 table.customStyles th.notificationBackground,
122 .notificationBackground {
123 background: {$this->options['notificationBackground']};
124 color: {$this->options['notificationFont']}
125 }
126 ";
127 }
128
129 if (!empty($this->options['notificationFont'])) {
130 $styles .= "
131 table.customStyles th.notificationFont,
132 .notificationFont {
133 color: {$this->options['notificationFont']}
134 }
135 ";
136 }
137
138 if (!empty($this->options['evenRow'])) {
139 $styles .= "
140 table.customStyles tr:nth-child(even) {
141 background: {$this->options['evenRow']}
142 }
143 ";
144 }
145
146 if (!empty($this->options['fontColor'])) {
147 $styles .= "
148 table.customStyles {
149 color: {$this->options['fontColor']}
150 }
151 ";
152 }
153
154 return $styles;
155 }
156
157 private function getPrayerNameStyles()
158 {
159 $styles = '';
160
161 if (!empty($this->options['prayerName'])) {
162 $styles .= "
163 table.customStyles th.prayerName {
164 background: {$this->options['prayerName']}
165 }
166 ";
167 }
168
169 if (!empty($this->options['prayerNameFont'])) {
170 $styles .= "
171 table.customStyles th.prayerName {
172 color: {$this->options['prayerNameFont']}
173 }
174 .x-board-modern #time-table-section h4 {
175 color: {$this->options['prayerNameFont']}
176 }
177 ";
178 }
179
180 return $styles;
181 }
182
183 private function getHighlightStyles()
184 {
185 $styles = '';
186
187 if (!empty($this->options['highlight'])) {
188 $highlightBackground = $this->options['highlight'];
189
190 $styles .= "
191 :root {
192 --dpt-highlight: {$highlightBackground} !important;
193 }
194 table.customStyles tr.highlight, th.highlight, td.highlight {
195 background: {$highlightBackground} !important;
196 }
197 ";
198 }
199
200 if (!empty($this->options['highlightFont'])) {
201 $highlightFont = $this->options['highlightFont'];
202 $styles .= "
203 :root {
204 --dpt-highlight-font: {$highlightFont} !important;
205 }
206 table.customStyles tr.highlight, th.highlight, td.highlight {
207 color: {$highlightFont} !important;
208 }
209 div.dptScNextPrayer {
210 color: {$highlightFont};
211 }
212 ";
213 }
214
215 return $styles;
216 }
217
218 private function getDigitalScreenStyles()
219 {
220 $styles = '';
221
222 if (!empty($this->options['digitalScreenRed'])) {
223 $styles .= "
224 .x-board .bg-red {
225 background: {$this->options['digitalScreenRed']} !important
226 }
227 ";
228 }
229
230 if (!empty($this->options['digitalScreenLightRed'])) {
231 $styles .= "
232 .x-board .l-red {
233 background: {$this->options['digitalScreenLightRed']} !important
234 }
235 ";
236 }
237
238 if (!empty($this->options['digitalScreenGreen'])) {
239 $nextPrayerRowBg = $this->options['digitalScreenGreen'];
240 $styles .= "
241 #dsPrayerTimetable tr.nextPrayer td,
242 .x-board tr.nextPrayer td {
243 background: {$nextPrayerRowBg} !important;
244 }
245 ";
246 }
247
248 if (!empty($this->options['digitalScreenSlideBg'])) {
249 $slideBg = $this->options['digitalScreenSlideBg'];
250 $styles .= "
251 .x-board .bg-green {
252 background-color: {$slideBg} !important
253 }
254 .x-board .nextPrayer .title,
255 .dpt-wrapper-container .prayer-time.highlight {
256 background-color: {$slideBg} !important;
257 }
258 ";
259 }
260
261 if (!empty($this->options['digitalScreenGreenFont'])) {
262 $nextPrayerFont = $this->options['digitalScreenGreenFont'];
263 $styles .= "
264 .x-board .bg-green td,
265 .x-board .bg-green div,
266 .x-board .bg-green h2,
267 .x-board .bg-green h3,
268 .x-board .bg-green h4 {
269 color: {$nextPrayerFont} !important;
270 }
271 .x-board span.nextPrayer {
272 font-weight: bold;
273 color: {$nextPrayerFont};
274 }
275 .x-board tr.nextPrayer td {
276 color: {$nextPrayerFont} !important;
277 }
278 .quranVerse {
279 color: {$nextPrayerFont};
280 }
281 div.dptScNextPrayer {
282 color: {$nextPrayerFont};
283 }
284 ";
285 }
286
287 if (!empty($this->options['digitalScreenPrayerName'])) {
288 $styles .= "
289 .x-board td.prayerName {
290 background: {$this->options['digitalScreenPrayerName']} !important
291 }
292 ";
293 }
294
295 return $styles;
296 }
297
298 private function minifyCss($css)
299 {
300 // Remove comments
301 $css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css);
302 // Remove space after colons and unnecessary whitespace
303 $css = str_replace([': ', "\r\n", "\r", "\n", "\t", ' ', ' '], [':', ' '], $css);
304 return trim($css);
305 }
306 }
307