kompass/components/partials/checkbox-option.php

29 lines
943 B
PHP
Raw Normal View History

2024-02-26 14:47:51 +01:00
<?php
function kompass_print_checkbox(string $settingName) {
2024-02-26 14:47:51 +01:00
$currentSetting = get_option($settingName, []);
if (!is_array($currentSetting)) {
$currentSetting = [$currentSetting];
}
2024-02-26 14:47:51 +01:00
$options = ['kompass_limit_login_lockout_notify' => [
'email' => __('E-Mail to site admin', 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 = in_array($radioOption, $currentSetting) ? 'checked ' : '' ;
2024-02-26 14:47:51 +01:00
echo '<input ' .
$isChecked .
'type="checkbox"
name="' . $settingName . '[]"
value="' . $radioOption . '"
id="setting_' . $settingName . '_' . $radioOption . '" />' .
'<label for="setting_' . $settingName . '_' . $radioOption . '">' . $optionText . '</label><br />';
}
}