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