Code

< 40 %
40-60 %
> 60 %
1
<?php
2
/**
3
 * Plugin Name: Easy Forms for Mailchimp
4
 * Plugin URI:  https://yikesplugins.com/plugin/easy-forms-for-mailchimp/
5
 * 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://yikesplugins.com/support/knowledge-base/finding-your-mailchimp-api-key/" target="_blank">Mailchimp API key</a>.
6
 * Version:     6.8.5
7
 * Author:      YIKES, Inc.
8
 * Author URI:  https://www.yikesplugins.com/
9
 * License:     GPL-3.0+
10
 * License URI: http://www.gnu.org/licenses/gpl-3.0.txt
11
 * Text Domain: yikes-inc-easy-mailchimp-extender
12
 *
13
 * Easy Forms for Mailchimp is free software: you can redistribute it and/or modify
14
 * it under the terms of the GNU General Public License as published by
15
 * the Free Software Foundation, either version 2 of the License, or
16
 * any later version.
17
 *
18
 * Easy Forms for Mailchimp is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with Easy Forms for Mailchimp. If not, see <http://www.gnu.org/licenses/>.
25
 *
26
 * We at YIKES, Inc. embrace the open source philosophy on a daily basis. We donate company time back to the WordPress project,
27
 * and constantly strive to improve the WordPress project and community as a whole.
28
 *
29
 * "'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'."
30
 * - Richard Stallman
31
 */
32
33
34
// If accessed directly, abort
35
if ( ! defined( 'WPINC' ) ) {
36
	die;
37
}
38
39
/**
40
 *  Define version constant
41
 *
42
 *  @since 6.1.3
43
 */
44
if ( ! defined( 'YIKES_MC_VERSION' ) ) {
45
	define( 'YIKES_MC_VERSION', '6.8.5' );
46
}
47
48
/**
49
 *  Define path constant to our plugin directory.
50
 *
51
 *  @since 6.0.0
52
 */
53
if ( ! defined( 'YIKES_MC_PATH' ) ) {
54
	define( 'YIKES_MC_PATH', plugin_dir_path( __FILE__ ) );
55
}
56
57
/**
58
 *  Define URL constant to our plugin directory.
59
 *
60
 *  @since 6.0.0
61
 */
62
if ( ! defined( 'YIKES_MC_URL' ) ) {
63
	define( 'YIKES_MC_URL', plugin_dir_url( __FILE__ ) );
64
}
65
66
// Include our autoloader
67
require_once dirname( __FILE__ ) . '/class-loader.php';
68
69
/**
70
 *  activate_yikes_inc_easy_mailchimp_extender();
71
 *  Fires during activation.
72
 *
73
 *  This action is documented in includes/class-yikes-inc-easy-mailchimp-extender-activator.php
74
 *  and carries out some important tasks such as creating our custom database table if it doesn't
75
 *  already exist, and defining default options.
76
 *
77
 *  @since 6.0.0
78
 *  @return void
79
 */
80
register_activation_hook( __FILE__, 'activate_yikes_inc_easy_mailchimp_extender' );
81
function activate_yikes_inc_easy_mailchimp_extender( $network_wide ) {
82
	Yikes_Inc_Easy_Mailchimp_Extender_Activator::activate( $network_wide );
83
}
84
85
/**
86
 *  uninstall_yikes_inc_easy_mailchimp_extender();
87
 *  The code that runs during uninstall.
88
 *
89
 *  This action is documented in includes/class-yikes-inc-easy-mailchimp-extender-uninstall.php
90
 *  and carries out the deletion of Mailchimp transients, plugin options and Mailchimp form tables.
91
 *
92
 * @since 6.0.0
93
 *  @return void
94
 */
95
register_deactivation_hook( __FILE__, 'deactivate_yikes_inc_easy_mailchimp_extender' );
96
function deactivate_yikes_inc_easy_mailchimp_extender() {
97
	// delete the activation re-driect option
98
	update_option( 'yikes_mailchimp_activation_redirect', 'true' );
99
}
100
101
/**
102
 *  uninstall_yikes_inc_easy_mailchimp_extender();
103
 *  The code that runs during uninstall.
104
 *
105
 *  This action is documented in includes/class-yikes-inc-easy-mailchimp-extender-uninstall.php
106
 *  and carries out the deletion of Mailchimp transients, plugin options and Mailchimp form tables.
107
 *
108
 * @since 6.0.0
109
 * @return void
110
 */
111
register_uninstall_hook( __FILE__, 'uninstall_yikes_inc_easy_mailchimp_extender' );
112
function uninstall_yikes_inc_easy_mailchimp_extender() {
113
	Yikes_Inc_Easy_Mailchimp_Extender_Uninstaller::uninstall();
114
}
115
116
/**
117
 *  Multi-site blog creation
118
 *
119
 *  If a new blog is created on a mutli-site network
120
 *  we should run our activation hook to create the necessary form table
121
 *
122
 *  @since 6.0.0
123
 *  @return void
124
 */
125
add_action( 'wpmu_new_blog', 'yikes_easy_mailchimp_new_network_site', 10, 6 );
126
function yikes_easy_mailchimp_new_network_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
127
	if ( is_plugin_active_for_network( 'yikes-inc-easy-mailchimp-extender/yikes-inc-easy-mailchimp-extender.php' ) ) {
128
		switch_to_blog( $blog_id );
129
		Yikes_Inc_Easy_Mailchimp_Extender_Activator::activate( false );
130
		restore_current_blog();
131
	}
132
}
133
134
/**
135
 * Retrieve the forms interface that we should be using.
136
 *
137
 * By default this will use the new Options interface, but this can be
138
 * overridden by a constant, YIKES_MC_CUSTOM_DB.
139
 *
140
 * @author Jeremy Pry
141
 * @return Yikes_Inc_Easy_Mailchimp_Extender_Form_Interface
142
 */
143
function yikes_easy_mailchimp_extender_get_form_interface() {
144
	static $interface = null;
145
146
	if ( null === $interface ) {
147
		if ( yikes_inc_easy_mailchimp_extender_use_custom_db() ) {
148
			global $wpdb;
149
			$interface = new Yikes_Inc_Easy_Mailchimp_Extender_Forms( $wpdb );
150
		} else {
151
			$interface = new Yikes_Inc_Easy_Mailchimp_Extender_Option_Forms();
152
		}
153
	}
154
155
	return $interface;
156
}
157
158
/**
159
 * Determine whether we should use the custom database table.
160
 *
161
 * @author Jeremy Pry
162
 * @return bool Whether to use the custom database table.
163
 */
164
function yikes_inc_easy_mailchimp_extender_use_custom_db() {
165
	/**
166
	 * Filter whether we should use the custom database table instead of the Options API
167
	 *
168
	 * @param bool $use_custom_db True to use the custom database table, false to use the Options API.
169
	 */
170
	return (bool) apply_filters( 'yikes_easy_mailchimp_extender_use_custom_db', defined( 'YIKES_EMCE_CUSTOM_DB' ) && YIKES_EMCE_CUSTOM_DB );
171
}
172
173
/**
174
 *  Begins execution of the plugin.
175
 *
176
 *  @since 6.0.0
177
 *  @return Yikes_Inc_Easy_Mailchimp_Extender
178
 */
179
function yikes_inc_easy_mailchimp_extender() {
180
	static $plugin = null;
181
182
	if ( null === $plugin ) {
183
		$plugin = new Yikes_Inc_Easy_Mailchimp_Extender( yikes_easy_mailchimp_extender_get_form_interface() );
184
		$plugin->run();
185
	}
186
187
	return $plugin;
188
}
189
yikes_inc_easy_mailchimp_extender()->run();
190
191
/**
192
 * Helper function to return our API key
193
 * Support the use of a PHP constant
194
 *
195
 * @return string Mailchimp API key from the PHP constant, or the options
196
 * @security strip away tags and patch security
197
 * @since 6.2.2
198
 */
199
function yikes_get_mc_api_key() {
200
	if ( defined( 'YIKES_MC_API_KEY' ) ) {
201
		return trim( strip_tags( YIKES_MC_API_KEY ) );
202
	}
203
204
	return trim( strip_tags( get_option( 'yikes-mc-api-key', '' ) ) );
205
}
206
207
/**
208
 * Get the API Manager instance.
209
 *
210
 * @author Jeremy Pry
211
 * @return Yikes_Inc_Easy_Mailchimp_API_Manager
212
 */
213
function yikes_get_mc_api_manager() {
214
	static $manager = null;
215
216
	if ( null === $manager ) {
217
		$manager = new Yikes_Inc_Easy_Mailchimp_API_Manager( yikes_get_mc_api_key() );
218
	}
219
220
	return $manager;
221
}
222
223
add_action( 'plugins_loaded', 'yikes_mailchimp_plugin_textdomain' );
224
function yikes_mailchimp_plugin_textdomain() {
225
	load_plugin_textdomain( 'yikes-inc-easy-mailchimp-extender', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
226
}
227
228
/*
229
*	Enjoy this wonderfully powerful (and free) plugin.
230
*	~<|:D
231
*/
232