Completed
Push — master ( 75f6d6...937118 )
by Evan
05:05
created

yikes-inc-easy-mailchimp-extender.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 46 and the first side effect is on line 36.

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.

Loading history...
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.4
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 version constant
41
 *
42
 * 	@since 6.1.3
43
 *	@return void
44
 */
45
if ( ! defined( 'YIKES_MC_VERSION' ) ) {
46
	define( 'YIKES_MC_VERSION' , '6.1.4' );
47
}
48
49
/**
50
 * 	Define path constant to our plugin directory.
51
 *
52
 * 	@since 6.0.0
53
 *	@return void
54
 */
55
if ( ! defined( 'YIKES_MC_PATH' ) ) {
56
	define( 'YIKES_MC_PATH' , plugin_dir_path( __FILE__ ) );
57
}
58
59
/**
60
 * 	Define URL constant to our plugin directory.
61
 *
62
 * 	@since 6.0.0
63
 *	@return void
64
 */
65
if ( ! defined( 'YIKES_MC_URL' ) ) {
66
	define( 'YIKES_MC_URL' , plugin_dir_url( __FILE__ ) );
67
}
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
	require_once YIKES_MC_PATH . 'includes/class-yikes-inc-easy-mailchimp-extender-activator.php';
83
	add_option( 'yikes_mailchimp_activation_redirect', 'true' );
84
	Yikes_Inc_Easy_Mailchimp_Extender_Activator::activate( $network_wide );
85
}
86
87
/**
88
 *	uninstall_yikes_inc_easy_mailchimp_extender();
89
 * 	The code that runs during uninstall.
90
 *
91
 * 	This action is documented in includes/class-yikes-inc-easy-mailchimp-extender-uninstall.php
92
 *	and carries out the deletion of MailChimp transients, plugin options and MailChimp form tables.
93
 *
94
 * @since 6.0.0
95
 *	@return void
96
 */
97
register_deactivation_hook( __FILE__, 'deactivate_yikes_inc_easy_mailchimp_extender' );
98
function deactivate_yikes_inc_easy_mailchimp_extender() {
99
	// delete the activation re-driect option
100
	update_option( 'yikes_mailchimp_activation_redirect', 'true' );
101
}
102
103
/**
104
 *	uninstall_yikes_inc_easy_mailchimp_extender();
105
 * 	The code that runs during uninstall.
106
 *
107
 * 	This action is documented in includes/class-yikes-inc-easy-mailchimp-extender-uninstall.php
108
 *	and carries out the deletion of MailChimp transients, plugin options and MailChimp form tables.
109
 *
110
 * @since 6.0.0
111
 *	@return void
112
 */
113
register_uninstall_hook( __FILE__, 'uninstall_yikes_inc_easy_mailchimp_extender' );
114
function uninstall_yikes_inc_easy_mailchimp_extender() {
115
	require_once YIKES_MC_PATH . 'includes/class-yikes-inc-easy-mailchimp-extender-uninstall.php';
116
	Yikes_Inc_Easy_Mailchimp_Extender_Uninstaller::uninstall();
117
}
118
119
/**
120
 * 	Multi-site blog creation
121
 *
122
 *	If a new blog is created on a mutli-site network
123
 *	we should run our activation hook to create the necessary form table
124
 *
125
 * 	@since 6.0.0
126
 *	@return void
127
 */
128
add_action( 'wpmu_new_blog', 'yikes_easy_mailchimp_new_network_site', 10, 6 );
129
function yikes_easy_mailchimp_new_network_site( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
130
	global $wpdb, $switched;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
131
	if ( is_plugin_active_for_network( 'yikes-inc-easy-mailchimp-extender/yikes-inc-easy-mailchimp-extender.php' ) ) {
132
		require_once YIKES_MC_PATH . 'includes/class-yikes-inc-easy-mailchimp-extender-activator.php';
133
		$old_blog = $wpdb->blogid;
134
		switch_to_blog( $blog_id );
135
		Yikes_Inc_Easy_Mailchimp_Extender_Activator::activate( $networkwide = null );
136
		switch_to_blog( $old_blog );
137
	}
138
}
139
140
/**
141
 * The base plugin class
142
 * admin-specific hooks, filters and all functionality
143
 */
144
require plugin_dir_path( __FILE__ ) . 'includes/class-yikes-inc-easy-mailchimp-extender.php';
145
146
/**
147
 * 	Begins execution of the plugin.
148
 *
149
 * 	@since 6.0.0
150
 *	@return Yikes_Inc_Easy_Mailchimp_Extender
151
 */
152
function run_yikes_inc_easy_mailchimp_extender() {
153
	$plugin = new Yikes_Inc_Easy_Mailchimp_Extender();
154
	$plugin->run();
155
}
156
run_yikes_inc_easy_mailchimp_extender();
157
158
/**
159
 * Helper function to return our API key
160
 * Support the use of a PHP constant
161
 * @return string MailChimp API key from the PHP constant, or the options
162
 */
163
function yikes_get_mc_api_key() {
164
	if ( defined( 'YIKES_MC_API_KEY' ) ) {
165
		return trim( YIKES_MC_API_KEY );
166
	}
167
	return trim( get_option( 'yikes-mc-api-key', '' ) );
168
}
169
170
add_action( 'plugins_loaded', 'yikes_mailchimp_plugin_textdomain' );
171
function yikes_mailchimp_plugin_textdomain() {
172
	load_plugin_textdomain( 'yikes-inc-easy-mailchimp-extender', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
173
}
174
175
/*
176
*	Enjoy this wonderfully powerful (and free) plugin.
177
*	~<|:D
178
*/
179