36 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?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 />';
 | 
						|
    }
 | 
						|
}
 |