PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Helpers/global/field.php +0 -988 trunk → 11.1.1 View file →
@@ -1,988 +1,0 @@
1 -<?php
2 -defined('ABSPATH') || die('Restricted Access');
3 -
4 -use AcyMailing\Helpers\SecurityHelper;
5 -
6 -/**
7 - * @param ?mixed $selected
8 - */
9 -function acym_radio(
10 - array $options,
11 - string $name,
12 - $selected = null,
13 - array $attributes = [],
14 - array $params = [],
15 - bool $frontDisplay = false,
16 - array $disabledOptions = []
17 -): void {
18 - $id = preg_replace(
19 - '#[^a-zA-Z0-9_]+#mi',
20 - '_',
21 - str_replace(
22 - ['[', ']'],
23 - ['_', ''],
24 - empty($params['id']) ? $name : $params['id']
25 - )
26 - );
27 -
28 - $objValue = empty($params['objectValue']) ? 'value' : $params['objectValue'];
29 - $objText = empty($params['objectText']) ? 'text' : $params['objectText'];
30 -
31 - $attributes['type'] = 'radio';
32 - $attributes['name'] = $name;
33 - if (empty($params['containerClass'])) {
34 - $params['containerClass'] = '';
35 - }
36 -
37 - echo '<div class="acym_radio_group '.esc_attr($params['containerClass']).'">';
38 - $k = 0;
39 - foreach ($options as $value => $label) {
40 - $currentAttributes = $attributes;
41 - $currentAttributes['class'] = '';
42 - unset($currentAttributes['related']);
43 -
44 - if (is_object($label)) {
45 - if (!empty($label->class)) {
46 - $currentAttributes['class'] = $label->class;
47 - }
48 -
49 - $value = $label->$objValue;
50 - $label = $label->$objText;
51 - }
52 -
53 - $currentId = empty($params['useIncrement']) ? $id.$value : $id.$k;
54 -
55 - $currentAttributes['value'] = $value;
56 - $currentAttributes['id'] = $currentId;
57 -
58 - if (isset($attributes['related'][$value])) {
59 - $currentAttributes['acym-data-related'] = $attributes['related'][$value];
60 - }
61 -
62 - $extraClass = '';
63 - if (!empty($disabledOptions[$value])) {
64 - $currentAttributes['disabled'] = 'disabled';
65 - $extraClass = ' '.$disabledOptions[$value]['disabledClass'];
66 - $currentAttributes['class'] .= $extraClass;
67 - }
68 -
69 - if (!empty($params['required'])) {
70 - $currentAttributes['required'] = 'required';
71 - unset($params['required']);
72 - }
73 -
74 - if (!empty($disabledOptions[$value]['tooltipTxt'])) {
75 - ob_start();
76 - }
77 -
78 - if (!$frontDisplay) {
79 - echo '<i data-radio="'.esc_attr($currentId).'" class="acymicon-radio-button-checked acym_radio_checked'.esc_attr($extraClass).'"></i>';
80 - echo '<i data-radio="'.esc_attr($currentId).'" class="acymicon-radio-button-unchecked acym_radio_unchecked'.esc_attr($extraClass).'"></i>';
81 - }
82 -
83 - echo '<input ';
84 - checked((string)$value === (string)$selected);
85 - foreach ($currentAttributes as $oneAttribute => $oneValue) {
86 - if (is_array($oneValue) || is_object($oneValue)) {
87 - $oneValue = json_encode($oneValue);
88 - } elseif ($oneValue === true) {
89 - $oneValue = $oneAttribute;
90 - }
91 -
92 - echo ' '.esc_attr($oneAttribute).'="'.esc_attr($oneValue).'"';
93 - }
94 - echo ' />';
95 -
96 - echo '<label for="'.esc_attr($currentId).'" id="'.esc_attr($currentId).'-lbl" class="'.esc_attr($extraClass).'">';
97 - echo wp_kses(
98 - acym_translation($label),
99 - [
100 - 'input' => [
101 - 'type' => true,
102 - 'value' => true,
103 - 'name' => true,
104 - 'placeholder' => true,
105 - ],
106 - ]
107 - );
108 - echo '</label>';
109 -
110 - if (!empty($disabledOptions[$value]['tooltipTxt'])) {
111 - $currentOption = ob_get_clean();
112 - acym_tooltip(
113 - [
114 - 'hoveredText' => $currentOption,
115 - 'textShownInTooltip' => $disabledOptions[$value]['tooltipTxt'],
116 - ]
117 - );
118 - }
119 -
120 - if (!empty($params['pluginMode'])) {
121 - echo '<br />';
122 - }
123 - $k++;
124 - }
125 - echo '</div>';
126 -}
127 -
128 -function acym_boolean(
129 - string $name,
130 - bool $selected = false,
131 - ?string $id = null,
132 - array $attributes = [],
133 - string $yes = 'ACYM_YES',
134 - string $no = 'ACYM_NO'
135 -): void {
136 - $options = [
137 - '1' => acym_translation($yes),
138 - '0' => acym_translation($no),
139 - ];
140 -
141 - $params = ['id' => $id];
142 - if (!empty($attributes['containerClass'])) {
143 - $params['containerClass'] = $attributes['containerClass'];
144 - unset($attributes['containerClass']);
145 - }
146 -
147 - acym_radio(
148 - $options,
149 - $name,
150 - $selected ? 1 : 0,
151 - $attributes,
152 - $params,
153 - !acym_isAdmin()
154 - );
155 -}
156 -
157 -/**
158 - * @param ?mixed $selected
159 - */
160 -function acym_select(
161 - array $data,
162 - string $name,
163 - $selected = null,
164 - ?array $attribs = null,
165 - string $optKey = 'value',
166 - string $optText = 'text',
167 - ?string $idtag = null,
168 - bool $translate = false,
169 - bool $display = false
170 -): string {
171 - if (empty($attribs)) {
172 - $attribs = [];
173 - }
174 -
175 - $attribs['name'] = $name;
176 - $attribs['id'] = str_replace(['[', ']', ' '], '', empty($idtag) ? $name : $idtag);
177 -
178 - if (!$display) {
179 - ob_start();
180 - }
181 -
182 - echo '<select ';
183 - foreach ($attribs as $oneAttribute => $oneValue) {
184 - if (is_array($oneValue) || is_object($oneValue)) {
185 - $oneValue = json_encode($oneValue);
186 - } elseif ($oneValue === true) {
187 - $oneValue = $oneAttribute;
188 - }
189 -
190 - echo ' '.esc_attr($oneAttribute).'="'.esc_attr($oneValue).'"';
191 - }
192 - echo '>';
193 -
194 - foreach ($data as $key => $oneOption) {
195 - $disabled = false;
196 - if (is_object($oneOption)) {
197 - $value = $oneOption->$optKey;
198 - $text = $oneOption->$optText;
199 - if (isset($oneOption->disable)) {
200 - $disabled = $oneOption->disable;
201 - }
202 - } else {
203 - $value = $key;
204 - $text = $oneOption;
205 - }
206 -
207 - $value = (string)$value;
208 - $text = (string)$text;
209 -
210 - if ($translate) {
211 - $text = acym_translation($text);
212 - }
213 -
214 - if (strtolower($value) === '<optgroup>') {
215 - echo '<optgroup label="'.esc_attr($text).'">';
216 - } elseif (strtolower($value) === '</optgroup>') {
217 - echo '</optgroup>';
218 - } else {
219 - echo '<option value="'.esc_attr($value).'"';
220 - selected(strval($value) === strval($selected));
221 - disabled($disabled);
222 - echo '>'.esc_html($text).'</option>';
223 - }
224 - }
225 -
226 - echo '</select>';
227 -
228 - if (!$display) {
229 - return ob_get_clean();
230 - }
231 -
232 - return '';
233 -}
234 -
235 -function acym_selectMultiple(
236 - array $data,
237 - string $name,
238 - array $selected = [],
239 - array $attribs = [],
240 - string $optValue = 'value',
241 - string $optText = 'text',
242 - bool $display = false
243 -): string {
244 - if (substr($name, -2) !== '[]') {
245 - $name .= '[]';
246 - }
247 - $baseName = substr($name, 0, -2);
248 -
249 - $attribs['name'] = $name;
250 - $attribs['multiple'] = 'multiple';
251 -
252 - if (!$display) {
253 - ob_start();
254 - }
255 -
256 - echo '<input type="hidden" name="'.esc_attr($baseName).'" value="">';
257 - echo '<select ';
258 - foreach ($attribs as $oneAttribute => $oneValue) {
259 - if (is_array($oneValue) || is_object($oneValue)) {
260 - $oneValue = json_encode($oneValue);
261 - } elseif ($oneValue === true) {
262 - $oneValue = $oneAttribute;
263 - }
264 -
265 - echo ' '.esc_attr($oneAttribute).'="'.esc_attr($oneValue).'"';
266 - }
267 - echo '>';
268 -
269 - foreach ($data as $oneDataKey => $oneDataValue) {
270 - if (is_object($oneDataValue)) {
271 - $value = $oneDataValue->$optValue;
272 - $text = $oneDataValue->$optText;
273 - } else {
274 - $value = $oneDataKey;
275 - $text = $oneDataValue;
276 - }
277 -
278 - $value = (string)$value;
279 - $text = (string)$text;
280 -
281 - if (strtolower($value) === '<optgroup>') {
282 - echo '<optgroup label="'.esc_attr($text).'">';
283 - } elseif (strtolower($value) === '</optgroup>') {
284 - echo '</optgroup>';
285 - } else {
286 - echo '<option value="'.esc_attr($value).'"';
287 - selected(in_array($value, $selected));
288 - disabled(is_object($oneDataValue) && !empty($oneDataValue->disable));
289 - echo '>'.esc_html($text).'</option>';
290 - }
291 - }
292 -
293 - echo '</select>';
294 -
295 - if (!$display) {
296 - return ob_get_clean();
297 - }
298 -
299 - return '';
300 -}
301 -
302 -/**
303 - * @param mixed $value
304 - */
305 -function acym_selectOption(
306 - $value,
307 - string $text = '',
308 - string $optKey = 'value',
309 - string $optText = 'text',
310 - bool $disable = false
311 -): object {
312 - $option = new stdClass();
313 - $option->$optKey = $value;
314 - $option->$optText = acym_translation($text);
315 - $option->disable = $disable;
316 -
317 - return $option;
318 -}
319 -
320 -/**
321 - * @param string|array $options The string name or the new options in an array
322 - * @param mixed $value
323 - */
324 -function acym_switch(
325 - $options,
326 - $value = '',
327 - ?string $label = null,
328 - array $attrInput = [],
329 - string $labelClass = 'medium-6 small-9',
330 - string $switchContainerClass = 'auto',
331 - string $switchClass = '',
332 - ?string $toggle = null
333 -): void {
334 - static $occurrence = 100;
335 - $occurrence++;
336 -
337 - // A switch displayed in a filter or a condition is cloned for every row
338 - $id = (is_array($options) && !empty($options['idPrefix']) ? $options['idPrefix'] : '').'switch_'.$occurrence;
339 -
340 - //TODO remove old parameters in January 2027 (only used in WC, Hika, VM and ultimate member plugins, which were updated in July 2026
341 - if (!is_array($options)) {
342 - $options = [
343 - 'name' => $options,
344 - 'value' => $value,
345 - 'label' => $label,
346 - 'attributes' => $attrInput,
347 - 'labelClass' => $labelClass,
348 - 'switchContainerClass' => $switchContainerClass,
349 - 'switchClass' => $switchClass,
350 - 'toggle' => $toggle,
351 - 'toggleOpen' => true,
352 - 'disabled' => false,
353 - ];
354 - } else {
355 - $options['attributes'] = $options['attributes'] ?? [];
356 - $options['labelClass'] = $options['labelClass'] ?? 'medium-6 small-9';
357 - $options['switchContainerClass'] = $options['switchContainerClass'] ?? 'auto';
358 - $options['switchClass'] = $options['switchClass'] ?? '';
359 - $options['toggleOpen'] = $options['toggleOpen'] ?? true;
360 - $options['disabled'] = $options['disabled'] ?? false;
361 - }
362 -
363 - $checkboxAriaLabel = '';
364 - if (!empty($options['attributes']['aria-label'])) {
365 - $checkboxAriaLabel = $options['attributes']['aria-label'];
366 - unset($options['attributes']['aria-label']);
367 - }
368 -
369 - $options['attributes']['name'] = $options['name'];
370 - $options['attributes']['data-switch'] = $id;
371 - $options['attributes']['value'] = $options['value'];
372 -
373 - if (!empty($options['toggle'])) {
374 - $options['attributes']['data-toggle-switch'] = $options['toggle'];
375 - $options['attributes']['data-toggle-switch-open'] = $options['toggleOpen'] ? 'show' : 'hide';
376 - }
377 -
378 - if (!empty($options['label']) || !empty($options['tooltip'])) {
379 - echo '<label for="'.esc_attr($id).'" class="cell '.esc_attr($options['labelClass']).' switch-label">';
380 - if (!empty($options['label'])) {
381 - echo esc_html($options['label']);
382 - }
383 -
384 - if (!empty($options['tooltip'])) {
385 - acym_tooltip($options['tooltip']);
386 - }
387 -
388 - if (!empty($options['tip'])) {
389 - acym_info($options['tip']);
390 - }
391 - echo '</label>';
392 - echo '<div class="cell '.esc_attr($options['switchContainerClass']).'">';
393 - }
394 -
395 - $labelSwitchDisabled = !$options['disabled'] ? '' : ' disabled';
396 - ?>
397 -
398 - <div class="switch <?php echo esc_attr($options['switchClass']); ?>">
399 - <input type="hidden"
400 - <?php
401 - foreach ($options['attributes'] as $oneAttribute => $oneValue) {
402 - if (is_array($oneValue) || is_object($oneValue)) {
403 - $oneValue = json_encode($oneValue);
404 - } elseif ($oneValue === true) {
405 - $oneValue = $oneAttribute;
406 - }
407 -
408 - echo ' '.esc_attr($oneAttribute).'="'.esc_attr($oneValue).'"';
409 - }
410 - ?>
411 - >
412 -
413 - <input class="switch-input"
414 - type="checkbox"
415 - id="<?php echo esc_attr($id); ?>"
416 - value="1"
417 - tabindex="0"
418 - role="switch"
419 - <?php
420 - checked($options['value'] == 1);
421 - disabled($options['disabled']);
422 - if (!empty($checkboxAriaLabel)) {
423 - echo ' aria-label="'.esc_attr($checkboxAriaLabel).'"';
424 - }
425 - ?>
426 - >
427 - <label class="switch-paddle switch-label <?php echo esc_attr($labelSwitchDisabled); ?>" for="<?php echo esc_attr($id); ?>">
428 - <span class="switch-active" aria-hidden="true">1</span>
429 - <span class="switch-inactive" aria-hidden="true">0</span>
430 - </label>
431 - </div>
432 -
433 - <?php
434 - if (!empty($options['label']) || !empty($options['tooltip'])) {
435 - echo '</div>';
436 - }
437 -}
438 -
439 -function acym_showMore(string $toggle, string $text = 'ACYM_SHOW_MORE', string $class = ''): void
440 -{
441 - ?>
442 - <div class="showmore <?php echo esc_attr($class); ?>" data-toggle-showmore="<?php echo esc_attr($toggle); ?>">
443 - <label>
444 - <?php echo esc_html(acym_translation($text)); ?><i class="acymicon-keyboard-arrow-down"></i>
445 - </label>
446 - </div>
447 - <?php
448 -}
449 -
450 -function acym_generateCountryNumber(string $name, string $defaultvalue = ''): void
451 -{
452 - $country = [
453 - '' => acym_translation('ACYM_PHONE_NOCOUNTRY'),
454 - '93' => 'Afghanistan',
455 - '355' => 'Albania',
456 - '213' => 'Algeria',
457 - '1684' => 'American Samoa',
458 - '376' => 'Andorra',
459 - '244' => 'Angola',
460 - '1264' => 'Anguilla',
461 - '672' => 'Antarctica',
462 - '1268' => 'Antigua & Barbuda',
463 - '54' => 'Argentina',
464 - '374' => 'Armenia',
465 - '297' => 'Aruba',
466 - '247' => 'Ascension Island',
467 - '61' => 'Australia',
468 - '43' => 'Austria',
469 - '994' => 'Azerbaijan',
470 - '1242' => 'Bahamas',
471 - '973' => 'Bahrain',
472 - '880' => 'Bangladesh',
473 - '1246' => 'Barbados',
474 - '375' => 'Belarus',
475 - '32' => 'Belgium',
476 - '501' => 'Belize',
477 - '229' => 'Benin',
478 - '1441' => 'Bermuda',
479 - '975' => 'Bhutan',
480 - '591' => 'Bolivia',
481 - '387' => 'Bosnia/Herzegovina',
482 - '267' => 'Botswana',
483 - '55' => 'Brazil',
484 - '1284' => 'British Virgin Islands',
485 - '673' => 'Brunei',
486 - '359' => 'Bulgaria',
487 - '226' => 'Burkina Faso',
488 - '257' => 'Burundi',
489 - '855' => 'Cambodia',
490 - '237' => 'Cameroon',
491 - '1' => 'Canada/USA',
492 - '238' => 'Cape Verde Islands',
493 - '1345' => 'Cayman Islands',
494 - '236' => 'Central African Republic',
495 - '235' => 'Chad Republic',
496 - '56' => 'Chile',
497 - '86' => 'China',
498 - '6724' => 'Christmas Island',
499 - '6722' => 'Cocos Keeling Island',
500 - '57' => 'Colombia',
501 - '269' => 'Comoros',
502 - '243' => 'Congo Democratic Republic',
503 - '242' => 'Congo, Republic of',
504 - '682' => 'Cook Islands',
505 - '506' => 'Costa Rica',
506 - '225' => 'Cote D\'Ivoire',
507 - '385' => 'Croatia',
508 - '53' => 'Cuba',
509 - '357' => 'Cyprus',
510 - '420' => 'Czech Republic',
511 - '45' => 'Denmark',
512 - '253' => 'Djibouti',
513 - '1767' => 'Dominica',
514 - '1809' => 'Dominican Republic',
515 - '593' => 'Ecuador',
516 - '20' => 'Egypt',
517 - '503' => 'El Salvador',
518 - '240' => 'Equatorial Guinea',
519 - '291' => 'Eritrea',
520 - '372' => 'Estonia',
521 - '251' => 'Ethiopia',
522 - '500' => 'Falkland Islands',
523 - '298' => 'Faroe Island',
524 - '679' => 'Fiji Islands',
525 - '358' => 'Finland',
526 - '33' => 'France',
527 - '596' => 'French Antilles/Martinique',
528 - '594' => 'French Guiana',
529 - '689' => 'French Polynesia',
530 - '241' => 'Gabon Republic',
531 - '220' => 'Gambia',
532 - '995' => 'Georgia',
533 - '49' => 'Germany',
534 - '233' => 'Ghana',
535 - '350' => 'Gibraltar',
536 - '30' => 'Greece',
537 - '299' => 'Greenland',
538 - '1473' => 'Grenada',
539 - '590' => 'Guadeloupe',
540 - '1671' => 'Guam',
541 - '502' => 'Guatemala',
542 - '224' => 'Guinea Republic',
543 - '245' => 'Guinea-Bissau',
544 - '592' => 'Guyana',
545 - '509' => 'Haiti',
546 - '504' => 'Honduras',
547 - '852' => 'Hong Kong',
548 - '36' => 'Hungary',
549 - '354' => 'Iceland',
550 - '91' => 'India',
551 - '62' => 'Indonesia',
552 - '964' => 'Iraq',
553 - '98' => 'Iran',
554 - '353' => 'Ireland',
555 - '972' => 'Israel',
556 - '39' => 'Italy',
557 - '1876' => 'Jamaica',
558 - '81' => 'Japan',
559 - '962' => 'Jordan',
560 - '254' => 'Kenya',
561 - '686' => 'Kiribati',
562 - '3774' => 'Kosovo',
563 - '965' => 'Kuwait',
564 - '996' => 'Kyrgyzstan',
565 - '856' => 'Laos',
566 - '371' => 'Latvia',
567 - '961' => 'Lebanon',
568 - '266' => 'Lesotho',
569 - '231' => 'Liberia',
570 - '218' => 'Libya',
571 - '423' => 'Liechtenstein',
572 - '370' => 'Lithuania',
573 - '352' => 'Luxembourg',
574 - '853' => 'Macau',
575 - '389' => 'Macedonia',
576 - '261' => 'Madagascar',
577 - '265' => 'Malawi',
578 - '60' => 'Malaysia',
579 - '960' => 'Maldives',
580 - '223' => 'Mali Republic',
581 - '356' => 'Malta',
582 - '692' => 'Marshall Islands',
583 - '222' => 'Mauritania',
584 - '230' => 'Mauritius',
585 - '52' => 'Mexico',
586 - '691' => 'Micronesia',
587 - '373' => 'Moldova',
588 - '377' => 'Monaco',
589 - '976' => 'Mongolia',
590 - '382' => 'Montenegro',
591 - '1664' => 'Montserrat',
592 - '212' => 'Morocco',
593 - '258' => 'Mozambique',
594 - '95' => 'Myanmar (Burma)',
595 - '264' => 'Namibia',
596 - '674' => 'Nauru',
597 - '977' => 'Nepal',
598 - '31' => 'Netherlands',
599 - '599' => 'Netherlands Antilles',
600 - '687' => 'New Caledonia',
601 - '64' => 'New Zealand',
602 - '505' => 'Nicaragua',
603 - '227' => 'Niger Republic',
604 - '234' => 'Nigeria',
605 - '683' => 'Niue Island',
606 - '6723' => 'Norfolk',
607 - '850' => 'North Korea',
608 - '47' => 'Norway',
609 - '968' => 'Oman Dem Republic',
610 - '92' => 'Pakistan',
611 - '680' => 'Palau Republic',
612 - '970' => 'Palestine',
613 - '507' => 'Panama',
614 - '675' => 'Papua New Guinea',
615 - '595' => 'Paraguay',
616 - '51' => 'Peru',
617 - '63' => 'Philippines',
618 - '48' => 'Poland',
619 - '351' => 'Portugal',
620 - '1787' => 'Puerto Rico',
621 - '974' => 'Qatar',
622 - '262' => 'Reunion Island',
623 - '40' => 'Romania',
624 - '7' => 'Russia',
625 - '250' => 'Rwanda Republic',
626 - '1670' => 'Saipan/Mariannas',
627 - '378' => 'San Marino',
628 - '239' => 'Sao Tome/Principe',
629 - '966' => 'Saudi Arabia',
630 - '221' => 'Senegal',
631 - '381' => 'Serbia',
632 - '248' => 'Seychelles Island',
633 - '232' => 'Sierra Leone',
634 - '65' => 'Singapore',
635 - '421' => 'Slovakia',
636 - '386' => 'Slovenia',
637 - '677' => 'Solomon Islands',
638 - '252' => 'Somalia Republic',
639 - '685' => 'Somoa',
640 - '27' => 'South Africa',
641 - '82' => 'South Korea',
642 - '34' => 'Spain',
643 - '94' => 'Sri Lanka',
644 - '290' => 'St. Helena',
645 - '1869' => 'St. Kitts',
646 - '1758' => 'St. Lucia',
647 - '508' => 'St. Pierre',
648 - '1784' => 'St. Vincent',
649 - '249' => 'Sudan',
650 - '597' => 'Suriname',
651 - '268' => 'Swaziland',
652 - '46' => 'Sweden',
653 - '41' => 'Switzerland',
654 - '963' => 'Syria',
655 - '886' => 'Taiwan',
656 - '992' => 'Tajikistan',
657 - '255' => 'Tanzania',
658 - '66' => 'Thailand',
659 - '228' => 'Togo Republic',
660 - '690' => 'Tokelau',
661 - '676' => 'Tonga Islands',
662 - '1868' => 'Trinidad & Tobago',
663 - '216' => 'Tunisia',
664 - '90' => 'Turkey',
665 - '993' => 'Turkmenistan',
666 - '1649' => 'Turks & Caicos Island',
667 - '688' => 'Tuvalu',
668 - '256' => 'Uganda',
669 - '380' => 'Ukraine',
670 - '971' => 'United Arab Emirates',
671 - '44' => 'United Kingdom',
672 - '598' => 'Uruguay',
673 - '1 ' => 'USA/Canada',
674 - '998' => 'Uzbekistan',
675 - '678' => 'Vanuatu',
676 - '3966' => 'Vatican City',
677 - '58' => 'Venezuela',
678 - '84' => 'Vietnam',
679 - '1340' => 'Virgin Islands (US)',
680 - '681' => 'Wallis/Futuna Islands',
681 - '967' => 'Yemen Arab Republic',
682 - '260' => 'Zambia',
683 - '263' => 'Zimbabwe',
684 - ];
685 -
686 - $countryCodeForSelect = [];
687 -
688 - foreach ($country as $key => $one) {
689 - $countryCodeForSelect[$key] = '+'.$key.' ('.$one.')';
690 - }
691 -
692 - acym_select(
693 - $countryCodeForSelect,
694 - $name,
695 - empty($defaultvalue) ? '' : $defaultvalue,
696 - [
697 - 'class' => 'acym__select__country acym__select',
698 - 'autocomplete' => 'tel-country-code',
699 - 'aria-label' => acym_translation('ACYM_PHONE_COUNTRY_CODE'),
700 - ],
701 - 'value',
702 - 'text',
703 - null,
704 - false,
705 - true
706 - );
707 -}
708 -
709 -function acym_cancelButton(string $text = 'ACYM_CANCEL', string $url = '', string $class = 'button medium-6 large-shrink'): void
710 -{
711 - if (empty($url)) {
712 - $url = acym_completeLink(acym_getVar('cmd', 'ctrl').'&task=listing');
713 - }
714 -
715 - echo '<a href="'.esc_url($url).'" class="cell '.esc_attr($class).' acym__button__cancel">'.esc_html(acym_translation($text)).'</a>';
716 -}
717 -
718 -/**
719 - * Options:
720 - * classContainer => Classes applied on the main container
721 - * hoveredText => Text shown on the page
722 - * classText => Classes applied to the hovered text container
723 - * titleShownInTooltip => Title added above the tooltip text
724 - * textShownInTooltip => Text shown inside the tooltip box
725 - * link => URL to redirect on click to the hovered text
726 - * classLink => Classes applied on the link element if any
727 - */
728 -function acym_tooltip(array $options): void
729 -{
730 - if (!isset($options['classContainer'])) $options['classContainer'] = '';
731 - if (!isset($options['classText'])) $options['classText'] = '';
732 - if (!isset($options['titleShownInTooltip'])) $options['titleShownInTooltip'] = '';
733 - if (!isset($options['textShownInTooltip'])) $options['textShownInTooltip'] = '';
734 - if (!isset($options['hoveredText'])) $options['hoveredText'] = '';
735 - if (!isset($options['classLink'])) $options['classLink'] = '';
736 -
737 - echo '<span class="acym__tooltip '.esc_attr($options['classContainer']).'">';
738 - echo '<span class="acym__tooltip__text '.esc_attr($options['classText']).'">';
739 -
740 - if (!empty($options['titleShownInTooltip'])) {
741 - echo '<span class="acym__tooltip__title">';
742 - }
743 - echo esc_html($options['titleShownInTooltip']);
744 - if (!empty($options['titleShownInTooltip'])) {
745 - echo '</span>';
746 - }
747 -
748 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Text escaped by caller, too many possible inputs.
749 - echo $options['textShownInTooltip'];
750 - echo '</span>';
751 -
752 - if (!empty($options['link'])) {
753 - echo '<a
754 - href="'.esc_url($options['link']).'"
755 - title="'.esc_attr($options['titleShownInTooltip']).'"
756 - target="_blank"
757 - class="'.esc_attr($options['classLink']).'">';
758 - }
759 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Text escaped by caller, too many possible inputs.
760 - echo $options['hoveredText'];
761 - if (!empty($options['link'])) {
762 - echo '</a>';
763 - }
764 - echo '</span>';
765 -}
766 -
767 -/**
768 - * Options:
769 - * textShownInTooltip => Text shown inside the tooltip box
770 - * classContainer => Classes applied on the main container
771 - * classText => Classes applied to the hovered icon container
772 - * classIcon => Classes applied to the hovered icon
773 - * isWarning => Is the tooltip icon should be more visible
774 - * classLink => Classes applied on the link element if any
775 - */
776 -function acym_info(array $options): void
777 -{
778 - if (!isset($options['textShownInTooltip'])) $options['textShownInTooltip'] = '';
779 - if (!isset($options['classContainer'])) $options['classContainer'] = '';
780 - if (!isset($options['classText'])) $options['classText'] = '';
781 - if (!isset($options['classIcon'])) $options['classIcon'] = '';
782 - if (!isset($options['isWarning'])) $options['isWarning'] = false;
783 -
784 - $classWarning = $options['isWarning'] ? 'acym__tooltip__info__warning' : '';
785 -
786 - acym_tooltip(
787 - [
788 - 'hoveredText' => '<span class="acym__tooltip__info__container '.$options['classIcon'].'"><i class="acym__tooltip__info__icon acymicon-info-circle '.esc_attr(
789 - $classWarning
790 - ).'"></i></span>',
791 - 'textShownInTooltip' => acym_translation($options['textShownInTooltip']),
792 - 'classContainer' => 'acym__tooltip__info '.$options['classContainer'],
793 - 'classText' => $options['classText'],
794 - ]
795 - );
796 -}
797 -
798 -function acym_sortBy(array $options, string $listing, string $default = '', string $defaultSortOrdering = 'desc'): void
799 -{
800 - $default = empty($default) ? reset($options) : $default;
801 -
802 - $selected = acym_getVar('string', $listing.'_ordering', $default);
803 - $orderingSortOrder = acym_getVar('string', $listing.'_ordering_sort_order', $defaultSortOrdering);
804 - $classSortOrder = $orderingSortOrder === 'asc' ? 'acymicon-sort-amount-asc' : 'acymicon-sort-amount-desc';
805 -
806 - echo '<span class="acym__color__dark-gray">'.esc_html(acym_translation('ACYM_SORT_BY')).'</span>';
807 - acym_select(
808 - $options,
809 - $listing.'_ordering',
810 - $selected,
811 - [
812 - 'id' => 'acym__listing__ordering',
813 - 'class' => 'acym__select acym__select__sort',
814 - ],
815 - 'value',
816 - 'text',
817 - null,
818 - false,
819 - true
820 - );
821 -
822 - $tooltipText = $orderingSortOrder === 'asc' ? acym_translation('ACYM_SORT_ASC') : acym_translation('ACYM_SORT_DESC');
823 - acym_tooltip(
824 - [
825 - 'hoveredText' => '<i class="'.$classSortOrder.' acym__listing__ordering__sort-order" aria-hidden="true"></i>',
826 - 'textShownInTooltip' => $tooltipText,
827 - ]
828 - );
829 -
830 - echo '<input type="hidden" id="acym__listing__ordering__sort-order--input" name="'.esc_attr($listing).'_ordering_sort_order" value="'.esc_attr($orderingSortOrder).'">';
831 -}
832 -
833 -function acym_checkbox(
834 - array $values,
835 - string $name,
836 - array $selected = [],
837 - string $label = '',
838 - string $parentClass = '',
839 - string $labelClass = '',
840 - array $dataAttr = []
841 -): void {
842 - echo '<div class="'.esc_attr($parentClass).'"><div class="cell acym__label '.esc_attr($labelClass).'">'.esc_html($label).'</div><div class="cell auto grid-x">';
843 - foreach ($values as $key => $value) {
844 - ?>
845 - <label class="cell grid-x margin-top-1">
846 - <input type="checkbox"
847 - name="<?php echo esc_attr($name); ?>"
848 - value="<?php echo esc_attr($key); ?>"
849 - <?php checked(in_array($key, $selected)); ?>
850 - <?php
851 - if (!empty($dataAttr[$key])) {
852 - echo 'data-attr="'.esc_attr($dataAttr[$key]).'"';
853 - }
854 - ?>>
855 - <?php echo wp_kses($value, SecurityHelper::ALLOWED_HTML_CHECKBOX_LABEL); ?>
856 - </label>
857 - <?php
858 - }
859 - echo '</div></div>';
860 -}
861 -
862 -function acym_switchFilter(array $switchOptions, string $selected, string $name, string $addClass = ''): string
863 -{
864 - $return = '<input type="hidden" id="acym__type-template-'.esc_attr($name).'" name="'.esc_attr($name).'" value="'.esc_attr($selected).'">';
865 - foreach ($switchOptions as $value => $text) {
866 - $class = 'button button-secondary acym__type__choosen cell small-6 xlarge-auto large-shrink';
867 - if ($value === $selected) {
868 - $class .= ' is-active';
869 - }
870 - $class .= ' '.$addClass;
871 - $return .= '<button class="'.esc_attr($class).'" type="button" data-type="'.esc_attr($value).'">'.esc_html(acym_translation($text)).'</button>';
872 - }
873 -
874 - return $return;
875 -}
876 -
877 -function acym_filterStatus(array $options, string $selected, string $name): void
878 -{
879 - echo '<input type="hidden" id="acym_filter_status" name="'.esc_attr($name).'" value="'.esc_attr($selected).'"/>';
880 -
881 - foreach ($options as $value => $text) {
882 - ?>
883 - <button type="button"
884 - acym-data-status="<?php echo esc_attr($value); ?>"
885 - class="acym__filter__status<?php echo $value === $selected ? ' font-bold acym__status__select' : ''; ?>"
886 - <?php disabled(!is_null($text[1]) && empty($text[1])); ?>
887 - >
888 - <?php echo esc_html(acym_translation($text[0])); ?>
889 - <?php
890 - if (!empty($text[2]) && 'pending' == $text[2]) {
891 - echo ' <i class="acymicon-exclamation-triangle acym__color__orange" style="font-size: 15px;"></i>';
892 - }
893 -
894 - if (!is_null($text[1])) {
895 - echo '<span class="acym__filter__status__number"> ('.esc_html($text[1]).')</span>';
896 - }
897 - ?>
898 - </button>
899 - <?php
900 - }
901 -}
902 -
903 -function acym_filterSearch(
904 - string $search,
905 - string $name,
906 - string $placeholder = 'ACYM_SEARCH',
907 - bool $showClearBtn = true,
908 - string $additionalClasses = ''
909 -): void {
910 - ?>
911 - <div class="input-group acym__search-area <?php echo esc_attr($additionalClasses); ?>">
912 - <div class="input-group-button">
913 - <button class="button acym__search__button"><i class="acymicon-search"></i></button>
914 - </div>
915 - <input class="input-group-field acym__search-field"
916 - type="text"
917 - name="<?php echo esc_attr($name); ?>"
918 - placeholder="<?php echo esc_attr(acym_translation($placeholder)); ?>"
919 - value="<?php echo esc_attr($search); ?>">
920 - <?php if ($showClearBtn) { ?>
921 - <span class="acym__search-clear"><i class="acymicon-close"></i></span>
922 - <?php } ?>
923 - </div>
924 - <?php
925 -}
926 -
927 -/**
928 - * @param mixed $value
929 - */
930 -function acym_displayParam(string $type, $value, string $name): void
931 -{
932 - if (!include_once ACYM_FRONT.'Params'.DS.$type.'.php') {
933 - return;
934 - }
935 -
936 - $class = 'JFormField'.ucfirst($type);
937 -
938 - $field = new $class();
939 - $field->value = $value;
940 - $field->name = $name;
941 -
942 - echo wp_kses($field->getInput(), SecurityHelper::ALLOWED_HTML_PARAM_FIELD);
943 -}
944 -
945 -function acym_externalLink(
946 - string $text,
947 - string $link,
948 - bool $displayIcon = true,
949 - bool $openInNewTab = true,
950 - array $classesA = []
951 -): void {
952 - $classesA[] = 'acym__external__link';
953 - ?>
954 - <a
955 - href="<?php echo esc_url($link); ?>"
956 - class="<?php echo esc_attr(implode(' ', $classesA)); ?>"
957 - <?php
958 - if ($openInNewTab) {
959 - echo 'target="_blank"';
960 - }
961 - ?>
962 - >
963 - <?php echo esc_html(acym_translation($text)); ?>
964 - <?php
965 - if ($displayIcon) {
966 - echo ' <i class="acymicon-external-link"></i>';
967 - }
968 - ?>
969 - </a>
970 - <?php
971 -}
972 -
973 -function acym_getFormattedAttributes(array $attributes): string
974 -{
975 - $params = '';
976 - foreach ($attributes as $oneAttribute => $oneValue) {
977 - $params .= ' '.$oneAttribute;
978 -
979 - if ($oneValue !== true) {
980 - if (is_array($oneValue) || is_object($oneValue)) {
981 - $oneValue = json_encode($oneValue);
982 - }
983 - $params .= '="'.esc_attr($oneValue).'"';
984 - }
985 - }
986 -
987 - return $params;
988 -}