<?php
/**
 * Pro-only module settings helpers (badges and add-on CTAs).
 *
 * Not packaged in the wordpress.org Lite zip. Full builds load this from
 * ModuleSettingsUi; the Pro add-on loads a copy when Lite does not ship it.
 *
 * @package WP_PowerSuite
 */

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

if ( ! function_exists( 'wpps_render_premium_badge' ) ) {
	function wpps_render_premium_badge(): void {
		echo ' <span class="wpps-pro-badge">' . esc_html__( 'Pro', 'wppowersuite-lite' ) . '</span>';
	}
}

if ( ! function_exists( 'wpps_render_premium_upsell_notice' ) ) {
	/**
	 * Inline Pro notice: license page if the add-on is installed, else purchase URL.
	 */
	function wpps_render_premium_upsell_notice(): void {
		$url = function_exists( 'wp_powersuite_premium_upsell_url' )
			? wp_powersuite_premium_upsell_url()
			: ( defined( 'WP_POWERSUITE_PRODUCT_URL' ) ? WP_POWERSUITE_PRODUCT_URL : 'https://wppowersuite.com/' );
		$can = function_exists( 'wp_powersuite_can_activate_license' ) && wp_powersuite_can_activate_license();
		?>
	<div class="notice notice-info inline" style="margin:0 0 12px; padding:8px 12px;">
		<p style="margin:0;">
			<?php
			if ( $can ) {
				echo wp_kses_post(
					sprintf(
						/* translators: %s: URL to license page */
						__( 'This feature is in WP PowerSuite Pro. <a href="%s">Open License</a> on the add-on to use it.', 'wppowersuite-lite' ),
						esc_url( $url )
					)
				);
			} else {
				echo wp_kses(
					sprintf(
						/* translators: %s: URL to purchase WP PowerSuite Pro */
						__( 'This is included with WP PowerSuite Pro. <a href="%s" target="_blank" rel="noopener noreferrer">Upgrade to Pro</a> to add it.', 'wppowersuite-lite' ),
						esc_url( $url )
					),
					[
						'a' => [
							'href'   => true,
							'target' => true,
							'rel'    => true,
						],
					]
				);
			}
			?>
		</p>
	</div>
		<?php
	}
}
