<?php

defined( 'ABSPATH' ) || exit;

$login_form_args = [
        'echo'           => false,
        'label_username' => esc_html__( 'Username or Email', 'integrate-google-drive-premium' ),
        'label_password' => esc_html__( 'Password', 'integrate-google-drive-premium' ),
        'label_remember' => esc_html__( 'Remember Me', 'integrate-google-drive-premium' ),
        'label_log_in'   => esc_html__( 'Log In', 'integrate-google-drive-premium' ),
        'form_id'        => 'igd-login-form',
        'id_username'    => 'igd-user-login',
        'id_password'    => 'igd-user-pass',
        'id_remember'    => 'igd-remember-me',
        'id_submit'      => 'igd-login-submit',
];

$login_form = wp_login_form( $login_form_args );

$title       = esc_html__( 'Login Required!', 'integrate-google-drive-premium' );
$description = esc_html__( 'Please log in to access this module.', 'integrate-google-drive-premium' );

$default_message = sprintf(
        '<h3>%s</h3><p>%s</p>',
        $title,
        $description
);

$login_type    = igd_get_settings( 'loginType', 'form' );
$login_url     = igd_get_settings( 'loginUrl', wp_login_url( $_SERVER['REQUEST_URI'] ) );
$login_message = igd_get_settings( 'loginMessage', $default_message );
?>

<div class="igd-login-screen" data-shortcode_id="<?php echo esc_attr( $this->data['id'] ?? '' ); ?>">

    <?php echo wp_kses_post( $login_message ); ?>

    <?php if ( 'redirect' === $login_type ) : ?>
        <a href="<?php echo esc_url( $login_url ); ?>"
           class="igd-btn btn-primary igd-login-link">
            <?php esc_html_e( 'Login', 'integrate-google-drive-premium' ); ?>
        </a>
    <?php else : ?>
        <?php echo $login_form; ?>
    <?php endif; ?>

    <p class="igd-form-error"></p>
</div>
