{% import "/common/macros.twig" as icwp_macros %}
<style>
	#ButtonBuyNow {
		margin: 20px;
	}
	.card {
		margin-bottom: 20px;
	}
	.license-summary .card-body {
		padding: 0;
	}

</style>

<div class="row">
	<div class="col-5">
		<div class="card license-summary">
			<div class="card-header">
				<h5 class="mb-0">{{ strings.title_license_summary }}</h5>
			</div>
			<div class="card-body">
				{% if flags.has_error %}
					<div class="alert alert-warning mb-0">{{ vars.error }}</div>
				{% endif %}
				<table class="table table-hover table-sm mb-0">
					<tbody>
						{% for license_key, license_val in vars.license_table %}
							{% if license_val is not empty %}
								<tr>
									<th scope="row">{{ attribute(strings, license_key) }}:</th>
									<td class="">{{ license_val|raw }}</td>
								</tr>
							{% endif %}
						{% endfor %}
					</tbody>
				</table>
			</div>
		</div>

		<div class="card">
			<div class="card-header">
				<h5 class="mb-2">{{ strings.title_license_activation }}</h5>
				<h6 class="card-subtitle text-muted">{{ strings.check_availability }}</h6>
			</div>
			<div class="card-body">

				<ol>
					<li>
						<a target="_blank" href="{{ aHrefs.keyless_cp }}">{{ strings.activate_site_in }}</a>
					</li>
					<li>{{ strings.url_to_activate }}:
						<code class="font-weight-bold">{{ vars.activation_url }}</code></li>
					<li>{{ strings.license_check_limit }}.
						<br />({{ strings.more_frequent }})
					</li>
				</ol>

				<form method="post" class="licenseForm">
					{% for ajax_key, ajax_val in ajax.license_action %}
						<input type="hidden" name="{{ ajax_key }}" value="{{ ajax_val }}" />
					{% endfor %}
					<input type="hidden" name="license-action" value="check" />
					<p class="text-center">
						<button class="btn btn-success m-2" type="submit"
								{% if not flags.button_enabled_check %}disabled="disabled"{% endif %} >
							{{ strings.check_license }}
						</button>
					</p>
				</form>

				<div class="row">
					<div class="col-6 text-start">
						{% if flags.is_pro %}
							<form method="post" class="licenseForm">
								{% for ajax_key, ajax_val in ajax.license_action %}
									<input type="hidden" name="{{ ajax_key }}" value="{{ ajax_val }}" />
								{% endfor %}
								<input type="hidden" name="license-action" value="clear" />

								<button class="btn btn-link p-0" type="submit"
										style="text-decoration: none; font-size: small;"
										{% if not flags.button_enabled_check %}disabled="disabled"{% endif %} >
									<span class="text-danger">&#10008; {{ strings.clear_license }}</span>
								</button>
							</form>
						{% else %}
							<a href="https://shsec.io/buyshieldpro" target="_blank" class="card-link"
							   class="">{{ strings.go_pro }}</a>
						{% endif %}
					</div>

					<div class="col-6 text-end">
						<form method="post" id="ConnectionDebug">
							{% for ajax_key, ajax_val in ajax.connection_debug %}
								<input type="hidden" name="{{ ajax_key }}" value="{{ ajax_val }}" />
							{% endfor %}
							<p class="mb-0 text-end">
								<button class="btn btn-link btn-sm p-0"
										title="{{ strings.incase_debug }}"
										type="submit">{{ strings.debug }}</button>
							</p>
						</form>
					</div>

				</div>
			</div>

		</div>

		{% if not flags.is_premium %}
			<div class="card gopro-card">
				<div class="card-body">

					<p>Shield Security Pro is available from our online store and may be purchased
					   in US Dollar, &euro;uros, or &pound;GBPounds</p>
					<ol>
						<li>Just grab a new license from the
							<a href="https://shsec.io/buyshieldpro" target="_blank">Shield Pro store</a>.</li>
						<li>Register your site URL with our control panel.</li>
						<li>Activate your license on your sites using the 'Check License' button.</li>
					</ol>

					<p class="text-center">
						<a href="https://shsec.io/buyshieldpro" target="_blank" id="ButtonBuyNow"
						   class="btn btn-large btn-outline-success">
							Upgrade To Shield Pro Now</a>
					</p>
				</div>
			</div>
		{% endif %}

	</div>

	<div class="col-7">
	  <div class="card gopro-card">

		<div id="collone" aria-labelledby="headingOne">
		  <div class="card-body">
			  <p><a href="https://shsec.io/gp" target="_blank" class="btn btn-outline-success">
					  See All PRO Features and Extras</a></p>
			<dl class="pro-features">
				<dt>Easiest, Frustration-Free WP Pro-Upgrade Anywhere</dt>
				<dd>No more license keys to remember/copy-paste! Simply activate your site URL in your
					{{ icwp_macros.shieldpro }} control panel and get Pro features enabled on your site automatically.
				</dd>

				<dt>Protect your <code>wp-config.php</code> files</dt>
				<dd>The only WordPress security plugin to add monitoring of your
					<code>wp-config.php</code> files with automatic rollback and recovery.</dd>

				<dt>MainWP Integration (no extra extension plugins required)</dt>
				<dd>Use MainWP to manage and monitor the security of all your WordPress sites.</dd>

				<dt>Malware Scanner: Auto-learning and Detects Never-Before-Seen Malware</dt>
				<dd>Detects common and uncommon malware patterns in PHP files and alerts you immediately.
					<br />With ShieldNET crowd-sourcing intelligence, Shield automatically hides false-positives
					so you can focus on risks that matter, and can ignore the noise that wastes your time.
				</dd>

				<dt>ShieldNET Integration</dt>
				<dd>Take advantage of the intelligence gathered throughout the entire Shield network to protect
					your WordPress sites.</dd>

				<dt>Traffic Rate Limiting</dt>
				<dd>Prevent abuse of your web hosting resources by detecting and blocking bots that send
					too many requests to your site.
				</dd>

				<dt>Plugin and Theme Vulnerability Scanner</dt>
				<dd>Alerts to plugin/theme vulnerabilities.
					Shield can then automatically upgrade as updates become available.
				</dd>

				<dt>Catch Hacks Immediately - Plugins and Themes Guard</dt>
				<dd>Be alerted to ANY unauthorized changes to plugins/themes.</dd>

				<dt>Powerful User Password Policies</dt>
				<dd>Ensures that all users maintain strong passwords.</dd>

				<dt>Support for WooCommerce &amp; other 3rd party plugins</dt>
				<dd>Provide tighter security for your WooCommerce customers.
				</dd>

				<dt>Exclusive Customer Support</dt>
				<dd>Technical support for Shield is exclusive to Pro customers.</dd>

				<dt>Import and Export of plugin options</dt>
				<dd>Automatically import settings directly from 1 site to another.</dd>

				<dt>Exclusive Early-Access </dt>
				<dd>Be 1st to get new security features, as soon as they're available.</dd>

				<dt>Unlimited Audit Trail</dt>
				<dd>Retain logs for as long as you need - no limits.</dd>

				<dt>White Label</dt>
				<dd>Re-Brand Shield Security as your own!</dd>

				<dt>Customize text shown to visitors</dt>
				<dd>Edit customer-facing messages/text of the Shield plugin.</dd>
			</dl>
		  </div>
		</div>
	  </div>
	</div>

</div>
<hr />

<script type="text/javascript">
var iCWP_WPSF_LicenseHandler = new function () {

	var bRequestCurrentlyRunning = false;

	var submitLicenseForm = function ( event ) {
		iCWP_WPSF_BodyOverlay.show();

		if ( bRequestCurrentlyRunning ) {
			return false;
		}
		bRequestCurrentlyRunning = true;
		event.preventDefault();

		let $oForm = jQuery( this );
		jQuery.post( ajaxurl, $oForm.serialize(),
			function ( oResponse ) {
				if ( typeof oResponse !== 'undefined' && typeof oResponse.data !== 'undefined' ) {
					iCWP_WPSF_Toaster.showMessage( oResponse.data.message, oResponse.data.success );
				}
			}
		).always( function () {
				bRequestCurrentlyRunning = false;
				// iCWP_WPSF_BodyOverlay.hide();
				setTimeout( function () {
					location.reload( true );
				}, 2000 );
			}
		);
	};

	this.initialise = function () {
		jQuery( document ).ready( function () {
			jQuery( document ).on( "submit", "form.licenseForm", submitLicenseForm );
		} );
	};
}();

var iCWP_WPSF_ConnectionDebug = new function () {
	let connectionDebug = function ( event ) {
		iCWP_WPSF_BodyOverlay.show();
		event.preventDefault();

		var $oForm = jQuery( this );
		jQuery.post( ajaxurl, $oForm.serialize(),
			function ( oResponse ) {
				alert( oResponse.data.message );
			}
		).always( function () {
				iCWP_WPSF_BodyOverlay.hide();
			}
		);
	};

	this.initialise = function () {
		jQuery( document ).ready( function () {
			jQuery( document ).on( "submit", "form#ConnectionDebug", connectionDebug );
		} );
	};
}();

iCWP_WPSF_LicenseHandler.initialise();
iCWP_WPSF_ConnectionDebug.initialise();
</script>