kompass/components/partials/radio-option.php

36 lines
1.4 KiB
PHP
Raw Normal View History

2024-02-26 14:47:51 +01:00
<?php
function kompass_print_radio(string $settingName) {
$currentSetting = get_option($settingName, '');
2024-02-26 14:47:51 +01:00
$options = [
'kompass_limit_login_client_type' => [
'REMOTE_ADDR' => __('Direct connection', BDP_LV_PLUGIN_SLUG),
'HTTP_X_FORWARDED_FOR' => __('Behind a proxy', BDP_LV_PLUGIN_SLUG)
2024-02-26 14:47:51 +01:00
],
'kompass_limit_login_cookies' => [
true => __('Yes', BDP_LV_PLUGIN_SLUG),
false => __('No', BDP_LV_PLUGIN_SLUG)
2024-02-26 14:47:51 +01:00
],
'kompass_password_minimal_strength' => [
'1' => __('Allow all password strengths', BDP_LV_PLUGIN_SLUG),
'2' => __('At least passwords with medium strength', BDP_LV_PLUGIN_SLUG),
'3' => __('Only allow strong passwords', BDP_LV_PLUGIN_SLUG)
2024-02-26 14:47:51 +01:00
]
];
if(!isset($options[$settingName])) {
return;
}
$setting = $options[$settingName];
foreach ($setting as $radioOption => $optionText) {
$isChecked = $currentSetting == $radioOption ? 'checked ' : '' ;
echo '<input
' . $isChecked .
' type="radio"
name="' . $settingName . '"
value="' . $radioOption . '"
id="setting_' . $settingName . '_' . $radioOption . '" />' .
'<label for="setting_' . $settingName . '_' . $radioOption . '">' . $optionText . '</label><br />';
2024-02-26 14:47:51 +01:00
}
}