<?php 
$site_unique_token = '';
$unique_identity_key = 'st_site-unique-identity';
// Get the value of the option
$unique_identity_value = get_option($unique_identity_key, false);
if( $unique_identity_value !== false ) {
    $site_unique_token = $unique_identity_value;
}

# 1.) license key for proqyz - metakeys
global 
	$ST_OPTION_st_proqyz__license_key, 
	$ST_OPTION_st_proqyz__enable_key,
	$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;

# 2.)(optional for save post)
if(isset($_POST['proQuiz_LMS_config']) && !empty($_POST['proQuiz_LMS_config'])) {
    if($_POST['proQuiz_LMS_config'] == 1) {
        
        $api_key = $_POST[$ST_OPTION_st_proqyz__license_key];
        //$api_enable = isset($_POST[$ST_OPTION_st_proqyz__enable_key])? $_POST[$ST_OPTION_st_proqyz__enable_key] : 0;

        update_option($ST_OPTION_st_proqyz__license_key, $api_key);
        // update_option($ST_OPTION_st_proqyz__enable_key, $api_enable);
    
    }
}

# 3.) meta values
$st_proqyz_license_key  = "";
$st_proqyz_enable       = 1;

$st_proqyz_license_key  = get_option($ST_OPTION_st_proqyz__license_key,$st_proqyz_license_key);
$st_proqyz_enable       = get_option($ST_OPTION_st_proqyz__enable_key,$st_proqyz_enable);


?>
<style>
    body {
        background: #f0f0f1;
        color: #3c434a;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
        font-size: 13px;
        line-height: 1.4em;
        min-width: 600px;
    }

    h2, h3 {
        color: #1d2327;
        font-size: 1.3em;
        margin: 1em 0;
    }
    h1, h2, h3, h4, h5, h6 {
        display: block;
        font-weight: 600;
    }
    
    .notice { display:none; }
</style>
<div class="wrap proqyz_license-key">
    <div class="general_tab">
        <h2>ProQyz License key</h2>
        <p>Connect ProQyz to your Domain (website)</p>
        <table class="form-table">
            <tbody>
                <tr valign="top">
                    <th scope="row" class="titledesc">
                    <label for="woocommerce_maxmind_geolocation_license_key">Your unique Domain key</label>
                    </th>
                    <td class="forminp">
                    <fieldset>
                        <legend class="screen-reader-text">
                            <span>Domain Key </span>
                        </legend>
                        <div class="input-group">
                            <input 
                                class="regular-input form-control" 
                                type="password" 
                                name="st-site-unique-token" 
                                id="st-site-unique-token" 
                                style="width:100%;background:#ffffff;" 
                                value="<?php echo $site_unique_token; ?>" 
                                placeholder="Your unique Domain key"
                                readonly
                                />
                            <span class="input-group-btn">
                            <button 
                                class="btn btn-default" 
                                data-st-type="copy-to-clipboard" 
                                data-st-copy-target="#st-site-unique-token" 
                                type="button"
                                >Copy to Clipboard</button>
                            </span>
                        </div>
                        <p class="description">Paste domain key in ProQyz domain section to connect your domain.</p>
                    </fieldset>
                    </td>
                </tr>
            </tbody>
        </table>
        <form method="post" id="mainform" action="" enctype="multipart/form-data">
            <table class="form-table">
                <tbody>
                    <tr valign="top">
                    <th scope="row" class="titledesc">
                        <label for="woocommerce_maxmind_geolocation_license_key">
                        ProQyz License Key
                        </label>
                    </th>
                    <td class="forminp">
                        <fieldset>
                            <legend class="screen-reader-text">
                                <span>ProQuiz LMS License key</span>
                            </legend>
                            <div class="form-field">
                                <input 
                                    class="regular-input form-control" 
                                    type="password" 
                                    name="<?php echo $ST_OPTION_st_proqyz__license_key; ?>" 
                                    id="<?php echo $ST_OPTION_st_proqyz__license_key; ?>" 
                                    style="width:100%;" 
                                    value="<?php echo $st_proqyz_license_key; ?>" 
                                    placeholder="Enter ProQyz License key. Click here."
                                />
                            </div>
                            <div class="">
                            </div>
                        </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" name="proQuiz_LMS_config" value="1" />
            </p>
        </form>
    </div>
</div>