<?php
/**
 * Plugin Name: Apex View Insights
 * Description: Lightweight local post, page, and WooCommerce product view insights with views vs sales reporting.
 * Version: 1.0.0
 * Author: Apex Digital
 * Requires at least: 6.0
 * Requires PHP: 7.4
 * WC requires at least: 7.0
 * WC tested up to: 10.0
 * License: GPLv2 or later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: apex-view-insights
 */

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

define( 'AVIN_VERSION', '1.0.0' );
define( 'AVIN_DB_VERSION', '0.3.0' );
define( 'AVIN_PLUGIN_FILE', __FILE__ );
define( 'AVIN_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'AVIN_PLUGIN_URL', plugin_dir_url( __FILE__ ) );

add_action(
	'before_woocommerce_init',
	function () {
		if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
			\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', AVIN_PLUGIN_FILE, true );
			\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', AVIN_PLUGIN_FILE, true );
		}
	}
);

require_once AVIN_PLUGIN_DIR . 'includes/Core/Installer.php';
require_once AVIN_PLUGIN_DIR . 'includes/Core/Plugin.php';
require_once AVIN_PLUGIN_DIR . 'includes/Data/AnalyticsRepository.php';
require_once AVIN_PLUGIN_DIR . 'includes/Data/ViewsRepository.php';
require_once AVIN_PLUGIN_DIR . 'includes/Data/WooCommerceMetrics.php';
require_once AVIN_PLUGIN_DIR . 'includes/Tracking/BotFilter.php';
require_once AVIN_PLUGIN_DIR . 'includes/Tracking/Tracker.php';
require_once AVIN_PLUGIN_DIR . 'includes/Admin/Exporter.php';
require_once AVIN_PLUGIN_DIR . 'includes/Admin/AdminColumns.php';
require_once AVIN_PLUGIN_DIR . 'includes/Admin/Admin.php';

register_activation_hook( __FILE__, array( 'AVIN_Installer', 'activate' ) );
register_deactivation_hook( __FILE__, array( 'AVIN_Installer', 'deactivate' ) );

add_action(
	'plugins_loaded',
	function () {
		AVIN_Plugin::instance()->init();
	}
);
