<?php 
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals
/**
 * PPWP Lite: Post Tags Protection 
 */
?>

<h2 class="ppw-cat__title"> <?php echo esc_html__('PPWP Lite: Tags Protection','password-protect-page');?></h2>
<form method="post" id="ppwp_protect_tag_form" class="ppw-cat__form">
	<input type="hidden" id="ppw_tag_form_nonce" value="<?php echo esc_attr( wp_create_nonce(PPW_Constants::GENERAL_FORM_NONCE) ); ?>" />
	<div class="form__option-wrapper">
		<span class="form__option-switch-btn">
			<label class="pda_switch ppw-switch__wrapper" for="ppwp_is_protect_tag">
				<input type="checkbox" id="ppwp_is_protect_tag" <?php echo $is_protect ? 'checked' : '' ?> />
				<span class="pda-slider round ppw-switch--btn"></span>
			</label>
		</span>
		<span class="form__option-label">
			<?php echo esc_html__('Password Protect Tags', 'password-protect-page') ?>
		</span>
	</div>
	<p class="form__desc"><?php echo wp_kses_post( sprintf( '<a target="_blank" rel="noreferrer noopener" href="%1$s">%2$s</a> %3$s <a href="%4$s">%5$s</a>.', 'https://passwordprotectwp.com/docs/password-protect-wordpress-tags/?utm_source=user-website&utm_medium=tags-protection&utm_campaign=ppwp-free', __( 'Protect all posts under protected tags', 'password-protect-page' ), __( 'with a single password. Customize the password form using', 'password-protect-page' ), admin_url( 'customize.php?autofocus[panel]=ppwp' ), __( 'WordPress Customizer', 'password-protect-page' ) ) ); ?></p>
	<p class="form__select-wrapper form__input-wrapper">
		<label class="form__label form__label-cats" for="ppwp-cat-select"><?php echo esc_html__('Select your private tags', 'password-protect-page') ?></label>
		<select class="form__select" id="ppwp_protected_tags_selected" multiple="multiple">
			<?php
			foreach ($tags as $tag) {
				$selected = in_array($tag->term_id, $protected_tags) ? 'selected' : '';
				echo '<option ' . esc_attr( $selected ) . ' value="' . esc_attr( $tag->term_id ) . '">' . esc_html( $tag->name ) . '</option>';
			}
			?>
		</select>
		<div id="ppwp_error_protected_tags_selected" style="display: none; color: red; position: absolute; font-size: 12px;"><?php esc_html_e( 'This field is required.', 'password-protect-page' ); ?></div>
	</p>
	<p class="form__input-wrapper">
		<label class="form__label form__label__pass" for="ppwp_tags_password"><?php echo esc_html__('Set a password', 'password-protect-page') ?></label>
		<input class="form__input" id="ppwp_tags_password" type="text" placeholder="Enter a password" value="<?php echo esc_html( $password ) ?>">
		<div id="ppwp_error_tags_password" style="display: none; color: red; position: absolute; font-size: 12px;"><?php esc_html_e( 'This field is required.', 'password-protect-page' ); ?></div>
	</p>
	<p class="form__btn-wrapper">
		<input type="submit" name="submit" id="ppwp-submit" class="button button-primary" value="<?php esc_attr_e( 'Save Changes', 'password-protect-page' ); ?>">
	</p>
</form>
