<?php 

function login_cb() {
    $landing_page = ($option = get_option("landing_page")) ? $option : "dashboard";
	$login_user = ($option = get_option("login_user")) ? $option : "Email";
	$login_pass = ($option = get_option("login_pass")) ? $option : "Password";
	$login_btn_text = ($option = get_option("login_btn_text")) ? $option : "Login <i class=\"fas fa-sign-in-alt\"></i>";
    $option = get_option("home_url");
    $redirect = ($option && $option !== "") ? $option : $landing_page;
    if(isset($_GET['redirect'])) {
        if($redirect === $landing_page) {
            $redirect .= ($_GET['redirect'] === "") ? "" : $_GET['redirect'];
            unset($_GET['redirect']);
            if (_count($_GET)) {
                $redirect .= "?".http_build_query($_GET);
            }
        } else {
            $redirect .= ($_GET['redirect'] === "") ? $landing_page : $_GET['redirect'];
            unset($_GET['redirect']);
            if (_count($_GET)) {
                $redirect .= "?".http_build_query($_GET);
            }
        }
        
    } else {
        if($redirect !== $landing_page) {
            $redirect .= $landing_page;
        }
    }
	?>
	<form class="login" method="post" id="login-form" action="app/includes/ajax.php" data-redirect="<?php echo $redirect; ?>" data-clearform="1" data-callback="redirectLogin">
        <?php 
        	input(['label' => $login_user, 'id' => 'email']);
        	input(['label' => $login_pass, 'id' => 'password', 'type' => 'password']);
        	input(['label' => '<small>Remember Me</small>', 'id' => 'remember_me', 'type' => 'checkbox']);
        	alert();
        	submit_btn('login', $login_btn_text);
         ?>
         <label class="pull-right">
            Forgot Password?
            <a href="<?php echo FORGOT_PASS_PAGE ?>">Click Here</a>
            <?php do_action("login_page_links"); ?>
        </label>
    </form>
	<?php
	global $post_meta;
	add_page_javascript('app/assets/js/page-scripts/submit.js');
	add_page_javascript('app/assets/js/page-scripts/js-functions.js');
}