<?php
/**
 * Centralized Pro upgrade URLs and CTA labels for the Free edition.
 *
 * @package UM_Elementor_Free
 * @since   2.7
 */

namespace UM_Elementor;

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

final class UM_Elementor_Pro_Links {

	/** Freemius Pro product checkout (product 11848, plan 20186). */
	private const CHECKOUT_BASE = 'https://checkout.freemius.com/mode/dialog/plugin/11848/plan/20186/';

	/**
	 * Upgrade URL with attribution for conversion tracking.
	 *
	 * @param string $source e.g. 'editor-card', 'admin-notice'.
	 */
	public static function upgrade_url( string $source ): string {
		$url = self::CHECKOUT_BASE;

		if ( function_exists( 'umwfe_fs' ) ) {
			$fs_url = umwfe_fs()->get_upgrade_url();
			if ( is_string( $fs_url ) && $fs_url !== '' ) {
				$url = $fs_url;
			}
		}

		return add_query_arg(
			[
				'utm_source' => 'free-plugin',
				'utm_medium' => sanitize_key( $source ),
			],
			$url
		);
	}

	/**
	 * CTA label for upgrade buttons (price is managed in Freemius, not hardcoded).
	 */
	public static function price_label(): string {
		return apply_filters(
			'umwfe_pro_price_label',
			__( 'Get Pro', 'ultimate-member-widgets-for-elementor' )
		);
	}
}

\class_alias( __NAMESPACE__ . '\\UM_Elementor_Pro_Links', 'UM_Elementor_Pro_Links' );
