Support for site verification codes

This commit is contained in:
2024-03-16 14:21:57 +01:00
parent 96e084e353
commit bee1f6c96c
20 changed files with 271 additions and 61 deletions

View File

@ -0,0 +1,28 @@
<?php
function kompass_print_checkbox(string $settingName) {
$currentSetting = get_option($settingName, []);
if (!is_array($currentSetting)) {
$currentSetting = [$currentSetting];
}
$options = ['kompass_limit_login_lockout_notify' => [
'email' => __('E-Mail to site admin', BDP_LV_PLUGIN_SLUG)
],
];
if(!isset($options[$settingName])) {
return;
}
$setting = $options[$settingName];
foreach ($setting as $radioOption => $optionText) {
$isChecked = in_array($radioOption, $currentSetting) ? 'checked ' : '' ;
echo '<input ' .
$isChecked .
'type="checkbox"
name="' . $settingName . '[]"
value="' . $radioOption . '"
id="setting_' . $settingName . '_' . $radioOption . '" />' .
'<label for="setting_' . $settingName . '_' . $radioOption . '">' . $optionText . '</label><br />';
}
}

View File

@ -0,0 +1,35 @@
<?php
function kompass_print_radio(string $settingName) {
$currentSetting = get_option($settingName, '');
$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)
],
'kompass_limit_login_cookies' => [
true => __('Yes', BDP_LV_PLUGIN_SLUG),
false => __('No', BDP_LV_PLUGIN_SLUG)
],
'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)
]
];
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 />';
}
}

View File

@ -0,0 +1,19 @@
<?php
function kompass_print_textbox($settingName, $settingValue, $style = '') {
echo '<input style="' . $style . '" type="text" name="' . $settingName . '" value="' . $settingValue. '" />';
if (defined('WP_DEBUG') && WP_DEBUG == true) {
echo '<br />' . $settingName;
}
}
function _kompass_limit_logins_settings_callback(array $args) {
$setting = get_option($args['setting'], null);
$style = isset($args['style']) ? $args['style'] : '';
$value = esc_attr($setting);
if (isset($args['unit_division'])) {
$value = (int)$value / (int)$args['unit_division'];
}
kompass_print_textbox($args['setting'], $value, $style);
}