<?php
/**
 * Single point of truth for "does the current user have Pro?".
 *
 * Every Pro-gated file in includes/pro/ — and every hook the free code
 * exposes for Pro to extend — should check nrbb_is_pro() and nothing
 * else. Never call nrbb_fs() directly from feature code.
 *
 * @package Briefify
 */

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

/**
 * Whether the current install should get Pro features.
 *
 * Uses Freemius's can_use_premium_code() rather than is_paying(): it's
 * the SDK's own documented gate for "should premium code run" (used
 * internally by the SDK itself, including its can_use_premium_code__premium_only()
 * helper for its automated free/premium code-splitting). Unlike is_paying(),
 * it correctly returns true during an active trial — someone on a trial
 * should see Pro features, not just someone who has already paid.
 *
 * @return bool
 */
function nrbb_is_pro() {
	$is_pro = function_exists( 'nrbb_fs' ) && nrbb_fs()->can_use_premium_code();

	/**
	 * Filter whether the current install should get Pro features.
	 *
	 * Local-testing escape hatch — lets a developer simulate a Pro
	 * install without going through a real (or sandboxed) Freemius
	 * purchase. See NOTES.md for how to use this. Never fires unless
	 * something explicitly hooks it, so production behavior is always
	 * exactly what Freemius reports.
	 *
	 * @param bool $is_pro
	 */
	return (bool) apply_filters( 'nrbb_is_pro', $is_pro );
}
