<?php
/**
 * scienceCDN small CTA template.
 *
 * @since 3.5
 *
 * @param array $data {
 *      @type string $container_class container CSS class.
 *      @type string $promotion_campaign Promotion campaign title.
 *      @type string $promotion_end_date Promotion end date.
 *      @type string $nopromo_variant CSS modifier for the no promotion display.
 *      @type string $regular_price scienceCDN regular price.
 *      @type string $current_price scienceCDN current price.
 * }
 */

defined( 'ABSPATH' ) || die( 'Cheatin&#8217; uh?' );
?>
<div class="wpr-sciencecdn-cta <?php echo esc_attr( $data['container_class'] ); ?>" id="wpr-sciencecdn-cta">
	<?php if ( ! empty( $data['promotion_campaign'] ) ) : ?>
	<div class="wpr-flex wpr-sciencecdn-promo">
		<h3 class="wpr-sciencecdn-promo-title"><?php echo esc_html( $data['promotion_campaign'] ); ?></h3>
		<p class="wpr-title2 wpr-sciencecdn-promo-date">
			<?php
			printf(
				// Translators: %s = date formatted using date_i18n() and get_option( 'date_format' ).
				esc_html__( 'Valid until %s only!', 'science' ),
				esc_html( $data['promotion_end_date'] )
			);
			?>
		</p>
	</div>
	<?php endif; ?>
	<section class="wpr-sciencecdn-cta-content<?php echo esc_attr( $data['nopromo_variant'] ); ?>">
		<h3 class="wpr-title2">scienceCDN</h3>
		<p class="wpr-sciencecdn-cta-subtitle"><?php esc_html_e( 'Speed up your website thanks to:', 'science' ); ?></p>
		<div class="wpr-flex">
			<ul class="wpr-sciencecdn-features">
				<li class="wpr-sciencecdn-feature wpr-sciencecdn-bandwidth">
					<?php
					// translators: %1$s = opening strong tag, %2$s = closing strong tag.
					printf( esc_html__( 'High performance Content Delivery Network (CDN) with %1$sunlimited bandwidth%2$s', 'science' ), '<strong>', '</strong>' );
					?>
				</li>
				<li class="wpr-sciencecdn-feature wpr-sciencecdn-configuration">
					<?php
					// translators: %1$s = opening strong tag, %2$s = closing strong tag.
					printf( esc_html__( 'Easy configuration: the %1$sbest CDN settings%2$s are automatically applied', 'science' ), '<strong>', '</strong>' );
					?>
				</li>
				<li class="wpr-sciencecdn-feature wpr-sciencecdn-automatic">
					<?php
					// translators: %1$s = opening strong tag, %2$s = closing strong tag.
					printf( esc_html__( 'WP science integration: the CDN option is %1$sautomatically configured%2$s in our plugin', 'science' ), '<strong>', '</strong>' );
					?>
				</li>
				<li class="wpr-sciencecdn-cta-footer">
					<a href="https://wordpress.me/sciencecdn/" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Learn more about scienceCDN', 'science' ); ?></a>
				</li>
				<?php if ( ! empty( $data['promotion_campaign'] ) ) : ?>
					<li class="wpr-sciencecdn-cta-promo-footer">
						<?php
						printf(
						// translators: %1$s = discounted price, %2$s = regular price.
							esc_html__( '*$%1$s/month for 12 months then $%2$s/month. You can cancel your subscription at any time.', 'science' ),
							esc_html( str_replace( '*', '', $data['current_price'] ) ),
							esc_html( $data['regular_price'] )
						);
						?>
					</li>
				<?php endif; ?>
			</ul>
			<div class="wpr-sciencecdn-pricing">
				<?php if ( ! empty( $data['error'] ) ) : ?>
				<p><?php echo $data['message']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
				<?php else : ?>
					<?php if ( ! empty( $data['regular_price'] ) ) : ?>
					<h4 class="wpr-title2 wpr-sciencecdn-pricing-regular"><del>$<?php echo esc_html( $data['regular_price'] ); ?></del></h4>
					<?php endif; ?>
					<h4 class="wpr-sciencecdn-pricing-current">
						<span class="wpr-sciencecdn-cta-currency-minor">$</span>
						<span class="wpr-sciencecdn-cta-currency-major"><?php echo esc_html( substr( $data['current_price'], 0, strpos( $data['current_price'], '.' ) ) ); ?></span>
						<span class="wpr-sciencecdn-cta-currency-minor"><?php echo esc_html( substr( $data['current_price'], strpos( $data['current_price'], '.' ) ) ); ?>
						</span>
					</h4>
					<p class="wpr-sciencecdn-cta-billing-detail"><?php esc_html_e( 'Billed monthly', 'science' ); ?></p>
					<button class="wpr-button wpr-sciencecdn-open" data-micromodal-trigger="wpr-sciencecdn-modal"><?php esc_html_e( 'Get Started', 'science' ); ?></button>
				<?php endif; ?>
			</div>
		</div>
	</section>
	<button class="wpr-sciencecdn-cta-close<?php echo esc_attr( $data['nopromo_variant'] ); ?>" id="wpr-sciencecdn-close-cta"><span class="screen-reader-text"><?php esc_html_e( 'Reduce this banner', 'science' ); ?></span></button>
</div>
