PluginProbe ʕ •ᴥ•ʔ
پارسی دیت – Parsi Date / 6.2.1
پارسی دیت – Parsi Date v6.2.1
6.2.1 6.2 6.1 5.1.6 5.1.7 5.1.8 5.1.8.2 6.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.0.0-alpha 2.1 2.1.1 2.1.2 2.1.3 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0.1 2.3.0.2 2.3.1 2.3.2 2.3.3 2.3.4 3.0.1 3.0.2 3.0.3 4.0.0 4.0.1 4.0.2 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5
wp-parsidate / inc / Core / Names.php
wp-parsidate / inc / Core Last commit date
Archive.php 3 weeks ago Calendar.php 3 weeks ago Core.php 3 weeks ago Names.php 3 weeks ago Posts.php 3 weeks ago WPP_ParsiDate.php 3 weeks ago
Names.php
389 lines
1 <?php
2 /**
3 * Months class
4 *
5 * Get month names
6 */
7
8 namespace WPParsidate\Core;
9
10 use WPParsidate\Helper\Cache;
11 use WPParsidate\Settings\Settings;
12
13 class Names {
14 /**
15 * Get Gregorian month names, Months type is persian, dari, kurdish, pashto
16 *
17 * @param string|null $type Type of months name
18 * @param bool $short Return short month names
19 *
20 * @return array|mixed|null
21 */
22 public static function getGregorianMonths( ?string $type = null, bool $short = false ) {
23 if ( is_null( $type ) ) {
24 $type = Settings::get( 'months_name_type', 'persian' );
25 }
26
27 $cacheKey = 'gregorian_months_name_' . $type . ( $short ? '_short' : '' );
28 $cache = Cache::get( $cacheKey, false );
29 if ( is_array( $cache ) ) {
30 return $cache;
31 }
32
33 if ( $type === 'dari' ) {
34 $names = array(
35 '',
36 'جنوری',
37 'فبروری',
38 '�
39 ارچ',
40 'اپریل',
41 '�
42 ی',
43 'جون',
44 'جولای',
45 'آگست',
46 'سپت�
47 بر',
48 'اکتوبر',
49 'نو�
50 بر',
51 'دس�
52 بر'
53 );
54
55 } elseif ( $type === 'kurdish' ) {
56 $names = array(
57 '',
58 'کانوونی دووە�
59 ',
60 'شوبات',
61 'ئازار',
62 'نیسان',
63 'ئایار',
64 'حوزەیران',
65 'تە�
66
67 ووز',
68 'ئاب',
69 'ئەیلوول',
70 'تشرینی یەکە�
71 ',
72 'تشرینی دووە�
73 ',
74 'کانوونی یەکە�
75 '
76 );
77
78 } elseif ( $type === 'pashto' ) {
79 $names = array(
80 '',
81 'جنوري',
82 'فبروري',
83 '�
84 ارچ',
85 'اپرېل',
86 '�
87 ې',
88 'جون',
89 'جولای',
90 'اګست',
91 'سپت�
92 بر',
93 'اکتوبر',
94 'نو�
95 بر',
96 'دس�
97 بر'
98 );
99
100 } else {
101 $names = array(
102 '',
103 'ژانویه',
104 'فوریه',
105 '�
106 ارس',
107 'آوریل',
108 '�
109 ه',
110 'ژوئن',
111 'ژوئیه',
112 'اوت',
113 'سپتا�
114 بر',
115 'اکتبر',
116 'نوا�
117 بر',
118 'دسا�
119 بر'
120 );
121 }
122
123 if ( $short ) {
124 $names = array_map(
125 static fn( $name ) => mb_substr( $name, 0, 3 ),
126 $names
127 );
128 }
129
130 $names = apply_filters( 'wp_parsidate_name_of_gregorian_months', $names, $type, $short );
131 Cache::set( $cacheKey, $names );
132
133 return $names;
134 }
135
136 /**
137 * Get month names, Months type is persian, dari, kurdish, pashto
138 *
139 * @param string|null $type Type of months name
140 *
141 * @return array|mixed|null
142 */
143 public static function getMonths( ?string $type = null ) {
144 if ( is_null( $type ) ) {
145 $type = Settings::get( 'months_name_type', 'persian' );
146 }
147
148 $cache = Cache::get( 'months_name_' . $type, false );
149 if ( is_array( $cache ) ) {
150 return $cache;
151 }
152
153 if ( $type === 'dari' ) {
154 $names = array(
155 '',
156 'ح�
157 ل',
158 'ثور',
159 'جوزا',
160 'سرطان',
161 'اسد',
162 'سنبله',
163 '�
164 یزان',
165 'عقرب',
166 'قوس',
167 'جدی',
168 'دلو',
169 'حوت'
170 );
171
172 } elseif ( $type === 'kurdish' ) {
173 $names = array(
174 '',
175 'خاکەلێوە',
176 'گوڵان',
177 'جۆزەردان',
178 'پووشپەڕ',
179 'گەلاوێژ',
180 'خەر�
181 انان',
182 'ڕەزبەر',
183 'گەڵاڕێزان',
184 'سەر�
185 اوەز',
186 'بەفرانبار',
187 'ڕێبەندان',
188 'ڕەشە�
189 ە'
190 );
191
192 } elseif ( $type === 'pashto' ) {
193 $names = array(
194 '',
195 'وری',
196 'غويی',
197 'غبرګولی',
198 'چنګاښ',
199 'ز�
200 ری',
201 'وږی',
202 'تله',
203 'لړ�
204 ',
205 'ليندۍ',
206 '�
207 رغو�
208 ی',
209 'سلواغه',
210 'كب'
211 );
212
213 } else {
214 $names = array(
215 '',
216 'فروردین',
217 'اردیبهشت',
218 'خرداد',
219 'تیر',
220 '�
221 رداد',
222 'شهریور',
223 '�
224 هر',
225 'آبان',
226 'آذر',
227 'دی',
228 'به�
229 ن',
230 'اسفند'
231 );
232 }
233
234 $names = apply_filters( 'wp_parsidate_name_of_months', $names, $type );
235 Cache::set( 'months_name_' . $type, $names );
236
237 return $names;
238 }
239
240 /**
241 * Get week day names, Week day type is persian, dari, kurdish, pashto
242 *
243 * @param string|null $type Type of week day name
244 *
245 * @return array|mixed|null
246 */
247 public static function getWeekDays( ?string $type = null ) {
248 if ( is_null( $type ) ) {
249 $type = Settings::get( 'months_name_type', 'persian' );
250 }
251
252 $cache = Cache::get( 'week_day_names_' . $type, false );
253 if ( is_array( $cache ) ) {
254 return $cache;
255 }
256
257 if ( $type === 'kurdish' ) {
258 $names = array(
259 'یه‌ش�
260 ه',
261 'دوشَ�
262 ه',
263 'سه‌ش�
264 ه',
265 'چوارش�
266 ه',
267 'پنش�
268 ه',
269 'جــِـ�
270 َه',
271 'شَ�
272 َه',
273 );
274
275 } elseif ( $type === 'pashto' ) {
276 $names = array(
277 'یونۍ',
278 'دونۍ',
279 'درېنۍ',
280 '�
281 لورنۍ',
282 'پنځنۍ',
283 'ج�
284 عه',
285 'خالي',
286 );
287
288 } else {
289 // Persian and Dari is equal names
290 $names = array(
291 'یکشنبه',
292 'دوشنبه',
293 'سه‌شنبه',
294 'چهارشنبه',
295 'پنجشنبه',
296 'ج�
297 عه',
298 'شنبه'
299 );
300 }
301
302 $names = apply_filters( 'wp_parsidate_name_of_week_days', $names, $type );
303 Cache::set( 'week_day_names_' . $type, $names );
304
305 return $names;
306 }
307
308 /**
309 * Get Gregorian week day names, Week day type is persian, dari, kurdish, pashto
310 *
311 * @param string|null $type Type of week day name
312 * @param bool $short Return short week day names
313 *
314 * @return array|mixed|null
315 */
316 public static function getGregorianWeekDays( ?string $type = null, bool $short = false ) {
317 if ( is_null( $type ) ) {
318 $type = Settings::get( 'months_name_type', 'persian' );
319 }
320
321 $cacheKey = 'gregorian_week_day_names_' . $type . ( $short ? '_short' : '' );
322 $cache = Cache::get( $cacheKey, false );
323 if ( is_array( $cache ) ) {
324 return $cache;
325 }
326
327 if ( $type === 'kurdish' ) {
328 $names = array(
329 'یەکشە�
330
331 ە',
332 'دووشە�
333
334 ە',
335 'سێشە�
336
337 ە',
338 'چوارشە�
339
340 ە',
341 'پێنجشە�
342
343 ە',
344 'هەینی',
345 'شە�
346
347 ە',
348 );
349
350 } elseif ( $type === 'pashto' ) {
351 $names = array(
352 'یکشنبه',
353 'دوشنبه',
354 'سې شنبه',
355 'چهارشنبه',
356 'پنجشنبه',
357 'ج�
358 عه',
359 'شنبه',
360 );
361
362 } else {
363 // Persian and Dari is equal names
364 $names = array(
365 'یکشنبه',
366 'دوشنبه',
367 'سه‌شنبه',
368 'چهارشنبه',
369 'پنجشنبه',
370 'ج�
371 عه',
372 'شنبه'
373 );
374 }
375
376 if ( $short ) {
377 $names = array_map(
378 static fn( $name ) => mb_substr( $name, 0, 2 ),
379 $names
380 );
381 }
382
383 $names = apply_filters( 'wp_parsidate_name_of_gregorian_week_days', $names, $type, $short );
384 Cache::set( $cacheKey, $names );
385
386 return $names;
387 }
388 }
389