<?php 
/**
 * page: Login settings
 */
global 
	$ST_OPTION_st_proqyz__license_key, 
	$ST_OPTION_st_proqyz__enable,
	$ST_OPTION_st_proqyz__auth_redirect_enable_key,
	$ST_OPTION_st_proqyz__auth_signup_url_key,
	$ST_OPTION_st_proqyz__auth_signin_url_key,
	$ST_OPTION_st_proqyz__auth_ielts_account_complete;


if(isset($_POST['st-pro-quiz__settings-authorization-save']) && !empty($_POST['st-pro-quiz__settings-authorization-save'])){
    if($_POST['st-pro-quiz__settings-authorization-save'] == "1"){
        
        $enable_auth_redirect       = isset($_POST[$ST_OPTION_st_proqyz__auth_redirect_enable_key])? $_POST[$ST_OPTION_st_proqyz__auth_redirect_enable_key] : 0;
        $auth_signin_url            = isset($_POST[$ST_OPTION_st_proqyz__auth_signin_url_key])? $_POST[$ST_OPTION_st_proqyz__auth_signin_url_key] : "/wp-login.php";
        $auth_signup_url            = isset($_POST[$ST_OPTION_st_proqyz__auth_signup_url_key])? $_POST[$ST_OPTION_st_proqyz__auth_signup_url_key] : "/wp-login.php";
        $ielts_redirect             = isset($_POST[$ST_OPTION_st_proqyz__auth_ielts_account_complete])? $_POST[$ST_OPTION_st_proqyz__auth_ielts_account_complete] : 0;


        update_option($ST_OPTION_st_proqyz__auth_redirect_enable_key,$enable_auth_redirect);
        update_option($ST_OPTION_st_proqyz__auth_signin_url_key,$auth_signin_url);
        update_option($ST_OPTION_st_proqyz__auth_signup_url_key,$auth_signup_url);
        update_option($ST_OPTION_st_proqyz__auth_ielts_account_complete,$ielts_redirect);

    }
}

$enable_auth_redirect   = get_option($ST_OPTION_st_proqyz__auth_redirect_enable_key,0);
$auth_signin_url        = get_option($ST_OPTION_st_proqyz__auth_signin_url_key,"/wp-login.php");
$auth_signup_url        = get_option($ST_OPTION_st_proqyz__auth_signup_url_key,"/wp-login.php");
$ielts_redirect         = get_option($ST_OPTION_st_proqyz__auth_ielts_account_complete,0);

?>
<style>.notice { display:none; }</style>
<div class="wrap proqyz_login-settings">
    <h2>Login Settings </h2>


    <form method="POST">
        <table class="form-table">
            <tbody>
                
                <tr class="">
                    <th scope="row" class="titledesc">
                        <label for="st-pro-quiz__auth-login-url">
                            Login Page
                            <span class="woocommerce-help-tip" tabindex="0" aria-label="Login page url">
                            
                            </span>
                        </label>
                    </th>
                    <td class="forminp forminp-text">
                        <input 
                            name="<?php echo $ST_OPTION_st_proqyz__auth_signin_url_key; ?>" 
                            id="st-pro-quiz__auth-signin-url" 
                            type="text" 
                            style="" 
                            value="<?php echo $auth_signin_url; ?>" 
                            class="st-pro-quiz__settings-input" 
                            placeholder="" 
                        /> 	
                        <p class="description">
                            Leave Blank for autodirect (defalt: wp-login.php)
                        </p>						
                    </td>			
                </tr>

                <tr class="">
                    <th scope="row" class="titledesc">
                        <label for="st-pro-quiz__auth-signup-url">
                            Signup Page
                            <span class="woocommerce-help-tip" tabindex="0" aria-label="Login page url">
                            
                            </span>
                        </label>
                    </th>
                    <td class="forminp forminp-text">
                        <input 
                            name="<?php echo $ST_OPTION_st_proqyz__auth_signup_url_key; ?>" 
                            id="st-pro-quiz__auth-signup-url" 
                            type="text" 
                            style="" 
                            value="<?php echo $auth_signup_url; ?>" 
                            class="st-pro-quiz__settings-input" 
                            placeholder="" 
                        /> 
                        <p class="description">
                            Leave Blank for autodirect (defalt: wp-login.php)
                        </p>							
                    </td>			
                </tr>

                <tr class="">
                    <th scope="row" class="titledesc">Enable Redirect</th>
                    <td class="forminp forminp-checkbox ">
                        <fieldset>
                            <legend class="screen-reader-text">
                                <span>Enable Redirect</span>
                            </legend>
                            <label for="st-pro-quiz_auth-redirect-enable">
                                <input 
                                    name="<?php echo $ST_OPTION_st_proqyz__auth_redirect_enable_key; ?>" 
                                    id="st-pro-quiz_auth-redirect-enable" 
                                    type="checkbox" 
                                    class="" 
                                    value="1" 
                                    <?php echo ($enable_auth_redirect == '1')? 'checked' : ''; ?>
                                />	Redirect after login/signup					
                            </label> 
                            <p class="description">
                                This feature automatically redirects users back to the previous page after they signup or login.
                            </p>																
                        </fieldset>
                    </td>
                </tr>

                <tr class="">
                    <th scope="row" class="titledesc">Complete Profile Redirect</th>
                    <td class="forminp forminp-checkbox ">
                        <fieldset>
                            <legend class="screen-reader-text">
                                <span>Complete Profile Redirect</span>
                            </legend>
                            <label for="st-pro-quiz_auth-account-complete-btn">
                                <input 
                                    name="<?php echo $ST_OPTION_st_proqyz__auth_ielts_account_complete; ?>" 
                                    id="st-pro-quiz_auth-account-complete-btn" 
                                    type="checkbox" 
                                    class="" 
                                    value="1" 
                                    <?php echo ($ielts_redirect == '1')? 'checked' : ''; ?>
                                />	Redirect after login/signup					
                            </label> 
                            <p class="description">
                                After signup user will redirect to Account completion page (IELTS)
                            </p>																
                        </fieldset>
                    </td>
                </tr>

            </tbody>
        </table>

        <p class="submit">
            <button name="save" class="button-primary woocommerce-save-button" type="submit" value="Save changes">
                Save changes
            </button>
            <input 
                type="hidden" 
                id="st-pro-quiz__settings-authorization-save" 
                name="st-pro-quiz__settings-authorization-save" 
                value="1" 
            />		
        </p>
    </form>

</div>
