<?php

/**
 * @package CsvImporterPlusforACF
 */

/*
Plugin Name: CSV Importer Plus for ACF
Plugin URI: https://csvimporterplusforacf.com/
Description: CSV Importer Plus for ACF maps & imports CSV data to Posts, Pages, CPTs & WooCommerce products, with or without ACF fields.
Author: mobeenraheem
Requires at least: 5.8
Requires PHP: 8.1.2
Tested up to: 6.9
Version: 1.4.4
License: GPLv2 or later
Text Domain: csv-importer-plus-for-acf
Domain Path: /languages/
*/

// make sure we don't expose any info if called directly
if (!defined('ABSPATH')) exit; // Exit if accessed directly

use CIPFA\base\CIPFA_Deactivate;
use CIPFA\base\CIPFA_Activate;
use CIPFA\base\CIPFA_BaseController;
use CIPFA\CIPFA_Init;

//composer autoload
if (file_exists(dirname(__FILE__) . '/vendor/autoload.php')) {
   require_once dirname(__FILE__) . '/vendor/autoload.php';
}

// Load translations
add_action('init', function () {
   $domain = 'csv-importer-plus-for-acf';
   $mofile = CIPFA_BaseController::$plugin_path . 'languages/' . $domain . '-' . determine_locale() . '.mo';
   if (file_exists($mofile)) {
      load_textdomain($domain, $mofile);
   }
});

//plugin activation
register_activation_hook(__FILE__, array(CIPFA_Activate::class, 'cipfa_activate'));
//plugin deactivation
register_deactivation_hook(__FILE__, array(CIPFA_Deactivate::class, 'cipfa_deactivate'));

add_action('plugins_loaded', 'cipfa_all_plugins_loaded', 20);
function cipfa_all_plugins_loaded()
{
   //initialization of classes
   if (class_exists('CIPFA\\CIPFA_Init') && !class_exists('CIPPFA\\CIPPFA_Init')) {
      CIPFA_Init::cipfa_registerServices();
   }
}
