<?php

namespace SplitPay\Core;

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

class UpgradeCTA {

	public static function getPricingUrl(): string {
		return admin_url( 'admin.php?page=bsd-split-pay-stripe-connect-woo-settings-pricing' );
	}

	public static function renderInlineUpgrade( string $featureName ): void {
		$url = self::getPricingUrl();
		echo '<div class="spp-upgrade-cta-inline">';
		echo '<p>Upgrade to PRO to unlock ' . esc_html( $featureName ) . '.</p>';
		echo '<a href="' . esc_url( $url ) . '" class="button button-primary">Upgrade Now</a>';
		echo '</div>';
	}

	public static function renderTabUpgrade( string $tabName, string $description = '' ): void {
		$url = self::getPricingUrl();
		echo '<div class="spp-upgrade-cta-tab" style="text-align:center;">';
		echo '<h2>' . esc_html( $tabName ) . '</h2>';
		if ( $description !== '' ) {
			echo '<p>' . esc_html( $description ) . '</p>';
		}
		echo '<a href="' . esc_url( $url ) . '" class="button button-primary button-hero">Upgrade to PRO</a>';
		echo '</div>';
	}

	public static function isPremium(): bool {
		if ( ! function_exists( 'BSD_Split_Pay_Stripe_Connect_Woo\bsdwcscsp_fs' ) ) {
			return false;
		}

		$fs = \BSD_Split_Pay_Stripe_Connect_Woo\bsdwcscsp_fs();

		return $fs->is__premium_only() && $fs->can_use_premium_code();
	}
}
