Completed
Branch Gutenberg/master (662364)
by
unknown
137:53 queued 125:13
created
core/libraries/plugin_api/EE_Register_Addon.lib.php 2 patches
Indentation   +1097 added lines, -1097 removed lines patch added patch discarded remove patch
@@ -22,1155 +22,1155 @@
 block discarded – undo
22 22
 class EE_Register_Addon implements EEI_Plugin_API
23 23
 {
24 24
 
25
-    /**
26
-     * possibly truncated version of the EE core version string
27
-     *
28
-     * @var string
29
-     */
30
-    protected static $_core_version = '';
25
+	/**
26
+	 * possibly truncated version of the EE core version string
27
+	 *
28
+	 * @var string
29
+	 */
30
+	protected static $_core_version = '';
31 31
 
32
-    /**
33
-     * Holds values for registered addons
34
-     *
35
-     * @var array
36
-     */
37
-    protected static $_settings = array();
32
+	/**
33
+	 * Holds values for registered addons
34
+	 *
35
+	 * @var array
36
+	 */
37
+	protected static $_settings = array();
38 38
 
39
-    /**
40
-     * @var  array $_incompatible_addons keys are addon SLUGS
41
-     * (first argument passed to EE_Register_Addon::register()), keys are
42
-     * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004).
43
-     * Generally this should be used sparingly, as we don't want to muddle up
44
-     * EE core with knowledge of ALL the addons out there.
45
-     * If you want NO versions of an addon to run with a certain version of core,
46
-     * it's usually best to define the addon's "min_core_version" as part of its call
47
-     * to EE_Register_Addon::register(), rather than using this array with a super high value for its
48
-     * minimum plugin version.
49
-     * @access    protected
50
-     */
51
-    protected static $_incompatible_addons = array(
52
-        'Multi_Event_Registration' => '2.0.11.rc.002',
53
-        'Promotions'               => '1.0.0.rc.084',
54
-    );
39
+	/**
40
+	 * @var  array $_incompatible_addons keys are addon SLUGS
41
+	 * (first argument passed to EE_Register_Addon::register()), keys are
42
+	 * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004).
43
+	 * Generally this should be used sparingly, as we don't want to muddle up
44
+	 * EE core with knowledge of ALL the addons out there.
45
+	 * If you want NO versions of an addon to run with a certain version of core,
46
+	 * it's usually best to define the addon's "min_core_version" as part of its call
47
+	 * to EE_Register_Addon::register(), rather than using this array with a super high value for its
48
+	 * minimum plugin version.
49
+	 * @access    protected
50
+	 */
51
+	protected static $_incompatible_addons = array(
52
+		'Multi_Event_Registration' => '2.0.11.rc.002',
53
+		'Promotions'               => '1.0.0.rc.084',
54
+	);
55 55
 
56 56
 
57
-    /**
58
-     * We should always be comparing core to a version like '4.3.0.rc.000',
59
-     * not just '4.3.0'.
60
-     * So if the addon developer doesn't provide that full version string,
61
-     * fill in the blanks for them
62
-     *
63
-     * @param string $min_core_version
64
-     * @return string always like '4.3.0.rc.000'
65
-     */
66
-    protected static function _effective_version($min_core_version)
67
-    {
68
-        // versions: 4 . 3 . 1 . p . 123
69
-        // offsets:    0 . 1 . 2 . 3 . 4
70
-        $version_parts = explode('.', $min_core_version);
71
-        // check they specified the micro version (after 2nd period)
72
-        if (! isset($version_parts[2])) {
73
-            $version_parts[2] = '0';
74
-        }
75
-        // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
76
-        // soon we can assume that's 'rc', but this current version is 'alpha'
77
-        if (! isset($version_parts[3])) {
78
-            $version_parts[3] = 'dev';
79
-        }
80
-        if (! isset($version_parts[4])) {
81
-            $version_parts[4] = '000';
82
-        }
83
-        return implode('.', $version_parts);
84
-    }
57
+	/**
58
+	 * We should always be comparing core to a version like '4.3.0.rc.000',
59
+	 * not just '4.3.0'.
60
+	 * So if the addon developer doesn't provide that full version string,
61
+	 * fill in the blanks for them
62
+	 *
63
+	 * @param string $min_core_version
64
+	 * @return string always like '4.3.0.rc.000'
65
+	 */
66
+	protected static function _effective_version($min_core_version)
67
+	{
68
+		// versions: 4 . 3 . 1 . p . 123
69
+		// offsets:    0 . 1 . 2 . 3 . 4
70
+		$version_parts = explode('.', $min_core_version);
71
+		// check they specified the micro version (after 2nd period)
72
+		if (! isset($version_parts[2])) {
73
+			$version_parts[2] = '0';
74
+		}
75
+		// if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
76
+		// soon we can assume that's 'rc', but this current version is 'alpha'
77
+		if (! isset($version_parts[3])) {
78
+			$version_parts[3] = 'dev';
79
+		}
80
+		if (! isset($version_parts[4])) {
81
+			$version_parts[4] = '000';
82
+		}
83
+		return implode('.', $version_parts);
84
+	}
85 85
 
86 86
 
87
-    /**
88
-     * Returns whether or not the min core version requirement of the addon is met
89
-     *
90
-     * @param string $min_core_version    the minimum core version required by the addon
91
-     * @param string $actual_core_version the actual core version, optional
92
-     * @return boolean
93
-     */
94
-    public static function _meets_min_core_version_requirement(
95
-        $min_core_version,
96
-        $actual_core_version = EVENT_ESPRESSO_VERSION
97
-    ) {
98
-        return version_compare(
99
-            self::_effective_version($actual_core_version),
100
-            self::_effective_version($min_core_version),
101
-            '>='
102
-        );
103
-    }
87
+	/**
88
+	 * Returns whether or not the min core version requirement of the addon is met
89
+	 *
90
+	 * @param string $min_core_version    the minimum core version required by the addon
91
+	 * @param string $actual_core_version the actual core version, optional
92
+	 * @return boolean
93
+	 */
94
+	public static function _meets_min_core_version_requirement(
95
+		$min_core_version,
96
+		$actual_core_version = EVENT_ESPRESSO_VERSION
97
+	) {
98
+		return version_compare(
99
+			self::_effective_version($actual_core_version),
100
+			self::_effective_version($min_core_version),
101
+			'>='
102
+		);
103
+	}
104 104
 
105 105
 
106
-    /**
107
-     * Method for registering new EE_Addons.
108
-     * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
109
-     * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
110
-     * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
111
-     * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
112
-     * 'activate_plugin', it registers the addon still, but its components are not registered
113
-     * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
114
-     * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
115
-     * (so that we can detect that the addon has activated on the subsequent request)
116
-     *
117
-     * @since    4.3.0
118
-     * @param string                  $addon_name                       [Required] the EE_Addon's name.
119
-     * @param  array                  $setup_args                       {
120
-     *                                                                  An array of arguments provided for registering
121
-     *                                                                  the message type.
122
-     * @type  string                  $class_name                       the addon's main file name.
123
-     *                                                                  If left blank, generated from the addon name,
124
-     *                                                                  changes something like "calendar" to
125
-     *                                                                  "EE_Calendar"
126
-     * @type string                   $min_core_version                 the minimum version of EE Core that the
127
-     *                                                                  addon will work with. eg "4.8.1.rc.084"
128
-     * @type string                   $version                          the "software" version for the addon. eg
129
-     *                                                                  "1.0.0.p" for a first stable release, or
130
-     *                                                                  "1.0.0.rc.043" for a version in progress
131
-     * @type string                   $main_file_path                   the full server path to the main file
132
-     *                                                                  loaded directly by WP
133
-     * @type DomainInterface $domain                                    child class of
134
-     *                                                                  EventEspresso\core\domain\DomainBase
135
-     * @type string                   $domain_fqcn                      Fully Qualified Class Name
136
-     *                                                                  for the addon's Domain class
137
-     *                                                                  (see EventEspresso\core\domain\Domain)
138
-     * @type string                   $admin_path                       full server path to the folder where the
139
-     *                                                                  addon\'s admin files reside
140
-     * @type string                   $admin_callback                   a method to be called when the EE Admin is
141
-     *                                                                  first invoked, can be used for hooking into
142
-     *                                                                  any admin page
143
-     * @type string                   $config_section                   the section name for this addon's
144
-     *                                                                  configuration settings section
145
-     *                                                                  (defaults to "addons")
146
-     * @type string                   $config_class                     the class name for this addon's
147
-     *                                                                  configuration settings object
148
-     * @type string                   $config_name                      the class name for this addon's
149
-     *                                                                  configuration settings object
150
-     * @type string                   $autoloader_paths                 [Required] an array of class names and the full
151
-     *                                                                  server paths to those files.
152
-     * @type string                   $autoloader_folders               an array of  "full server paths" for any
153
-     *                                                                  folders containing classes that might be
154
-     *                                                                  invoked by the addon
155
-     * @type string                   $dms_paths                        [Required] an array of full server paths to
156
-     *                                                                  folders that contain data migration scripts.
157
-     *                                                                  The key should be the EE_Addon class name that
158
-     *                                                                  this set of data migration scripts belongs to.
159
-     *                                                                  If the EE_Addon class is namespaced, then this
160
-     *                                                                  needs to be the Fully Qualified Class Name
161
-     * @type string                   $module_paths                     an array of full server paths to any
162
-     *                                                                  EED_Modules used by the addon
163
-     * @type string                   $shortcode_paths                  an array of full server paths to folders
164
-     *                                                                  that contain EES_Shortcodes
165
-     * @type string                   $widget_paths                     an array of full server paths to folders
166
-     *                                                                  that contain WP_Widgets
167
-     * @type string                   $pue_options
168
-     * @type array                    $capabilities                     an array indexed by role name
169
-     *                                                                  (i.e administrator,author ) and the values
170
-     *                                                                  are an array of caps to add to the role.
171
-     *                                                                  'administrator' => array(
172
-     *                                                                  'read_addon',
173
-     *                                                                  'edit_addon',
174
-     *                                                                  etc.
175
-     *                                                                  ).
176
-     * @type EE_Meta_Capability_Map[] $capability_maps                  an array of EE_Meta_Capability_Map object
177
-     *                                                                  for any addons that need to register any
178
-     *                                                                  special meta mapped capabilities.  Should
179
-     *                                                                  be indexed where the key is the
180
-     *                                                                  EE_Meta_Capability_Map class name and the
181
-     *                                                                  values are the arguments sent to the class.
182
-     * @type array                    $model_paths                      array of folders containing DB models
183
-     * @see      EE_Register_Model
184
-     * @type array                    $class_paths                      array of folders containing DB classes
185
-     * @see      EE_Register_Model
186
-     * @type array                    $model_extension_paths            array of folders containing DB model
187
-     *                                                                  extensions
188
-     * @see      EE_Register_Model_Extension
189
-     * @type array                    $class_extension_paths            array of folders containing DB class
190
-     *                                                                  extensions
191
-     * @see      EE_Register_Model_Extension
192
-     * @type array message_types {
193
-     *                                                                  An array of message types with the key as
194
-     *                                                                  the message type name and the values as
195
-     *                                                                  below:
196
-     * @type string                   $mtfilename                       [Required] The filename of the message type
197
-     *                                                                  being registered. This will be the main
198
-     *                                                                  EE_{Message Type Name}_message_type class.
199
-     *                                                                  for example:
200
-     *                                                                  EE_Declined_Registration_message_type.class.php
201
-     * @type array                    $autoloadpaths                    [Required] An array of paths to add to the
202
-     *                                                                  messages autoloader for the new message type.
203
-     * @type array                    $messengers_to_activate_with      An array of messengers that this message
204
-     *                                                                  type should activate with. Each value in
205
-     *                                                                  the
206
-     *                                                                  array
207
-     *                                                                  should match the name property of a
208
-     *                                                                  EE_messenger. Optional.
209
-     * @type array                    $messengers_to_validate_with      An array of messengers that this message
210
-     *                                                                  type should validate with. Each value in
211
-     *                                                                  the
212
-     *                                                                  array
213
-     *                                                                  should match the name property of an
214
-     *                                                                  EE_messenger.
215
-     *                                                                  Optional.
216
-     *                                                                  }
217
-     * @type array                    $custom_post_types
218
-     * @type array                    $custom_taxonomies
219
-     * @type array                    $payment_method_paths             each element is the folder containing the
220
-     *                                                                  EE_PMT_Base child class
221
-     *                                                                  (eg,
222
-     *                                                                  '/wp-content/plugins/my_plugin/Payomatic/'
223
-     *                                                                  which contains the files
224
-     *                                                                  EE_PMT_Payomatic.pm.php)
225
-     * @type array                    $default_terms
226
-     * @type array                    $namespace                        {
227
-     *                                                                  An array with two items for registering the
228
-     *                                                                  addon's namespace. (If, for some reason, you
229
-     *                                                                  require additional namespaces,
230
-     *                                                                  use
231
-     *                                                                  EventEspresso\core\Psr4Autoloader::addNamespace()
232
-     *                                                                  directly)
233
-     * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
234
-     * @type string                   $FQNS                             the namespace prefix
235
-     * @type string                   $DIR                              a base directory for class files in the
236
-     *                                                                  namespace.
237
-     *                                                                  }
238
-     *                                                                  }
239
-     * @return void
240
-     * @throws DomainException
241
-     * @throws EE_Error
242
-     * @throws InvalidArgumentException
243
-     * @throws ReflectionException
244
-     * @throws InvalidDataTypeException
245
-     * @throws InvalidInterfaceException
246
-     */
247
-    public static function register($addon_name = '', $setup_args = array())
248
-    {
249
-        // required fields MUST be present, so let's make sure they are.
250
-        EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
251
-        // get class name for addon
252
-        $class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
253
-        // setup $_settings array from incoming values.
254
-        $addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
255
-        // setup PUE
256
-        EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
257
-        // does this addon work with this version of core or WordPress ?
258
-        if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
259
-            return;
260
-        }
261
-        // register namespaces
262
-        EE_Register_Addon::_setup_namespaces($addon_settings);
263
-        // check if this is an activation request
264
-        if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
265
-            // dont bother setting up the rest of the addon atm
266
-            return;
267
-        }
268
-        // we need cars
269
-        EE_Register_Addon::_setup_autoloaders($addon_name);
270
-        // register new models and extensions
271
-        EE_Register_Addon::_register_models_and_extensions($addon_name);
272
-        // setup DMS
273
-        EE_Register_Addon::_register_data_migration_scripts($addon_name);
274
-        // if config_class is present let's register config.
275
-        EE_Register_Addon::_register_config($addon_name);
276
-        // register admin pages
277
-        EE_Register_Addon::_register_admin_pages($addon_name);
278
-        // add to list of modules to be registered
279
-        EE_Register_Addon::_register_modules($addon_name);
280
-        // add to list of shortcodes to be registered
281
-        EE_Register_Addon::_register_shortcodes($addon_name);
282
-        // add to list of widgets to be registered
283
-        EE_Register_Addon::_register_widgets($addon_name);
284
-        // register capability related stuff.
285
-        EE_Register_Addon::_register_capabilities($addon_name);
286
-        // any message type to register?
287
-        EE_Register_Addon::_register_message_types($addon_name);
288
-        // any custom post type/ custom capabilities or default terms to register
289
-        EE_Register_Addon::_register_custom_post_types($addon_name);
290
-        // and any payment methods
291
-        EE_Register_Addon::_register_payment_methods($addon_name);
292
-        // load and instantiate main addon class
293
-        $addon = EE_Register_Addon::_load_and_init_addon_class($addon_name);
294
-        // delay calling after_registration hook on each addon until after all add-ons have been registered.
295
-        add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999);
296
-    }
106
+	/**
107
+	 * Method for registering new EE_Addons.
108
+	 * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
109
+	 * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
110
+	 * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
111
+	 * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
112
+	 * 'activate_plugin', it registers the addon still, but its components are not registered
113
+	 * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
114
+	 * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
115
+	 * (so that we can detect that the addon has activated on the subsequent request)
116
+	 *
117
+	 * @since    4.3.0
118
+	 * @param string                  $addon_name                       [Required] the EE_Addon's name.
119
+	 * @param  array                  $setup_args                       {
120
+	 *                                                                  An array of arguments provided for registering
121
+	 *                                                                  the message type.
122
+	 * @type  string                  $class_name                       the addon's main file name.
123
+	 *                                                                  If left blank, generated from the addon name,
124
+	 *                                                                  changes something like "calendar" to
125
+	 *                                                                  "EE_Calendar"
126
+	 * @type string                   $min_core_version                 the minimum version of EE Core that the
127
+	 *                                                                  addon will work with. eg "4.8.1.rc.084"
128
+	 * @type string                   $version                          the "software" version for the addon. eg
129
+	 *                                                                  "1.0.0.p" for a first stable release, or
130
+	 *                                                                  "1.0.0.rc.043" for a version in progress
131
+	 * @type string                   $main_file_path                   the full server path to the main file
132
+	 *                                                                  loaded directly by WP
133
+	 * @type DomainInterface $domain                                    child class of
134
+	 *                                                                  EventEspresso\core\domain\DomainBase
135
+	 * @type string                   $domain_fqcn                      Fully Qualified Class Name
136
+	 *                                                                  for the addon's Domain class
137
+	 *                                                                  (see EventEspresso\core\domain\Domain)
138
+	 * @type string                   $admin_path                       full server path to the folder where the
139
+	 *                                                                  addon\'s admin files reside
140
+	 * @type string                   $admin_callback                   a method to be called when the EE Admin is
141
+	 *                                                                  first invoked, can be used for hooking into
142
+	 *                                                                  any admin page
143
+	 * @type string                   $config_section                   the section name for this addon's
144
+	 *                                                                  configuration settings section
145
+	 *                                                                  (defaults to "addons")
146
+	 * @type string                   $config_class                     the class name for this addon's
147
+	 *                                                                  configuration settings object
148
+	 * @type string                   $config_name                      the class name for this addon's
149
+	 *                                                                  configuration settings object
150
+	 * @type string                   $autoloader_paths                 [Required] an array of class names and the full
151
+	 *                                                                  server paths to those files.
152
+	 * @type string                   $autoloader_folders               an array of  "full server paths" for any
153
+	 *                                                                  folders containing classes that might be
154
+	 *                                                                  invoked by the addon
155
+	 * @type string                   $dms_paths                        [Required] an array of full server paths to
156
+	 *                                                                  folders that contain data migration scripts.
157
+	 *                                                                  The key should be the EE_Addon class name that
158
+	 *                                                                  this set of data migration scripts belongs to.
159
+	 *                                                                  If the EE_Addon class is namespaced, then this
160
+	 *                                                                  needs to be the Fully Qualified Class Name
161
+	 * @type string                   $module_paths                     an array of full server paths to any
162
+	 *                                                                  EED_Modules used by the addon
163
+	 * @type string                   $shortcode_paths                  an array of full server paths to folders
164
+	 *                                                                  that contain EES_Shortcodes
165
+	 * @type string                   $widget_paths                     an array of full server paths to folders
166
+	 *                                                                  that contain WP_Widgets
167
+	 * @type string                   $pue_options
168
+	 * @type array                    $capabilities                     an array indexed by role name
169
+	 *                                                                  (i.e administrator,author ) and the values
170
+	 *                                                                  are an array of caps to add to the role.
171
+	 *                                                                  'administrator' => array(
172
+	 *                                                                  'read_addon',
173
+	 *                                                                  'edit_addon',
174
+	 *                                                                  etc.
175
+	 *                                                                  ).
176
+	 * @type EE_Meta_Capability_Map[] $capability_maps                  an array of EE_Meta_Capability_Map object
177
+	 *                                                                  for any addons that need to register any
178
+	 *                                                                  special meta mapped capabilities.  Should
179
+	 *                                                                  be indexed where the key is the
180
+	 *                                                                  EE_Meta_Capability_Map class name and the
181
+	 *                                                                  values are the arguments sent to the class.
182
+	 * @type array                    $model_paths                      array of folders containing DB models
183
+	 * @see      EE_Register_Model
184
+	 * @type array                    $class_paths                      array of folders containing DB classes
185
+	 * @see      EE_Register_Model
186
+	 * @type array                    $model_extension_paths            array of folders containing DB model
187
+	 *                                                                  extensions
188
+	 * @see      EE_Register_Model_Extension
189
+	 * @type array                    $class_extension_paths            array of folders containing DB class
190
+	 *                                                                  extensions
191
+	 * @see      EE_Register_Model_Extension
192
+	 * @type array message_types {
193
+	 *                                                                  An array of message types with the key as
194
+	 *                                                                  the message type name and the values as
195
+	 *                                                                  below:
196
+	 * @type string                   $mtfilename                       [Required] The filename of the message type
197
+	 *                                                                  being registered. This will be the main
198
+	 *                                                                  EE_{Message Type Name}_message_type class.
199
+	 *                                                                  for example:
200
+	 *                                                                  EE_Declined_Registration_message_type.class.php
201
+	 * @type array                    $autoloadpaths                    [Required] An array of paths to add to the
202
+	 *                                                                  messages autoloader for the new message type.
203
+	 * @type array                    $messengers_to_activate_with      An array of messengers that this message
204
+	 *                                                                  type should activate with. Each value in
205
+	 *                                                                  the
206
+	 *                                                                  array
207
+	 *                                                                  should match the name property of a
208
+	 *                                                                  EE_messenger. Optional.
209
+	 * @type array                    $messengers_to_validate_with      An array of messengers that this message
210
+	 *                                                                  type should validate with. Each value in
211
+	 *                                                                  the
212
+	 *                                                                  array
213
+	 *                                                                  should match the name property of an
214
+	 *                                                                  EE_messenger.
215
+	 *                                                                  Optional.
216
+	 *                                                                  }
217
+	 * @type array                    $custom_post_types
218
+	 * @type array                    $custom_taxonomies
219
+	 * @type array                    $payment_method_paths             each element is the folder containing the
220
+	 *                                                                  EE_PMT_Base child class
221
+	 *                                                                  (eg,
222
+	 *                                                                  '/wp-content/plugins/my_plugin/Payomatic/'
223
+	 *                                                                  which contains the files
224
+	 *                                                                  EE_PMT_Payomatic.pm.php)
225
+	 * @type array                    $default_terms
226
+	 * @type array                    $namespace                        {
227
+	 *                                                                  An array with two items for registering the
228
+	 *                                                                  addon's namespace. (If, for some reason, you
229
+	 *                                                                  require additional namespaces,
230
+	 *                                                                  use
231
+	 *                                                                  EventEspresso\core\Psr4Autoloader::addNamespace()
232
+	 *                                                                  directly)
233
+	 * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
234
+	 * @type string                   $FQNS                             the namespace prefix
235
+	 * @type string                   $DIR                              a base directory for class files in the
236
+	 *                                                                  namespace.
237
+	 *                                                                  }
238
+	 *                                                                  }
239
+	 * @return void
240
+	 * @throws DomainException
241
+	 * @throws EE_Error
242
+	 * @throws InvalidArgumentException
243
+	 * @throws ReflectionException
244
+	 * @throws InvalidDataTypeException
245
+	 * @throws InvalidInterfaceException
246
+	 */
247
+	public static function register($addon_name = '', $setup_args = array())
248
+	{
249
+		// required fields MUST be present, so let's make sure they are.
250
+		EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
251
+		// get class name for addon
252
+		$class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
253
+		// setup $_settings array from incoming values.
254
+		$addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
255
+		// setup PUE
256
+		EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
257
+		// does this addon work with this version of core or WordPress ?
258
+		if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
259
+			return;
260
+		}
261
+		// register namespaces
262
+		EE_Register_Addon::_setup_namespaces($addon_settings);
263
+		// check if this is an activation request
264
+		if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
265
+			// dont bother setting up the rest of the addon atm
266
+			return;
267
+		}
268
+		// we need cars
269
+		EE_Register_Addon::_setup_autoloaders($addon_name);
270
+		// register new models and extensions
271
+		EE_Register_Addon::_register_models_and_extensions($addon_name);
272
+		// setup DMS
273
+		EE_Register_Addon::_register_data_migration_scripts($addon_name);
274
+		// if config_class is present let's register config.
275
+		EE_Register_Addon::_register_config($addon_name);
276
+		// register admin pages
277
+		EE_Register_Addon::_register_admin_pages($addon_name);
278
+		// add to list of modules to be registered
279
+		EE_Register_Addon::_register_modules($addon_name);
280
+		// add to list of shortcodes to be registered
281
+		EE_Register_Addon::_register_shortcodes($addon_name);
282
+		// add to list of widgets to be registered
283
+		EE_Register_Addon::_register_widgets($addon_name);
284
+		// register capability related stuff.
285
+		EE_Register_Addon::_register_capabilities($addon_name);
286
+		// any message type to register?
287
+		EE_Register_Addon::_register_message_types($addon_name);
288
+		// any custom post type/ custom capabilities or default terms to register
289
+		EE_Register_Addon::_register_custom_post_types($addon_name);
290
+		// and any payment methods
291
+		EE_Register_Addon::_register_payment_methods($addon_name);
292
+		// load and instantiate main addon class
293
+		$addon = EE_Register_Addon::_load_and_init_addon_class($addon_name);
294
+		// delay calling after_registration hook on each addon until after all add-ons have been registered.
295
+		add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999);
296
+	}
297 297
 
298 298
 
299
-    /**
300
-     * @param string $addon_name
301
-     * @param array  $setup_args
302
-     * @return void
303
-     * @throws EE_Error
304
-     */
305
-    private static function _verify_parameters($addon_name, array $setup_args)
306
-    {
307
-        // required fields MUST be present, so let's make sure they are.
308
-        if (empty($addon_name) || ! is_array($setup_args)) {
309
-            throw new EE_Error(
310
-                __(
311
-                    '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.',
312
-                    'event_espresso'
313
-                )
314
-            );
315
-        }
316
-        if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
317
-            throw new EE_Error(
318
-                sprintf(
319
-                    __(
320
-                        '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',
321
-                        'event_espresso'
322
-                    ),
323
-                    implode(',', array_keys($setup_args))
324
-                )
325
-            );
326
-        }
327
-        // check that addon has not already been registered with that name
328
-        if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
329
-            throw new EE_Error(
330
-                sprintf(
331
-                    __(
332
-                        'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
333
-                        'event_espresso'
334
-                    ),
335
-                    $addon_name
336
-                )
337
-            );
338
-        }
339
-    }
299
+	/**
300
+	 * @param string $addon_name
301
+	 * @param array  $setup_args
302
+	 * @return void
303
+	 * @throws EE_Error
304
+	 */
305
+	private static function _verify_parameters($addon_name, array $setup_args)
306
+	{
307
+		// required fields MUST be present, so let's make sure they are.
308
+		if (empty($addon_name) || ! is_array($setup_args)) {
309
+			throw new EE_Error(
310
+				__(
311
+					'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.',
312
+					'event_espresso'
313
+				)
314
+			);
315
+		}
316
+		if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
317
+			throw new EE_Error(
318
+				sprintf(
319
+					__(
320
+						'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',
321
+						'event_espresso'
322
+					),
323
+					implode(',', array_keys($setup_args))
324
+				)
325
+			);
326
+		}
327
+		// check that addon has not already been registered with that name
328
+		if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
329
+			throw new EE_Error(
330
+				sprintf(
331
+					__(
332
+						'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
333
+						'event_espresso'
334
+					),
335
+					$addon_name
336
+				)
337
+			);
338
+		}
339
+	}
340 340
 
341 341
 
342
-    /**
343
-     * @param string $addon_name
344
-     * @param array  $setup_args
345
-     * @return string
346
-     */
347
-    private static function _parse_class_name($addon_name, array $setup_args)
348
-    {
349
-        if (empty($setup_args['class_name'])) {
350
-            // generate one by first separating name with spaces
351
-            $class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
352
-            // capitalize, then replace spaces with underscores
353
-            $class_name = str_replace(' ', '_', ucwords($class_name));
354
-        } else {
355
-            $class_name = $setup_args['class_name'];
356
-        }
357
-        // check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
358
-        return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
359
-            ? $class_name
360
-            : 'EE_' . $class_name;
361
-    }
342
+	/**
343
+	 * @param string $addon_name
344
+	 * @param array  $setup_args
345
+	 * @return string
346
+	 */
347
+	private static function _parse_class_name($addon_name, array $setup_args)
348
+	{
349
+		if (empty($setup_args['class_name'])) {
350
+			// generate one by first separating name with spaces
351
+			$class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
352
+			// capitalize, then replace spaces with underscores
353
+			$class_name = str_replace(' ', '_', ucwords($class_name));
354
+		} else {
355
+			$class_name = $setup_args['class_name'];
356
+		}
357
+		// check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
358
+		return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
359
+			? $class_name
360
+			: 'EE_' . $class_name;
361
+	}
362 362
 
363 363
 
364
-    /**
365
-     * @param string $class_name
366
-     * @param array  $setup_args
367
-     * @return array
368
-     */
369
-    private static function _get_addon_settings($class_name, array $setup_args)
370
-    {
371
-        // setup $_settings array from incoming values.
372
-        $addon_settings = array(
373
-            // generated from the addon name, changes something like "calendar" to "EE_Calendar"
374
-            'class_name'            => $class_name,
375
-            // the addon slug for use in URLs, etc
376
-            'plugin_slug'           => isset($setup_args['plugin_slug'])
377
-                ? (string) $setup_args['plugin_slug']
378
-                : '',
379
-            // page slug to be used when generating the "Settings" link on the WP plugin page
380
-            'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
381
-                ? (string) $setup_args['plugin_action_slug']
382
-                : '',
383
-            // the "software" version for the addon
384
-            'version'               => isset($setup_args['version'])
385
-                ? (string) $setup_args['version']
386
-                : '',
387
-            // the minimum version of EE Core that the addon will work with
388
-            'min_core_version'      => isset($setup_args['min_core_version'])
389
-                ? (string) $setup_args['min_core_version']
390
-                : '',
391
-            // the minimum version of WordPress that the addon will work with
392
-            'min_wp_version'        => isset($setup_args['min_wp_version'])
393
-                ? (string) $setup_args['min_wp_version']
394
-                : EE_MIN_WP_VER_REQUIRED,
395
-            // full server path to main file (file loaded directly by WP)
396
-            'main_file_path'        => isset($setup_args['main_file_path'])
397
-                ? (string) $setup_args['main_file_path']
398
-                : '',
399
-            // instance of \EventEspresso\core\domain\DomainInterface
400
-            'domain'                => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface
401
-                ? $setup_args['domain']
402
-                : null,
403
-            // Fully Qualified Class Name for the addon's Domain class
404
-            'domain_fqcn'           => isset($setup_args['domain_fqcn'])
405
-                ? (string) $setup_args['domain_fqcn']
406
-                : '',
407
-            // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
408
-            'admin_path'            => isset($setup_args['admin_path'])
409
-                ? (string) $setup_args['admin_path'] : '',
410
-            // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
411
-            'admin_callback'        => isset($setup_args['admin_callback'])
412
-                ? (string) $setup_args['admin_callback']
413
-                : '',
414
-            // the section name for this addon's configuration settings section (defaults to "addons")
415
-            'config_section'        => isset($setup_args['config_section'])
416
-                ? (string) $setup_args['config_section']
417
-                : 'addons',
418
-            // the class name for this addon's configuration settings object
419
-            'config_class'          => isset($setup_args['config_class'])
420
-                ? (string) $setup_args['config_class'] : '',
421
-            // the name given to the config for this addons' configuration settings object (optional)
422
-            'config_name'           => isset($setup_args['config_name'])
423
-                ? (string) $setup_args['config_name'] : '',
424
-            // an array of "class names" => "full server paths" for any classes that might be invoked by the addon
425
-            'autoloader_paths'      => isset($setup_args['autoloader_paths'])
426
-                ? (array) $setup_args['autoloader_paths']
427
-                : array(),
428
-            // an array of  "full server paths" for any folders containing classes that might be invoked by the addon
429
-            'autoloader_folders'    => isset($setup_args['autoloader_folders'])
430
-                ? (array) $setup_args['autoloader_folders']
431
-                : array(),
432
-            // array of full server paths to any EE_DMS data migration scripts used by the addon.
433
-            // The key should be the EE_Addon class name that this set of data migration scripts belongs to.
434
-            // If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name
435
-            'dms_paths'             => isset($setup_args['dms_paths'])
436
-                ? (array) $setup_args['dms_paths']
437
-                : array(),
438
-            // array of full server paths to any EED_Modules used by the addon
439
-            'module_paths'          => isset($setup_args['module_paths'])
440
-                ? (array) $setup_args['module_paths']
441
-                : array(),
442
-            // array of full server paths to any EES_Shortcodes used by the addon
443
-            'shortcode_paths'       => isset($setup_args['shortcode_paths'])
444
-                ? (array) $setup_args['shortcode_paths']
445
-                : array(),
446
-            'shortcode_fqcns'       => isset($setup_args['shortcode_fqcns'])
447
-                ? (array) $setup_args['shortcode_fqcns']
448
-                : array(),
449
-            // array of full server paths to any WP_Widgets used by the addon
450
-            'widget_paths'          => isset($setup_args['widget_paths'])
451
-                ? (array) $setup_args['widget_paths']
452
-                : array(),
453
-            // array of PUE options used by the addon
454
-            'pue_options'           => isset($setup_args['pue_options'])
455
-                ? (array) $setup_args['pue_options']
456
-                : array(),
457
-            'message_types'         => isset($setup_args['message_types'])
458
-                ? (array) $setup_args['message_types']
459
-                : array(),
460
-            'capabilities'          => isset($setup_args['capabilities'])
461
-                ? (array) $setup_args['capabilities']
462
-                : array(),
463
-            'capability_maps'       => isset($setup_args['capability_maps'])
464
-                ? (array) $setup_args['capability_maps']
465
-                : array(),
466
-            'model_paths'           => isset($setup_args['model_paths'])
467
-                ? (array) $setup_args['model_paths']
468
-                : array(),
469
-            'class_paths'           => isset($setup_args['class_paths'])
470
-                ? (array) $setup_args['class_paths']
471
-                : array(),
472
-            'model_extension_paths' => isset($setup_args['model_extension_paths'])
473
-                ? (array) $setup_args['model_extension_paths']
474
-                : array(),
475
-            'class_extension_paths' => isset($setup_args['class_extension_paths'])
476
-                ? (array) $setup_args['class_extension_paths']
477
-                : array(),
478
-            'custom_post_types'     => isset($setup_args['custom_post_types'])
479
-                ? (array) $setup_args['custom_post_types']
480
-                : array(),
481
-            'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
482
-                ? (array) $setup_args['custom_taxonomies']
483
-                : array(),
484
-            'payment_method_paths'  => isset($setup_args['payment_method_paths'])
485
-                ? (array) $setup_args['payment_method_paths']
486
-                : array(),
487
-            'default_terms'         => isset($setup_args['default_terms'])
488
-                ? (array) $setup_args['default_terms']
489
-                : array(),
490
-            // if not empty, inserts a new table row after this plugin's row on the WP Plugins page
491
-            // that can be used for adding upgrading/marketing info
492
-            'plugins_page_row'      => isset($setup_args['plugins_page_row'])
493
-                ? $setup_args['plugins_page_row']
494
-                : '',
495
-            'namespace'             => isset(
496
-                $setup_args['namespace']['FQNS'],
497
-                $setup_args['namespace']['DIR']
498
-            )
499
-                ? (array) $setup_args['namespace']
500
-                : array(),
501
-        );
502
-        // if plugin_action_slug is NOT set, but an admin page path IS set,
503
-        // then let's just use the plugin_slug since that will be used for linking to the admin page
504
-        $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
505
-                                                && ! empty($addon_settings['admin_path'])
506
-            ? $addon_settings['plugin_slug']
507
-            : $addon_settings['plugin_action_slug'];
508
-        // full server path to main file (file loaded directly by WP)
509
-        $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
510
-        return $addon_settings;
511
-    }
364
+	/**
365
+	 * @param string $class_name
366
+	 * @param array  $setup_args
367
+	 * @return array
368
+	 */
369
+	private static function _get_addon_settings($class_name, array $setup_args)
370
+	{
371
+		// setup $_settings array from incoming values.
372
+		$addon_settings = array(
373
+			// generated from the addon name, changes something like "calendar" to "EE_Calendar"
374
+			'class_name'            => $class_name,
375
+			// the addon slug for use in URLs, etc
376
+			'plugin_slug'           => isset($setup_args['plugin_slug'])
377
+				? (string) $setup_args['plugin_slug']
378
+				: '',
379
+			// page slug to be used when generating the "Settings" link on the WP plugin page
380
+			'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
381
+				? (string) $setup_args['plugin_action_slug']
382
+				: '',
383
+			// the "software" version for the addon
384
+			'version'               => isset($setup_args['version'])
385
+				? (string) $setup_args['version']
386
+				: '',
387
+			// the minimum version of EE Core that the addon will work with
388
+			'min_core_version'      => isset($setup_args['min_core_version'])
389
+				? (string) $setup_args['min_core_version']
390
+				: '',
391
+			// the minimum version of WordPress that the addon will work with
392
+			'min_wp_version'        => isset($setup_args['min_wp_version'])
393
+				? (string) $setup_args['min_wp_version']
394
+				: EE_MIN_WP_VER_REQUIRED,
395
+			// full server path to main file (file loaded directly by WP)
396
+			'main_file_path'        => isset($setup_args['main_file_path'])
397
+				? (string) $setup_args['main_file_path']
398
+				: '',
399
+			// instance of \EventEspresso\core\domain\DomainInterface
400
+			'domain'                => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface
401
+				? $setup_args['domain']
402
+				: null,
403
+			// Fully Qualified Class Name for the addon's Domain class
404
+			'domain_fqcn'           => isset($setup_args['domain_fqcn'])
405
+				? (string) $setup_args['domain_fqcn']
406
+				: '',
407
+			// path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
408
+			'admin_path'            => isset($setup_args['admin_path'])
409
+				? (string) $setup_args['admin_path'] : '',
410
+			// a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
411
+			'admin_callback'        => isset($setup_args['admin_callback'])
412
+				? (string) $setup_args['admin_callback']
413
+				: '',
414
+			// the section name for this addon's configuration settings section (defaults to "addons")
415
+			'config_section'        => isset($setup_args['config_section'])
416
+				? (string) $setup_args['config_section']
417
+				: 'addons',
418
+			// the class name for this addon's configuration settings object
419
+			'config_class'          => isset($setup_args['config_class'])
420
+				? (string) $setup_args['config_class'] : '',
421
+			// the name given to the config for this addons' configuration settings object (optional)
422
+			'config_name'           => isset($setup_args['config_name'])
423
+				? (string) $setup_args['config_name'] : '',
424
+			// an array of "class names" => "full server paths" for any classes that might be invoked by the addon
425
+			'autoloader_paths'      => isset($setup_args['autoloader_paths'])
426
+				? (array) $setup_args['autoloader_paths']
427
+				: array(),
428
+			// an array of  "full server paths" for any folders containing classes that might be invoked by the addon
429
+			'autoloader_folders'    => isset($setup_args['autoloader_folders'])
430
+				? (array) $setup_args['autoloader_folders']
431
+				: array(),
432
+			// array of full server paths to any EE_DMS data migration scripts used by the addon.
433
+			// The key should be the EE_Addon class name that this set of data migration scripts belongs to.
434
+			// If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name
435
+			'dms_paths'             => isset($setup_args['dms_paths'])
436
+				? (array) $setup_args['dms_paths']
437
+				: array(),
438
+			// array of full server paths to any EED_Modules used by the addon
439
+			'module_paths'          => isset($setup_args['module_paths'])
440
+				? (array) $setup_args['module_paths']
441
+				: array(),
442
+			// array of full server paths to any EES_Shortcodes used by the addon
443
+			'shortcode_paths'       => isset($setup_args['shortcode_paths'])
444
+				? (array) $setup_args['shortcode_paths']
445
+				: array(),
446
+			'shortcode_fqcns'       => isset($setup_args['shortcode_fqcns'])
447
+				? (array) $setup_args['shortcode_fqcns']
448
+				: array(),
449
+			// array of full server paths to any WP_Widgets used by the addon
450
+			'widget_paths'          => isset($setup_args['widget_paths'])
451
+				? (array) $setup_args['widget_paths']
452
+				: array(),
453
+			// array of PUE options used by the addon
454
+			'pue_options'           => isset($setup_args['pue_options'])
455
+				? (array) $setup_args['pue_options']
456
+				: array(),
457
+			'message_types'         => isset($setup_args['message_types'])
458
+				? (array) $setup_args['message_types']
459
+				: array(),
460
+			'capabilities'          => isset($setup_args['capabilities'])
461
+				? (array) $setup_args['capabilities']
462
+				: array(),
463
+			'capability_maps'       => isset($setup_args['capability_maps'])
464
+				? (array) $setup_args['capability_maps']
465
+				: array(),
466
+			'model_paths'           => isset($setup_args['model_paths'])
467
+				? (array) $setup_args['model_paths']
468
+				: array(),
469
+			'class_paths'           => isset($setup_args['class_paths'])
470
+				? (array) $setup_args['class_paths']
471
+				: array(),
472
+			'model_extension_paths' => isset($setup_args['model_extension_paths'])
473
+				? (array) $setup_args['model_extension_paths']
474
+				: array(),
475
+			'class_extension_paths' => isset($setup_args['class_extension_paths'])
476
+				? (array) $setup_args['class_extension_paths']
477
+				: array(),
478
+			'custom_post_types'     => isset($setup_args['custom_post_types'])
479
+				? (array) $setup_args['custom_post_types']
480
+				: array(),
481
+			'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
482
+				? (array) $setup_args['custom_taxonomies']
483
+				: array(),
484
+			'payment_method_paths'  => isset($setup_args['payment_method_paths'])
485
+				? (array) $setup_args['payment_method_paths']
486
+				: array(),
487
+			'default_terms'         => isset($setup_args['default_terms'])
488
+				? (array) $setup_args['default_terms']
489
+				: array(),
490
+			// if not empty, inserts a new table row after this plugin's row on the WP Plugins page
491
+			// that can be used for adding upgrading/marketing info
492
+			'plugins_page_row'      => isset($setup_args['plugins_page_row'])
493
+				? $setup_args['plugins_page_row']
494
+				: '',
495
+			'namespace'             => isset(
496
+				$setup_args['namespace']['FQNS'],
497
+				$setup_args['namespace']['DIR']
498
+			)
499
+				? (array) $setup_args['namespace']
500
+				: array(),
501
+		);
502
+		// if plugin_action_slug is NOT set, but an admin page path IS set,
503
+		// then let's just use the plugin_slug since that will be used for linking to the admin page
504
+		$addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
505
+												&& ! empty($addon_settings['admin_path'])
506
+			? $addon_settings['plugin_slug']
507
+			: $addon_settings['plugin_action_slug'];
508
+		// full server path to main file (file loaded directly by WP)
509
+		$addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
510
+		return $addon_settings;
511
+	}
512 512
 
513 513
 
514
-    /**
515
-     * @param string $addon_name
516
-     * @param array  $addon_settings
517
-     * @return boolean
518
-     */
519
-    private static function _addon_is_compatible($addon_name, array $addon_settings)
520
-    {
521
-        global $wp_version;
522
-        $incompatibility_message = '';
523
-        // check whether this addon version is compatible with EE core
524
-        if (isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
525
-            && ! self::_meets_min_core_version_requirement(
526
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
527
-                $addon_settings['version']
528
-            )
529
-        ) {
530
-            $incompatibility_message = sprintf(
531
-                __(
532
-                    '%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.',
533
-                    'event_espresso'
534
-                ),
535
-                $addon_name,
536
-                '<br />',
537
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
538
-                '<span style="font-weight: bold; color: #D54E21;">',
539
-                '</span><br />'
540
-            );
541
-        } elseif (! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
542
-        ) {
543
-            $incompatibility_message = sprintf(
544
-                __(
545
-                    '%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".',
546
-                    'event_espresso'
547
-                ),
548
-                $addon_name,
549
-                self::_effective_version($addon_settings['min_core_version']),
550
-                self::_effective_version(espresso_version()),
551
-                '<br />',
552
-                '<span style="font-weight: bold; color: #D54E21;">',
553
-                '</span><br />'
554
-            );
555
-        } elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
556
-            $incompatibility_message = sprintf(
557
-                __(
558
-                    '%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.',
559
-                    'event_espresso'
560
-                ),
561
-                $addon_name,
562
-                $addon_settings['min_wp_version'],
563
-                '<br />',
564
-                '<span style="font-weight: bold; color: #D54E21;">',
565
-                '</span><br />'
566
-            );
567
-        }
568
-        if (! empty($incompatibility_message)) {
569
-            // remove 'activate' from the REQUEST
570
-            // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
571
-            unset($_GET['activate'], $_REQUEST['activate']);
572
-            if (current_user_can('activate_plugins')) {
573
-                // show an error message indicating the plugin didn't activate properly
574
-                EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
575
-            }
576
-            // BAIL FROM THE ADDON REGISTRATION PROCESS
577
-            return false;
578
-        }
579
-        // addon IS compatible
580
-        return true;
581
-    }
514
+	/**
515
+	 * @param string $addon_name
516
+	 * @param array  $addon_settings
517
+	 * @return boolean
518
+	 */
519
+	private static function _addon_is_compatible($addon_name, array $addon_settings)
520
+	{
521
+		global $wp_version;
522
+		$incompatibility_message = '';
523
+		// check whether this addon version is compatible with EE core
524
+		if (isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
525
+			&& ! self::_meets_min_core_version_requirement(
526
+				EE_Register_Addon::$_incompatible_addons[ $addon_name ],
527
+				$addon_settings['version']
528
+			)
529
+		) {
530
+			$incompatibility_message = sprintf(
531
+				__(
532
+					'%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.',
533
+					'event_espresso'
534
+				),
535
+				$addon_name,
536
+				'<br />',
537
+				EE_Register_Addon::$_incompatible_addons[ $addon_name ],
538
+				'<span style="font-weight: bold; color: #D54E21;">',
539
+				'</span><br />'
540
+			);
541
+		} elseif (! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
542
+		) {
543
+			$incompatibility_message = sprintf(
544
+				__(
545
+					'%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".',
546
+					'event_espresso'
547
+				),
548
+				$addon_name,
549
+				self::_effective_version($addon_settings['min_core_version']),
550
+				self::_effective_version(espresso_version()),
551
+				'<br />',
552
+				'<span style="font-weight: bold; color: #D54E21;">',
553
+				'</span><br />'
554
+			);
555
+		} elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
556
+			$incompatibility_message = sprintf(
557
+				__(
558
+					'%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.',
559
+					'event_espresso'
560
+				),
561
+				$addon_name,
562
+				$addon_settings['min_wp_version'],
563
+				'<br />',
564
+				'<span style="font-weight: bold; color: #D54E21;">',
565
+				'</span><br />'
566
+			);
567
+		}
568
+		if (! empty($incompatibility_message)) {
569
+			// remove 'activate' from the REQUEST
570
+			// so WP doesn't erroneously tell the user the plugin activated fine when it didn't
571
+			unset($_GET['activate'], $_REQUEST['activate']);
572
+			if (current_user_can('activate_plugins')) {
573
+				// show an error message indicating the plugin didn't activate properly
574
+				EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
575
+			}
576
+			// BAIL FROM THE ADDON REGISTRATION PROCESS
577
+			return false;
578
+		}
579
+		// addon IS compatible
580
+		return true;
581
+	}
582 582
 
583 583
 
584
-    /**
585
-     * if plugin update engine is being used for auto-updates,
586
-     * then let's set that up now before going any further so that ALL addons can be updated
587
-     * (not needed if PUE is not being used)
588
-     *
589
-     * @param string $addon_name
590
-     * @param string $class_name
591
-     * @param array  $setup_args
592
-     * @return void
593
-     */
594
-    private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
595
-    {
596
-        if (! empty($setup_args['pue_options'])) {
597
-            self::$_settings[ $addon_name ]['pue_options'] = array(
598
-                'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
599
-                    ? (string) $setup_args['pue_options']['pue_plugin_slug']
600
-                    : 'espresso_' . strtolower($class_name),
601
-                'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
602
-                    ? (string) $setup_args['pue_options']['plugin_basename']
603
-                    : plugin_basename($setup_args['main_file_path']),
604
-                'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
605
-                    ? (string) $setup_args['pue_options']['checkPeriod']
606
-                    : '24',
607
-                'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
608
-                    ? (string) $setup_args['pue_options']['use_wp_update']
609
-                    : false,
610
-            );
611
-            add_action(
612
-                'AHEE__EE_System__brew_espresso__after_pue_init',
613
-                array('EE_Register_Addon', 'load_pue_update')
614
-            );
615
-        }
616
-    }
584
+	/**
585
+	 * if plugin update engine is being used for auto-updates,
586
+	 * then let's set that up now before going any further so that ALL addons can be updated
587
+	 * (not needed if PUE is not being used)
588
+	 *
589
+	 * @param string $addon_name
590
+	 * @param string $class_name
591
+	 * @param array  $setup_args
592
+	 * @return void
593
+	 */
594
+	private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
595
+	{
596
+		if (! empty($setup_args['pue_options'])) {
597
+			self::$_settings[ $addon_name ]['pue_options'] = array(
598
+				'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
599
+					? (string) $setup_args['pue_options']['pue_plugin_slug']
600
+					: 'espresso_' . strtolower($class_name),
601
+				'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
602
+					? (string) $setup_args['pue_options']['plugin_basename']
603
+					: plugin_basename($setup_args['main_file_path']),
604
+				'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
605
+					? (string) $setup_args['pue_options']['checkPeriod']
606
+					: '24',
607
+				'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
608
+					? (string) $setup_args['pue_options']['use_wp_update']
609
+					: false,
610
+			);
611
+			add_action(
612
+				'AHEE__EE_System__brew_espresso__after_pue_init',
613
+				array('EE_Register_Addon', 'load_pue_update')
614
+			);
615
+		}
616
+	}
617 617
 
618 618
 
619
-    /**
620
-     * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
621
-     *
622
-     * @param array $addon_settings
623
-     * @return void
624
-     */
625
-    private static function _setup_namespaces(array $addon_settings)
626
-    {
627
-        //
628
-        if (isset(
629
-            $addon_settings['namespace']['FQNS'],
630
-            $addon_settings['namespace']['DIR']
631
-        )) {
632
-            EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
633
-                $addon_settings['namespace']['FQNS'],
634
-                $addon_settings['namespace']['DIR']
635
-            );
636
-        }
637
-    }
619
+	/**
620
+	 * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
621
+	 *
622
+	 * @param array $addon_settings
623
+	 * @return void
624
+	 */
625
+	private static function _setup_namespaces(array $addon_settings)
626
+	{
627
+		//
628
+		if (isset(
629
+			$addon_settings['namespace']['FQNS'],
630
+			$addon_settings['namespace']['DIR']
631
+		)) {
632
+			EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
633
+				$addon_settings['namespace']['FQNS'],
634
+				$addon_settings['namespace']['DIR']
635
+			);
636
+		}
637
+	}
638 638
 
639 639
 
640
-    /**
641
-     * @param string $addon_name
642
-     * @param array  $addon_settings
643
-     * @return bool
644
-     * @throws EE_Error
645
-     * @throws InvalidArgumentException
646
-     * @throws ReflectionException
647
-     * @throws InvalidDataTypeException
648
-     * @throws InvalidInterfaceException
649
-     */
650
-    private static function _addon_activation($addon_name, array $addon_settings)
651
-    {
652
-        // this is an activation request
653
-        if (did_action('activate_plugin')) {
654
-            // to find if THIS is the addon that was activated, just check if we have already registered it or not
655
-            // (as the newly-activated addon wasn't around the first time addons were registered).
656
-            // Note: the presence of pue_options in the addon registration options will initialize the $_settings
657
-            // property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
658
-            if (! isset(self::$_settings[ $addon_name ])
659
-                || (isset(self::$_settings[ $addon_name ])
660
-                    && ! isset(self::$_settings[ $addon_name ]['class_name'])
661
-                )
662
-            ) {
663
-                self::$_settings[ $addon_name ] = $addon_settings;
664
-                $addon = self::_load_and_init_addon_class($addon_name);
665
-                $addon->set_activation_indicator_option();
666
-                // dont bother setting up the rest of the addon.
667
-                // we know it was just activated and the request will end soon
668
-            }
669
-            return true;
670
-        }
671
-        // make sure this was called in the right place!
672
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
673
-            || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
674
-        ) {
675
-            EE_Error::doing_it_wrong(
676
-                __METHOD__,
677
-                sprintf(
678
-                    __(
679
-                        '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.',
680
-                        'event_espresso'
681
-                    ),
682
-                    $addon_name
683
-                ),
684
-                '4.3.0'
685
-            );
686
-        }
687
-        // make sure addon settings are set correctly without overwriting anything existing
688
-        if (isset(self::$_settings[ $addon_name ])) {
689
-            self::$_settings[ $addon_name ] += $addon_settings;
690
-        } else {
691
-            self::$_settings[ $addon_name ] = $addon_settings;
692
-        }
693
-        return false;
694
-    }
640
+	/**
641
+	 * @param string $addon_name
642
+	 * @param array  $addon_settings
643
+	 * @return bool
644
+	 * @throws EE_Error
645
+	 * @throws InvalidArgumentException
646
+	 * @throws ReflectionException
647
+	 * @throws InvalidDataTypeException
648
+	 * @throws InvalidInterfaceException
649
+	 */
650
+	private static function _addon_activation($addon_name, array $addon_settings)
651
+	{
652
+		// this is an activation request
653
+		if (did_action('activate_plugin')) {
654
+			// to find if THIS is the addon that was activated, just check if we have already registered it or not
655
+			// (as the newly-activated addon wasn't around the first time addons were registered).
656
+			// Note: the presence of pue_options in the addon registration options will initialize the $_settings
657
+			// property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
658
+			if (! isset(self::$_settings[ $addon_name ])
659
+				|| (isset(self::$_settings[ $addon_name ])
660
+					&& ! isset(self::$_settings[ $addon_name ]['class_name'])
661
+				)
662
+			) {
663
+				self::$_settings[ $addon_name ] = $addon_settings;
664
+				$addon = self::_load_and_init_addon_class($addon_name);
665
+				$addon->set_activation_indicator_option();
666
+				// dont bother setting up the rest of the addon.
667
+				// we know it was just activated and the request will end soon
668
+			}
669
+			return true;
670
+		}
671
+		// make sure this was called in the right place!
672
+		if (! did_action('AHEE__EE_System__load_espresso_addons')
673
+			|| did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
674
+		) {
675
+			EE_Error::doing_it_wrong(
676
+				__METHOD__,
677
+				sprintf(
678
+					__(
679
+						'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.',
680
+						'event_espresso'
681
+					),
682
+					$addon_name
683
+				),
684
+				'4.3.0'
685
+			);
686
+		}
687
+		// make sure addon settings are set correctly without overwriting anything existing
688
+		if (isset(self::$_settings[ $addon_name ])) {
689
+			self::$_settings[ $addon_name ] += $addon_settings;
690
+		} else {
691
+			self::$_settings[ $addon_name ] = $addon_settings;
692
+		}
693
+		return false;
694
+	}
695 695
 
696 696
 
697
-    /**
698
-     * @param string $addon_name
699
-     * @return void
700
-     * @throws EE_Error
701
-     */
702
-    private static function _setup_autoloaders($addon_name)
703
-    {
704
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
705
-            // setup autoloader for single file
706
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
707
-        }
708
-        // setup autoloaders for folders
709
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
710
-            foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
711
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
712
-            }
713
-        }
714
-    }
697
+	/**
698
+	 * @param string $addon_name
699
+	 * @return void
700
+	 * @throws EE_Error
701
+	 */
702
+	private static function _setup_autoloaders($addon_name)
703
+	{
704
+		if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
705
+			// setup autoloader for single file
706
+			EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
707
+		}
708
+		// setup autoloaders for folders
709
+		if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
710
+			foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
711
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
712
+			}
713
+		}
714
+	}
715 715
 
716 716
 
717
-    /**
718
-     * register new models and extensions
719
-     *
720
-     * @param string $addon_name
721
-     * @return void
722
-     * @throws EE_Error
723
-     */
724
-    private static function _register_models_and_extensions($addon_name)
725
-    {
726
-        // register new models
727
-        if (! empty(self::$_settings[ $addon_name ]['model_paths'])
728
-            || ! empty(self::$_settings[ $addon_name ]['class_paths'])
729
-        ) {
730
-            EE_Register_Model::register(
731
-                $addon_name,
732
-                array(
733
-                    'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
734
-                    'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
735
-                )
736
-            );
737
-        }
738
-        // register model extensions
739
-        if (! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
740
-            || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
741
-        ) {
742
-            EE_Register_Model_Extensions::register(
743
-                $addon_name,
744
-                array(
745
-                    'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
746
-                    'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
747
-                )
748
-            );
749
-        }
750
-    }
717
+	/**
718
+	 * register new models and extensions
719
+	 *
720
+	 * @param string $addon_name
721
+	 * @return void
722
+	 * @throws EE_Error
723
+	 */
724
+	private static function _register_models_and_extensions($addon_name)
725
+	{
726
+		// register new models
727
+		if (! empty(self::$_settings[ $addon_name ]['model_paths'])
728
+			|| ! empty(self::$_settings[ $addon_name ]['class_paths'])
729
+		) {
730
+			EE_Register_Model::register(
731
+				$addon_name,
732
+				array(
733
+					'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
734
+					'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
735
+				)
736
+			);
737
+		}
738
+		// register model extensions
739
+		if (! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
740
+			|| ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
741
+		) {
742
+			EE_Register_Model_Extensions::register(
743
+				$addon_name,
744
+				array(
745
+					'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
746
+					'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
747
+				)
748
+			);
749
+		}
750
+	}
751 751
 
752 752
 
753
-    /**
754
-     * @param string $addon_name
755
-     * @return void
756
-     * @throws EE_Error
757
-     */
758
-    private static function _register_data_migration_scripts($addon_name)
759
-    {
760
-        // setup DMS
761
-        if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
762
-            EE_Register_Data_Migration_Scripts::register(
763
-                $addon_name,
764
-                array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
765
-            );
766
-        }
767
-    }
753
+	/**
754
+	 * @param string $addon_name
755
+	 * @return void
756
+	 * @throws EE_Error
757
+	 */
758
+	private static function _register_data_migration_scripts($addon_name)
759
+	{
760
+		// setup DMS
761
+		if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
762
+			EE_Register_Data_Migration_Scripts::register(
763
+				$addon_name,
764
+				array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
765
+			);
766
+		}
767
+	}
768 768
 
769 769
 
770
-    /**
771
-     * @param string $addon_name
772
-     * @return void
773
-     * @throws EE_Error
774
-     */
775
-    private static function _register_config($addon_name)
776
-    {
777
-        // if config_class is present let's register config.
778
-        if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
779
-            EE_Register_Config::register(
780
-                self::$_settings[ $addon_name ]['config_class'],
781
-                array(
782
-                    'config_section' => self::$_settings[ $addon_name ]['config_section'],
783
-                    'config_name'    => self::$_settings[ $addon_name ]['config_name'],
784
-                )
785
-            );
786
-        }
787
-    }
770
+	/**
771
+	 * @param string $addon_name
772
+	 * @return void
773
+	 * @throws EE_Error
774
+	 */
775
+	private static function _register_config($addon_name)
776
+	{
777
+		// if config_class is present let's register config.
778
+		if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
779
+			EE_Register_Config::register(
780
+				self::$_settings[ $addon_name ]['config_class'],
781
+				array(
782
+					'config_section' => self::$_settings[ $addon_name ]['config_section'],
783
+					'config_name'    => self::$_settings[ $addon_name ]['config_name'],
784
+				)
785
+			);
786
+		}
787
+	}
788 788
 
789 789
 
790
-    /**
791
-     * @param string $addon_name
792
-     * @return void
793
-     * @throws EE_Error
794
-     */
795
-    private static function _register_admin_pages($addon_name)
796
-    {
797
-        if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
798
-            EE_Register_Admin_Page::register(
799
-                $addon_name,
800
-                array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
801
-            );
802
-        }
803
-    }
790
+	/**
791
+	 * @param string $addon_name
792
+	 * @return void
793
+	 * @throws EE_Error
794
+	 */
795
+	private static function _register_admin_pages($addon_name)
796
+	{
797
+		if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
798
+			EE_Register_Admin_Page::register(
799
+				$addon_name,
800
+				array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
801
+			);
802
+		}
803
+	}
804 804
 
805 805
 
806
-    /**
807
-     * @param string $addon_name
808
-     * @return void
809
-     * @throws EE_Error
810
-     */
811
-    private static function _register_modules($addon_name)
812
-    {
813
-        if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
814
-            EE_Register_Module::register(
815
-                $addon_name,
816
-                array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
817
-            );
818
-        }
819
-    }
806
+	/**
807
+	 * @param string $addon_name
808
+	 * @return void
809
+	 * @throws EE_Error
810
+	 */
811
+	private static function _register_modules($addon_name)
812
+	{
813
+		if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
814
+			EE_Register_Module::register(
815
+				$addon_name,
816
+				array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
817
+			);
818
+		}
819
+	}
820 820
 
821 821
 
822
-    /**
823
-     * @param string $addon_name
824
-     * @return void
825
-     * @throws EE_Error
826
-     */
827
-    private static function _register_shortcodes($addon_name)
828
-    {
829
-        if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
830
-            || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
831
-        ) {
832
-            EE_Register_Shortcode::register(
833
-                $addon_name,
834
-                array(
835
-                    'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
836
-                        ? self::$_settings[ $addon_name ]['shortcode_paths']
837
-                        : array(),
838
-                    'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
839
-                        ? self::$_settings[ $addon_name ]['shortcode_fqcns']
840
-                        : array(),
841
-                )
842
-            );
843
-        }
844
-    }
822
+	/**
823
+	 * @param string $addon_name
824
+	 * @return void
825
+	 * @throws EE_Error
826
+	 */
827
+	private static function _register_shortcodes($addon_name)
828
+	{
829
+		if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
830
+			|| ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
831
+		) {
832
+			EE_Register_Shortcode::register(
833
+				$addon_name,
834
+				array(
835
+					'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
836
+						? self::$_settings[ $addon_name ]['shortcode_paths']
837
+						: array(),
838
+					'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
839
+						? self::$_settings[ $addon_name ]['shortcode_fqcns']
840
+						: array(),
841
+				)
842
+			);
843
+		}
844
+	}
845 845
 
846 846
 
847
-    /**
848
-     * @param string $addon_name
849
-     * @return void
850
-     * @throws EE_Error
851
-     */
852
-    private static function _register_widgets($addon_name)
853
-    {
854
-        if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
855
-            EE_Register_Widget::register(
856
-                $addon_name,
857
-                array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
858
-            );
859
-        }
860
-    }
847
+	/**
848
+	 * @param string $addon_name
849
+	 * @return void
850
+	 * @throws EE_Error
851
+	 */
852
+	private static function _register_widgets($addon_name)
853
+	{
854
+		if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
855
+			EE_Register_Widget::register(
856
+				$addon_name,
857
+				array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
858
+			);
859
+		}
860
+	}
861 861
 
862 862
 
863
-    /**
864
-     * @param string $addon_name
865
-     * @return void
866
-     * @throws EE_Error
867
-     */
868
-    private static function _register_capabilities($addon_name)
869
-    {
870
-        if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
871
-            EE_Register_Capabilities::register(
872
-                $addon_name,
873
-                array(
874
-                    'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
875
-                    'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
876
-                )
877
-            );
878
-        }
879
-    }
863
+	/**
864
+	 * @param string $addon_name
865
+	 * @return void
866
+	 * @throws EE_Error
867
+	 */
868
+	private static function _register_capabilities($addon_name)
869
+	{
870
+		if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
871
+			EE_Register_Capabilities::register(
872
+				$addon_name,
873
+				array(
874
+					'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
875
+					'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
876
+				)
877
+			);
878
+		}
879
+	}
880 880
 
881 881
 
882
-    /**
883
-     * @param string $addon_name
884
-     * @return void
885
-     * @throws EE_Error
886
-     */
887
-    private static function _register_message_types($addon_name)
888
-    {
889
-        if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
890
-            add_action(
891
-                'EE_Brewing_Regular___messages_caf',
892
-                array('EE_Register_Addon', 'register_message_types')
893
-            );
894
-        }
895
-    }
882
+	/**
883
+	 * @param string $addon_name
884
+	 * @return void
885
+	 * @throws EE_Error
886
+	 */
887
+	private static function _register_message_types($addon_name)
888
+	{
889
+		if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
890
+			add_action(
891
+				'EE_Brewing_Regular___messages_caf',
892
+				array('EE_Register_Addon', 'register_message_types')
893
+			);
894
+		}
895
+	}
896 896
 
897 897
 
898
-    /**
899
-     * @param string $addon_name
900
-     * @return void
901
-     * @throws EE_Error
902
-     */
903
-    private static function _register_custom_post_types($addon_name)
904
-    {
905
-        if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])
906
-            || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
907
-        ) {
908
-            EE_Register_CPT::register(
909
-                $addon_name,
910
-                array(
911
-                    'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
912
-                    'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
913
-                    'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
914
-                )
915
-            );
916
-        }
917
-    }
898
+	/**
899
+	 * @param string $addon_name
900
+	 * @return void
901
+	 * @throws EE_Error
902
+	 */
903
+	private static function _register_custom_post_types($addon_name)
904
+	{
905
+		if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])
906
+			|| ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
907
+		) {
908
+			EE_Register_CPT::register(
909
+				$addon_name,
910
+				array(
911
+					'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
912
+					'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
913
+					'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
914
+				)
915
+			);
916
+		}
917
+	}
918 918
 
919 919
 
920
-    /**
921
-     * @param string $addon_name
922
-     * @return void
923
-     * @throws InvalidArgumentException
924
-     * @throws InvalidInterfaceException
925
-     * @throws InvalidDataTypeException
926
-     * @throws DomainException
927
-     * @throws EE_Error
928
-     */
929
-    private static function _register_payment_methods($addon_name)
930
-    {
931
-        if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
932
-            EE_Register_Payment_Method::register(
933
-                $addon_name,
934
-                array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
935
-            );
936
-        }
937
-    }
920
+	/**
921
+	 * @param string $addon_name
922
+	 * @return void
923
+	 * @throws InvalidArgumentException
924
+	 * @throws InvalidInterfaceException
925
+	 * @throws InvalidDataTypeException
926
+	 * @throws DomainException
927
+	 * @throws EE_Error
928
+	 */
929
+	private static function _register_payment_methods($addon_name)
930
+	{
931
+		if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
932
+			EE_Register_Payment_Method::register(
933
+				$addon_name,
934
+				array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
935
+			);
936
+		}
937
+	}
938 938
 
939 939
 
940
-    /**
941
-     * Loads and instantiates the EE_Addon class and adds it onto the registry
942
-     *
943
-     * @param string $addon_name
944
-     * @return EE_Addon
945
-     * @throws InvalidArgumentException
946
-     * @throws InvalidInterfaceException
947
-     * @throws InvalidDataTypeException
948
-     * @throws ReflectionException
949
-     * @throws EE_Error
950
-     */
951
-    private static function _load_and_init_addon_class($addon_name)
952
-    {
953
-        $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader();
954
-        $addon = $loader->getShared(
955
-            self::$_settings[ $addon_name ]['class_name'],
956
-            array('EE_Registry::create(addon)' => true)
957
-        );
958
-        // setter inject dep map if required
959
-        if ($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null) {
960
-            $addon->setDependencyMap($loader->getShared('EE_Dependency_Map'));
961
-        }
962
-        // setter inject domain if required
963
-        if ($addon instanceof RequiresDomainInterface
964
-            && $addon->domain() === null
965
-        ) {
966
-            // using supplied Domain object
967
-            $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
968
-                ? self::$_settings[ $addon_name ]['domain']
969
-                : null;
970
-            // or construct one using Domain FQCN
971
-            if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
972
-                $domain = $loader->getShared(
973
-                    self::$_settings[ $addon_name ]['domain_fqcn'],
974
-                    array(
975
-                        new EventEspresso\core\domain\values\FilePath(
976
-                            self::$_settings[ $addon_name ]['main_file_path']
977
-                        ),
978
-                        EventEspresso\core\domain\values\Version::fromString(
979
-                            self::$_settings[ $addon_name ]['version']
980
-                        ),
981
-                    )
982
-                );
983
-            }
984
-            if ($domain instanceof DomainInterface) {
985
-                $addon->setDomain($domain);
986
-            }
987
-        }
988
-        $addon->set_name($addon_name);
989
-        $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
990
-        $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
991
-        $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
992
-        $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
993
-        $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
994
-        $addon->set_version(self::$_settings[ $addon_name ]['version']);
995
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
996
-        $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
997
-        $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
998
-        $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
999
-        // unfortunately this can't be hooked in upon construction, because we don't have
1000
-        // the plugin mainfile's path upon construction.
1001
-        register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
1002
-        // call any additional admin_callback functions during load_admin_controller hook
1003
-        if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1004
-            add_action(
1005
-                'AHEE__EE_System__load_controllers__load_admin_controllers',
1006
-                array($addon, self::$_settings[ $addon_name ]['admin_callback'])
1007
-            );
1008
-        }
1009
-        return $addon;
1010
-    }
940
+	/**
941
+	 * Loads and instantiates the EE_Addon class and adds it onto the registry
942
+	 *
943
+	 * @param string $addon_name
944
+	 * @return EE_Addon
945
+	 * @throws InvalidArgumentException
946
+	 * @throws InvalidInterfaceException
947
+	 * @throws InvalidDataTypeException
948
+	 * @throws ReflectionException
949
+	 * @throws EE_Error
950
+	 */
951
+	private static function _load_and_init_addon_class($addon_name)
952
+	{
953
+		$loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader();
954
+		$addon = $loader->getShared(
955
+			self::$_settings[ $addon_name ]['class_name'],
956
+			array('EE_Registry::create(addon)' => true)
957
+		);
958
+		// setter inject dep map if required
959
+		if ($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null) {
960
+			$addon->setDependencyMap($loader->getShared('EE_Dependency_Map'));
961
+		}
962
+		// setter inject domain if required
963
+		if ($addon instanceof RequiresDomainInterface
964
+			&& $addon->domain() === null
965
+		) {
966
+			// using supplied Domain object
967
+			$domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
968
+				? self::$_settings[ $addon_name ]['domain']
969
+				: null;
970
+			// or construct one using Domain FQCN
971
+			if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
972
+				$domain = $loader->getShared(
973
+					self::$_settings[ $addon_name ]['domain_fqcn'],
974
+					array(
975
+						new EventEspresso\core\domain\values\FilePath(
976
+							self::$_settings[ $addon_name ]['main_file_path']
977
+						),
978
+						EventEspresso\core\domain\values\Version::fromString(
979
+							self::$_settings[ $addon_name ]['version']
980
+						),
981
+					)
982
+				);
983
+			}
984
+			if ($domain instanceof DomainInterface) {
985
+				$addon->setDomain($domain);
986
+			}
987
+		}
988
+		$addon->set_name($addon_name);
989
+		$addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
990
+		$addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
991
+		$addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
992
+		$addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
993
+		$addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
994
+		$addon->set_version(self::$_settings[ $addon_name ]['version']);
995
+		$addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
996
+		$addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
997
+		$addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
998
+		$addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
999
+		// unfortunately this can't be hooked in upon construction, because we don't have
1000
+		// the plugin mainfile's path upon construction.
1001
+		register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
1002
+		// call any additional admin_callback functions during load_admin_controller hook
1003
+		if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1004
+			add_action(
1005
+				'AHEE__EE_System__load_controllers__load_admin_controllers',
1006
+				array($addon, self::$_settings[ $addon_name ]['admin_callback'])
1007
+			);
1008
+		}
1009
+		return $addon;
1010
+	}
1011 1011
 
1012 1012
 
1013
-    /**
1014
-     *    load_pue_update - Update notifications
1015
-     *
1016
-     * @return void
1017
-     * @throws InvalidArgumentException
1018
-     * @throws InvalidDataTypeException
1019
-     * @throws InvalidInterfaceException
1020
-     */
1021
-    public static function load_pue_update()
1022
-    {
1023
-        // load PUE client
1024
-        require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php';
1025
-        // cycle thru settings
1026
-        foreach (self::$_settings as $settings) {
1027
-            if (! empty($settings['pue_options'])) {
1028
-                // initiate the class and start the plugin update engine!
1029
-                new PluginUpdateEngineChecker(
1030
-                    // host file URL
1031
-                    'https://eventespresso.com',
1032
-                    // plugin slug(s)
1033
-                    array(
1034
-                        'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1035
-                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1036
-                    ),
1037
-                    // options
1038
-                    array(
1039
-                        'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
1040
-                        'lang_domain'       => 'event_espresso',
1041
-                        'checkPeriod'       => $settings['pue_options']['checkPeriod'],
1042
-                        'option_key'        => 'site_license_key',
1043
-                        'options_page_slug' => 'event_espresso',
1044
-                        'plugin_basename'   => $settings['pue_options']['plugin_basename'],
1045
-                        // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
1046
-                        'use_wp_update'     => $settings['pue_options']['use_wp_update'],
1047
-                    )
1048
-                );
1049
-            }
1050
-        }
1051
-    }
1013
+	/**
1014
+	 *    load_pue_update - Update notifications
1015
+	 *
1016
+	 * @return void
1017
+	 * @throws InvalidArgumentException
1018
+	 * @throws InvalidDataTypeException
1019
+	 * @throws InvalidInterfaceException
1020
+	 */
1021
+	public static function load_pue_update()
1022
+	{
1023
+		// load PUE client
1024
+		require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php';
1025
+		// cycle thru settings
1026
+		foreach (self::$_settings as $settings) {
1027
+			if (! empty($settings['pue_options'])) {
1028
+				// initiate the class and start the plugin update engine!
1029
+				new PluginUpdateEngineChecker(
1030
+					// host file URL
1031
+					'https://eventespresso.com',
1032
+					// plugin slug(s)
1033
+					array(
1034
+						'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1035
+						'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1036
+					),
1037
+					// options
1038
+					array(
1039
+						'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
1040
+						'lang_domain'       => 'event_espresso',
1041
+						'checkPeriod'       => $settings['pue_options']['checkPeriod'],
1042
+						'option_key'        => 'site_license_key',
1043
+						'options_page_slug' => 'event_espresso',
1044
+						'plugin_basename'   => $settings['pue_options']['plugin_basename'],
1045
+						// if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
1046
+						'use_wp_update'     => $settings['pue_options']['use_wp_update'],
1047
+					)
1048
+				);
1049
+			}
1050
+		}
1051
+	}
1052 1052
 
1053 1053
 
1054
-    /**
1055
-     * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
1056
-     *
1057
-     * @since 4.4.0
1058
-     * @return void
1059
-     * @throws EE_Error
1060
-     */
1061
-    public static function register_message_types()
1062
-    {
1063
-        foreach (self::$_settings as $addon_name => $settings) {
1064
-            if (! empty($settings['message_types'])) {
1065
-                foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1066
-                    EE_Register_Message_Type::register($message_type, $message_type_settings);
1067
-                }
1068
-            }
1069
-        }
1070
-    }
1054
+	/**
1055
+	 * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
1056
+	 *
1057
+	 * @since 4.4.0
1058
+	 * @return void
1059
+	 * @throws EE_Error
1060
+	 */
1061
+	public static function register_message_types()
1062
+	{
1063
+		foreach (self::$_settings as $addon_name => $settings) {
1064
+			if (! empty($settings['message_types'])) {
1065
+				foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1066
+					EE_Register_Message_Type::register($message_type, $message_type_settings);
1067
+				}
1068
+			}
1069
+		}
1070
+	}
1071 1071
 
1072 1072
 
1073
-    /**
1074
-     * This deregisters an addon that was previously registered with a specific addon_name.
1075
-     *
1076
-     * @since    4.3.0
1077
-     * @param string $addon_name the name for the addon that was previously registered
1078
-     * @throws DomainException
1079
-     * @throws EE_Error
1080
-     * @throws InvalidArgumentException
1081
-     * @throws InvalidDataTypeException
1082
-     * @throws InvalidInterfaceException
1083
-     */
1084
-    public static function deregister($addon_name = null)
1085
-    {
1086
-        if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1087
-            try {
1088
-                do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1089
-                $class_name = self::$_settings[ $addon_name ]['class_name'];
1090
-                if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1091
-                    // setup DMS
1092
-                    EE_Register_Data_Migration_Scripts::deregister($addon_name);
1093
-                }
1094
-                if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1095
-                    // register admin page
1096
-                    EE_Register_Admin_Page::deregister($addon_name);
1097
-                }
1098
-                if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1099
-                    // add to list of modules to be registered
1100
-                    EE_Register_Module::deregister($addon_name);
1101
-                }
1102
-                if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1103
-                    || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1104
-                ) {
1105
-                    // add to list of shortcodes to be registered
1106
-                    EE_Register_Shortcode::deregister($addon_name);
1107
-                }
1108
-                if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1109
-                    // if config_class present let's register config.
1110
-                    EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1111
-                }
1112
-                if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1113
-                    // add to list of widgets to be registered
1114
-                    EE_Register_Widget::deregister($addon_name);
1115
-                }
1116
-                if (! empty(self::$_settings[ $addon_name ]['model_paths'])
1117
-                    || ! empty(self::$_settings[ $addon_name ]['class_paths'])
1118
-                ) {
1119
-                    // add to list of shortcodes to be registered
1120
-                    EE_Register_Model::deregister($addon_name);
1121
-                }
1122
-                if (! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1123
-                    || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1124
-                ) {
1125
-                    // add to list of shortcodes to be registered
1126
-                    EE_Register_Model_Extensions::deregister($addon_name);
1127
-                }
1128
-                if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1129
-                    foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1130
-                        EE_Register_Message_Type::deregister($message_type);
1131
-                    }
1132
-                }
1133
-                // deregister capabilities for addon
1134
-                if (! empty(self::$_settings[ $addon_name ]['capabilities'])
1135
-                    || ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1136
-                ) {
1137
-                    EE_Register_Capabilities::deregister($addon_name);
1138
-                }
1139
-                // deregister custom_post_types for addon
1140
-                if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1141
-                    EE_Register_CPT::deregister($addon_name);
1142
-                }
1143
-                if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1144
-                    EE_Register_Payment_Method::deregister($addon_name);
1145
-                }
1146
-                $addon = EE_Registry::instance()->getAddon($class_name);
1147
-                if ($addon instanceof EE_Addon) {
1148
-                    remove_action(
1149
-                        'deactivate_' . $addon->get_main_plugin_file_basename(),
1150
-                        array($addon, 'deactivation')
1151
-                    );
1152
-                    remove_action(
1153
-                        'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1154
-                        array($addon, 'initialize_db_if_no_migrations_required')
1155
-                    );
1156
-                    // remove `after_registration` call
1157
-                    remove_action(
1158
-                        'AHEE__EE_System__load_espresso_addons__complete',
1159
-                        array($addon, 'after_registration'),
1160
-                        999
1161
-                    );
1162
-                }
1163
-                EE_Registry::instance()->removeAddon($class_name);
1164
-            } catch (OutOfBoundsException $addon_not_yet_registered_exception) {
1165
-                // the add-on was not yet registered in the registry,
1166
-                // so RegistryContainer::__get() throws this exception.
1167
-                // also no need to worry about this or log it,
1168
-                // it's ok to deregister an add-on before its registered in the registry
1169
-            } catch (Exception $e) {
1170
-                new ExceptionLogger($e);
1171
-            }
1172
-            unset(self::$_settings[ $addon_name ]);
1173
-            do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1174
-        }
1175
-    }
1073
+	/**
1074
+	 * This deregisters an addon that was previously registered with a specific addon_name.
1075
+	 *
1076
+	 * @since    4.3.0
1077
+	 * @param string $addon_name the name for the addon that was previously registered
1078
+	 * @throws DomainException
1079
+	 * @throws EE_Error
1080
+	 * @throws InvalidArgumentException
1081
+	 * @throws InvalidDataTypeException
1082
+	 * @throws InvalidInterfaceException
1083
+	 */
1084
+	public static function deregister($addon_name = null)
1085
+	{
1086
+		if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1087
+			try {
1088
+				do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1089
+				$class_name = self::$_settings[ $addon_name ]['class_name'];
1090
+				if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1091
+					// setup DMS
1092
+					EE_Register_Data_Migration_Scripts::deregister($addon_name);
1093
+				}
1094
+				if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1095
+					// register admin page
1096
+					EE_Register_Admin_Page::deregister($addon_name);
1097
+				}
1098
+				if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1099
+					// add to list of modules to be registered
1100
+					EE_Register_Module::deregister($addon_name);
1101
+				}
1102
+				if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1103
+					|| ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1104
+				) {
1105
+					// add to list of shortcodes to be registered
1106
+					EE_Register_Shortcode::deregister($addon_name);
1107
+				}
1108
+				if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1109
+					// if config_class present let's register config.
1110
+					EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1111
+				}
1112
+				if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1113
+					// add to list of widgets to be registered
1114
+					EE_Register_Widget::deregister($addon_name);
1115
+				}
1116
+				if (! empty(self::$_settings[ $addon_name ]['model_paths'])
1117
+					|| ! empty(self::$_settings[ $addon_name ]['class_paths'])
1118
+				) {
1119
+					// add to list of shortcodes to be registered
1120
+					EE_Register_Model::deregister($addon_name);
1121
+				}
1122
+				if (! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1123
+					|| ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1124
+				) {
1125
+					// add to list of shortcodes to be registered
1126
+					EE_Register_Model_Extensions::deregister($addon_name);
1127
+				}
1128
+				if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1129
+					foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1130
+						EE_Register_Message_Type::deregister($message_type);
1131
+					}
1132
+				}
1133
+				// deregister capabilities for addon
1134
+				if (! empty(self::$_settings[ $addon_name ]['capabilities'])
1135
+					|| ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1136
+				) {
1137
+					EE_Register_Capabilities::deregister($addon_name);
1138
+				}
1139
+				// deregister custom_post_types for addon
1140
+				if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1141
+					EE_Register_CPT::deregister($addon_name);
1142
+				}
1143
+				if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1144
+					EE_Register_Payment_Method::deregister($addon_name);
1145
+				}
1146
+				$addon = EE_Registry::instance()->getAddon($class_name);
1147
+				if ($addon instanceof EE_Addon) {
1148
+					remove_action(
1149
+						'deactivate_' . $addon->get_main_plugin_file_basename(),
1150
+						array($addon, 'deactivation')
1151
+					);
1152
+					remove_action(
1153
+						'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1154
+						array($addon, 'initialize_db_if_no_migrations_required')
1155
+					);
1156
+					// remove `after_registration` call
1157
+					remove_action(
1158
+						'AHEE__EE_System__load_espresso_addons__complete',
1159
+						array($addon, 'after_registration'),
1160
+						999
1161
+					);
1162
+				}
1163
+				EE_Registry::instance()->removeAddon($class_name);
1164
+			} catch (OutOfBoundsException $addon_not_yet_registered_exception) {
1165
+				// the add-on was not yet registered in the registry,
1166
+				// so RegistryContainer::__get() throws this exception.
1167
+				// also no need to worry about this or log it,
1168
+				// it's ok to deregister an add-on before its registered in the registry
1169
+			} catch (Exception $e) {
1170
+				new ExceptionLogger($e);
1171
+			}
1172
+			unset(self::$_settings[ $addon_name ]);
1173
+			do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1174
+		}
1175
+	}
1176 1176
 }
Please login to merge, or discard this patch.
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
         // offsets:    0 . 1 . 2 . 3 . 4
70 70
         $version_parts = explode('.', $min_core_version);
71 71
         // check they specified the micro version (after 2nd period)
72
-        if (! isset($version_parts[2])) {
72
+        if ( ! isset($version_parts[2])) {
73 73
             $version_parts[2] = '0';
74 74
         }
75 75
         // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
76 76
         // soon we can assume that's 'rc', but this current version is 'alpha'
77
-        if (! isset($version_parts[3])) {
77
+        if ( ! isset($version_parts[3])) {
78 78
             $version_parts[3] = 'dev';
79 79
         }
80
-        if (! isset($version_parts[4])) {
80
+        if ( ! isset($version_parts[4])) {
81 81
             $version_parts[4] = '000';
82 82
         }
83 83
         return implode('.', $version_parts);
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
         // setup PUE
256 256
         EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
257 257
         // does this addon work with this version of core or WordPress ?
258
-        if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
258
+        if ( ! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
259 259
             return;
260 260
         }
261 261
         // register namespaces
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
                 )
314 314
             );
315 315
         }
316
-        if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
316
+        if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
317 317
             throw new EE_Error(
318 318
                 sprintf(
319 319
                     __(
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
             );
326 326
         }
327 327
         // check that addon has not already been registered with that name
328
-        if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
328
+        if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) {
329 329
             throw new EE_Error(
330 330
                 sprintf(
331 331
                     __(
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
         // check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
358 358
         return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
359 359
             ? $class_name
360
-            : 'EE_' . $class_name;
360
+            : 'EE_'.$class_name;
361 361
     }
362 362
 
363 363
 
@@ -521,9 +521,9 @@  discard block
 block discarded – undo
521 521
         global $wp_version;
522 522
         $incompatibility_message = '';
523 523
         // check whether this addon version is compatible with EE core
524
-        if (isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
524
+        if (isset(EE_Register_Addon::$_incompatible_addons[$addon_name])
525 525
             && ! self::_meets_min_core_version_requirement(
526
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
526
+                EE_Register_Addon::$_incompatible_addons[$addon_name],
527 527
                 $addon_settings['version']
528 528
             )
529 529
         ) {
@@ -534,11 +534,11 @@  discard block
 block discarded – undo
534 534
                 ),
535 535
                 $addon_name,
536 536
                 '<br />',
537
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
537
+                EE_Register_Addon::$_incompatible_addons[$addon_name],
538 538
                 '<span style="font-weight: bold; color: #D54E21;">',
539 539
                 '</span><br />'
540 540
             );
541
-        } elseif (! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
541
+        } elseif ( ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
542 542
         ) {
543 543
             $incompatibility_message = sprintf(
544 544
                 __(
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
                 '</span><br />'
566 566
             );
567 567
         }
568
-        if (! empty($incompatibility_message)) {
568
+        if ( ! empty($incompatibility_message)) {
569 569
             // remove 'activate' from the REQUEST
570 570
             // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
571 571
             unset($_GET['activate'], $_REQUEST['activate']);
@@ -593,11 +593,11 @@  discard block
 block discarded – undo
593 593
      */
594 594
     private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
595 595
     {
596
-        if (! empty($setup_args['pue_options'])) {
597
-            self::$_settings[ $addon_name ]['pue_options'] = array(
596
+        if ( ! empty($setup_args['pue_options'])) {
597
+            self::$_settings[$addon_name]['pue_options'] = array(
598 598
                 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
599 599
                     ? (string) $setup_args['pue_options']['pue_plugin_slug']
600
-                    : 'espresso_' . strtolower($class_name),
600
+                    : 'espresso_'.strtolower($class_name),
601 601
                 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
602 602
                     ? (string) $setup_args['pue_options']['plugin_basename']
603 603
                     : plugin_basename($setup_args['main_file_path']),
@@ -655,12 +655,12 @@  discard block
 block discarded – undo
655 655
             // (as the newly-activated addon wasn't around the first time addons were registered).
656 656
             // Note: the presence of pue_options in the addon registration options will initialize the $_settings
657 657
             // property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
658
-            if (! isset(self::$_settings[ $addon_name ])
659
-                || (isset(self::$_settings[ $addon_name ])
660
-                    && ! isset(self::$_settings[ $addon_name ]['class_name'])
658
+            if ( ! isset(self::$_settings[$addon_name])
659
+                || (isset(self::$_settings[$addon_name])
660
+                    && ! isset(self::$_settings[$addon_name]['class_name'])
661 661
                 )
662 662
             ) {
663
-                self::$_settings[ $addon_name ] = $addon_settings;
663
+                self::$_settings[$addon_name] = $addon_settings;
664 664
                 $addon = self::_load_and_init_addon_class($addon_name);
665 665
                 $addon->set_activation_indicator_option();
666 666
                 // dont bother setting up the rest of the addon.
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
             return true;
670 670
         }
671 671
         // make sure this was called in the right place!
672
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
672
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons')
673 673
             || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
674 674
         ) {
675 675
             EE_Error::doing_it_wrong(
@@ -685,10 +685,10 @@  discard block
 block discarded – undo
685 685
             );
686 686
         }
687 687
         // make sure addon settings are set correctly without overwriting anything existing
688
-        if (isset(self::$_settings[ $addon_name ])) {
689
-            self::$_settings[ $addon_name ] += $addon_settings;
688
+        if (isset(self::$_settings[$addon_name])) {
689
+            self::$_settings[$addon_name] += $addon_settings;
690 690
         } else {
691
-            self::$_settings[ $addon_name ] = $addon_settings;
691
+            self::$_settings[$addon_name] = $addon_settings;
692 692
         }
693 693
         return false;
694 694
     }
@@ -701,13 +701,13 @@  discard block
 block discarded – undo
701 701
      */
702 702
     private static function _setup_autoloaders($addon_name)
703 703
     {
704
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
704
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
705 705
             // setup autoloader for single file
706
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
706
+            EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
707 707
         }
708 708
         // setup autoloaders for folders
709
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
710
-            foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
709
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
710
+            foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
711 711
                 EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
712 712
             }
713 713
         }
@@ -724,26 +724,26 @@  discard block
 block discarded – undo
724 724
     private static function _register_models_and_extensions($addon_name)
725 725
     {
726 726
         // register new models
727
-        if (! empty(self::$_settings[ $addon_name ]['model_paths'])
728
-            || ! empty(self::$_settings[ $addon_name ]['class_paths'])
727
+        if ( ! empty(self::$_settings[$addon_name]['model_paths'])
728
+            || ! empty(self::$_settings[$addon_name]['class_paths'])
729 729
         ) {
730 730
             EE_Register_Model::register(
731 731
                 $addon_name,
732 732
                 array(
733
-                    'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
734
-                    'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
733
+                    'model_paths' => self::$_settings[$addon_name]['model_paths'],
734
+                    'class_paths' => self::$_settings[$addon_name]['class_paths'],
735 735
                 )
736 736
             );
737 737
         }
738 738
         // register model extensions
739
-        if (! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
740
-            || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
739
+        if ( ! empty(self::$_settings[$addon_name]['model_extension_paths'])
740
+            || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
741 741
         ) {
742 742
             EE_Register_Model_Extensions::register(
743 743
                 $addon_name,
744 744
                 array(
745
-                    'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
746
-                    'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
745
+                    'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'],
746
+                    'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'],
747 747
                 )
748 748
             );
749 749
         }
@@ -758,10 +758,10 @@  discard block
 block discarded – undo
758 758
     private static function _register_data_migration_scripts($addon_name)
759 759
     {
760 760
         // setup DMS
761
-        if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
761
+        if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
762 762
             EE_Register_Data_Migration_Scripts::register(
763 763
                 $addon_name,
764
-                array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
764
+                array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])
765 765
             );
766 766
         }
767 767
     }
@@ -775,12 +775,12 @@  discard block
 block discarded – undo
775 775
     private static function _register_config($addon_name)
776 776
     {
777 777
         // if config_class is present let's register config.
778
-        if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
778
+        if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
779 779
             EE_Register_Config::register(
780
-                self::$_settings[ $addon_name ]['config_class'],
780
+                self::$_settings[$addon_name]['config_class'],
781 781
                 array(
782
-                    'config_section' => self::$_settings[ $addon_name ]['config_section'],
783
-                    'config_name'    => self::$_settings[ $addon_name ]['config_name'],
782
+                    'config_section' => self::$_settings[$addon_name]['config_section'],
783
+                    'config_name'    => self::$_settings[$addon_name]['config_name'],
784 784
                 )
785 785
             );
786 786
         }
@@ -794,10 +794,10 @@  discard block
 block discarded – undo
794 794
      */
795 795
     private static function _register_admin_pages($addon_name)
796 796
     {
797
-        if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
797
+        if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
798 798
             EE_Register_Admin_Page::register(
799 799
                 $addon_name,
800
-                array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
800
+                array('page_path' => self::$_settings[$addon_name]['admin_path'])
801 801
             );
802 802
         }
803 803
     }
@@ -810,10 +810,10 @@  discard block
 block discarded – undo
810 810
      */
811 811
     private static function _register_modules($addon_name)
812 812
     {
813
-        if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
813
+        if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
814 814
             EE_Register_Module::register(
815 815
                 $addon_name,
816
-                array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
816
+                array('module_paths' => self::$_settings[$addon_name]['module_paths'])
817 817
             );
818 818
         }
819 819
     }
@@ -826,17 +826,17 @@  discard block
 block discarded – undo
826 826
      */
827 827
     private static function _register_shortcodes($addon_name)
828 828
     {
829
-        if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
830
-            || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
829
+        if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])
830
+            || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
831 831
         ) {
832 832
             EE_Register_Shortcode::register(
833 833
                 $addon_name,
834 834
                 array(
835
-                    'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
836
-                        ? self::$_settings[ $addon_name ]['shortcode_paths']
835
+                    'shortcode_paths' => isset(self::$_settings[$addon_name]['shortcode_paths'])
836
+                        ? self::$_settings[$addon_name]['shortcode_paths']
837 837
                         : array(),
838
-                    'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
839
-                        ? self::$_settings[ $addon_name ]['shortcode_fqcns']
838
+                    'shortcode_fqcns' => isset(self::$_settings[$addon_name]['shortcode_fqcns'])
839
+                        ? self::$_settings[$addon_name]['shortcode_fqcns']
840 840
                         : array(),
841 841
                 )
842 842
             );
@@ -851,10 +851,10 @@  discard block
 block discarded – undo
851 851
      */
852 852
     private static function _register_widgets($addon_name)
853 853
     {
854
-        if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
854
+        if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
855 855
             EE_Register_Widget::register(
856 856
                 $addon_name,
857
-                array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
857
+                array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])
858 858
             );
859 859
         }
860 860
     }
@@ -867,12 +867,12 @@  discard block
 block discarded – undo
867 867
      */
868 868
     private static function _register_capabilities($addon_name)
869 869
     {
870
-        if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
870
+        if ( ! empty(self::$_settings[$addon_name]['capabilities'])) {
871 871
             EE_Register_Capabilities::register(
872 872
                 $addon_name,
873 873
                 array(
874
-                    'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
875
-                    'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
874
+                    'capabilities'    => self::$_settings[$addon_name]['capabilities'],
875
+                    'capability_maps' => self::$_settings[$addon_name]['capability_maps'],
876 876
                 )
877 877
             );
878 878
         }
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
      */
887 887
     private static function _register_message_types($addon_name)
888 888
     {
889
-        if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
889
+        if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
890 890
             add_action(
891 891
                 'EE_Brewing_Regular___messages_caf',
892 892
                 array('EE_Register_Addon', 'register_message_types')
@@ -902,15 +902,15 @@  discard block
 block discarded – undo
902 902
      */
903 903
     private static function _register_custom_post_types($addon_name)
904 904
     {
905
-        if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])
906
-            || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
905
+        if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])
906
+            || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])
907 907
         ) {
908 908
             EE_Register_CPT::register(
909 909
                 $addon_name,
910 910
                 array(
911
-                    'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
912
-                    'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
913
-                    'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
911
+                    'cpts'          => self::$_settings[$addon_name]['custom_post_types'],
912
+                    'cts'           => self::$_settings[$addon_name]['custom_taxonomies'],
913
+                    'default_terms' => self::$_settings[$addon_name]['default_terms'],
914 914
                 )
915 915
             );
916 916
         }
@@ -928,10 +928,10 @@  discard block
 block discarded – undo
928 928
      */
929 929
     private static function _register_payment_methods($addon_name)
930 930
     {
931
-        if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
931
+        if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
932 932
             EE_Register_Payment_Method::register(
933 933
                 $addon_name,
934
-                array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
934
+                array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])
935 935
             );
936 936
         }
937 937
     }
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
     {
953 953
         $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader();
954 954
         $addon = $loader->getShared(
955
-            self::$_settings[ $addon_name ]['class_name'],
955
+            self::$_settings[$addon_name]['class_name'],
956 956
             array('EE_Registry::create(addon)' => true)
957 957
         );
958 958
         // setter inject dep map if required
@@ -964,19 +964,19 @@  discard block
 block discarded – undo
964 964
             && $addon->domain() === null
965 965
         ) {
966 966
             // using supplied Domain object
967
-            $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
968
-                ? self::$_settings[ $addon_name ]['domain']
967
+            $domain = self::$_settings[$addon_name]['domain'] instanceof DomainInterface
968
+                ? self::$_settings[$addon_name]['domain']
969 969
                 : null;
970 970
             // or construct one using Domain FQCN
971
-            if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
971
+            if ($domain === null && self::$_settings[$addon_name]['domain_fqcn'] !== '') {
972 972
                 $domain = $loader->getShared(
973
-                    self::$_settings[ $addon_name ]['domain_fqcn'],
973
+                    self::$_settings[$addon_name]['domain_fqcn'],
974 974
                     array(
975 975
                         new EventEspresso\core\domain\values\FilePath(
976
-                            self::$_settings[ $addon_name ]['main_file_path']
976
+                            self::$_settings[$addon_name]['main_file_path']
977 977
                         ),
978 978
                         EventEspresso\core\domain\values\Version::fromString(
979
-                            self::$_settings[ $addon_name ]['version']
979
+                            self::$_settings[$addon_name]['version']
980 980
                         ),
981 981
                     )
982 982
                 );
@@ -986,24 +986,24 @@  discard block
 block discarded – undo
986 986
             }
987 987
         }
988 988
         $addon->set_name($addon_name);
989
-        $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
990
-        $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
991
-        $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
992
-        $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
993
-        $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
994
-        $addon->set_version(self::$_settings[ $addon_name ]['version']);
995
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
996
-        $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
997
-        $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
998
-        $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
989
+        $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']);
990
+        $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']);
991
+        $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']);
992
+        $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']);
993
+        $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']);
994
+        $addon->set_version(self::$_settings[$addon_name]['version']);
995
+        $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version']));
996
+        $addon->set_config_section(self::$_settings[$addon_name]['config_section']);
997
+        $addon->set_config_class(self::$_settings[$addon_name]['config_class']);
998
+        $addon->set_config_name(self::$_settings[$addon_name]['config_name']);
999 999
         // unfortunately this can't be hooked in upon construction, because we don't have
1000 1000
         // the plugin mainfile's path upon construction.
1001 1001
         register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
1002 1002
         // call any additional admin_callback functions during load_admin_controller hook
1003
-        if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1003
+        if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) {
1004 1004
             add_action(
1005 1005
                 'AHEE__EE_System__load_controllers__load_admin_controllers',
1006
-                array($addon, self::$_settings[ $addon_name ]['admin_callback'])
1006
+                array($addon, self::$_settings[$addon_name]['admin_callback'])
1007 1007
             );
1008 1008
         }
1009 1009
         return $addon;
@@ -1021,10 +1021,10 @@  discard block
 block discarded – undo
1021 1021
     public static function load_pue_update()
1022 1022
     {
1023 1023
         // load PUE client
1024
-        require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php';
1024
+        require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php';
1025 1025
         // cycle thru settings
1026 1026
         foreach (self::$_settings as $settings) {
1027
-            if (! empty($settings['pue_options'])) {
1027
+            if ( ! empty($settings['pue_options'])) {
1028 1028
                 // initiate the class and start the plugin update engine!
1029 1029
                 new PluginUpdateEngineChecker(
1030 1030
                     // host file URL
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
                     // plugin slug(s)
1033 1033
                     array(
1034 1034
                         'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1035
-                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1035
+                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'),
1036 1036
                     ),
1037 1037
                     // options
1038 1038
                     array(
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
     public static function register_message_types()
1062 1062
     {
1063 1063
         foreach (self::$_settings as $addon_name => $settings) {
1064
-            if (! empty($settings['message_types'])) {
1064
+            if ( ! empty($settings['message_types'])) {
1065 1065
                 foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1066 1066
                     EE_Register_Message_Type::register($message_type, $message_type_settings);
1067 1067
                 }
@@ -1083,70 +1083,70 @@  discard block
 block discarded – undo
1083 1083
      */
1084 1084
     public static function deregister($addon_name = null)
1085 1085
     {
1086
-        if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1086
+        if (isset(self::$_settings[$addon_name]['class_name'])) {
1087 1087
             try {
1088 1088
                 do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1089
-                $class_name = self::$_settings[ $addon_name ]['class_name'];
1090
-                if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1089
+                $class_name = self::$_settings[$addon_name]['class_name'];
1090
+                if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
1091 1091
                     // setup DMS
1092 1092
                     EE_Register_Data_Migration_Scripts::deregister($addon_name);
1093 1093
                 }
1094
-                if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1094
+                if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
1095 1095
                     // register admin page
1096 1096
                     EE_Register_Admin_Page::deregister($addon_name);
1097 1097
                 }
1098
-                if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1098
+                if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
1099 1099
                     // add to list of modules to be registered
1100 1100
                     EE_Register_Module::deregister($addon_name);
1101 1101
                 }
1102
-                if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1103
-                    || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1102
+                if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])
1103
+                    || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
1104 1104
                 ) {
1105 1105
                     // add to list of shortcodes to be registered
1106 1106
                     EE_Register_Shortcode::deregister($addon_name);
1107 1107
                 }
1108
-                if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1108
+                if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
1109 1109
                     // if config_class present let's register config.
1110
-                    EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1110
+                    EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1111 1111
                 }
1112
-                if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1112
+                if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
1113 1113
                     // add to list of widgets to be registered
1114 1114
                     EE_Register_Widget::deregister($addon_name);
1115 1115
                 }
1116
-                if (! empty(self::$_settings[ $addon_name ]['model_paths'])
1117
-                    || ! empty(self::$_settings[ $addon_name ]['class_paths'])
1116
+                if ( ! empty(self::$_settings[$addon_name]['model_paths'])
1117
+                    || ! empty(self::$_settings[$addon_name]['class_paths'])
1118 1118
                 ) {
1119 1119
                     // add to list of shortcodes to be registered
1120 1120
                     EE_Register_Model::deregister($addon_name);
1121 1121
                 }
1122
-                if (! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1123
-                    || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1122
+                if ( ! empty(self::$_settings[$addon_name]['model_extension_paths'])
1123
+                    || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
1124 1124
                 ) {
1125 1125
                     // add to list of shortcodes to be registered
1126 1126
                     EE_Register_Model_Extensions::deregister($addon_name);
1127 1127
                 }
1128
-                if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1129
-                    foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1128
+                if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
1129
+                    foreach ((array) self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
1130 1130
                         EE_Register_Message_Type::deregister($message_type);
1131 1131
                     }
1132 1132
                 }
1133 1133
                 // deregister capabilities for addon
1134
-                if (! empty(self::$_settings[ $addon_name ]['capabilities'])
1135
-                    || ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1134
+                if ( ! empty(self::$_settings[$addon_name]['capabilities'])
1135
+                    || ! empty(self::$_settings[$addon_name]['capability_maps'])
1136 1136
                 ) {
1137 1137
                     EE_Register_Capabilities::deregister($addon_name);
1138 1138
                 }
1139 1139
                 // deregister custom_post_types for addon
1140
-                if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1140
+                if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1141 1141
                     EE_Register_CPT::deregister($addon_name);
1142 1142
                 }
1143
-                if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1143
+                if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1144 1144
                     EE_Register_Payment_Method::deregister($addon_name);
1145 1145
                 }
1146 1146
                 $addon = EE_Registry::instance()->getAddon($class_name);
1147 1147
                 if ($addon instanceof EE_Addon) {
1148 1148
                     remove_action(
1149
-                        'deactivate_' . $addon->get_main_plugin_file_basename(),
1149
+                        'deactivate_'.$addon->get_main_plugin_file_basename(),
1150 1150
                         array($addon, 'deactivation')
1151 1151
                     );
1152 1152
                     remove_action(
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
             } catch (Exception $e) {
1170 1170
                 new ExceptionLogger($e);
1171 1171
             }
1172
-            unset(self::$_settings[ $addon_name ]);
1172
+            unset(self::$_settings[$addon_name]);
1173 1173
             do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1174 1174
         }
1175 1175
     }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    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
-                    ); ?>
52
+					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 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            '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.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'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.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.62.rc.055');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.62.rc.055');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.