-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzulu-edm-connector.php
143 lines (122 loc) · 5.01 KB
/
zulu-edm-connector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/*
=== Zulu eDM sync with Contact Form 7 Connector ===
Requires PHP: 5.3.0
Contributors: zululabs
Author URL: https://github.com/zululabsshaka/zulu_edm_wp_connector
Tags: Zulu eDM, email service provider,email API cf7, contact form 7, Contact Form 7 Integrations, contact forms, Zulu eDM Integrations
Requires at least: 4.6
Tested up to: 4.9.6
Stable tag: trunk
License: GPLv3.0 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Donate link: https://donate.wwf.org.au/adopt/tiger
*/
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly
}
// Declare some global constants
define('ZE_CONNECTOR_VERSION', '1.0');
define('ZE_CONNECTOR_DB_VERSION', '1.0');
define('ZE_CONNECTOR_ROOT', dirname(__FILE__));
define('ZE_CONNECTOR_URL', plugins_url('/', __FILE__));
define('ZE_CONNECTOR_BASE_FILE', basename(dirname(__FILE__)) . '/zulu-edm-connector.php');
define('ZE_CONNECTOR_PATH', plugin_dir_path(__FILE__)); //use for include files to other files
define('ZE_CONNECTOR_PRODUCT_NAME', 'Zulu eDM Connector');
define('ZE_CONNECTOR_CURRENT_THEME', get_stylesheet_directory());
//load_plugin_textdomain('zeconnector', false, basename(dirname(__FILE__)) . '/languages');
/*
* include utility classes
*/
if (!class_exists('Ze_Connector_Utility')) {
include( ZE_CONNECTOR_ROOT . '/includes/class-ze-utility.php' );
}
if (!class_exists('Ze_Connector_Service')) {
include( ZE_CONNECTOR_ROOT . '/includes/class-ze-service.php' );
}
/*
* Main ZE connector class
* @class Ze_Connector_Init
* @since 1.0
*/
class Ze_Connector_Init {
/**
* Set things up.
* @since 1.0
*/
public function __construct() {
//run on activation of plugin
//register_activation_hook(__FILE__, array($this, 'ze_connector_activate'));
//run on deactivation of plugin
//register_deactivation_hook(__FILE__, array($this, 'ze_connector_deactivate'));
// validate is contact form 7 plugin exist
add_action('admin_init', array($this, 'validate_parent_plugin_exists'));
// register admin menu under "Contact" > "Integration"
add_action('admin_menu', array($this, 'register_ze_menu_pages'));
// load the js and css files
add_action('init', array($this, 'load_css_and_js_files'));
}
/**
* Validate parent Plugin Contact Form 7 exist and activated
* @access public
* @since 1.0
*/
public function validate_parent_plugin_exists() {
$plugin = plugin_basename(__FILE__);
if ((!is_plugin_active('contact-form-7/wp-contact-form-7.php') ) && (!is_plugin_active('zulu-edm-connector/zulu-edm-connector') )) {
add_action('admin_notices', array($this, 'contact_form_7_missing_notice'));
deactivate_plugins($plugin);
if (isset($_GET['activate'])) {
// Do not sanitize it because we are destroying the variables from URL
unset($_GET['activate']);
}
}
}
/**
* If Contact Form 7 plugin is not installed or activated then throw the error
*
* @access public
* @return mixed error_message, an array containing the error message
*
* @since 1.0 initial version
*/
public function contact_form_7_missing_notice() {
$plugin_error = Ze_Connector_Utility::instance()->admin_notice(array(
'type' => 'error',
'message' => 'Zulu eDM Connector Add-on requires Contact Form 7 plugin and LACRM plugin to be installed and activated.'
));
echo $plugin_error;
}
/**
* Create/Register menu items for the plugin.
* @since 1.0
*/
public function register_ze_menu_pages() {
$current_role = Ze_Connector_Utility::instance()->get_current_user_role();
}
public function load_css_and_js_files() {
add_action('admin_print_styles', array($this, 'add_css_files'));
add_action('admin_print_scripts', array($this, 'add_js_files'));
}
/**
* enqueue CSS files
* @since 1.0
*/
public function add_css_files() {
if (is_admin() && ( isset($_GET['page']) && ( ( $_GET['page'] == 'wpcf7-new' ) || ( $_GET['page'] == 'wpcf7-zulu-edm-config' ) || ( $_GET['page'] == 'wpcf7' ) ) )) {
wp_enqueue_style('ze-connector-css', ZE_CONNECTOR_URL . 'assets/css/ze-connector.css', ZE_CONNECTOR_VERSION, true);
}
}
/**
* enqueue JS files
* @since 1.0
*/
public function add_js_files() {
if (is_admin() && ( isset($_GET['page']) && ( ( $_GET['page'] == 'wpcf7-new' ) || ( $_GET['page'] == 'wpcf7-zulu-edm-config' ) ) )) {
wp_enqueue_script('ze-connector-js', ZE_CONNECTOR_URL . 'assets/js/ze-connector.js', ZE_CONNECTOR_VERSION, true);
wp_enqueue_script('jquery-json', ZE_CONNECTOR_URL . 'assets/js/jquery.json.js', '', '2.3', true);
}
}
}
// Initialize the LACRM connector class
$init = new Ze_Connector_Init();