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