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