<?php
/**
 * Freemius SDK Initialization — DaazSync (FREE)
 *
 * Integration following the official Freemius guide:
 * https://freemius.com/help/documentation/wordpress-sdk/
 *
 * is_premium is FALSE here because this is the FREE plugin.
 * The PRO plugin (daazsync-pro) loads with is_premium TRUE.
 *
 * @package NewsSync
 */

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

if ( ! function_exists( 'newssync_freemius' ) ) {

	function newssync_freemius() {
		global $newssync_freemius;

		if ( ! isset( $newssync_freemius ) ) {
			// Include Freemius SDK.
			// Uses dirname(__FILE__) so no plugin constants needed at load time.
			require_once dirname( __FILE__ ) . '/freemius/start.php';

			$newssync_freemius = fs_dynamic_init( array(
				'id'               => '27280',
				'slug'             => 'daazsync',
				'type'             => 'plugin',
				'public_key'       => 'pk_36ed4e8d56dc4084c1ba9e5728b02',
				'is_premium'       => false,
				'has_premium_version' => true,
				'has_addons'       => false,
				'has_paid_plans'   => true,
				'is_org_compliant' => true,
				'menu'             => array(
					'slug'       => 'daazsync',
					'first-path' => 'plugins.php',
					'support'    => false,
				),
			) );
		}

		return $newssync_freemius;
	}

	// Init Freemius.
	newssync_freemius();

	// After opt-in, redirect to the plugin's admin page (not home_url).
	newssync_freemius()->add_filter( 'after_connect_url', function() {
		return admin_url( 'admin.php?page=daazsync' );
	} );

	// Signal that SDK was initiated.
	do_action( 'newssync_freemius_loaded' );
}
