<?php
/**
 * Freemius compatibility helpers for Lantern Span People Directory.
 *
 * @package LanternSpanPeopleDirectory
 */

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

/**
 * Returns the initialized Freemius SDK instance.
 *
 * @return object|null
 */
function lspd_get_freemius() {
	if ( ! function_exists( 'lpd_fs' ) ) {
		return null;
	}

	$instance = lpd_fs();
	return is_object( $instance ) ? $instance : null;
}

/**
 * Returns the plugin icon used in Freemius screens.
 *
 * @return string
 */
function lspd_freemius_icon_path() {
	return defined( 'LSPD_PATH' ) ? LSPD_PATH . 'assets/images/lspd-icon.png' : '';
}

/**
 * Applies product-specific Freemius settings.
 *
 * @return void
 */
function lspd_configure_freemius() {
	$freemius = lspd_get_freemius();
	if ( null === $freemius || ! is_callable( array( $freemius, 'add_filter' ) ) ) {
		return;
	}

	$freemius->add_filter( 'plugin_icon', 'lspd_freemius_icon_path' );
	$freemius->add_filter( 'deactivate_on_activation', '__return_false' );
}

lspd_configure_freemius();
