| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: FormsCRM |
| 4 |
* Plugin URI: https://closemarketing.net/formscrm |
| 5 |
* Description: Connects Forms with CRM. |
| 6 |
* Version: 3.6 |
| 7 |
* Author: Closemarketing |
| 8 |
* Author URI: https://close.marketing |
| 9 |
* Text Domain: formscrm |
| 10 |
* Domain Path: /languages |
| 11 |
* License: GPL-2.0+ |
| 12 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 13 |
* |
| 14 |
* @package WordPress |
| 15 |
* @author Closemarketing |
| 16 |
* @copyright 2021 Closemarketing |
| 17 |
* @license GPL-2.0+ |
| 18 |
* |
| 19 |
* @wordpress-plugin |
| 20 |
* |
| 21 |
* Prefix: fcrm |
| 22 |
*/ |
| 23 |
|
| 24 |
defined( 'ABSPATH' ) || die( 'No script kiddies please!' ); |
| 25 |
|
| 26 |
define( 'FORMSCRM_VERSION', '3.6' ); |
| 27 |
|
| 28 |
add_action( 'plugins_loaded', 'fcrm_plugin_init' ); |
| 29 |
/** |
| 30 |
* Load localization files |
| 31 |
* |
| 32 |
* @return void |
| 33 |
*/ |
| 34 |
function fcrm_plugin_init() { |
| 35 |
load_plugin_textdomain( 'formscrm', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); |
| 36 |
} |
| 37 |
|
| 38 |
require_once 'includes/debug.php'; |
| 39 |
require_once 'includes/class-library-crm.php'; |
| 40 |
require_once 'includes/class-admin-options.php'; |
| 41 |
|
| 42 |
// Prevents fatal error is_plugin_active. |
| 43 |
if ( ! function_exists( 'is_plugin_active' ) ) { |
| 44 |
include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 45 |
} |
| 46 |
|
| 47 |
if ( is_plugin_active( 'gravityforms/gravityforms.php' ) || is_plugin_active( 'gravity-forms/gravityforms.php' ) ) { |
| 48 |
add_action( 'gform_loaded', array( 'FC_CRM_Bootstrap', 'load' ), 5 ); |
| 49 |
class FC_CRM_Bootstrap { |
| 50 |
|
| 51 |
public static function load() { |
| 52 |
|
| 53 |
if ( ! method_exists( 'GFForms', 'include_feed_addon_framework' ) ) { |
| 54 |
return; |
| 55 |
} |
| 56 |
|
| 57 |
require_once 'includes/class-gravityforms.php'; |
| 58 |
|
| 59 |
GFAddOn::register( 'GFCRM' ); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
function gf_crm() { |
| 64 |
return FCCRM::get_instance(); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
// ContactForms7. |
| 69 |
if ( is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) { |
| 70 |
require_once 'includes/class-contactform7.php'; |
| 71 |
} |
| 72 |
|
| 73 |
// WooCommerce. |
| 74 |
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { |
| 75 |
require_once 'includes/class-woocommerce.php'; |
| 76 |
} |
| 77 |
|
| 78 |
// Visitor Key. |
| 79 |
add_action( 'init', 'formscrm_visitorkey_session', 1 ); |
| 80 |
/** |
| 81 |
* Adds visitor key to the session. |
| 82 |
* |
| 83 |
* @return void |
| 84 |
*/ |
| 85 |
function formscrm_visitorkey_session() { |
| 86 |
global $wp_session; |
| 87 |
|
| 88 |
$visitor_key = isset( $_COOKIE['vk'] ) ? sanitize_text_field( $_COOKIE['vk'] ) : ''; |
| 89 |
if ( $visitor_key && ! isset( $wp_session['clientify_visitor_key'] ) ) { |
| 90 |
$wp_session['clientify_visitor_key'] = $visitor_key; |
| 91 |
} |
| 92 |
} |
| 93 |
|