forked from EvanHerman/yikes-inc-easy-mailchimp-extender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yikes-inc-easy-mailchimp-extender.php
231 lines (207 loc) · 7.27 KB
/
yikes-inc-easy-mailchimp-extender.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<?php
/**
* Plugin Name: Easy Forms for Mailchimp
* Plugin URI: https://codeparrots.com/plugin/easy-forms-for-mailchimp/
* Description: The ultimate Mailchimp WordPress plugin. Easily build <strong>unlimited forms for your Mailchimp lists</strong>, add them to your site and track subscriber activity. To get started, go to the settings page and enter your <a href="https://codeparrots.com/support/knowledge-base/finding-your-mailchimp-api-key/" target="_blank">Mailchimp API key</a>.
* Version: 6.8.10
* Author: Code Parrots
* Author URI: https://www.codeparrots.com/
* License: GPL-3.0+
* License URI: http://www.gnu.org/licenses/gpl-3.0.txt
* Text Domain: yikes-inc-easy-mailchimp-extender
*
* Easy Forms for Mailchimp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* Easy Forms for Mailchimp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Easy Forms for Mailchimp. If not, see <http://www.gnu.org/licenses/>.
*
* We at Code Parrots embrace the open source philosophy on a daily basis. We donate company time back to the WordPress project,
* and constantly strive to improve the WordPress project and community as a whole.
*
* "'Free software' is a matter of liberty, not price. To understand the concept, you should think of 'free' as in 'free speech,' not as in 'free beer'."
* - Richard Stallman
*/
// If accessed directly, abort
if ( ! defined( 'WPINC' ) ) {
die;
}
/**
* Define version constant
*
* @since 6.1.3
*/
if ( ! defined( 'YIKES_MC_VERSION' ) ) {
define( 'YIKES_MC_VERSION', '6.8.10' );
}
/**
* Define path constant to our plugin directory.
*
* @since 6.0.0
*/
if ( ! defined( 'YIKES_MC_PATH' ) ) {
define( 'YIKES_MC_PATH', plugin_dir_path( __FILE__ ) );
}
/**
* Define URL constant to our plugin directory.
*
* @since 6.0.0
*/
if ( ! defined( 'YIKES_MC_URL' ) ) {
define( 'YIKES_MC_URL', plugin_dir_url( __FILE__ ) );
}
// Include our autoloader
require_once dirname( __FILE__ ) . '/class-loader.php';
/**
* activate_yikes_inc_easy_mailchimp_extender();
* Fires during activation.
*
* This action is documented in includes/class-yikes-inc-easy-mailchimp-extender-activator.php
* and carries out some important tasks such as creating our custom database table if it doesn't
* already exist, and defining default options.
*
* @since 6.0.0
* @return void
*/
register_activation_hook( __FILE__, 'activate_yikes_inc_easy_mailchimp_extender' );
function activate_yikes_inc_easy_mailchimp_extender( $network_wide ) {
Yikes_Inc_Easy_Mailchimp_Extender_Activator::activate( $network_wide );
}
/**
* uninstall_yikes_inc_easy_mailchimp_extender();
* The code that runs during uninstall.
*
* This action is documented in includes/class-yikes-inc-easy-mailchimp-extender-uninstall.php
* and carries out the deletion of Mailchimp transients, plugin options and Mailchimp form tables.
*
* @since 6.0.0
* @return void
*/
register_deactivation_hook( __FILE__, 'deactivate_yikes_inc_easy_mailchimp_extender' );
function deactivate_yikes_inc_easy_mailchimp_extender() {
// delete the activation re-driect option
update_option( 'yikes_mailchimp_activation_redirect', 'true' );
}
/**
* uninstall_yikes_inc_easy_mailchimp_extender();
* The code that runs during uninstall.
*
* This action is documented in includes/class-yikes-inc-easy-mailchimp-extender-uninstall.php
* and carries out the deletion of Mailchimp transients, plugin options and Mailchimp form tables.
*
* @since 6.0.0
* @return void
*/
register_uninstall_hook( __FILE__, 'uninstall_yikes_inc_easy_mailchimp_extender' );
function uninstall_yikes_inc_easy_mailchimp_extender() {
Yikes_Inc_Easy_Mailchimp_Extender_Uninstaller::uninstall();
}
/**
* Multi-site blog creation
*
* If a new blog is created on a mutli-site network
* we should run our activation hook to create the necessary form table
*
* @since 6.0.0
* @return void
*/
add_action( 'wpmu_new_blog', 'yikes_easy_mailchimp_new_network_site', 10, 6 );
function yikes_easy_mailchimp_new_network_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
if ( is_plugin_active_for_network( 'yikes-inc-easy-mailchimp-extender/yikes-inc-easy-mailchimp-extender.php' ) ) {
switch_to_blog( $blog_id );
Yikes_Inc_Easy_Mailchimp_Extender_Activator::activate( false );
restore_current_blog();
}
}
/**
* Retrieve the forms interface that we should be using.
*
* By default this will use the new Options interface, but this can be
* overridden by a constant, YIKES_MC_CUSTOM_DB.
*
* @author Jeremy Pry
* @return Yikes_Inc_Easy_Mailchimp_Extender_Form_Interface
*/
function yikes_easy_mailchimp_extender_get_form_interface() {
static $interface = null;
if ( null === $interface ) {
if ( yikes_inc_easy_mailchimp_extender_use_custom_db() ) {
global $wpdb;
$interface = new Yikes_Inc_Easy_Mailchimp_Extender_Forms( $wpdb );
} else {
$interface = new Yikes_Inc_Easy_Mailchimp_Extender_Option_Forms();
}
}
return $interface;
}
/**
* Determine whether we should use the custom database table.
*
* @author Jeremy Pry
* @return bool Whether to use the custom database table.
*/
function yikes_inc_easy_mailchimp_extender_use_custom_db() {
/**
* Filter whether we should use the custom database table instead of the Options API
*
* @param bool $use_custom_db True to use the custom database table, false to use the Options API.
*/
return (bool) apply_filters( 'yikes_easy_mailchimp_extender_use_custom_db', defined( 'YIKES_EMCE_CUSTOM_DB' ) && YIKES_EMCE_CUSTOM_DB );
}
/**
* Begins execution of the plugin.
*
* @since 6.0.0
* @return Yikes_Inc_Easy_Mailchimp_Extender
*/
function yikes_inc_easy_mailchimp_extender() {
static $plugin = null;
if ( null === $plugin ) {
$plugin = new Yikes_Inc_Easy_Mailchimp_Extender( yikes_easy_mailchimp_extender_get_form_interface() );
$plugin->run();
}
return $plugin;
}
yikes_inc_easy_mailchimp_extender()->run();
/**
* Helper function to return our API key
* Support the use of a PHP constant
*
* @return string Mailchimp API key from the PHP constant, or the options
* @security strip away tags and patch security
* @since 6.2.2
*/
function yikes_get_mc_api_key() {
if ( defined( 'YIKES_MC_API_KEY' ) ) {
return trim( strip_tags( YIKES_MC_API_KEY ) );
}
return trim( strip_tags( get_option( 'yikes-mc-api-key', '' ) ) );
}
/**
* Get the API Manager instance.
*
* @author Jeremy Pry
* @return Yikes_Inc_Easy_Mailchimp_API_Manager
*/
function yikes_get_mc_api_manager() {
static $manager = null;
if ( null === $manager ) {
$manager = new Yikes_Inc_Easy_Mailchimp_API_Manager( yikes_get_mc_api_key() );
}
return $manager;
}
add_action( 'plugins_loaded', 'yikes_mailchimp_plugin_textdomain' );
function yikes_mailchimp_plugin_textdomain() {
load_plugin_textdomain( 'yikes-inc-easy-mailchimp-extender', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
}
/*
* Enjoy this wonderfully powerful (and free) plugin.
* ~<|:D
*/