<?php
/**
 * Pluginer Premium License Display
 *
 * This file is used to display the license management interface in the admin area.
 *
 * @package    Instalist
 * @subpackage Instalist/admin/partials
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( defined( 'PLUGINER_PREMIUM_VERSION' ) ) {

	$license_status = $data['status'] ?? '';

	if ( 'active' === $license_status ) {
		$is_active            = true;
		$notice_class         = 'success';
		$license_status_label = 'License is active';
		$disabled             = 'disabled';
	} elseif ( '' === $license_status ) {
		$is_active            = false;
		$notice_class         = 'warning';
		$license_status_label = 'License not activated yet.';
		$disabled             = '';
	} else {
		$is_active            = false;
		$notice_class         = 'error';
		$license_status_label = "<strong>Sorry, this license appears to be invalid or inactive</strong>. If you think this is an error, contact us at <a href='mailto:support@codingfix.com'>support@codingfix.com</a>. We’ll help you resolve this as soon as possible.";
		$disabled             = '';
	}
}
?>
<div class="wrap">
	<div class="plgnr-header">
		<img src="<?php echo esc_url( PLUGINER_URL . 'img/icon-256x256.webp' ); ?>" alt="Pluginer Logo" style="height: 60px; margin-right: 15px;">
		<h1>Pluginer</h1>
	</div>
	<hr>

	<?php
	if ( defined( 'PLUGINER_PREMIUM_VERSION' ) ) {
		?>

	<div>
		<div id="pluginer-license-status" class="plgnr-notice plgnr-notice-<?php echo esc_html( $notice_class ); ?>">
			<p><?php echo wp_kses_post( $license_status_label ); ?></p>
		</div>
		<form id="pluginer-license-form" method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
			<?php wp_nonce_field( 'pluginer_save_license' ); ?>
			<input type="hidden" name="action" value="insta_save_license">

			<table class="form-table">
				<tr>
					<th><label for="pluginer_license_email">Email</label></th>
					<td><input type="email" id="pluginer_license_email" name="pluginer_license_email" class="regular-text" value="<?php echo esc_attr( $data['email'] ); ?>"></td>
				</tr>
				<tr>
					<th><label for="pluginer_license_key">License Key</label></th>
					<td><input type="password" id="pluginer_license_key" name="pluginer_license_key" class="regular-text" value="<?php echo esc_attr( $data['key'] ); ?>" <?php echo esc_attr( $disabled ); ?>></td>
				</tr>
			</table>
			<?php
			submit_button(
				'Activate license',
				'primary',
				'submit',
				true,
				$is_active ? array( 'disabled' => 'disabled' ) : array()
			);
			?>
			<!-- <button id="pluginer-deactivate-license-verify" class="button">Verifica Licenza</button> -->
			<!-- <button id="pluginer-license-verify" class="button">Verifica Licenza</button> -->
		</form>
	</div>

	<hr>
		<?php
	}
	?>

	<h1>Why go Premium?</h1>

	<?php
	if ( ! defined( 'PLUGINER_PREMIUM_VERSION' ) ) {
		?>
		<a class="plgnr-go-premium-link" href="https://codingfix.com/checkout/?add-to-cart=2806" target="_blank" rel="noopener">
			<div class="plgnr-go-premium">
				<div class="plgnr-go">
					<h2>Go Premium now!</h2>
					<p>
						Reusable plugin lists for developers and agencies.<br>
						<strong>One-time payment, lifetime license, unlimited websites.</strong>
					</p>
				</div>
				<div>
					<img src="<?php echo esc_url( PLUGINER_URL . 'img/banner-772x250.webp' ); ?>" alt="Pluginer Premium">
				</div>
				<!-- <div>
					<a href="https://codingfix.com/checkout/?add-to-cart=2806" class="button button-primary button-go-premium">Buy a license now!</a>
				</div> -->
			</div>
		</a>
		<?php
	}
	?>

	<div class="features-container">
		<!-- Feature 1 -->
		<div class="feature">
			<div class="feature-text">
				<h3>Multiple Lists Management</h3>
				<p><strong>Manage multiple plugin lists.</strong> No more limitations: create and organize as many plugin lists as you need. Whether you’re running different client projects, testing environments, or personal setups, you’ll always have your preferred plugin stacks ready to go. This flexibility allows you to maintain organized workflows and quickly adapt to various client needs.</p>
			</div>
			<div class="video-thumb" data-video="<?php echo esc_url( PLUGINER_URL ) . 'admin/videos/multilist.webm'; ?>">
				<video muted loop autoplay playsinline>
					<source src="<?php echo esc_url( PLUGINER_URL ) . 'admin/videos/multilist.webm'; ?>" type="video/webm">
				</video>
			</div>
		</div>

		<!-- Feature 2 -->
		<div class="feature">
			<div class="feature-text">
				<h3>Selective Installation and Activation</h3>
				<p><strong>Install only the selected plugins of a list.</strong> Gain total control over plugin installation. Instead of installing an entire list at once, you can choose exactly which plugins to activate. Ideal for tailoring each project’s environment without unnecessary extras. This feature gives you greater control over your installations, allowing you to customize your setup based on the unique requirements of each site.</p>
			</div>
			<div class="video-thumb" data-video="<?php echo esc_url( PLUGINER_URL ) . 'admin/videos/sel-inst.webm'; ?>">
				<video muted loop autoplay playsinline>
					<source src="<?php echo esc_url( PLUGINER_URL ) . 'admin/videos/sel-inst.webm'; ?>" type="video/webm">
				</video>
			</div>
		</div>
	</div>
	<div class="features-container">
		<!-- Features 3 + 4 -->
		<div class="feature">
			<div class="feature-text">
				<h3>Create a Plugin List from Installed Plugins</h3>
				<ul>
					<li><strong>Create a list with all installed plugins (one-click mode)</strong> Instantly generate a list with the plugins that are already installed on your site. This feature is perfect for users who want to replicate successful setups across multiple sites, ensuring consistency and saving time in the process.</li>
					<li><strong>Create a list from currently installed plugins (selective mode)</strong>Load only installed plugins to create a list choosing among them: you'll be able to integrate the new list adding other plugins from the repo. This grants the maximun of flexibility to satisfy any type of need.</li>
				</ul>
			</div>
			<div class="video-thumb" data-video="<?php echo esc_url( PLUGINER_URL ) . 'admin/videos/local-lists.webm'; ?>">
				<video muted loop autoplay playsinline>
					<source src="<?php echo esc_url( PLUGINER_URL ) . 'admin/videos/local-lists.webm'; ?>" type="video/webm">
				</video>
			</div>
		</div>
		<div class="feature">
			<div class="feature-text">
				<h3>Priority Support</h3>
				<p><strong>Get priority support.</strong> As a premium user, you’ll receive priority support from our dedicated team. Whether you have questions, need assistance with setup, or encounter any issues, we’re here to help you quickly and efficiently. Our goal is to ensure you have the best possible experience with Pluginer Premium. Contact us at <a href="mailto:support@codingfix.com">support@codingfix.com</a></p>
			</div>
			<div class="video-thumb" data-video="<?php echo esc_url( PLUGINER_URL ) . 'admin/videos/ambulance.webm'; ?>">
				<video muted loop autoplay playsinline>
					<source src="<?php echo esc_url( PLUGINER_URL ) . 'admin/videos/ambulance.webm'; ?>" type="video/webm">
				</video>
				<p style="font-size:.8rem"><a href="https://www.vecteezy.com/free-videos/ambulance">Ambulance Stock Videos by Vecteezy</a></p>
			</div>
		</div>
	</div>

	<!-- Modal -->
	<div id="video-modal" class="modal">
		<span class="close"><span class="close-x">&times;</span></span>
		<div class="modal-content">
			<video id="modal-video" controls autoplay></video>
		</div>
	</div>

	<?php
	if ( ! defined( 'PLUGINER_PREMIUM_VERSION' ) ) {
		?>
		<a class="plgnr-go-premium-link" href="https://codingfix.com/checkout/?add-to-cart=2806" target="_blank" rel="noopener">
			<div class="plgnr-go-premium">
				<div class="plgnr-go">
					<h2>Go Premium now!</h2>
					<p>
						Reusable plugin lists for developers and agencies.<br>
						<strong>One-time payment, lifetime license, unlimited websites.</strong>
					</p>
				</div>
				<div>
					<img src="<?php echo esc_url( PLUGINER_URL . 'img/banner-772x250.webp' ); ?>" alt="Pluginer Premium">
				</div>
				<!-- <div>
					<a href="https://codingfix.com/checkout/?add-to-cart=2806" class="button button-primary button-go-premium">Buy a license now!</a>
				</div> -->
			</div>
		</a>
		<?php
	}
	?>
</div>
