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