Completed
Branch BUG-8957-add-countries (9d990b)
by
unknown
72:59 queued 53:55
created

espresso.php ➔ espresso_plugin_deactivation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php if ( ! defined( 'ABSPATH' ) ) {
2
	exit( 'No direct script access allowed' );
3
}
4
/*
5
  Plugin Name:		Event Espresso
6
  Plugin URI:  		http://eventespresso.com/pricing/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=wordpress_plugins_page&utm_content=support_link
7
  Description: 		Manage your events from your WordPress dashboard. Reduce your admin, reduce your costs make your life easier! | <a href="admin.php?page=espresso_support&action=contact_support">Support</a>
8
  Version:			4.9.18.rc.008
9
  Author:			Event Espresso
10
  Author URI: 		http://eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=wordpress_plugins_page&utm_content=support_link
11
  License: 		    GPLv2
12
  TextDomain: 		event_espresso
13
  GitHub Plugin URI: https://github.com/eventespresso/event-espresso-core
14
  Copyright 		(c) 2008-2014 Event Espresso  All Rights Reserved.
15
16
  This program is free software; you can redistribute it and/or modify
17
  it under the terms of the GNU General Public License as published by
18
  the Free Software Foundation; either version 2 of the License, or
19
  (at your option) any later version.
20
21
  This program is distributed in the hope that it will be useful,
22
  but WITHOUT ANY WARRANTY; without even the implied warranty of
23
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
  GNU General Public License for more details.
25
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29
 */
30
/**
31
 * Event Espresso
32
 * Event Registration and Management Plugin for WordPress
33
 *
34
 * @package          Event Espresso
35
 * @author           Seth Shoultes
36
 * @copyright    (c) 2008-2014 Event Espresso  All Rights Reserved.
37
 * @license          {@link http://eventespresso.com/support/terms-conditions/}
38
 * @see              Plugin Licensing
39
 * @link             {@link http://www.eventespresso.com}
40
 * @since            4.0
41
 */
42
if ( function_exists( 'espresso_version' ) ) {
43
44
	/**
45
	 *    espresso_duplicate_plugin_error
46
	 *    displays if more than one version of EE is activated at the same time
47
	 */
48
	function espresso_duplicate_plugin_error() {
49
		?>
50
		<div class="error">
51
			<p>
52
				<?php echo esc_html__(
53
				'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
				'event_espresso'
55
				); ?>
56
			</p>
57
		</div>
58
		<?php
59
		espresso_deactivate_plugin( plugin_basename( __FILE__ ) );
60
	}
61
	add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 );
62
63
} else {
64
65
	define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' );
66
67
	if ( ! version_compare( PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=' ) ) {
68
69
		/**
70
		 * espresso_minimum_php_version_error
71
		 *
72
		 * @return void
73
		 */
74
		function espresso_minimum_php_version_error() {
75
			?>
76
			<div class="error">
77
				<p>
78
					<?php
79
					printf(
80
						esc_html__(
81
							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
82
							'event_espresso'
83
						),
84
						EE_MIN_PHP_VER_REQUIRED,
85
						PHP_VERSION,
86
						'<br/>',
87
						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
88
					);
89
					?>
90
				</p>
91
			</div>
92
			<?php
93
			espresso_deactivate_plugin( plugin_basename( __FILE__ ) );
94
		}
95
		add_action( 'admin_notices', 'espresso_minimum_php_version_error', 1 );
96
97
	} else {
98
99
		/**
100
		 * espresso_version
101
		 * Returns the plugin version
102
		 *
103
		 * @return string
104
		 */
105
		function espresso_version() {
106
			return apply_filters( 'FHEE__espresso__espresso_version', '4.9.18.rc.008' );
107
		}
108
109
		// define versions
110
		define( 'EVENT_ESPRESSO_VERSION', espresso_version() );
111
		define( 'EE_MIN_WP_VER_REQUIRED', '4.1' );
112
		define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' );
113
		define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' );
114
		define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ );
115
116
		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
117
		if ( ! defined( 'DS' ) ) {
118
			define( 'DS', '/' );
119
		}
120
		if ( ! defined( 'PS' ) ) {
121
			define( 'PS', PATH_SEPARATOR );
122
		}
123
		if ( ! defined( 'SP' ) ) {
124
			define( 'SP', ' ' );
125
		}
126
		if ( ! defined( 'EENL' ) ) {
127
			define( 'EENL', "\n" );
128
		}
129
		define( 'EE_SUPPORT_EMAIL', '[email protected]' );
130
		// define the plugin directory and URL
131
		define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) );
132
		define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) );
133
		define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) );
134
		// main root folder paths
135
		define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS );
136
		define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS );
137
		define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS );
138
		define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS );
139
		define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS );
140
		define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS );
141
		define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS );
142
		define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS );
143
		// core system paths
144
		define( 'EE_ADMIN', EE_CORE . 'admin' . DS );
145
		define( 'EE_CPTS', EE_CORE . 'CPTs' . DS );
146
		define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS );
147
		define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS );
148
		define( 'EE_BUSINESS', EE_CORE . 'business' . DS );
149
		define( 'EE_MODELS', EE_CORE . 'db_models' . DS );
150
		define( 'EE_HELPERS', EE_CORE . 'helpers' . DS );
151
		define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS );
152
		define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS );
153
		define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS );
154
		define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS );
155
		define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS );
156
		// gateways
157
		define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS );
158
		define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS );
159
		// asset URL paths
160
		define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS );
161
		define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS );
162
		define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS );
163
		define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS );
164
		define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' );
165
		define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' );
166
		// define upload paths
167
		$uploads = wp_upload_dir();
168
		// define the uploads directory and URL
169
		define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS );
170
		define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS );
171
		// define the templates directory and URL
172
		define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS );
173
		define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS );
174
		// define the gateway directory and URL
175
		define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS );
176
		define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS );
177
		// languages folder/path
178
		define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS );
179
		define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS );
180
		//check for dompdf fonts in uploads
181
		if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) {
182
			define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS );
183
		}
184
		//ajax constants
185
		define(
186
			'EE_FRONT_AJAX',
187
			isset( $_REQUEST['ee_front_ajax'] ) || isset( $_REQUEST['data']['ee_front_ajax'] ) ? true : false
188
		);
189
		define(
190
			'EE_ADMIN_AJAX',
191
			isset( $_REQUEST['ee_admin_ajax'] ) || isset( $_REQUEST['data']['ee_admin_ajax'] ) ? true : false
192
		);
193
		//just a handy constant occasionally needed for finding values representing infinity in the DB
194
		//you're better to use this than its straight value (currently -1) in case you ever
195
		//want to change its default value! or find when -1 means infinity
196
		define( 'EE_INF_IN_DB', -1 );
197
		define( 'EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX );
198
		define( 'EE_DEBUG', false );
199
200
201
		/**
202
		 *    espresso_plugin_activation
203
		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
204
		 */
205
		function espresso_plugin_activation() {
206
			update_option( 'ee_espresso_activation', true );
207
		}
208
		register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' );
209
210
211
212
		/**
213
		 *    espresso_load_error_handling
214
		 *    this function loads EE's class for handling exceptions and errors
215
		 */
216
		function espresso_load_error_handling() {
217
			// load debugging tools
218
			if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) {
219
				require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' );
220
				EEH_Debug_Tools::instance();
221
			}
222
			// load error handling
223
			if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) {
224
				require_once( EE_CORE . 'EE_Error.core.php' );
225
			} else {
226
				wp_die( esc_html__( 'The EE_Error core class could not be loaded.', 'event_espresso' ) );
227
			}
228
		}
229
230
231
232
		/**
233
		 *    espresso_load_required
234
		 *    given a class name and path, this function will load that file or throw an exception
235
		 *
236
		 * @param    string $classname
237
		 * @param    string $full_path_to_file
238
		 * @throws    EE_Error
239
		 */
240
		function espresso_load_required( $classname, $full_path_to_file ) {
241
			static $error_handling_loaded = false;
242
			if ( ! $error_handling_loaded ) {
243
				espresso_load_error_handling();
244
				$error_handling_loaded = true;
245
			}
246
			if ( is_readable( $full_path_to_file ) ) {
247
				require_once( $full_path_to_file );
248
			} else {
249
				throw new EE_Error (
250
					sprintf(
251
						esc_html__(
252
							'The %s class file could not be located or is not readable due to file permissions.',
253
							'event_espresso'
254
						),
255
						$classname
256
						)
257
				);
258
			}
259
		}
260
261
		espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' );
262
		espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' );
263
		espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' );
264
		new EE_Bootstrap();
265
266
	}
267
}
268
269
if ( ! function_exists( 'espresso_deactivate_plugin' ) ) {
270
271
	/**
272
	 *    deactivate_plugin
273
	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
274
	 *
275
	 * @access public
276
	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
277
	 * @return    void
278
	 */
279
	function espresso_deactivate_plugin( $plugin_basename = '' ) {
280
		if ( ! function_exists( 'deactivate_plugins' ) ) {
281
			require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
282
		}
283
		unset( $_GET['activate'], $_REQUEST['activate'] );
284
		deactivate_plugins( $plugin_basename );
285
	}
286
287
}
288