<?php
/**
 * @package   	      Electronic Signature Add-on for Forminator
 * @contributors      Kevin Michael Gray (Approve Me), Abu Sohib (Approve Me)
 * @wordpress-plugin
 * Plugin Name:       Electronic Signature Add-on for Forminator by ApproveMe.com
 * Plugin URI:        http://aprv.me/2lfrDYG
 * Description:       This add-on makes it possible to automatically email a WP E-Signature document (or redirect a user to a document) after the user has succesfully submitted a Forminator Forms. You can also insert data from the submitted Forminator Form into the WP E-Signature document.
 * Version:           1.1.5
 * Author:            ApproveMe.com
 * Author URI:        https://www.approveme.com/
 * Text Domain:       esig-forminator
 * Domain Path:       /languages
 */

// If this file is called directly, abort.
if (!defined('WPINC')) {
    die;
}

if (!defined("ESIGNATURE_FORMINATOR_ADDON_URL")) {
    define('ESIGNATURE_FORMINATOR_ADDON_URL', plugins_url("/", __FILE__));
}

// esig asset directory url
if (!defined('ESIGN_FORMINATOR_ASSETS_DIR_URI'))
define('ESIGN_FORMINATOR_ASSETS_DIR_URI', plugins_url('admin/assets', __FILE__));

require_once( plugin_dir_path( __FILE__ ) . 'includes/esig-forminator-functions.php' );
require_once( plugin_dir_path( __FILE__ ) . 'includes/esig-forminator.php' );
register_activation_hook( __FILE__, array( 'ESIG_FORMINATOR', 'activate' ) );
register_deactivation_hook( __FILE__, array( 'ESIG_FORMINATOR', 'deactivate' ) );

require_once( plugin_dir_path( __FILE__ ) . 'admin/about/autoload.php' );
require_once( plugin_dir_path( __FILE__ ) . 'includes/forminator-esig-settings.php' );
require_once( plugin_dir_path( __FILE__ ) . 'includes/esig-forminator-document-view.php' );


require_once( plugin_dir_path( __FILE__ ) . 'admin/esig-forminator-admin.php' );
add_action( 'plugins_loaded', array( 'esigForminatorAdmin', 'get_instance' ) );
require_once( plugin_dir_path( __FILE__ ) . 'admin/esig-forminator-filters.php' );
add_action( 'plugins_loaded', array( 'esigForminatorFilters', 'instance' ) );





function forminator_addon_esign_dir() {
	return trailingslashit( dirname( __FILE__ ) );
}

// Forminator_Addon_Loader::get_instance();
function esigForminatorAddonLoader() {

    /*if (!class_exists('Forminator_Integration_Loader')) {
       wp_admin_notice(__('Electronic Signature Add-on for Forminator by ApproveMe.com this version 
       requires Forminator version 1.30 or greater', 'esig-forminator'),
       ['type'=>'warning' ]);
       return false;
    } */
    if (!class_exists('Forminator_API')) return false;

    Forminator_API::initialize(); 
    
   
   
    // check forminator integration loader class exists or not
    if( class_exists('Forminator_Integration_Loader') ) {
        require_once(plugin_dir_path(__FILE__) . 'admin/integration/esign-forminator-integration.php');
        require_once(plugin_dir_path(__FILE__) . 'admin/integration/esign-forminator-form-settings.php');
        require_once(plugin_dir_path(__FILE__) . 'admin/integration/esign-forminator-form-hooks.php');
        Forminator_Integration_Loader::get_instance()->register('ForminatorAddon_Esignature');
    } else {
        require_once(plugin_dir_path(__FILE__) . 'admin/old-integration/esign-forminator-integration.php');
        require_once(plugin_dir_path(__FILE__) . 'admin/old-integration/esign-forminator-form-settings.php');
        require_once(plugin_dir_path(__FILE__) . 'admin/old-integration/esign-forminator-form-hooks.php');
        Forminator_Addon_Loader::get_instance()->register('ForminatorAddon_Esignature');
    }
   
   
    
    
  }
 add_action( 'plugins_loaded', 'esigForminatorAddonLoader');

