<?php

/*
 * Plugin Name:       Eventful For Elementor
 * Plugin URI:        http://wp-plugins.themeatelier.net/eventful
 * Description:       Seamlessly showcase events from The Events Calendar in Elementor with customizable widgets and dynamic layouts.
 * Version:           1.2.8
 * Requires at least: 5.2
 * Requires PHP:      7.2
 * Author:            ThemeAtelier
 * Author URI:        https://themeatelier.net/
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       eventful-for-elementor
 * Domain Path:       /languages
 * Tested up to:       6.9.4
 * Elementor tested up to: 3.16.0
 * Elementor Pro tested up to: 3.16.0
 */

use ThemeAtelier\EventfulForElementor\Includes\EventfulForElementor;

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

require_once __DIR__ . '/vendor/autoload.php';

if (!defined('EVENTFUL_ELEMENTOR_VERSION')) {
    define('EVENTFUL_ELEMENTOR_VERSION', '1.2.8');
}
if (!defined('MINIMUM_ELEMENTOR_VERSION')) {
    define('MINIMUM_ELEMENTOR_VERSION', '3.5.0');
}
if (!defined('MINIMUM_PHP_VERSION')) {
    define('MINIMUM_PHP_VERSION', '7.3');
}
if (!defined('EVENTFUL_ELEMENTOR_EA_PREFIX')) {
    define('EVENTFUL_ELEMENTOR_EA_PREFIX', 'efe_ea_');
}
if (!defined('EVENTFUL_ELEMENTOR_PLUGIN_URL')) {
    define('EVENTFUL_ELEMENTOR_PLUGIN_URL', trailingslashit(plugins_url('/', __FILE__)));
}
if (!defined('EVENTFUL_ELEMENTOR_PLUGIN_PATH')) {
    define('EVENTFUL_ELEMENTOR_PLUGIN_PATH', trailingslashit(plugin_dir_path(__FILE__)));
}
if (!defined('EVENTFUL_ELEMENTOR_BASENAME')) {
    define('EVENTFUL_ELEMENTOR_BASENAME', plugin_basename(__FILE__));
}
if (!defined('EVENTFUL_ELEMENTOR_URL_ASSETS')) {
    define('EVENTFUL_ELEMENTOR_URL_ASSETS', plugin_dir_url(__FILE__) . 'src/Frontend/assets/');
}
if (!defined('EVENTFUL_ELEMENTOR_DEMO_URL')) {
    define('EVENTFUL_ELEMENTOR_DEMO_URL', 'https://wp-plugins.themeatelier.net/eventful/eventful-el-carousel/');
}

function eventful_for_elementor_run()
{
    // Launch the plugin.
    $EVENTFUL_FOR_ELEMENTOR = new EventfulForElementor();
    $EVENTFUL_FOR_ELEMENTOR->run();
}

// kick-off the plugin
include_once ABSPATH . 'wp-admin/includes/plugin.php';
if (! (is_plugin_active('eventful-pro-for-elementor/eventful-pro-for-elementor.php') || is_plugin_active_for_network('eventful-pro-for-elementor/eventful-pro-for-elementor.php'))) {
    eventful_for_elementor_run();
}

if (!function_exists('efpe_is_the_events_calendar_installed')) {

    function efpe_is_the_events_calendar_installed()
    {
        $file_path = 'the-events-calendar/the-events-calendar.php';
        $installed_plugins = get_plugins();

        return isset($installed_plugins[$file_path]);
    }
}



/**
 * Initialize the plugin tracker
 *
 * @return void
 */
function efpe_appsero_init()
{
    if (!class_exists('EfpeAppsero\Insights')) {
        require_once EVENTFUL_ELEMENTOR_PLUGIN_PATH . 'src/Admin/appsero/Client.php';
    }

    $client = new EfpeAppsero\Client( '86853a85-89bd-4d97-b917-deae714b207a', 'Eventful for Elementor', __FILE__ );

    // Active insights
    $client->insights()->init();
}

add_action('plugins_loaded', 'efpe_appsero_init');
