<?php

namespace The7\Admin\Notices;

defined( 'ABSPATH' ) || exit;

/**
 * One-time answer to a License Swap that landed on a license the newer line is denied to.
 *
 * Theme-authored fixed copy, not an Announcement: it reports the outcome of the action the
 * user just took, so it must appear even when the server authored no message. It rides the
 * registration settings-error channel, which makes it one-time by construction — the same
 * lifetime as the registration success and error notices.
 */
class Registration_Swap_Ineligible extends Abstract_Registration_Settings_Notice {

	/**
	 * Where a customer whose license is denied the newer line goes next.
	 */
	const PRICING_URL = 'https://the7.io/pricing/?utm_source=wp-admin&utm_medium=referral&utm_campaign=the7-v15-license-transition&utm_content=ineligible-license-registration';

	public function render() {
		$link = '<a href="' . esc_url( self::PRICING_URL ) . '" target="_blank" rel="noopener noreferrer">'
			. esc_html__( 'Review license options', 'the7mk2' )
			. '</a>';

		printf(
			'<p>%s</p>',
			wp_kses_post(
				sprintf(
					/* translators: 1: The7 major version, 2: "Review license options" link. */
					__( 'This license is not eligible for The7 %1$s. %2$s', 'the7mk2' ),
					esc_html( Version_Update_Notice::VERSION ),
					$link
				)
			)
		);
	}

	public function get_code() {
		return 'the7_license_swap_ineligible_notice';
	}

	protected function get_error_codes() {
		return array( \Presscore_Modules_ThemeUpdateModule::SWAP_INELIGIBLE_ERROR );
	}
}
