<?php
/**
 * The7 dashboard License Swap form.
 *
 * Rendered inside the modal opened by the [license_swap_button] announcement
 * shortcode. It posts to the very same handler as the ordinary registration form
 * (Presscore_Modules_ThemeUpdateModule::update_settings), so an already-registered
 * install can move onto a new purchase code without deregistering first.
 *
 * Deliberately carries no consent checkbox: the checkbox on the registration form
 * has no name attribute and only gates the submit button in JS. Consent was given
 * when this install was first registered.
 *
 * The hidden Swap marker is what lets an eligible swap continue straight into a Theme
 * Upgrade; the ordinary registration form omits it and never triggers one. The copy
 * promises that upgrade unconditionally because eligibility arrives with the
 * registration response and is unknowable at render time.
 *
 * @package The7
 */

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

<div class="the7-license-swap the7-postbox">
	<h3><?php echo esc_html_x( 'Already have a direct license?', 'admin', 'the7mk2' ); ?></h3>
	<p>
		<?php
		printf(
			/* translators: %s: The7 major version, e.g. "15". */
			esc_html_x( 'Enter your direct license key to automatically upgrade to The7 %s:', 'admin', 'the7mk2' ),
			esc_html( \The7\Admin\Notices\Version_Update_Notice::VERSION )
		);
		?>
	</p>
	<form method="post">
		<?php settings_fields( 'the7_theme_registration' ); ?>
		<input type="hidden" name="<?php echo esc_attr( Presscore_Modules_ThemeUpdateModule::LICENSE_SWAP_MARKER ); ?>" value="1">

		<p>
			<label class="screen-reader-text" for="the7-license-swap-code"><?php echo esc_html_x( 'Direct license key', 'admin', 'the7mk2' ); ?></label>
			<input id="the7-license-swap-code" class="of-input" name="the7_purchase_code" type="text" value="" size="36" title="<?php echo esc_attr_x( 'Direct license key', 'admin', 'the7mk2' ); ?>">
		</p>
		<p class="the7-license-swap-actions">
			<button type="submit" id="the7-license-swap-button" class="button button-primary" name="register_theme" value="register">
				<?php
				printf(
					/* translators: %s: The7 major version, e.g. "15". */
					esc_html_x( 'Upgrade to The7 %s', 'admin register a new license', 'the7mk2' ),
					esc_html( \The7\Admin\Notices\Version_Update_Notice::VERSION )
				);
				?>
			</button>
			<button type="button" class="button the7-popup-dismiss"><?php echo esc_html_x( 'Cancel', 'admin', 'the7mk2' ); ?></button>
		</p>
	</form>
</div>
