<?php
/**
 * Plugin Name: BSW Integration for Gravity Forms and Pipedrive
 * Plugin URI: https://wordpress.org/plugins/bsw-gravityforms-pipedrive
 * Description: Integrate Gravity Forms with Pipedrive CRM
 * Version: 1.5.4
 * Author: Bayard Service
 * License: GPL-2.0-or-later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: bsw-gravityforms-pipedrive
 * Domain Path: /languages
 *
 * @package bsw-gravityforms-pipedrive
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

define( 'BSWGRAVITYFORMSPIPEDRIVE_VERSION', '1.5.2' );

if ( ! defined( 'BSWGRAVITYFORMSPIPEDRIVE_PLUGIN_PATH' ) ) {
	define( 'BSWGRAVITYFORMSPIPEDRIVE_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
}

require_once BSWGRAVITYFORMSPIPEDRIVE_PLUGIN_PATH . 'vendor/autoload.php';

add_action( 'gform_loaded', array( 'BSWGRAVITYFORMSPIPEDRIVE_Bootstrap', 'load' ), 5 );

/**
 * Class BSWGRAVITYFORMSPIPEDRIVE_Bootstrap
 */
class BSWGRAVITYFORMSPIPEDRIVE_Bootstrap {

	/**
	 * Load the add-on
	 *
	 * @return void
	 */
	public static function load() {

		if ( ! method_exists( 'GFForms', 'include_addon_framework' ) ) {
			return;
		}

		include_once 'class-gf-pipedrive.php';

		GFAddOn::register( 'BSWGFPipedrive' );
	}
}

/**
 * Get an instance of the main plugin class.
 *
 * @return BSWGFPipedrive
 */
function BSWGRAVITYFORMSPIPEDRIVE_addon() {
	return BSWGFPipedrive::get_instance();
}

/**
 * Load plugin textdomain.
 */
function BSWGRAVITYFORMSPIPEDRIVE_load_textdomain() {
	load_plugin_textdomain( 'bsw-gravityforms-pipedrive', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}

add_action( 'init', 'BSWGRAVITYFORMSPIPEDRIVE_load_textdomain' );
