-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEE_MailChimp.class.php
137 lines (125 loc) · 5.68 KB
/
EE_MailChimp.class.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
<?php
define('ESPRESSO_MAILCHIMP_URL', plugin_dir_url(ESPRESSO_MAILCHIMP_MAIN_FILE));
define('ESPRESSO_MAILCHIMP_ADMIN_DIR', ESPRESSO_MAILCHIMP_DIR . 'admin' . DS . 'mailchimp' . DS);
define('ESPRESSO_MAILCHIMP_DB_DIR', ESPRESSO_MAILCHIMP_DIR . 'db' . DS);
define('ESPRESSO_MAILCHIMP_DMS_PATH', ESPRESSO_MAILCHIMP_DB_DIR . 'migration_scripts' . DS);
define('ESPRESSO_MAILCHIMP_FORMS_PATH', ESPRESSO_MAILCHIMP_DIR . 'includes' . DS . 'forms' . DS);
define('ESPRESSO_MAILCHIMP_MODELS_PATH', ESPRESSO_MAILCHIMP_DB_DIR . 'models' . DS);
define('ESPRESSO_MAILCHIMP_CLASSES_PATH', ESPRESSO_MAILCHIMP_DB_DIR . 'classes' . DS);
define('ESPRESSO_MAILCHIMP_SETTINGS_PAGE_SLUG', 'mailchimp');
define('ESPRESSO_MAILCHIMP_ACTIVE_OPTION', 'ee_mailchimp_active');
define('ESPRESSO_MAILCHIMP_API_OPTIONS', 'ee_mailchimp_user_settings');
/**
* Class EE_MailChimp
*
* @package Event Espresso
* @subpackage ee4-mailchimp
*/
class EE_MailChimp extends EE_Addon
{
/**
* For registering the activation hook.
*/
const activation_indicator_option_name = 'ee4_mailchimp_activation';
/**
* name used to save the config
*/
const CONFIG_NAME = 'Mailchimp';
/**
* Class used for storing config
*/
const CONFIG_CLASS = 'EE_Mailchimp_Config';
/**
* Register our add-on in EE.
*
* @access public
* @return void
* @throws EE_Error
*/
public static function register_addon()
{
// Register our add-on via Plugin API.
EE_Register_Addon::register(
'MailChimp',
[
'version' => ESPRESSO_MAILCHIMP_VERSION,
'class_name' => 'EE_MailChimp',
'min_core_version' => '4.9.26',
'main_file_path' => ESPRESSO_MAILCHIMP_MAIN_FILE,
'admin_path' => ESPRESSO_MAILCHIMP_ADMIN_DIR,
'admin_callback' => 'additional_mailchimp_admin_hooks',
'config_class' => EE_MailChimp::CONFIG_CLASS,
'config_name' => EE_MailChimp::CONFIG_NAME,
'autoloader_paths' => [
'EE_Mailchimp_Config_Api_Settings' => ESPRESSO_MAILCHIMP_DIR
. 'EE_Mailchimp_Config_Api_Settings.php',
'EE_MCI_Controller' => ESPRESSO_MAILCHIMP_DIR . 'lib' . DS
. 'EE_MCI_Controller.class.php',
'Mailchimp_Admin_Page' => ESPRESSO_MAILCHIMP_ADMIN_DIR
. 'Mailchimp_Admin_Page.core.php',
'Mailchimp_Admin_Page_Init' => ESPRESSO_MAILCHIMP_ADMIN_DIR
. 'Mailchimp_Admin_Page_Init.core.php',
'EE_Mailchimp_Config' => ESPRESSO_MAILCHIMP_DIR . 'EE_Mailchimp_Config.php',
'EE_Div_Per_Section_Spaced_Layout' => ESPRESSO_MAILCHIMP_FORMS_PATH
. 'EE_Div_Per_Section_Spaced_Layout.strategy.php',
'EE_MC_Metabox_Form' => ESPRESSO_MAILCHIMP_FORMS_PATH . 'EE_MC_Metabox_Form.form.php',
'EE_MC_Lists_Form' => ESPRESSO_MAILCHIMP_FORMS_PATH . 'EE_MC_Lists_Form.form.php',
'EE_MC_Merge_Fields_Form' => ESPRESSO_MAILCHIMP_FORMS_PATH
. 'EE_MC_Merge_Fields_Form.form.php',
'EE_MC_Interest_Categories_Form' => ESPRESSO_MAILCHIMP_FORMS_PATH
. 'EE_MC_Interest_Categories_Form.form.php',
],
'model_paths' => [ESPRESSO_MAILCHIMP_MODELS_PATH],
'class_paths' => [ESPRESSO_MAILCHIMP_CLASSES_PATH],
'dms_paths' => [ESPRESSO_MAILCHIMP_DMS_PATH],
'module_paths' => [ESPRESSO_MAILCHIMP_DIR . 'EED_Mailchimp.module.php'],
'pue_options' => [
'pue_plugin_slug' => 'eea-mailchimp',
'checkPeriod' => '24',
'use_wp_update' => false,
],
]
);
}
/**
* a safe space for addons to add additional logic like setting hooks
* that will run immediately after addon registration
* making this a great place for code that needs to be "omnipresent"
*/
public function after_registration()
{
require_once(ESPRESSO_MAILCHIMP_DIR . 'lib' . DS . 'sdk' . DS . 'vendor' . DS . 'autoload.php');
}
/**
* Additional admin hooks.
*
* @access public
* @return void
*/
public static function additional_mailchimp_admin_hooks()
{
// Is admin and not in M-Mode ?
if (is_admin() && ! EE_Maintenance_Mode::instance()->level()) {
add_filter('plugin_action_links', ['EE_MailChimp', 'espresso_mailchimp_plugin_settings'], 10, 2);
}
}
/**
* Add a settings link to the Plugins page.
*
* @param array $links List of existing links.
* @param string $file Main plugins file name.
* @return array Updated Links list
*/
public static function espresso_mailchimp_plugin_settings($links, $file)
{
if ($file === ESPRESSO_MAILCHIMP_BASE_NAME) {
$link = 'admin.php?page=' . ESPRESSO_MAILCHIMP_SETTINGS_PAGE_SLUG;
// before other links
array_unshift(
$links,
'<a href="' . $link . '">' . esc_html__('Settings', 'event_espresso') . '</a>'
);
}
return $links;
}
}