Completed
Branch BUG-10351-incompatible-addons (fdd399)
by
unknown
43:54 queued 32:11
created
core/libraries/plugin_api/EE_Register_Addon.lib.php 1 patch
Indentation   +637 added lines, -637 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	protected static $_incompatible_addons = array(
49 49
 		'Multi_Event_Registration' => '2.0.11.rc.002',
50 50
 		'Promotions' => '1.0.0.rc.084',
51
-    );
51
+	);
52 52
 
53 53
 
54 54
 
@@ -219,660 +219,660 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public static function register( $addon_name = '', $setup_args = array() ) {
221 221
 		// required fields MUST be present, so let's make sure they are.
222
-        \EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
223
-        // get class name for addon
222
+		\EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
223
+		// get class name for addon
224 224
 		$class_name = \EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
225 225
 		//setup $_settings array from incoming values.
226
-        $addon_settings = \EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
227
-        // setup PUE
228
-        \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
229
-        // does this addon work with this version of core or WordPress ?
230
-        if ( ! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings) ) {
231
-            return;
226
+		$addon_settings = \EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
227
+		// setup PUE
228
+		\EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
229
+		// does this addon work with this version of core or WordPress ?
230
+		if ( ! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings) ) {
231
+			return;
232 232
 		}
233 233
 		// register namespaces
234
-        \EE_Register_Addon::_setup_namespaces($addon_settings);
235
-        // check if this is an activation request
236
-        if ( \EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
237
-            // dont bother setting up the rest of the addon atm
238
-            return;
239
-        }
240
-        // we need cars
241
-        \EE_Register_Addon::_setup_autoloaders($addon_name);
242
-        // register new models and extensions
243
-        \EE_Register_Addon::_register_models_and_extensions($addon_name);
244
-        // setup DMS
245
-        \EE_Register_Addon::_register_data_migration_scripts($addon_name);
246
-        // if config_class is present let's register config.
247
-        \EE_Register_Addon::_register_config($addon_name);
248
-        // register admin pages
249
-        \EE_Register_Addon::_register_admin_pages($addon_name);
250
-        // add to list of modules to be registered
251
-        \EE_Register_Addon::_register_modules($addon_name);
252
-        // add to list of shortcodes to be registered
253
-        \EE_Register_Addon::_register_shortcodes($addon_name);
254
-        // add to list of widgets to be registered
255
-        \EE_Register_Addon::_register_widgets($addon_name);
256
-        // register capability related stuff.
257
-        \EE_Register_Addon::_register_capabilities($addon_name);
258
-        // any message type to register?
259
-        \EE_Register_Addon::_register_message_types($addon_name);
234
+		\EE_Register_Addon::_setup_namespaces($addon_settings);
235
+		// check if this is an activation request
236
+		if ( \EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
237
+			// dont bother setting up the rest of the addon atm
238
+			return;
239
+		}
240
+		// we need cars
241
+		\EE_Register_Addon::_setup_autoloaders($addon_name);
242
+		// register new models and extensions
243
+		\EE_Register_Addon::_register_models_and_extensions($addon_name);
244
+		// setup DMS
245
+		\EE_Register_Addon::_register_data_migration_scripts($addon_name);
246
+		// if config_class is present let's register config.
247
+		\EE_Register_Addon::_register_config($addon_name);
248
+		// register admin pages
249
+		\EE_Register_Addon::_register_admin_pages($addon_name);
250
+		// add to list of modules to be registered
251
+		\EE_Register_Addon::_register_modules($addon_name);
252
+		// add to list of shortcodes to be registered
253
+		\EE_Register_Addon::_register_shortcodes($addon_name);
254
+		// add to list of widgets to be registered
255
+		\EE_Register_Addon::_register_widgets($addon_name);
256
+		// register capability related stuff.
257
+		\EE_Register_Addon::_register_capabilities($addon_name);
258
+		// any message type to register?
259
+		\EE_Register_Addon::_register_message_types($addon_name);
260 260
 		// any custom post type/ custom capabilities or default terms to register
261
-        \EE_Register_Addon::_register_custom_post_types($addon_name);
262
-        // and any payment methods
263
-        \EE_Register_Addon::_register_payment_methods($addon_name);
261
+		\EE_Register_Addon::_register_custom_post_types($addon_name);
262
+		// and any payment methods
263
+		\EE_Register_Addon::_register_payment_methods($addon_name);
264 264
 		// load and instantiate main addon class
265
-        $addon = \EE_Register_Addon::_load_and_init_addon_class($addon_name);
266
-        $addon->after_registration();
267
-    }
268
-
269
-
270
-
271
-    /**
272
-     * @param string $addon_name
273
-     * @param array  $setup_args
274
-     * @return void
275
-     * @throws \EE_Error
276
-     */
277
-    private static function _verify_parameters($addon_name, array $setup_args)
278
-    {
279
-        // required fields MUST be present, so let's make sure they are.
280
-        if (empty($addon_name) || ! is_array($setup_args)) {
281
-            throw new EE_Error(
282
-                __(
283
-                    'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.',
284
-                    'event_espresso'
285
-                )
286
-            );
287
-        }
288
-        if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
289
-            throw new EE_Error(
290
-                sprintf(
291
-                    __(
292
-                        'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s',
293
-                        'event_espresso'
294
-                    ),
295
-                    implode(',', array_keys($setup_args))
296
-                )
297
-            );
298
-        }
299
-        // check that addon has not already been registered with that name
300
-        if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) {
301
-            throw new EE_Error(
302
-                sprintf(
303
-                    __(
304
-                        'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
305
-                        'event_espresso'
306
-                    ),
307
-                    $addon_name
308
-                )
309
-            );
310
-        }
265
+		$addon = \EE_Register_Addon::_load_and_init_addon_class($addon_name);
266
+		$addon->after_registration();
267
+	}
268
+
269
+
270
+
271
+	/**
272
+	 * @param string $addon_name
273
+	 * @param array  $setup_args
274
+	 * @return void
275
+	 * @throws \EE_Error
276
+	 */
277
+	private static function _verify_parameters($addon_name, array $setup_args)
278
+	{
279
+		// required fields MUST be present, so let's make sure they are.
280
+		if (empty($addon_name) || ! is_array($setup_args)) {
281
+			throw new EE_Error(
282
+				__(
283
+					'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.',
284
+					'event_espresso'
285
+				)
286
+			);
287
+		}
288
+		if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
289
+			throw new EE_Error(
290
+				sprintf(
291
+					__(
292
+						'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s',
293
+						'event_espresso'
294
+					),
295
+					implode(',', array_keys($setup_args))
296
+				)
297
+			);
298
+		}
299
+		// check that addon has not already been registered with that name
300
+		if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) {
301
+			throw new EE_Error(
302
+				sprintf(
303
+					__(
304
+						'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
305
+						'event_espresso'
306
+					),
307
+					$addon_name
308
+				)
309
+			);
310
+		}
311 311
 	}
312 312
 
313 313
 
314 314
 
315
-    /**
316
-     * @param string $addon_name
317
-     * @param array  $setup_args
318
-     * @return string
319
-     */
320
-    private static function _parse_class_name($addon_name, array $setup_args)
321
-    {
322
-        if (empty($setup_args['class_name'])) {
323
-            // generate one by first separating name with spaces
324
-            $class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
325
-            //capitalize, then replace spaces with underscores
326
-            $class_name = str_replace(' ', '_', ucwords($class_name));
327
-        } else {
328
-            $class_name = $setup_args['class_name'];
329
-        }
330
-        return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name;
331
-    }
332
-
333
-
334
-
335
-    /**
336
-     * @param string $class_name
337
-     * @param array  $setup_args
338
-     * @return array
339
-     */
340
-    private static function _get_addon_settings($class_name, array $setup_args)
341
-    {
342
-        //setup $_settings array from incoming values.
343
-        $addon_settings = array(
344
-            // generated from the addon name, changes something like "calendar" to "EE_Calendar"
345
-            'class_name'            => $class_name,
346
-            // the addon slug for use in URLs, etc
347
-            'plugin_slug'           => isset($setup_args['plugin_slug'])
348
-                ? (string)$setup_args['plugin_slug']
349
-                : '',
350
-            // page slug to be used when generating the "Settings" link on the WP plugin page
351
-            'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
352
-                ? (string)$setup_args['plugin_action_slug']
353
-                : '',
354
-            // the "software" version for the addon
355
-            'version'               => isset($setup_args['version'])
356
-                ? (string)$setup_args['version']
357
-                : '',
358
-            // the minimum version of EE Core that the addon will work with
359
-            'min_core_version'      => isset($setup_args['min_core_version'])
360
-                ? (string)$setup_args['min_core_version']
361
-                : '',
362
-            // the minimum version of WordPress that the addon will work with
363
-            'min_wp_version'        => isset($setup_args['min_wp_version'])
364
-                ? (string)$setup_args['min_wp_version']
365
-                : EE_MIN_WP_VER_REQUIRED,
366
-            // full server path to main file (file loaded directly by WP)
367
-            'main_file_path'        => isset($setup_args['main_file_path'])
368
-                ? (string)$setup_args['main_file_path']
369
-                : '',
370
-            // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
371
-            'admin_path'            => isset($setup_args['admin_path'])
372
-                ? (string)$setup_args['admin_path'] : '',
373
-            // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
374
-            'admin_callback'        => isset($setup_args['admin_callback'])
375
-                ? (string)$setup_args['admin_callback']
376
-                : '',
377
-            // the section name for this addon's configuration settings section (defaults to "addons")
378
-            'config_section'        => isset($setup_args['config_section'])
379
-                ? (string)$setup_args['config_section']
380
-                : 'addons',
381
-            // the class name for this addon's configuration settings object
382
-            'config_class'          => isset($setup_args['config_class'])
383
-                ? (string)$setup_args['config_class'] : '',
384
-            //the name given to the config for this addons' configuration settings object (optional)
385
-            'config_name'           => isset($setup_args['config_name'])
386
-                ? (string)$setup_args['config_name'] : '',
387
-            // an array of "class names" => "full server paths" for any classes that might be invoked by the addon
388
-            'autoloader_paths'      => isset($setup_args['autoloader_paths'])
389
-                ? (array)$setup_args['autoloader_paths']
390
-                : array(),
391
-            // an array of  "full server paths" for any folders containing classes that might be invoked by the addon
392
-            'autoloader_folders'    => isset($setup_args['autoloader_folders'])
393
-                ? (array)$setup_args['autoloader_folders']
394
-                : array(),
395
-            // array of full server paths to any EE_DMS data migration scripts used by the addon
396
-            'dms_paths'             => isset($setup_args['dms_paths'])
397
-                ? (array)$setup_args['dms_paths']
398
-                : array(),
399
-            // array of full server paths to any EED_Modules used by the addon
400
-            'module_paths'          => isset($setup_args['module_paths'])
401
-                ? (array)$setup_args['module_paths']
402
-                : array(),
403
-            // array of full server paths to any EES_Shortcodes used by the addon
404
-            'shortcode_paths'       => isset($setup_args['shortcode_paths'])
405
-                ? (array)$setup_args['shortcode_paths']
406
-                : array(),
407
-            // array of full server paths to any WP_Widgets used by the addon
408
-            'widget_paths'          => isset($setup_args['widget_paths'])
409
-                ? (array)$setup_args['widget_paths']
410
-                : array(),
411
-            // array of PUE options used by the addon
412
-            'pue_options'           => isset($setup_args['pue_options'])
413
-                ? (array)$setup_args['pue_options']
414
-                : array(),
415
-            'message_types'         => isset($setup_args['message_types'])
416
-                ? (array)$setup_args['message_types']
417
-                : array(),
418
-            'capabilities'          => isset($setup_args['capabilities'])
419
-                ? (array)$setup_args['capabilities']
420
-                : array(),
421
-            'capability_maps'       => isset($setup_args['capability_maps'])
422
-                ? (array)$setup_args['capability_maps']
423
-                : array(),
424
-            'model_paths'           => isset($setup_args['model_paths'])
425
-                ? (array)$setup_args['model_paths']
426
-                : array(),
427
-            'class_paths'           => isset($setup_args['class_paths'])
428
-                ? (array)$setup_args['class_paths']
429
-                : array(),
430
-            'model_extension_paths' => isset($setup_args['model_extension_paths'])
431
-                ? (array)$setup_args['model_extension_paths']
432
-                : array(),
433
-            'class_extension_paths' => isset($setup_args['class_extension_paths'])
434
-                ? (array)$setup_args['class_extension_paths']
435
-                : array(),
436
-            'custom_post_types'     => isset($setup_args['custom_post_types'])
437
-                ? (array)$setup_args['custom_post_types']
438
-                : array(),
439
-            'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
440
-                ? (array)$setup_args['custom_taxonomies']
441
-                : array(),
442
-            'payment_method_paths'  => isset($setup_args['payment_method_paths'])
443
-                ? (array)$setup_args['payment_method_paths']
444
-                : array(),
445
-            'default_terms'         => isset($setup_args['default_terms'])
446
-                ? (array)$setup_args['default_terms']
447
-                : array(),
448
-            // if not empty, inserts a new table row after this plugin's row on the WP Plugins page
449
-            // that can be used for adding upgrading/marketing info
450
-            'plugins_page_row'      => isset($setup_args['plugins_page_row'])
451
-                ? $setup_args['plugins_page_row']
452
-                : '',
453
-            'namespace'             => isset(
454
-                $setup_args['namespace'],
455
-                $setup_args['namespace']['FQNS'],
456
-                $setup_args['namespace']['DIR']
457
-            )
458
-                ? (array)$setup_args['namespace']
459
-                : array(),
460
-        );
461
-        // if plugin_action_slug is NOT set, but an admin page path IS set,
462
-        // then let's just use the plugin_slug since that will be used for linking to the admin page
463
-        $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
464
-                                                && ! empty($addon_settings['admin_path'])
465
-            ? $addon_settings['plugin_slug']
466
-            : $addon_settings['plugin_action_slug'];
467
-        // full server path to main file (file loaded directly by WP)
468
-        $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
469
-        return $addon_settings;
315
+	/**
316
+	 * @param string $addon_name
317
+	 * @param array  $setup_args
318
+	 * @return string
319
+	 */
320
+	private static function _parse_class_name($addon_name, array $setup_args)
321
+	{
322
+		if (empty($setup_args['class_name'])) {
323
+			// generate one by first separating name with spaces
324
+			$class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
325
+			//capitalize, then replace spaces with underscores
326
+			$class_name = str_replace(' ', '_', ucwords($class_name));
327
+		} else {
328
+			$class_name = $setup_args['class_name'];
329
+		}
330
+		return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name;
470 331
 	}
471 332
 
472 333
 
473 334
 
474
-    /**
475
-     * @param string $addon_name
476
-     * @param array  $addon_settings
477
-     * @return boolean
478
-     */
335
+	/**
336
+	 * @param string $class_name
337
+	 * @param array  $setup_args
338
+	 * @return array
339
+	 */
340
+	private static function _get_addon_settings($class_name, array $setup_args)
341
+	{
342
+		//setup $_settings array from incoming values.
343
+		$addon_settings = array(
344
+			// generated from the addon name, changes something like "calendar" to "EE_Calendar"
345
+			'class_name'            => $class_name,
346
+			// the addon slug for use in URLs, etc
347
+			'plugin_slug'           => isset($setup_args['plugin_slug'])
348
+				? (string)$setup_args['plugin_slug']
349
+				: '',
350
+			// page slug to be used when generating the "Settings" link on the WP plugin page
351
+			'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
352
+				? (string)$setup_args['plugin_action_slug']
353
+				: '',
354
+			// the "software" version for the addon
355
+			'version'               => isset($setup_args['version'])
356
+				? (string)$setup_args['version']
357
+				: '',
358
+			// the minimum version of EE Core that the addon will work with
359
+			'min_core_version'      => isset($setup_args['min_core_version'])
360
+				? (string)$setup_args['min_core_version']
361
+				: '',
362
+			// the minimum version of WordPress that the addon will work with
363
+			'min_wp_version'        => isset($setup_args['min_wp_version'])
364
+				? (string)$setup_args['min_wp_version']
365
+				: EE_MIN_WP_VER_REQUIRED,
366
+			// full server path to main file (file loaded directly by WP)
367
+			'main_file_path'        => isset($setup_args['main_file_path'])
368
+				? (string)$setup_args['main_file_path']
369
+				: '',
370
+			// path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
371
+			'admin_path'            => isset($setup_args['admin_path'])
372
+				? (string)$setup_args['admin_path'] : '',
373
+			// a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
374
+			'admin_callback'        => isset($setup_args['admin_callback'])
375
+				? (string)$setup_args['admin_callback']
376
+				: '',
377
+			// the section name for this addon's configuration settings section (defaults to "addons")
378
+			'config_section'        => isset($setup_args['config_section'])
379
+				? (string)$setup_args['config_section']
380
+				: 'addons',
381
+			// the class name for this addon's configuration settings object
382
+			'config_class'          => isset($setup_args['config_class'])
383
+				? (string)$setup_args['config_class'] : '',
384
+			//the name given to the config for this addons' configuration settings object (optional)
385
+			'config_name'           => isset($setup_args['config_name'])
386
+				? (string)$setup_args['config_name'] : '',
387
+			// an array of "class names" => "full server paths" for any classes that might be invoked by the addon
388
+			'autoloader_paths'      => isset($setup_args['autoloader_paths'])
389
+				? (array)$setup_args['autoloader_paths']
390
+				: array(),
391
+			// an array of  "full server paths" for any folders containing classes that might be invoked by the addon
392
+			'autoloader_folders'    => isset($setup_args['autoloader_folders'])
393
+				? (array)$setup_args['autoloader_folders']
394
+				: array(),
395
+			// array of full server paths to any EE_DMS data migration scripts used by the addon
396
+			'dms_paths'             => isset($setup_args['dms_paths'])
397
+				? (array)$setup_args['dms_paths']
398
+				: array(),
399
+			// array of full server paths to any EED_Modules used by the addon
400
+			'module_paths'          => isset($setup_args['module_paths'])
401
+				? (array)$setup_args['module_paths']
402
+				: array(),
403
+			// array of full server paths to any EES_Shortcodes used by the addon
404
+			'shortcode_paths'       => isset($setup_args['shortcode_paths'])
405
+				? (array)$setup_args['shortcode_paths']
406
+				: array(),
407
+			// array of full server paths to any WP_Widgets used by the addon
408
+			'widget_paths'          => isset($setup_args['widget_paths'])
409
+				? (array)$setup_args['widget_paths']
410
+				: array(),
411
+			// array of PUE options used by the addon
412
+			'pue_options'           => isset($setup_args['pue_options'])
413
+				? (array)$setup_args['pue_options']
414
+				: array(),
415
+			'message_types'         => isset($setup_args['message_types'])
416
+				? (array)$setup_args['message_types']
417
+				: array(),
418
+			'capabilities'          => isset($setup_args['capabilities'])
419
+				? (array)$setup_args['capabilities']
420
+				: array(),
421
+			'capability_maps'       => isset($setup_args['capability_maps'])
422
+				? (array)$setup_args['capability_maps']
423
+				: array(),
424
+			'model_paths'           => isset($setup_args['model_paths'])
425
+				? (array)$setup_args['model_paths']
426
+				: array(),
427
+			'class_paths'           => isset($setup_args['class_paths'])
428
+				? (array)$setup_args['class_paths']
429
+				: array(),
430
+			'model_extension_paths' => isset($setup_args['model_extension_paths'])
431
+				? (array)$setup_args['model_extension_paths']
432
+				: array(),
433
+			'class_extension_paths' => isset($setup_args['class_extension_paths'])
434
+				? (array)$setup_args['class_extension_paths']
435
+				: array(),
436
+			'custom_post_types'     => isset($setup_args['custom_post_types'])
437
+				? (array)$setup_args['custom_post_types']
438
+				: array(),
439
+			'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
440
+				? (array)$setup_args['custom_taxonomies']
441
+				: array(),
442
+			'payment_method_paths'  => isset($setup_args['payment_method_paths'])
443
+				? (array)$setup_args['payment_method_paths']
444
+				: array(),
445
+			'default_terms'         => isset($setup_args['default_terms'])
446
+				? (array)$setup_args['default_terms']
447
+				: array(),
448
+			// if not empty, inserts a new table row after this plugin's row on the WP Plugins page
449
+			// that can be used for adding upgrading/marketing info
450
+			'plugins_page_row'      => isset($setup_args['plugins_page_row'])
451
+				? $setup_args['plugins_page_row']
452
+				: '',
453
+			'namespace'             => isset(
454
+				$setup_args['namespace'],
455
+				$setup_args['namespace']['FQNS'],
456
+				$setup_args['namespace']['DIR']
457
+			)
458
+				? (array)$setup_args['namespace']
459
+				: array(),
460
+		);
461
+		// if plugin_action_slug is NOT set, but an admin page path IS set,
462
+		// then let's just use the plugin_slug since that will be used for linking to the admin page
463
+		$addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
464
+												&& ! empty($addon_settings['admin_path'])
465
+			? $addon_settings['plugin_slug']
466
+			: $addon_settings['plugin_action_slug'];
467
+		// full server path to main file (file loaded directly by WP)
468
+		$addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
469
+		return $addon_settings;
470
+	}
471
+
472
+
473
+
474
+	/**
475
+	 * @param string $addon_name
476
+	 * @param array  $addon_settings
477
+	 * @return boolean
478
+	 */
479 479
 	private static function _addon_is_compatible( $addon_name, array $addon_settings ) {
480
-        global $wp_version;
481
-        $incompatibility_message = '';
482
-        //check whether this addon version is compatible with EE core
483
-        if (
484
-            isset(EE_Register_Addon::$_incompatible_addons[$addon_name])
485
-            && ! self::_meets_min_core_version_requirement(
486
-                EE_Register_Addon::$_incompatible_addons[$addon_name],
487
-                $addon_settings['version']
488
-            )
489
-        ) {
490
-            $incompatibility_message = sprintf(
491
-                __(
492
-                    '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.'
493
-                ),
494
-                $addon_name,
495
-                '<br />',
496
-                EE_Register_Addon::$_incompatible_addons[$addon_name],
497
-                '<span style="font-weight: bold; color: #D54E21;">',
498
-                '</span><br />'
499
-            );
500
-        } else if (
501
-            ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
502
-        ) {
503
-            $incompatibility_message = sprintf(
504
-                __(
505
-                    '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".',
506
-                    'event_espresso'
507
-                ),
508
-                $addon_name,
509
-                self::_effective_version($addon_settings['min_core_version']),
510
-                self::_effective_version(espresso_version()),
511
-                '<br />',
512
-                '<span style="font-weight: bold; color: #D54E21;">',
513
-                '</span><br />'
514
-            );
515
-        } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
516
-            $incompatibility_message = sprintf(
517
-                __(
518
-                    '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.',
519
-                    'event_espresso'
520
-                ),
521
-                $addon_name,
522
-                $addon_settings['min_wp_version'],
523
-                '<br />',
524
-                '<span style="font-weight: bold; color: #D54E21;">',
525
-                '</span><br />'
526
-            );
527
-        }
528
-        if ( ! empty($incompatibility_message)) {
529
-            // remove 'activate' from the REQUEST
530
-            // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
531
-            unset($_GET['activate'], $_REQUEST['activate']);
532
-            if (current_user_can('activate_plugins')) {
533
-                // show an error message indicating the plugin didn't activate properly
534
-                EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
535
-            }
536
-            // BAIL FROM THE ADDON REGISTRATION PROCESS
537
-            return false;
538
-        }
539
-        // addon IS compatible
540
-        return true;
480
+		global $wp_version;
481
+		$incompatibility_message = '';
482
+		//check whether this addon version is compatible with EE core
483
+		if (
484
+			isset(EE_Register_Addon::$_incompatible_addons[$addon_name])
485
+			&& ! self::_meets_min_core_version_requirement(
486
+				EE_Register_Addon::$_incompatible_addons[$addon_name],
487
+				$addon_settings['version']
488
+			)
489
+		) {
490
+			$incompatibility_message = sprintf(
491
+				__(
492
+					'%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.'
493
+				),
494
+				$addon_name,
495
+				'<br />',
496
+				EE_Register_Addon::$_incompatible_addons[$addon_name],
497
+				'<span style="font-weight: bold; color: #D54E21;">',
498
+				'</span><br />'
499
+			);
500
+		} else if (
501
+			! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
502
+		) {
503
+			$incompatibility_message = sprintf(
504
+				__(
505
+					'%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".',
506
+					'event_espresso'
507
+				),
508
+				$addon_name,
509
+				self::_effective_version($addon_settings['min_core_version']),
510
+				self::_effective_version(espresso_version()),
511
+				'<br />',
512
+				'<span style="font-weight: bold; color: #D54E21;">',
513
+				'</span><br />'
514
+			);
515
+		} else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
516
+			$incompatibility_message = sprintf(
517
+				__(
518
+					'%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.',
519
+					'event_espresso'
520
+				),
521
+				$addon_name,
522
+				$addon_settings['min_wp_version'],
523
+				'<br />',
524
+				'<span style="font-weight: bold; color: #D54E21;">',
525
+				'</span><br />'
526
+			);
527
+		}
528
+		if ( ! empty($incompatibility_message)) {
529
+			// remove 'activate' from the REQUEST
530
+			// so WP doesn't erroneously tell the user the plugin activated fine when it didn't
531
+			unset($_GET['activate'], $_REQUEST['activate']);
532
+			if (current_user_can('activate_plugins')) {
533
+				// show an error message indicating the plugin didn't activate properly
534
+				EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
535
+			}
536
+			// BAIL FROM THE ADDON REGISTRATION PROCESS
537
+			return false;
538
+		}
539
+		// addon IS compatible
540
+		return true;
541 541
 	}
542 542
 
543 543
 
544 544
 
545
-    /**
546
-     * if plugin update engine is being used for auto-updates,
547
-     * then let's set that up now before going any further so that ALL addons can be updated
548
-     * (not needed if PUE is not being used)
549
-     *
550
-     * @param string $addon_name
551
-     * @param string $class_name
552
-     * @param array  $setup_args
553
-     * @return void
554
-     */
545
+	/**
546
+	 * if plugin update engine is being used for auto-updates,
547
+	 * then let's set that up now before going any further so that ALL addons can be updated
548
+	 * (not needed if PUE is not being used)
549
+	 *
550
+	 * @param string $addon_name
551
+	 * @param string $class_name
552
+	 * @param array  $setup_args
553
+	 * @return void
554
+	 */
555 555
 	private static function _parse_pue_options( $addon_name, $class_name, array $setup_args ) {
556
-        if ( ! empty($setup_args['pue_options'])) {
557
-            self::$_settings[$addon_name]['pue_options'] = array(
558
-                'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
559
-                    ? (string)$setup_args['pue_options']['pue_plugin_slug']
560
-                    : 'espresso_' . strtolower($class_name),
561
-                'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
562
-                    ? (string)$setup_args['pue_options']['plugin_basename']
563
-                    : plugin_basename($setup_args['main_file_path']),
564
-                'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
565
-                    ? (string)$setup_args['pue_options']['checkPeriod']
566
-                    : '24',
567
-                'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
568
-                    ? (string)$setup_args['pue_options']['use_wp_update']
569
-                    : false,
570
-            );
571
-            add_action(
572
-                'AHEE__EE_System__brew_espresso__after_pue_init',
573
-                array('EE_Register_Addon', 'load_pue_update')
574
-            );
575
-        }
556
+		if ( ! empty($setup_args['pue_options'])) {
557
+			self::$_settings[$addon_name]['pue_options'] = array(
558
+				'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
559
+					? (string)$setup_args['pue_options']['pue_plugin_slug']
560
+					: 'espresso_' . strtolower($class_name),
561
+				'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
562
+					? (string)$setup_args['pue_options']['plugin_basename']
563
+					: plugin_basename($setup_args['main_file_path']),
564
+				'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
565
+					? (string)$setup_args['pue_options']['checkPeriod']
566
+					: '24',
567
+				'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
568
+					? (string)$setup_args['pue_options']['use_wp_update']
569
+					: false,
570
+			);
571
+			add_action(
572
+				'AHEE__EE_System__brew_espresso__after_pue_init',
573
+				array('EE_Register_Addon', 'load_pue_update')
574
+			);
575
+		}
576 576
 	}
577 577
 
578 578
 
579 579
 
580
-    /**
581
-     * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
582
-     *
583
-     * @param array $addon_settings
584
-     * @return void
585
-     */
586
-    private static function _setup_namespaces(array $addon_settings)
587
-    {
588
-        //
589
-        if (
590
-        isset(
591
-            $addon_settings['namespace'],
592
-            $addon_settings['namespace']['FQNS'],
593
-            $addon_settings['namespace']['DIR']
594
-        )
595
-        ) {
596
-            EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
597
-                $addon_settings['namespace']['FQNS'],
598
-                $addon_settings['namespace']['DIR']
599
-            );
600
-        }
601
-    }
602
-
603
-
604
-
605
-    /**
606
-     * @param string $addon_name
607
-     * @param array  $addon_settings
608
-     * @return bool
609
-     */
580
+	/**
581
+	 * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
582
+	 *
583
+	 * @param array $addon_settings
584
+	 * @return void
585
+	 */
586
+	private static function _setup_namespaces(array $addon_settings)
587
+	{
588
+		//
589
+		if (
590
+		isset(
591
+			$addon_settings['namespace'],
592
+			$addon_settings['namespace']['FQNS'],
593
+			$addon_settings['namespace']['DIR']
594
+		)
595
+		) {
596
+			EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
597
+				$addon_settings['namespace']['FQNS'],
598
+				$addon_settings['namespace']['DIR']
599
+			);
600
+		}
601
+	}
602
+
603
+
604
+
605
+	/**
606
+	 * @param string $addon_name
607
+	 * @param array  $addon_settings
608
+	 * @return bool
609
+	 */
610 610
 	private static function _addon_activation( $addon_name, array $addon_settings ) {
611
-        // this is an activation request
612
-        if (did_action('activate_plugin')) {
613
-            //to find if THIS is the addon that was activated,
614
-            //just check if we have already registered it or not
615
-            //(as the newly-activated addon wasn't around the first time addons were registered)
616
-            if ( ! isset(self::$_settings[$addon_name])) {
617
-                self::$_settings[$addon_name] = $addon_settings;
618
-                $addon = self::_load_and_init_addon_class($addon_name);
619
-                $addon->set_activation_indicator_option();
620
-                // dont bother setting up the rest of the addon.
621
-                // we know it was just activated and the request will end soon
622
-            }
623
-            return true;
624
-        } else {
625
-            // make sure this was called in the right place!
626
-            if (
627
-                ! did_action('AHEE__EE_System__load_espresso_addons')
628
-                || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
629
-            ) {
630
-                EE_Error::doing_it_wrong(
631
-                    __METHOD__,
632
-                    sprintf(
633
-                        __(
634
-                            'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.',
635
-                            'event_espresso'
636
-                        ),
637
-                        $addon_name
638
-                    ),
639
-                    '4.3.0'
640
-                );
641
-            }
642
-            // make sure addon settings are set correctly without overwriting anything existing
643
-            if (isset(self::$_settings[$addon_name])) {
644
-                self::$_settings[$addon_name] += $addon_settings;
645
-            } else {
646
-                self::$_settings[$addon_name] = $addon_settings;
647
-            }
648
-        }
649
-        return false;
650
-    }
651
-
652
-
653
-
654
-    /**
655
-     * @param string $addon_name
656
-     * @return void
657
-     * @throws \EE_Error
658
-     */
659
-    private static function _setup_autoloaders($addon_name)
660
-    {
661
-        if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
662
-            // setup autoloader for single file
663
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
664
-        }
665
-        // setup autoloaders for folders
666
-        if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
667
-            foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
668
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
669
-            }
670
-        }
671
-    }
672
-
673
-
674
-
675
-    /**
676
-     * register new models and extensions
677
-     *
678
-     * @param string $addon_name
679
-     * @return void
680
-     * @throws \EE_Error
681
-     */
611
+		// this is an activation request
612
+		if (did_action('activate_plugin')) {
613
+			//to find if THIS is the addon that was activated,
614
+			//just check if we have already registered it or not
615
+			//(as the newly-activated addon wasn't around the first time addons were registered)
616
+			if ( ! isset(self::$_settings[$addon_name])) {
617
+				self::$_settings[$addon_name] = $addon_settings;
618
+				$addon = self::_load_and_init_addon_class($addon_name);
619
+				$addon->set_activation_indicator_option();
620
+				// dont bother setting up the rest of the addon.
621
+				// we know it was just activated and the request will end soon
622
+			}
623
+			return true;
624
+		} else {
625
+			// make sure this was called in the right place!
626
+			if (
627
+				! did_action('AHEE__EE_System__load_espresso_addons')
628
+				|| did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
629
+			) {
630
+				EE_Error::doing_it_wrong(
631
+					__METHOD__,
632
+					sprintf(
633
+						__(
634
+							'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.',
635
+							'event_espresso'
636
+						),
637
+						$addon_name
638
+					),
639
+					'4.3.0'
640
+				);
641
+			}
642
+			// make sure addon settings are set correctly without overwriting anything existing
643
+			if (isset(self::$_settings[$addon_name])) {
644
+				self::$_settings[$addon_name] += $addon_settings;
645
+			} else {
646
+				self::$_settings[$addon_name] = $addon_settings;
647
+			}
648
+		}
649
+		return false;
650
+	}
651
+
652
+
653
+
654
+	/**
655
+	 * @param string $addon_name
656
+	 * @return void
657
+	 * @throws \EE_Error
658
+	 */
659
+	private static function _setup_autoloaders($addon_name)
660
+	{
661
+		if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
662
+			// setup autoloader for single file
663
+			EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
664
+		}
665
+		// setup autoloaders for folders
666
+		if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
667
+			foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
668
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
669
+			}
670
+		}
671
+	}
672
+
673
+
674
+
675
+	/**
676
+	 * register new models and extensions
677
+	 *
678
+	 * @param string $addon_name
679
+	 * @return void
680
+	 * @throws \EE_Error
681
+	 */
682 682
 	private static function _register_models_and_extensions( $addon_name ) {
683
-        // register new models
684
-        if (
685
-            ! empty(self::$_settings[$addon_name]['model_paths'])
686
-            || ! empty(self::$_settings[$addon_name]['class_paths'])
687
-        ) {
688
-            EE_Register_Model::register(
689
-                $addon_name,
690
-                array(
691
-                    'model_paths' => self::$_settings[$addon_name]['model_paths'],
692
-                    'class_paths' => self::$_settings[$addon_name]['class_paths'],
693
-                )
694
-            );
695
-        }
696
-        // register model extensions
697
-        if (
698
-            ! empty(self::$_settings[$addon_name]['model_extension_paths'])
699
-            || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
700
-        ) {
701
-            EE_Register_Model_Extensions::register(
702
-                $addon_name,
703
-                array(
704
-                    'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'],
705
-                    'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'],
706
-                )
707
-            );
708
-        }
709
-    }
710
-
711
-
712
-
713
-    /**
714
-     * @param string $addon_name
715
-     * @return void
716
-     * @throws \EE_Error
717
-     */
683
+		// register new models
684
+		if (
685
+			! empty(self::$_settings[$addon_name]['model_paths'])
686
+			|| ! empty(self::$_settings[$addon_name]['class_paths'])
687
+		) {
688
+			EE_Register_Model::register(
689
+				$addon_name,
690
+				array(
691
+					'model_paths' => self::$_settings[$addon_name]['model_paths'],
692
+					'class_paths' => self::$_settings[$addon_name]['class_paths'],
693
+				)
694
+			);
695
+		}
696
+		// register model extensions
697
+		if (
698
+			! empty(self::$_settings[$addon_name]['model_extension_paths'])
699
+			|| ! empty(self::$_settings[$addon_name]['class_extension_paths'])
700
+		) {
701
+			EE_Register_Model_Extensions::register(
702
+				$addon_name,
703
+				array(
704
+					'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'],
705
+					'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'],
706
+				)
707
+			);
708
+		}
709
+	}
710
+
711
+
712
+
713
+	/**
714
+	 * @param string $addon_name
715
+	 * @return void
716
+	 * @throws \EE_Error
717
+	 */
718 718
 	private static function _register_data_migration_scripts( $addon_name ) {
719
-        // setup DMS
720
-        if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
721
-            EE_Register_Data_Migration_Scripts::register(
722
-                $addon_name,
723
-                array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])
724
-            );
725
-        }
726
-    }
727
-
728
-
729
-    /**
730
-     * @param string $addon_name
731
-     * @return void
732
-     * @throws \EE_Error
733
-     */
719
+		// setup DMS
720
+		if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
721
+			EE_Register_Data_Migration_Scripts::register(
722
+				$addon_name,
723
+				array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])
724
+			);
725
+		}
726
+	}
727
+
728
+
729
+	/**
730
+	 * @param string $addon_name
731
+	 * @return void
732
+	 * @throws \EE_Error
733
+	 */
734 734
 	private static function _register_config( $addon_name ) {
735
-        // if config_class is present let's register config.
736
-        if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
737
-            EE_Register_Config::register(
738
-                self::$_settings[$addon_name]['config_class'],
739
-                array(
740
-                    'config_section' => self::$_settings[$addon_name]['config_section'],
741
-                    'config_name'    => self::$_settings[$addon_name]['config_name'],
742
-                )
743
-            );
744
-        }
745
-    }
746
-
747
-
748
-    /**
749
-     * @param string $addon_name
750
-     * @return void
751
-     * @throws \EE_Error
752
-     */
735
+		// if config_class is present let's register config.
736
+		if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
737
+			EE_Register_Config::register(
738
+				self::$_settings[$addon_name]['config_class'],
739
+				array(
740
+					'config_section' => self::$_settings[$addon_name]['config_section'],
741
+					'config_name'    => self::$_settings[$addon_name]['config_name'],
742
+				)
743
+			);
744
+		}
745
+	}
746
+
747
+
748
+	/**
749
+	 * @param string $addon_name
750
+	 * @return void
751
+	 * @throws \EE_Error
752
+	 */
753 753
 	private static function _register_admin_pages( $addon_name ) {
754
-        if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
755
-            EE_Register_Admin_Page::register(
756
-                $addon_name,
757
-                array('page_path' => self::$_settings[$addon_name]['admin_path'])
758
-            );
759
-        }
760
-    }
761
-
762
-
763
-    /**
764
-     * @param string $addon_name
765
-     * @return void
766
-     * @throws \EE_Error
767
-     */
754
+		if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
755
+			EE_Register_Admin_Page::register(
756
+				$addon_name,
757
+				array('page_path' => self::$_settings[$addon_name]['admin_path'])
758
+			);
759
+		}
760
+	}
761
+
762
+
763
+	/**
764
+	 * @param string $addon_name
765
+	 * @return void
766
+	 * @throws \EE_Error
767
+	 */
768 768
 	private static function _register_modules( $addon_name ) {
769
-        if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
770
-            EE_Register_Module::register(
771
-                $addon_name,
772
-                array('module_paths' => self::$_settings[$addon_name]['module_paths'])
773
-            );
774
-        }
775
-    }
776
-
777
-
778
-    /**
779
-     * @param string $addon_name
780
-     * @return void
781
-     * @throws \EE_Error
782
-     */
769
+		if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
770
+			EE_Register_Module::register(
771
+				$addon_name,
772
+				array('module_paths' => self::$_settings[$addon_name]['module_paths'])
773
+			);
774
+		}
775
+	}
776
+
777
+
778
+	/**
779
+	 * @param string $addon_name
780
+	 * @return void
781
+	 * @throws \EE_Error
782
+	 */
783 783
 	private static function _register_shortcodes( $addon_name ) {
784
-        if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) {
785
-            EE_Register_Shortcode::register(
786
-                $addon_name,
787
-                array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths'])
788
-            );
789
-        }
790
-    }
791
-
792
-
793
-    /**
794
-     * @param string $addon_name
795
-     * @return void
796
-     * @throws \EE_Error
797
-     */
784
+		if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) {
785
+			EE_Register_Shortcode::register(
786
+				$addon_name,
787
+				array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths'])
788
+			);
789
+		}
790
+	}
791
+
792
+
793
+	/**
794
+	 * @param string $addon_name
795
+	 * @return void
796
+	 * @throws \EE_Error
797
+	 */
798 798
 	private static function _register_widgets( $addon_name ) {
799
-        if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
800
-            EE_Register_Widget::register(
801
-                $addon_name,
802
-                array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])
803
-            );
804
-        }
805
-    }
806
-
807
-
808
-    /**
809
-     * @param string $addon_name
810
-     * @return void
811
-     * @throws \EE_Error
812
-     */
799
+		if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
800
+			EE_Register_Widget::register(
801
+				$addon_name,
802
+				array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])
803
+			);
804
+		}
805
+	}
806
+
807
+
808
+	/**
809
+	 * @param string $addon_name
810
+	 * @return void
811
+	 * @throws \EE_Error
812
+	 */
813 813
 	private static function _register_capabilities( $addon_name ) {
814
-        if ( ! empty(self::$_settings[$addon_name]['capabilities'])) {
815
-            EE_Register_Capabilities::register(
816
-                $addon_name,
817
-                array(
818
-                    'capabilities'    => self::$_settings[$addon_name]['capabilities'],
819
-                    'capability_maps' => self::$_settings[$addon_name]['capability_maps'],
820
-                )
821
-            );
822
-        }
823
-    }
824
-
825
-
826
-    /**
827
-     * @param string $addon_name
828
-     * @return void
829
-     * @throws \EE_Error
830
-     */
814
+		if ( ! empty(self::$_settings[$addon_name]['capabilities'])) {
815
+			EE_Register_Capabilities::register(
816
+				$addon_name,
817
+				array(
818
+					'capabilities'    => self::$_settings[$addon_name]['capabilities'],
819
+					'capability_maps' => self::$_settings[$addon_name]['capability_maps'],
820
+				)
821
+			);
822
+		}
823
+	}
824
+
825
+
826
+	/**
827
+	 * @param string $addon_name
828
+	 * @return void
829
+	 * @throws \EE_Error
830
+	 */
831 831
 	private static function _register_message_types( $addon_name ) {
832
-        if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
833
-            add_action(
834
-                'EE_Brewing_Regular___messages_caf',
835
-                array('EE_Register_Addon', 'register_message_types')
836
-            );
837
-        }
838
-    }
839
-
840
-
841
-    /**
842
-     * @param string $addon_name
843
-     * @return void
844
-     * @throws \EE_Error
845
-     */
832
+		if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
833
+			add_action(
834
+				'EE_Brewing_Regular___messages_caf',
835
+				array('EE_Register_Addon', 'register_message_types')
836
+			);
837
+		}
838
+	}
839
+
840
+
841
+	/**
842
+	 * @param string $addon_name
843
+	 * @return void
844
+	 * @throws \EE_Error
845
+	 */
846 846
 	private static function _register_custom_post_types( $addon_name ) {
847
-        if (
848
-            ! empty(self::$_settings[$addon_name]['custom_post_types'])
849
-            || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])
850
-        ) {
851
-            EE_Register_CPT::register(
852
-                $addon_name,
853
-                array(
854
-                    'cpts'          => self::$_settings[$addon_name]['custom_post_types'],
855
-                    'cts'           => self::$_settings[$addon_name]['custom_taxonomies'],
856
-                    'default_terms' => self::$_settings[$addon_name]['default_terms'],
857
-                )
858
-            );
859
-        }
860
-    }
861
-
862
-
863
-    /**
864
-     * @param string $addon_name
865
-     * @return void
866
-     * @throws \EE_Error
867
-     */
847
+		if (
848
+			! empty(self::$_settings[$addon_name]['custom_post_types'])
849
+			|| ! empty(self::$_settings[$addon_name]['custom_taxonomies'])
850
+		) {
851
+			EE_Register_CPT::register(
852
+				$addon_name,
853
+				array(
854
+					'cpts'          => self::$_settings[$addon_name]['custom_post_types'],
855
+					'cts'           => self::$_settings[$addon_name]['custom_taxonomies'],
856
+					'default_terms' => self::$_settings[$addon_name]['default_terms'],
857
+				)
858
+			);
859
+		}
860
+	}
861
+
862
+
863
+	/**
864
+	 * @param string $addon_name
865
+	 * @return void
866
+	 * @throws \EE_Error
867
+	 */
868 868
 	private static function _register_payment_methods( $addon_name ) {
869
-        if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
870
-            EE_Register_Payment_Method::register(
871
-                $addon_name,
872
-                array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])
873
-            );
874
-        }
875
-    }
869
+		if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
870
+			EE_Register_Payment_Method::register(
871
+				$addon_name,
872
+				array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])
873
+			);
874
+		}
875
+	}
876 876
 
877 877
 
878 878
 
@@ -901,14 +901,14 @@  discard block
 block discarded – undo
901 901
 		//unfortunately this can't be hooked in upon construction, because we don't have
902 902
 		//the plugin mainfile's path upon construction.
903 903
 		register_deactivation_hook( $addon->get_main_plugin_file(), array( $addon, 'deactivation' ) );
904
-        // call any additional admin_callback functions during load_admin_controller hook
905
-        if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) {
906
-            add_action(
907
-                'AHEE__EE_System__load_controllers__load_admin_controllers',
908
-                array($addon, self::$_settings[$addon_name]['admin_callback'])
909
-            );
910
-        }
911
-        return $addon;
904
+		// call any additional admin_callback functions during load_admin_controller hook
905
+		if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) {
906
+			add_action(
907
+				'AHEE__EE_System__load_controllers__load_admin_controllers',
908
+				array($addon, self::$_settings[$addon_name]['admin_callback'])
909
+			);
910
+		}
911
+		return $addon;
912 912
 	}
913 913
 
914 914
 
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
 		// cycle thru settings
925 925
 		foreach ( self::$_settings as $settings ) {
926 926
 			if ( ! empty( $settings['pue_options'] ) ) {
927
-                // initiate the class and start the plugin update engine!
927
+				// initiate the class and start the plugin update engine!
928 928
 				new PluginUpdateEngineChecker(
929 929
 				// host file URL
930 930
 					'https://eventespresso.com',
@@ -960,11 +960,11 @@  discard block
 block discarded – undo
960 960
 	 */
961 961
 	public static function register_message_types() {
962 962
 		foreach ( self::$_settings as $addon_name => $settings ) {
963
-		    if ( ! empty($settings['message_types'])) {
964
-                foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) {
965
-                    EE_Register_Message_Type::register($message_type, $message_type_settings);
966
-                }
967
-            }
963
+			if ( ! empty($settings['message_types'])) {
964
+				foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) {
965
+					EE_Register_Message_Type::register($message_type, $message_type_settings);
966
+				}
967
+			}
968 968
 		}
969 969
 	}
970 970
 
@@ -1006,15 +1006,15 @@  discard block
 block discarded – undo
1006 1006
 				EE_Register_Widget::deregister( $addon_name );
1007 1007
 			}
1008 1008
 			if ( ! empty( self::$_settings[ $addon_name ]['model_paths'] )
1009
-			     ||
1010
-			     ! empty( self::$_settings[ $addon_name ]['class_paths'] )
1009
+				 ||
1010
+				 ! empty( self::$_settings[ $addon_name ]['class_paths'] )
1011 1011
 			) {
1012 1012
 				// add to list of shortcodes to be registered
1013 1013
 				EE_Register_Model::deregister( $addon_name );
1014 1014
 			}
1015 1015
 			if ( ! empty( self::$_settings[ $addon_name ]['model_extension_paths'] )
1016
-			     ||
1017
-			     ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] )
1016
+				 ||
1017
+				 ! empty( self::$_settings[ $addon_name ]['class_extension_paths'] )
1018 1018
 			) {
1019 1019
 				// add to list of shortcodes to be registered
1020 1020
 				EE_Register_Model_Extensions::deregister( $addon_name );
Please login to merge, or discard this patch.
core/EE_Addon.core.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -282,16 +282,16 @@  discard block
 block discarded – undo
282 282
 
283 283
 
284 284
 
285
-    /**
286
-     * Takes care of double-checking that we're not in maintenance mode, and then
287
-     * initializing this addon's necessary initial data. This is called by default on new activations
288
-     * and reactivations
289
-     *
290
-     * @param boolean $verify_schema whether to verify the database's schema for this addon, or just its data.
291
-     *                               This is a resource-intensive job so we prefer to only do it when necessary
292
-     * @return void
293
-     * @throws \EE_Error
294
-     */
285
+	/**
286
+	 * Takes care of double-checking that we're not in maintenance mode, and then
287
+	 * initializing this addon's necessary initial data. This is called by default on new activations
288
+	 * and reactivations
289
+	 *
290
+	 * @param boolean $verify_schema whether to verify the database's schema for this addon, or just its data.
291
+	 *                               This is a resource-intensive job so we prefer to only do it when necessary
292
+	 * @return void
293
+	 * @throws \EE_Error
294
+	 */
295 295
 	public function initialize_db_if_no_migrations_required( $verify_schema = true ) {
296 296
 		if( $verify_schema === '' ) {
297 297
 			//wp core bug imo: if no args are passed to `do_action('some_hook_name')` besides the hook's name
@@ -307,11 +307,11 @@  discard block
 block discarded – undo
307 307
 			$this->initialize_default_data();
308 308
 			//@todo: this will probably need to be adjusted in 4.4 as the array changed formats I believe
309 309
 			EE_Data_Migration_Manager::instance()->update_current_database_state_to(
310
-			    array(
311
-			        'slug' => $this->name(),
312
-                    'version' => $this->version()
313
-                )
314
-            );
310
+				array(
311
+					'slug' => $this->name(),
312
+					'version' => $this->version()
313
+				)
314
+			);
315 315
 			/* make sure core's data is a-ok
316 316
 			 * (at the time of writing, we especially want to verify all the caps are present
317 317
 			 * because payment method type capabilities are added dynamically, and it's
@@ -355,11 +355,11 @@  discard block
 block discarded – undo
355 355
 		}
356 356
 		//if not DMS was found that should be ok. This addon just doesn't require any database changes
357 357
 		EE_Data_Migration_Manager::instance()->update_current_database_state_to(
358
-		    array(
359
-		        'slug' => $this->name(),
360
-                'version' => $this->version()
361
-            )
362
-        );
358
+			array(
359
+				'slug' => $this->name(),
360
+				'version' => $this->version()
361
+			)
362
+		);
363 363
 	}
364 364
 
365 365
 
@@ -401,8 +401,8 @@  discard block
 block discarded – undo
401 401
 		EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
402 402
 		//also it's possible there is new default data that needs to be added
403 403
 		add_action(
404
-		    'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' )
405
-        );
404
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' )
405
+		);
406 406
 	}
407 407
 
408 408
 
@@ -624,9 +624,9 @@  discard block
 block discarded – undo
624 624
 
625 625
 
626 626
 	/**
627
-     * sets hooks used in the admin
628
-     *
629
-     * @return void
627
+	 * sets hooks used in the admin
628
+	 *
629
+	 * @return void
630 630
 	 */
631 631
 	public function admin_init(){
632 632
 		// is admin and not in M-Mode ?
@@ -737,14 +737,14 @@  discard block
 block discarded – undo
737 737
 
738 738
 
739 739
 
740
-    /**
741
-     * a safe space for addons to add additional logic like setting hooks
742
-     * that will run immediately after addon registration
743
-     * making this a great place for code that needs to be "omnipresent"
744
-     */
740
+	/**
741
+	 * a safe space for addons to add additional logic like setting hooks
742
+	 * that will run immediately after addon registration
743
+	 * making this a great place for code that needs to be "omnipresent"
744
+	 */
745 745
 	public function after_registration()
746
-    {
747
-        // cricket chirp... cricket chirp...
746
+	{
747
+		// cricket chirp... cricket chirp...
748 748
 	}
749 749
 
750 750
 
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  *
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 *    class constructor
96 96
 	 */
97 97
 	public function __construct() {
98
-		add_action( 'AHEE__EE_System__load_controllers__load_admin_controllers', array( $this, 'admin_init' ) );
98
+		add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($this, 'admin_init'));
99 99
 	}
100 100
 
101 101
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	/**
104 104
 	 * @param mixed $version
105 105
 	 */
106
-	public function set_version( $version = NULL ) {
106
+	public function set_version($version = NULL) {
107 107
 		$this->_version = $version;
108 108
 	}
109 109
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	/**
122 122
 	 * @param mixed $min_core_version
123 123
 	 */
124
-	public function set_min_core_version( $min_core_version = NULL ) {
124
+	public function set_min_core_version($min_core_version = NULL) {
125 125
 		$this->_min_core_version = $min_core_version;
126 126
 	}
127 127
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @param string $addon_name
143 143
 	 * @return boolean
144 144
 	 */
145
-	public function set_name( $addon_name ) {
145
+	public function set_name($addon_name) {
146 146
 		return $this->_addon_name = $addon_name;
147 147
 	}
148 148
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	/**
171 171
 	 * @param string $plugin_basename
172 172
 	 */
173
-	public function set_plugin_basename( $plugin_basename ) {
173
+	public function set_plugin_basename($plugin_basename) {
174 174
 
175 175
 		$this->_plugin_basename = $plugin_basename;
176 176
 	}
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	/**
191 191
 	 * @param string $plugin_slug
192 192
 	 */
193
-	public function set_plugin_slug( $plugin_slug ) {
193
+	public function set_plugin_slug($plugin_slug) {
194 194
 
195 195
 		$this->_plugin_slug = $plugin_slug;
196 196
 	}
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	/**
211 211
 	 * @param string $plugin_action_slug
212 212
 	 */
213
-	public function set_plugin_action_slug( $plugin_action_slug ) {
213
+	public function set_plugin_action_slug($plugin_action_slug) {
214 214
 
215 215
 		$this->_plugin_action_slug = $plugin_action_slug;
216 216
 	}
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 	/**
231 231
 	 * @param array $plugins_page_row
232 232
 	 */
233
-	public function set_plugins_page_row( $plugins_page_row = array() ) {
233
+	public function set_plugins_page_row($plugins_page_row = array()) {
234 234
 		// sigh.... check for example content that I stupidly merged to master and remove it if found
235
-		if ( ! is_array( $plugins_page_row ) && strpos( $plugins_page_row, '<h3>Promotions Addon Upsell Info</h3>' ) !== false ) {
235
+		if ( ! is_array($plugins_page_row) && strpos($plugins_page_row, '<h3>Promotions Addon Upsell Info</h3>') !== false) {
236 236
 			$plugins_page_row = '';
237 237
 		}
238 238
 		$this->_plugins_page_row = $plugins_page_row;
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		do_action("AHEE__{$classname}__new_install");
251 251
 		do_action('AHEE__EE_Addon__new_install', $this);
252 252
 		EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
253
-		add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' ) );
253
+		add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required'));
254 254
 	}
255 255
 
256 256
 
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
 		do_action("AHEE__{$classname}__reactivation");
266 266
 		do_action('AHEE__EE_Addon__reactivation', $this);
267 267
 		EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
268
-		add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' ) );
268
+		add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required'));
269 269
 	}
270 270
 
271 271
 
272 272
 
273
-	public function deactivation(){
273
+	public function deactivation() {
274 274
 		$classname = get_class($this);
275 275
 //		echo "Deactivating $classname";die;
276 276
 		do_action("AHEE__{$classname}__deactivation");
277 277
 		do_action('AHEE__EE_Addon__deactivation', $this);
278 278
 		//check if the site no longer needs to be in maintenance mode
279
-		EE_Register_Addon::deregister( $this->name() );
279
+		EE_Register_Addon::deregister($this->name());
280 280
 		EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
281 281
 	}
282 282
 
@@ -292,16 +292,16 @@  discard block
 block discarded – undo
292 292
      * @return void
293 293
      * @throws \EE_Error
294 294
      */
295
-	public function initialize_db_if_no_migrations_required( $verify_schema = true ) {
296
-		if( $verify_schema === '' ) {
295
+	public function initialize_db_if_no_migrations_required($verify_schema = true) {
296
+		if ($verify_schema === '') {
297 297
 			//wp core bug imo: if no args are passed to `do_action('some_hook_name')` besides the hook's name
298 298
 			//(ie, no 2nd or 3rd arguments), instead of calling the registered callbacks with no arguments, it
299 299
 			//calls them with an argument of an empty string (ie ""), which evaluates to false
300 300
 			//so we need to treat the empty string as if nothing had been passed, and should instead use the default
301 301
 			$verify_schema = true;
302 302
 		}
303
-		if ( EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance ) {
304
-			if( $verify_schema ) {
303
+		if (EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
304
+			if ($verify_schema) {
305 305
 				$this->initialize_db();
306 306
 			}
307 307
 			$this->initialize_default_data();
@@ -319,15 +319,15 @@  discard block
 block discarded – undo
319 319
 			 * other data needs to be verified)
320 320
 			 */
321 321
 			EEH_Activation::initialize_db_content();
322
-			update_option( 'ee_flush_rewrite_rules', TRUE );
322
+			update_option('ee_flush_rewrite_rules', TRUE);
323 323
 			//in case there are lots of addons being activated at once, let's force garbage collection
324 324
 			//to help avoid memory limit errors
325 325
 			//EEH_Debug_Tools::instance()->measure_memory( 'db content initialized for ' . get_class( $this), true );
326 326
 			gc_collect_cycles();
327
-		}else{
327
+		} else {
328 328
 			//ask the data migration manager to init this addon's data
329 329
 			//when migrations are finished because we can't do it now
330
-			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for( $this->name() );
330
+			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for($this->name());
331 331
 		}
332 332
 	}
333 333
 
@@ -341,15 +341,15 @@  discard block
 block discarded – undo
341 341
 	 */
342 342
 	public function initialize_db() {
343 343
 		//find the migration script that sets the database to be compatible with the code
344
-		$current_dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms( $this->name() );
345
-		if( $current_dms_name ){
346
-			$current_data_migration_script = EE_Registry::instance()->load_dms( $current_dms_name );
347
-			$current_data_migration_script->set_migrating( FALSE );
344
+		$current_dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms($this->name());
345
+		if ($current_dms_name) {
346
+			$current_data_migration_script = EE_Registry::instance()->load_dms($current_dms_name);
347
+			$current_data_migration_script->set_migrating(FALSE);
348 348
 			$current_data_migration_script->schema_changes_before_migration();
349 349
 			$current_data_migration_script->schema_changes_after_migration();
350
-			if ( $current_data_migration_script->get_errors() ) {
351
-				foreach( $current_data_migration_script->get_errors() as $error ) {
352
-					EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ );
350
+			if ($current_data_migration_script->get_errors()) {
351
+				foreach ($current_data_migration_script->get_errors() as $error) {
352
+					EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
353 353
 				}
354 354
 			}
355 355
 		}
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 		 * default data)
382 382
 		 * @param EE_Addon $addon the addon that called this
383 383
 		 */
384
-		do_action( 'AHEE__EE_Addon__initialize_default_data__begin', $this );
384
+		do_action('AHEE__EE_Addon__initialize_default_data__begin', $this);
385 385
 		//override to insert default data. It is safe to use the models here
386 386
 		//because the site should not be in maintenance mode
387 387
 	}
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 		EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
402 402
 		//also it's possible there is new default data that needs to be added
403 403
 		add_action(
404
-		    'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' )
404
+		    'AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required')
405 405
         );
406 406
 	}
407 407
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 		do_action("AHEE__{$classname}__downgrade");
416 416
 		do_action('AHEE__EE_Addon__downgrade', $this);
417 417
 		//it's possible there's old default data that needs to be double-checked
418
-		add_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations', array( $this, 'initialize_db_if_no_migrations_required' ) );
418
+		add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations', array($this, 'initialize_db_if_no_migrations_required'));
419 419
 	}
420 420
 
421 421
 
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	 * plugin activation only. In the future, we'll want to do it on plugin updates too
427 427
 	 * @return bool
428 428
 	 */
429
-	public function set_db_update_option_name(){
429
+	public function set_db_update_option_name() {
430 430
 		EE_Error::doing_it_wrong(__FUNCTION__, __('EE_Addon::set_db_update_option_name was renamed to EE_Addon::set_activation_indicator_option', 'event_espresso'), '4.3.0.alpha.016');
431 431
 		//let's just handle this on the next request, ok? right now we're just not really ready
432 432
 		return $this->set_activation_indicator_option();
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 	 */
455 455
 	public function set_activation_indicator_option() {
456 456
 		// let's just handle this on the next request, ok? right now we're just not really ready
457
-		return update_option( $this->get_activation_indicator_option_name(), TRUE );
457
+		return update_option($this->get_activation_indicator_option_name(), TRUE);
458 458
 	}
459 459
 
460 460
 
@@ -462,8 +462,8 @@  discard block
 block discarded – undo
462 462
 	 * Gets the name of the wp option which is used to temporarily indicate that this addon was activated
463 463
 	 * @return string
464 464
 	 */
465
-	public function get_activation_indicator_option_name(){
466
-		return 'ee_activation_' . $this->name();
465
+	public function get_activation_indicator_option_name() {
466
+		return 'ee_activation_'.$this->name();
467 467
 	}
468 468
 
469 469
 
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 	 * Used by EE_System to set the request type of this addon. Should not be used by addon developers
474 474
 	 * @param int $req_type
475 475
 	 */
476
-	public function set_req_type( $req_type ) {
476
+	public function set_req_type($req_type) {
477 477
 		$this->_req_type = $req_type;
478 478
 	}
479 479
 
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 	 * of addons
485 485
 	 */
486 486
 	public function detect_req_type() {
487
-		if( ! $this->_req_type ){
487
+		if ( ! $this->_req_type) {
488 488
 			$this->detect_activation_or_upgrade();
489 489
 		}
490 490
 		return $this->_req_type;
@@ -497,36 +497,36 @@  discard block
 block discarded – undo
497 497
 	 * Should only be called once per request
498 498
 	 * @return void
499 499
 	 */
500
-	public function detect_activation_or_upgrade(){
500
+	public function detect_activation_or_upgrade() {
501 501
 		$activation_history_for_addon = $this->get_activation_history();
502 502
 //		d($activation_history_for_addon);
503 503
 		$request_type = EE_System::detect_req_type_given_activation_history($activation_history_for_addon, $this->get_activation_indicator_option_name(), $this->version());
504 504
 		$this->set_req_type($request_type);
505 505
 		$classname = get_class($this);
506
-		switch($request_type){
506
+		switch ($request_type) {
507 507
 			case EE_System::req_type_new_activation:
508
-				do_action( "AHEE__{$classname}__detect_activations_or_upgrades__new_activation" );
509
-				do_action( 'AHEE__EE_Addon__detect_activations_or_upgrades__new_activation', $this );
508
+				do_action("AHEE__{$classname}__detect_activations_or_upgrades__new_activation");
509
+				do_action('AHEE__EE_Addon__detect_activations_or_upgrades__new_activation', $this);
510 510
 				$this->new_install();
511
-				$this->update_list_of_installed_versions( $activation_history_for_addon );
511
+				$this->update_list_of_installed_versions($activation_history_for_addon);
512 512
 				break;
513 513
 			case EE_System::req_type_reactivation:
514
-				do_action( "AHEE__{$classname}__detect_activations_or_upgrades__reactivation" );
515
-				do_action( 'AHEE__EE_Addon__detect_activations_or_upgrades__reactivation', $this );
514
+				do_action("AHEE__{$classname}__detect_activations_or_upgrades__reactivation");
515
+				do_action('AHEE__EE_Addon__detect_activations_or_upgrades__reactivation', $this);
516 516
 				$this->reactivation();
517
-				$this->update_list_of_installed_versions( $activation_history_for_addon );
517
+				$this->update_list_of_installed_versions($activation_history_for_addon);
518 518
 				break;
519 519
 			case EE_System::req_type_upgrade:
520
-				do_action( "AHEE__{$classname}__detect_activations_or_upgrades__upgrade" );
521
-				do_action( 'AHEE__EE_Addon__detect_activations_or_upgrades__upgrade', $this );
520
+				do_action("AHEE__{$classname}__detect_activations_or_upgrades__upgrade");
521
+				do_action('AHEE__EE_Addon__detect_activations_or_upgrades__upgrade', $this);
522 522
 				$this->upgrade();
523
-				$this->update_list_of_installed_versions($activation_history_for_addon );
523
+				$this->update_list_of_installed_versions($activation_history_for_addon);
524 524
 				break;
525 525
 			case EE_System::req_type_downgrade:
526
-				do_action( "AHEE__{$classname}__detect_activations_or_upgrades__downgrade" );
527
-				do_action( 'AHEE__EE_Addon__detect_activations_or_upgrades__downgrade', $this );
526
+				do_action("AHEE__{$classname}__detect_activations_or_upgrades__downgrade");
527
+				do_action('AHEE__EE_Addon__detect_activations_or_upgrades__downgrade', $this);
528 528
 				$this->downgrade();
529
-				$this->update_list_of_installed_versions($activation_history_for_addon );
529
+				$this->update_list_of_installed_versions($activation_history_for_addon);
530 530
 				break;
531 531
 			case EE_System::req_type_normal:
532 532
 			default:
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 				break;
535 535
 		}
536 536
 
537
-		do_action( "AHEE__{$classname}__detect_if_activation_or_upgrade__complete" );
537
+		do_action("AHEE__{$classname}__detect_if_activation_or_upgrade__complete");
538 538
 	}
539 539
 
540 540
 	/**
@@ -543,17 +543,17 @@  discard block
 block discarded – undo
543 543
 	 * @param string $current_version_to_add
544 544
 	 * @return boolean success
545 545
 	 */
546
-	public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) {
547
-		if( ! $version_history ) {
546
+	public function update_list_of_installed_versions($version_history = NULL, $current_version_to_add = NULL) {
547
+		if ( ! $version_history) {
548 548
 			$version_history = $this->get_activation_history();
549 549
 		}
550
-		if( $current_version_to_add === NULL){
550
+		if ($current_version_to_add === NULL) {
551 551
 			$current_version_to_add = $this->version();
552 552
 		}
553
-		$version_history[ $current_version_to_add ][] = date( 'Y-m-d H:i:s',time() );
553
+		$version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time());
554 554
 		// resave
555 555
 //		echo "updating list of installed versions:".$this->get_activation_history_option_name();d($version_history);
556
-		return update_option( $this->get_activation_history_option_name(), $version_history );
556
+		return update_option($this->get_activation_history_option_name(), $version_history);
557 557
 	}
558 558
 
559 559
 	/**
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * of this addon
562 562
 	 * @return string
563 563
 	 */
564
-	public function get_activation_history_option_name(){
565
-		return self::ee_addon_version_history_option_prefix . $this->name();
564
+	public function get_activation_history_option_name() {
565
+		return self::ee_addon_version_history_option_prefix.$this->name();
566 566
 	}
567 567
 
568 568
 
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 	 * Gets the wp option which stores the activation history for this addon
572 572
 	 * @return array
573 573
 	 */
574
-	public function get_activation_history(){
574
+	public function get_activation_history() {
575 575
 		return get_option($this->get_activation_history_option_name(), NULL);
576 576
 	}
577 577
 
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 	/**
581 581
 	 * @param string $config_section
582 582
 	 */
583
-	public function set_config_section( $config_section = '' ) {
584
-		$this->_config_section = ! empty( $config_section ) ? $config_section : 'addons';
583
+	public function set_config_section($config_section = '') {
584
+		$this->_config_section = ! empty($config_section) ? $config_section : 'addons';
585 585
 	}
586 586
 	/**
587 587
 	 *	filepath to the main file, which can be used for register_activation_hook, register_deactivation_hook, etc.
@@ -594,14 +594,14 @@  discard block
 block discarded – undo
594 594
 	 * Sets the filepath to the main plugin file
595 595
 	 * @param string $filepath
596 596
 	 */
597
-	public function set_main_plugin_file( $filepath ) {
597
+	public function set_main_plugin_file($filepath) {
598 598
 		$this->_main_plugin_file = $filepath;
599 599
 	}
600 600
 	/**
601 601
 	 * gets the filepath to teh main file
602 602
 	 * @return string
603 603
 	 */
604
-	public function get_main_plugin_file(){
604
+	public function get_main_plugin_file() {
605 605
 		return $this->_main_plugin_file;
606 606
 	}
607 607
 
@@ -611,15 +611,15 @@  discard block
 block discarded – undo
611 611
 	 * @return string
612 612
 	 */
613 613
 	public function get_main_plugin_file_basename() {
614
-		return plugin_basename( $this->get_main_plugin_file() );
614
+		return plugin_basename($this->get_main_plugin_file());
615 615
 	}
616 616
 
617 617
 	/**
618 618
 	 * Gets the folder name which contains the main plugin file
619 619
 	 * @return string
620 620
 	 */
621
-	public function get_main_plugin_file_dirname(){
622
-		return dirname( $this->get_main_plugin_file() );
621
+	public function get_main_plugin_file_dirname() {
622
+		return dirname($this->get_main_plugin_file());
623 623
 	}
624 624
 
625 625
 
@@ -628,11 +628,11 @@  discard block
 block discarded – undo
628 628
      *
629 629
      * @return void
630 630
 	 */
631
-	public function admin_init(){
631
+	public function admin_init() {
632 632
 		// is admin and not in M-Mode ?
633
-		if ( is_admin() && ! EE_Maintenance_Mode::instance()->level() ) {
634
-			add_filter( 'plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2 );
635
-			add_filter( 'after_plugin_row_' . $this->_plugin_basename, array( $this, 'after_plugin_row' ), 10, 3 );
633
+		if (is_admin() && ! EE_Maintenance_Mode::instance()->level()) {
634
+			add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);
635
+			add_filter('after_plugin_row_'.$this->_plugin_basename, array($this, 'after_plugin_row'), 10, 3);
636 636
 		}
637 637
 	}
638 638
 
@@ -647,10 +647,10 @@  discard block
 block discarded – undo
647 647
 	 * @param $file
648 648
 	 * @return array
649 649
 	 */
650
-	public function plugin_action_links( $links, $file ) {
651
-		if ( $file === $this->plugin_basename() && $this->plugin_action_slug() !== '' ) {
650
+	public function plugin_action_links($links, $file) {
651
+		if ($file === $this->plugin_basename() && $this->plugin_action_slug() !== '') {
652 652
 			// before other links
653
-			array_unshift( $links, '<a href="admin.php?page=' . $this->plugin_action_slug() . '">' . __( 'Settings' ) . '</a>' );
653
+			array_unshift($links, '<a href="admin.php?page='.$this->plugin_action_slug().'">'.__('Settings').'</a>');
654 654
 		}
655 655
 		return $links;
656 656
 	}
@@ -668,17 +668,17 @@  discard block
 block discarded – undo
668 668
 	 * @param $status
669 669
 	 * @return void
670 670
 	 */
671
-	public function after_plugin_row( $plugin_file, $plugin_data, $status ) {
671
+	public function after_plugin_row($plugin_file, $plugin_data, $status) {
672 672
 
673 673
 		$after_plugin_row = '';
674
-		if ( $plugin_file === $this->plugin_basename() && $this->get_plugins_page_row() !== '' ) {
674
+		if ($plugin_file === $this->plugin_basename() && $this->get_plugins_page_row() !== '') {
675 675
 			$class = $status ? 'active' : 'inactive';
676 676
 			$plugins_page_row = $this->get_plugins_page_row();
677
-			$link_text = isset( $plugins_page_row[ 'link_text' ] ) ? $plugins_page_row[ 'link_text' ] : '';
678
-			$link_url = isset( $plugins_page_row[ 'link_url' ] ) ? $plugins_page_row[ 'link_url' ] : '';
679
-			$description = isset( $plugins_page_row[ 'description' ] ) ? $plugins_page_row[ 'description' ] : $plugins_page_row;
680
-			if ( ! empty( $link_text ) && ! empty( $link_url ) && ! empty( $description )) {
681
-				$after_plugin_row .= '<tr id="' . sanitize_title( $plugin_file ) . '-ee-addon" class="' . $class . '">';
677
+			$link_text = isset($plugins_page_row['link_text']) ? $plugins_page_row['link_text'] : '';
678
+			$link_url = isset($plugins_page_row['link_url']) ? $plugins_page_row['link_url'] : '';
679
+			$description = isset($plugins_page_row['description']) ? $plugins_page_row['description'] : $plugins_page_row;
680
+			if ( ! empty($link_text) && ! empty($link_url) && ! empty($description)) {
681
+				$after_plugin_row .= '<tr id="'.sanitize_title($plugin_file).'-ee-addon" class="'.$class.'">';
682 682
 				$after_plugin_row .= '<th class="check-column" scope="row"></th>';
683 683
 				$after_plugin_row .= '<td class="ee-addon-upsell-info-title-td plugin-title column-primary">';
684 684
 				$after_plugin_row .= '<style>
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 </style>';
721 721
 				$after_plugin_row .= '
722 722
 <p class="ee-addon-upsell-info-dv">
723
-	<a class="ee-button" href="' . $link_url . '">' . $link_text . ' &nbsp;<span class="dashicons dashicons-arrow-right-alt2" style="margin:0;"></span></a>
723
+	<a class="ee-button" href="' . $link_url.'">'.$link_text.' &nbsp;<span class="dashicons dashicons-arrow-right-alt2" style="margin:0;"></span></a>
724 724
 </p>';
725 725
 				$after_plugin_row .= '</td>';
726 726
 				$after_plugin_row .= '<td class="ee-addon-upsell-info-desc-td column-description desc">';
Please login to merge, or discard this patch.