1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/** |
3
|
|
|
* Plugin Name: Easy Forms for MailChimp by YIKES |
4
|
|
|
* Plugin URI: http://www.yikesinc.com/services/yikes-inc-easy-mailchimp-extender/ |
5
|
|
|
* Description: YIKES Easy Forms for MailChimp links your site to MailChimp and allows you to generate and display mailing list opt-in forms anywhere on your site with ease. |
6
|
|
|
* Version: 6.1.2 |
7
|
|
|
* Author: YIKES |
8
|
|
|
* Author URI: http://www.yikesinc.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
|
|
|
* YIKES 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
|
|
|
* YIKES 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. We eat, sleep and breathe WordPress. |
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 path constant to our plugin directory. |
41
|
|
|
* |
42
|
|
|
* @since 6.0.0 |
43
|
|
|
* @return void |
44
|
|
|
*/ |
45
|
|
|
if ( ! defined( 'YIKES_MC_PATH' ) ) { |
46
|
|
|
define( 'YIKES_MC_PATH' , plugin_dir_path( __FILE__ ) ); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Define URL constant to our plugin directory. |
51
|
|
|
* |
52
|
|
|
* @since 6.0.0 |
53
|
|
|
* @return void |
54
|
|
|
*/ |
55
|
|
|
if ( ! defined( 'YIKES_MC_URL' ) ) { |
56
|
|
|
define( 'YIKES_MC_URL' , plugin_dir_url( __FILE__ ) ); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* activate_yikes_inc_easy_mailchimp_extender(); |
61
|
|
|
* Fires during activation. |
62
|
|
|
* |
63
|
|
|
* This action is documented in includes/class-yikes-inc-easy-mailchimp-extender-activator.php |
64
|
|
|
* and carries out some important tasks such as creating our custom database table if it doesn't |
65
|
|
|
* already exist, and defining default options. |
66
|
|
|
* |
67
|
|
|
* @since 6.0.0 |
68
|
|
|
* @return void |
69
|
|
|
*/ |
70
|
|
|
register_activation_hook( __FILE__, 'activate_yikes_inc_easy_mailchimp_extender' ); |
71
|
|
|
function activate_yikes_inc_easy_mailchimp_extender( $network_wide ) { |
72
|
|
|
require_once YIKES_MC_PATH . 'includes/class-yikes-inc-easy-mailchimp-extender-activator.php'; |
73
|
|
|
add_option( 'yikes_mailchimp_activation_redirect', 'true' ); |
74
|
|
|
Yikes_Inc_Easy_Mailchimp_Extender_Activator::activate( $network_wide ); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* uninstall_yikes_inc_easy_mailchimp_extender(); |
79
|
|
|
* The code that runs during uninstall. |
80
|
|
|
* |
81
|
|
|
* This action is documented in includes/class-yikes-inc-easy-mailchimp-extender-uninstall.php |
82
|
|
|
* and carries out the deletion of MailChimp transients, plugin options and MailChimp form tables. |
83
|
|
|
* |
84
|
|
|
* @since 6.0.0 |
85
|
|
|
* @return void |
86
|
|
|
*/ |
87
|
|
|
register_deactivation_hook( __FILE__, 'deactivate_yikes_inc_easy_mailchimp_extender' ); |
88
|
|
|
function deactivate_yikes_inc_easy_mailchimp_extender() { |
89
|
|
|
// delete the activation re-driect option |
90
|
|
|
update_option( 'yikes_mailchimp_activation_redirect', 'true' ); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* uninstall_yikes_inc_easy_mailchimp_extender(); |
95
|
|
|
* The code that runs during uninstall. |
96
|
|
|
* |
97
|
|
|
* This action is documented in includes/class-yikes-inc-easy-mailchimp-extender-uninstall.php |
98
|
|
|
* and carries out the deletion of MailChimp transients, plugin options and MailChimp form tables. |
99
|
|
|
* |
100
|
|
|
* @since 6.0.0 |
101
|
|
|
* @return void |
102
|
|
|
*/ |
103
|
|
|
register_uninstall_hook( __FILE__, 'uninstall_yikes_inc_easy_mailchimp_extender' ); |
104
|
|
|
function uninstall_yikes_inc_easy_mailchimp_extender() { |
105
|
|
|
require_once YIKES_MC_PATH . 'includes/class-yikes-inc-easy-mailchimp-extender-uninstall.php'; |
106
|
|
|
Yikes_Inc_Easy_Mailchimp_Extender_Uninstaller::uninstall(); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Multi-site blog creation |
111
|
|
|
* |
112
|
|
|
* If a new blog is created on a mutli-site network |
113
|
|
|
* we should run our activation hook to create the necessary form table |
114
|
|
|
* |
115
|
|
|
* @since 6.0.0 |
116
|
|
|
* @return void |
117
|
|
|
*/ |
118
|
|
|
add_action( 'wpmu_new_blog', 'yikes_easy_mailchimp_new_network_site', 10, 6 ); |
119
|
|
|
function yikes_easy_mailchimp_new_network_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
120
|
|
|
global $wpdb, $switched; |
|
|
|
|
121
|
|
|
if ( is_plugin_active_for_network( 'yikes-inc-easy-mailchimp-extender/yikes-inc-easy-mailchimp-extender.php' ) ) { |
122
|
|
|
require_once YIKES_MC_PATH . 'includes/class-yikes-inc-easy-mailchimp-extender-activator.php'; |
123
|
|
|
$old_blog = $wpdb->blogid; |
124
|
|
|
switch_to_blog( $blog_id ); |
125
|
|
|
Yikes_Inc_Easy_Mailchimp_Extender_Activator::activate( $networkwide = null ); |
126
|
|
|
switch_to_blog( $old_blog ); |
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* The base plugin class |
132
|
|
|
* admin-specific hooks, filters and all functionality |
133
|
|
|
*/ |
134
|
|
|
require plugin_dir_path( __FILE__ ) . 'includes/class-yikes-inc-easy-mailchimp-extender.php'; |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Begins execution of the plugin. |
138
|
|
|
* |
139
|
|
|
* @since 6.0.0 |
140
|
|
|
* @return Yikes_Inc_Easy_Mailchimp_Extender |
141
|
|
|
*/ |
142
|
|
|
function run_yikes_inc_easy_mailchimp_extender() { |
143
|
|
|
$plugin = new Yikes_Inc_Easy_Mailchimp_Extender(); |
144
|
|
|
$plugin->run(); |
145
|
|
|
} |
146
|
|
|
run_yikes_inc_easy_mailchimp_extender(); |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Helper function to return our API key |
150
|
|
|
* Support the use of a PHP constant |
151
|
|
|
* @return string MailChimp API key from the PHP constant, or the options |
152
|
|
|
*/ |
153
|
|
|
function yikes_get_mc_api_key() { |
154
|
|
|
if ( defined( 'YIKES_MC_API_KEY' ) ) { |
155
|
|
|
return trim( YIKES_MC_API_KEY ); |
156
|
|
|
} |
157
|
|
|
return trim( get_option( 'yikes-mc-api-key', '' ) ); |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
add_action( 'plugins_loaded', 'yikes_mailchimp_plugin_textdomain' ); |
161
|
|
|
function yikes_mailchimp_plugin_textdomain() { |
162
|
|
|
load_plugin_textdomain( 'yikes-inc-easy-mailchimp-extender', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/* |
166
|
|
|
* Enjoy this wonderfully powerful (and free) plugin. |
167
|
|
|
* ~<|:D |
168
|
|
|
*/ |
169
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.