<?php
if ( ! defined( 'ABSPATH' ) ) exit;
/**
 * Plugin Name: ConsentPress – GDPR Cookie Consent
 * Plugin URI: https://consentpress.com
 * Description: Lightweight cookie consent banner with essential settings and a cookie policy table.
 * Version: 1.3.1
 * Requires at least: 5.6
 * Requires PHP: 7.4
 * Author: ICREATOR B.V.
 * Author URI: https://icreator.nl
 * License: GPLv2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: consentpress
 * Domain Path: /languages
 * 
 * @package ConsentPress
 * @copyright 2025 ICREATOR B.V.
 * @license GPL-2.0-or-later
 */
$iccb_plugin_data = get_file_data(__FILE__, ['Version' => 'Version'], 'plugin');
$iccb_version = $iccb_plugin_data['Version'] ?? '1.3.1';

define( 'ICCB_ROOT_PATH', plugin_dir_path( __FILE__ ) );
define( 'ICCB_ROOT_URL', plugin_dir_url( __FILE__ ) );
define( 'ICCB_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
define( 'ICCB_VERSION', $iccb_version );
define( 'ICCB_FILE', __FILE__ );

require_once ICCB_ROOT_PATH . 'includes/classes/Autoloader.php';
IcreatorCookieConsent\Autoloader::register('IcreatorCookieConsent', ICCB_ROOT_PATH . 'includes/classes');

if ( ! function_exists( 'iccb_fs' ) ) {
    // Create a helper function for easy SDK access.
    function iccb_fs() {
        global $iccb_fs;

        if ( ! isset( $iccb_fs ) ) {
            // Include Freemius SDK.
            require_once dirname( __FILE__ ) . '/vendor/freemius/start.php';
            $iccb_fs = fs_dynamic_init( array(
                'id'                  => '20191',
                'slug'                => 'consentpress',
                'premium_slug'        => 'consentpress-pro',
                'type'                => 'plugin',
                'public_key'          => 'pk_c8e3b1b53c88eb75da9c615860bcc',
                'is_premium'          => false,
                'is_premium_only'     => false,
                'has_addons'          => false,
                'has_paid_plans'      => true,
                'menu'                => array(
                    'slug'           => 'iccb_dashboard',
                    'support'        => false,
                ),
            ) );
        }

        return $iccb_fs;
    }

    // Init Freemius.
    iccb_fs();
    // Signal that SDK was initiated.
    do_action( 'iccb_fs_loaded' );
    iccb_fs()->add_action('after_uninstall', ['IcreatorCookieConsent\Plugin', 'uninstall']);
}


add_action('plugins_loaded', function () {
    IcreatorCookieConsent\Plugin::instance()->boot();
});

// Activation / deactivation
register_activation_hook(__FILE__, ['IcreatorCookieConsent\Plugin', 'activate']);
register_deactivation_hook(__FILE__, ['IcreatorCookieConsent\Plugin', 'deactivate']);
