unique key for the integration, must match with enum on the backend * 'name' => integration name that will be displayed on the UI side * 'type' => the type of integration, it can be plugin or theme * 'identifiers' => the file path (for plugin) or directory name (for theme) * 'iconFile' => file path of image logo file on: lead-crm-wp-plugin/admin/images/plugins * 'webhookUrl' => 365 Lead Management backend destination where we send our captured lead data * ) */ public const SUPPORTED_INTEGRATIONS = array( array( 'key' => 'cf7', 'name' => 'Contact Form 7', 'type' => Leadcrm_WP_Integration_Type::PLUGIN, 'identifiers' => array('contact-form-7/wp-contact-form-7.php'), 'iconFile' => 'cf7-logo.png', 'webhookUrl' => self::API_BASE_URL . '/integrations/contactformseven' ), array( 'key' => 'wpforms', 'name' => 'WPForms', 'type' => Leadcrm_WP_Integration_Type::PLUGIN, 'identifiers' => array('wpforms/wpforms.php', 'wpforms-lite/wpforms.php'), 'iconFile' => 'wpforms-logo.png', 'webhookUrl' => self::API_BASE_URL . '/integrations/wpforms' ), array( 'key' => 'elementor_form', 'name' => 'Elementor (Pro Form & Pro Elements)', 'type' => Leadcrm_WP_Integration_Type::PLUGIN, 'identifiers' => array('elementor-pro/elementor-pro.php', 'pro-elements/pro-elements.php'), 'iconFile' => 'elementor-form-logo.png', 'webhookUrl' => self::API_BASE_URL . '/integrations/elementorform' ), array( 'key' => 'gravity_form', 'name' => 'Gravity Forms', 'type' => Leadcrm_WP_Integration_Type::PLUGIN, 'identifiers' => array('gravityforms/gravityforms.php'), 'iconFile' => 'gravity-form-logo.png', 'webhookUrl' => self::API_BASE_URL . '/integrations/gravityform' ), array( 'key' => 'houzez', 'name' => 'Houzez', 'type' => Leadcrm_WP_Integration_Type::THEME, 'identifiers' => array('houzez'), 'iconFile' => 'houzez-logo.png', 'webhookUrl' => self::API_BASE_URL . '/integrations/houzez' ), array( 'key' => 'divi', 'name' => 'Divi', 'type' => Leadcrm_WP_Integration_Type::THEME, 'identifiers' => array('Divi'), 'iconFile' => 'divi-form-logo.png', 'webhookUrl' => self::API_BASE_URL . '/integrations/divi' ), array( 'key' => 'ninja_form', 'name' => 'Ninja Forms', 'type' => Leadcrm_WP_Integration_Type::PLUGIN, 'identifiers' => array('ninja-forms/ninja-forms.php'), 'iconFile' => 'ninja-form-logo.png', 'webhookUrl' => self::API_BASE_URL . '/integrations/ninjaform' ), array( 'key' => 'forminator_form', 'name' => 'Forminator', 'type' => Leadcrm_WP_Integration_Type::PLUGIN, 'identifiers' => array('forminator/forminator.php'), 'iconFile' => 'forminator-form-logo.png', 'webhookUrl' => self::API_BASE_URL . '/integrations/forminatorform' ), array( 'key' => 'fluent_form', 'name' => 'Fluent Forms', 'type' => Leadcrm_WP_Integration_Type::PLUGIN, 'identifiers' => array('fluentform/fluentform.php'), 'iconFile' => 'fluent-form-logo.png', 'webhookUrl' => self::API_BASE_URL . '/integrations/fluentform' ), array( 'key' => 'formidable_form', 'name' => 'Formidable Forms', 'type' => Leadcrm_WP_Integration_Type::PLUGIN, 'identifiers' => array('formidable/formidable.php'), 'iconFile' => 'formidable-form-logo.png', 'webhookUrl' => self::API_BASE_URL . '/integrations/formidableform' ), array( 'key' => 'everest_form', 'name' => 'Everest Forms', 'type' => Leadcrm_WP_Integration_Type::PLUGIN, 'identifiers' => array('everest-forms/everest-forms.php'), 'iconFile' => 'everest-form-logo.png', 'webhookUrl' => self::API_BASE_URL . '/integrations/everestform' ), array( 'key' => 'metform', 'name' => 'MetForm', 'type' => Leadcrm_WP_Integration_Type::PLUGIN, 'identifiers' => array('metform/metform.php'), 'iconFile' => 'metform-logo.png', 'webhookUrl' => self::API_BASE_URL . '/integrations/metform' ), ); /** * Effective API base URL, allowing a local override via wp-config.php: * define('LEADCRM_API_BASE_URL', 'http://127.0.0.1:8000'); * @return string */ public static function api_base_url() { if (defined('LEADCRM_API_BASE_URL') && is_string(LEADCRM_API_BASE_URL) && LEADCRM_API_BASE_URL !== '') { return rtrim(LEADCRM_API_BASE_URL, '/'); } return self::API_BASE_URL; } /** * Rewrite a production API URL to the local override host (if defined), * keeping the original path and query string. * @param string $url * @return string */ private static function apply_api_base_override($url) { if (!defined('LEADCRM_API_BASE_URL') || !is_string(LEADCRM_API_BASE_URL) || LEADCRM_API_BASE_URL === '') { return $url; } $parts = wp_parse_url($url); if (!is_array($parts) || !isset($parts['path'])) return $url; $override = rtrim(LEADCRM_API_BASE_URL, '/') . $parts['path']; if (isset($parts['query']) && $parts['query'] !== '') $override .= '?' . $parts['query']; return $override; } // For Subscribe OR Check User Token URL public static function get_webhook_subscription_url() { return self::apply_api_base_override(self::API_BASE_URL . '/leadcrm-wp-plugin-user-webhook-subscription'); } public static function get_webhook_url($integration_key) { $supported_keys = array_column(self::SUPPORTED_INTEGRATIONS, 'key'); $found_index = array_search($integration_key, $supported_keys, true); if ($found_index === false) return null; return self::apply_api_base_override(self::SUPPORTED_INTEGRATIONS[$found_index]['webhookUrl']); } public static function get_logo_url() { return plugins_url('admin/images/365-Lead-Management-Dark-Logo.png', dirname(__FILE__)); } public static function get_plugin_icon_url($file_path) { return plugins_url('admin/images/plugins/' . $file_path, dirname(__FILE__)); } } class Leadcrm_WP_Integration_Type { public const THEME = 'theme'; public const PLUGIN = 'plugin'; }