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