<?php

use IGD\Helpers;

defined('ABSPATH') || exit();

$title       = esc_html__( 'This content is password protected', 'integrate-google-drive' );
$description = esc_html__( 'To view it please enter your password below:', 'integrate-google-drive' );
$placeholder = esc_attr__( 'Enter Password', 'integrate-google-drive' );
$button_text = esc_html__( 'Unlock', 'integrate-google-drive' );

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

$password_message = Helpers::get_settings( 'passwordProtectedMessage', $default_message );
$spinner_url      = includes_url( 'images/wpspin.gif' );
$shortcode_id     = esc_attr( $this->data['id'] ?? '' );

?>

<div class="igd-password-protected igd-shortcode-wrap">

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

	<form id="igd-password-form"
	      class="igd-password-form"
	      method="post">

		<input type="hidden"
		       name="shortcode_id"
		       value="<?php echo $shortcode_id; ?>">

		<input type="password"
		       name="password"
		       required
		       placeholder="<?php echo esc_attr( $placeholder ); ?>">

		<button type="submit">
			<img src="<?php echo esc_url( $spinner_url ); ?>"
			     width="20"
			     height="20"
			     alt=""
			     aria-hidden="true">

            <i class="dashicons dashicons-unlock" aria-hidden="true"></i>
			<?php echo esc_html( $button_text ); ?>
		</button>

	</form>

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