<?php
/**
 * @package WordPress
 * @subpackage Campoal
 */

global $campoal_options;

// Check user is logged in and redirect to user page
$login_referer = isset($_GET['referer']) ? $_GET['referer'] : '';

$recaptcha_login = isset($campoal_options['conikal_google_recaptcha_login_field']) ? $campoal_options['conikal_google_recaptcha_login_field'] : 1;
$remember_login = isset($campoal_options['conikal_remember_login_field']) ? $campoal_options['conikal_remember_login_field'] : 'all';

$login_page = isset($campoal_options['conikal_page_login_field']) ? $campoal_options['conikal_page_login_field'] : 0;
$login_page = get_permalink($login_page);
$login_page_link = $login_page ? $login_page : '';
$forgot_pass_link = $login_page ? add_query_arg(array('action' => 'forgot'), $login_page_link) : '';
$reset_pass_link = $login_page ? add_query_arg(array('action' => 'reset'), $login_page_link) : '';
?>


<h2 class="ui centered header"><?php esc_html_e('Sign In', 'campoal') ?></h2>
<div class="respon-message" id="signinMessage"></div>
<form class="ui form" id="userLoginForm">
    <div class="required field">
        <label><?php esc_html_e('Email', 'campoal') ?></label>
        <div class="ui right icon large input">
            <input type="text" name="usernameSignin" id="usernameSignin" placeholder="<?php esc_attr_e('Username', 'campoal') ?>">
            <i class="user icon"></i>
        </div>
    </div>
    <div class="required field">
        <label><?php esc_html_e('Password', 'campoal') ?></label>
        <div class="ui right icon large input">
            <input type="password" name="passwordSignin" id="passwordSignin" placeholder="<?php esc_attr_e('Password', 'campoal') ?>">
            <i class="toggle-password eye link icon"></i>
        </div>
    </div>
    <?php if (conikal_show_google_reCaptcha() && $recaptcha_login) { ?>
        <?php get_template_part('templates/google', 'recaptcha'); ?>
    <?php } ?>
    <?php wp_nonce_field('signin_ajax_nonce', 'securitySignin', true); ?>
    <?php wp_referer_field(); ?>
    <input type="hidden" name="signSignin" id="signSignin" value="">
    <input type="hidden" name="refererID" id="refererID" value="<?php echo esc_attr( $login_referer ) ?>">
    <div class="inline field">
        <div class="ui toggle <?php echo esc_attr(in_array($remember_login, array('all', 'login')) ? 'checked ' : '') ?>checkbox">
            <input type="checkbox" name="rememberme" id="rememberSignin" class="hidden" <?php echo esc_attr(in_array($remember_login, array('all', 'login')) ? 'checked' : '') ?>>
            <label><?php esc_html_e('Remember me', 'campoal') ?></label>
        </div>
    </div>
    <div class="field">
        <div class="ui grid">
            <div class="nine wide column">
                <a href="#" class="ui primary large button" id="submitSignin"><?php esc_html_e('Sign In', 'campoal') ?></a>
            </div>
            <div class="seven wide right aligned column">
                <a href="<?php echo esc_url($forgot_pass_link) ?>" class="forgot-password" id="forgotPass"><?php esc_html_e('Forgot password?', 'campoal') ?></a>
            </div> 
        </div>
    </div>
</form>