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