Completed
Branch rest-authorization (c7240a)
by
unknown
13:01 queued 10:45
created
core/libraries/plugin_api/EE_Register_Messages_Template_Pack.lib.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -70,13 +70,13 @@  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
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         }
100 100
 
101 101
         if (self::_verify_class_not_exist($setup_args['classname'])) {
102
-            self::$_registry[ $identifier ] = [
102
+            self::$_registry[$identifier] = [
103 103
                 'path'      => (string) $setup_args['path'],
104 104
                 'classname' => (string) $setup_args['classname'],
105 105
             ];
@@ -151,14 +151,14 @@  discard block
 block discarded – undo
151 151
     {
152 152
         foreach (self::$_registry as $args) {
153 153
             // verify class_exists
154
-            if (! class_exists($args['classname'])) {
155
-                require_once($args['path'] . '/' . $args['classname'] . '.class.php');
154
+            if ( ! class_exists($args['classname'])) {
155
+                require_once($args['path'].'/'.$args['classname'].'.class.php');
156 156
             }
157 157
 
158 158
             // check again!
159 159
             if (class_exists($args['classname'])) {
160 160
                 $template_pack                           = new $args['classname']();
161
-                $template_packs[ $template_pack->dbref ] = $template_pack;
161
+                $template_packs[$template_pack->dbref] = $template_pack;
162 162
             }
163 163
         }
164 164
 
@@ -208,6 +208,6 @@  discard block
 block discarded – undo
208 208
      */
209 209
     public static function deregister($identifier = '')
210 210
     {
211
-        unset(self::$_registry[ $identifier ]);
211
+        unset(self::$_registry[$identifier]);
212 212
     }
213 213
 }
Please login to merge, or discard this patch.
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -10,202 +10,202 @@
 block discarded – undo
10 10
  */
11 11
 class EE_Register_Messages_Template_Pack implements EEI_Plugin_API
12 12
 {
13
-    /**
14
-     * Holds values for registered template pack
15
-     *
16
-     * @since 4.5.0
17
-     *
18
-     * @var array
19
-     */
20
-    protected static $_registry = [];
21
-
22
-
23
-    /**
24
-     * Used to register a new template pack with the messages system.
25
-     *
26
-     * Template packs are primarily defined via class extending EE_Messages_Template_Pack and are typically used to
27
-     * change entire layouts for a set of message templates.  This method is used to register the new template pack and
28
-     * automatically have it loaded in the appropriate places.
29
-     *
30
-     * This registry also verifies that there isn't already a template pack registered with the same name and if there
31
-     * is then it will add an EE_Error notice.
32
-     *
33
-     * Note that this only handles registering the your Template Pack class with the message template pack system.
34
-     * However, there is also a naming schema you must follow for templates you are providing with your template pack.
35
-     *
36
-     * @param string $identifier The internal reference used to refer to this template pack.  Note, this is first come,
37
-     *                           first serve.  If there is already a template pack registered with this name then the
38
-     *                           registry will assign a unique reference for it so it can still be activated (but this
39
-     *                           makes it harder to deregister as it will be unique per load - so its best to try to
40
-     *                           make this a unique string!)
41
-     * @param array  $setup_args array {
42
-     *                           An array of required values for registering the template pack.
43
-     * @type string  $path       The path for the new template pack class.
44
-     * @type string  $classname  The name of the new Template Pack Class.
45
-     *                           }
46
-     *
47
-     * @return void
48
-     * @throws EE_Error
49
-     *
50
-     * @see    core/libraries/messages/defaults/default/* for all the example templates the default template pack
51
-     *         supports.
52
-     *
53
-     *
54
-     * @since  4.5.0
55
-     * @see    EE_Messages_Template_Pack_Default for an example class
56
-     */
57
-    public static function register($identifier = '', array $setup_args = [])
58
-    {
59
-
60
-        // check for required params
61
-        if (empty($identifier) || empty($setup_args['path']) || empty($setup_args['classname'])) {
62
-            throw new EE_Error(
63
-                esc_html__(
64
-                    '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. ',
65
-                    'event_espresso'
66
-                )
67
-            );
68
-        }
69
-
70
-        // make sure we don't register twice
71
-        if (isset(self::$_registry[ $identifier ])) {
72
-            return;
73
-        }
74
-
75
-        // check that incoming $identifier doesn't already exist. If it does then we'll create a unique reference for this template pack.
76
-        if (isset(self::$_registry[ $identifier ])) {
77
-            $identifier = uniqid() . '_' . $identifier;
78
-        }
79
-
80
-
81
-        // make sure this was called in the right place!
82
-        if (
83
-            ! did_action('EE_Brewing_Regular___messages_caf')
84
-            || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
85
-        ) {
86
-            EE_Error::doing_it_wrong(
87
-                __METHOD__,
88
-                sprintf(
89
-                    esc_html__(
90
-                        '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.',
91
-                        'event_espresso'
92
-                    ),
93
-                    $identifier
94
-                ),
95
-                '4.5.0'
96
-            );
97
-        }
98
-
99
-        if (self::_verify_class_not_exist($setup_args['classname'])) {
100
-            self::$_registry[ $identifier ] = [
101
-                'path'      => (string) $setup_args['path'],
102
-                'classname' => (string) $setup_args['classname'],
103
-            ];
104
-        }
105
-
106
-        // hook into the system
107
-        add_filter(
108
-            'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
109
-            ['EE_Register_Messages_Template_Pack', 'set_template_pack_path'],
110
-            10
111
-        );
112
-        add_filter(
113
-            'FHEE__EED_Messages__get_template_packs__template_packs',
114
-            ['EE_Register_Messages_Template_Pack', 'set_template_pack'],
115
-            10
116
-        );
117
-    }
118
-
119
-
120
-    /**
121
-     * Callback for the FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.  This adds this template packs path
122
-     * to the messages autoloader paths.
123
-     *
124
-     * @param array $paths Array of paths already registered with the messages autoloader
125
-     *
126
-     * @return array
127
-     * @since  4.5.0
128
-     *
129
-     */
130
-    public static function set_template_pack_path(array $paths)
131
-    {
132
-        foreach (self::$_registry as $args) {
133
-            $paths[] = $args['path'];
134
-        }
135
-        return $paths;
136
-    }
137
-
138
-
139
-    /**
140
-     * Callback for the FHEE__EED_Messages__get_template_packs__template_packs filter. This adds the instantiated,
141
-     * registered template pack to the template packs array when requested by client code.
142
-     *
143
-     * @param EE_Messages_Template_Pack[] $template_packs
144
-     * @return EE_Messages_Template_Pack[]
145
-     * @since 4.5.0
146
-     *
147
-     */
148
-    public static function set_template_pack(array $template_packs)
149
-    {
150
-        foreach (self::$_registry as $args) {
151
-            // verify class_exists
152
-            if (! class_exists($args['classname'])) {
153
-                require_once($args['path'] . '/' . $args['classname'] . '.class.php');
154
-            }
155
-
156
-            // check again!
157
-            if (class_exists($args['classname'])) {
158
-                $template_pack                           = new $args['classname']();
159
-                $template_packs[ $template_pack->dbref ] = $template_pack;
160
-            }
161
-        }
162
-
163
-        return $template_packs;
164
-    }
165
-
166
-
167
-    /**
168
-     * This verifies that the classes for each registered template pack are unique  names.
169
-     *
170
-     * @param string $classname The classname being checked
171
-     *
172
-     * @return bool
173
-     */
174
-    private static function _verify_class_not_exist($classname)
175
-    {
176
-        // loop through the existing registry and see if the classname is already present.
177
-        foreach (self::$_registry as $args) {
178
-            if ($args['classname'] == $classname) {
179
-                EE_Error::add_error(
180
-                    sprintf(
181
-                        esc_html__(
182
-                            '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.',
183
-                            'event_espresso'
184
-                        ),
185
-                        $classname
186
-                    ),
187
-                    __FILE__,
188
-                    __LINE__,
189
-                    __FUNCTION__
190
-                );
191
-                return false;
192
-            }
193
-        }
194
-        return true;
195
-    }
196
-
197
-
198
-    /**
199
-     * This deregisters a variation set that was previously registered with the given slug.
200
-     *
201
-     * @param string $identifier The name for the variation set that was previously registered.
202
-     *
203
-     * @return void
204
-     * @since 4.5.0
205
-     *
206
-     */
207
-    public static function deregister($identifier = '')
208
-    {
209
-        unset(self::$_registry[ $identifier ]);
210
-    }
13
+	/**
14
+	 * Holds values for registered template pack
15
+	 *
16
+	 * @since 4.5.0
17
+	 *
18
+	 * @var array
19
+	 */
20
+	protected static $_registry = [];
21
+
22
+
23
+	/**
24
+	 * Used to register a new template pack with the messages system.
25
+	 *
26
+	 * Template packs are primarily defined via class extending EE_Messages_Template_Pack and are typically used to
27
+	 * change entire layouts for a set of message templates.  This method is used to register the new template pack and
28
+	 * automatically have it loaded in the appropriate places.
29
+	 *
30
+	 * This registry also verifies that there isn't already a template pack registered with the same name and if there
31
+	 * is then it will add an EE_Error notice.
32
+	 *
33
+	 * Note that this only handles registering the your Template Pack class with the message template pack system.
34
+	 * However, there is also a naming schema you must follow for templates you are providing with your template pack.
35
+	 *
36
+	 * @param string $identifier The internal reference used to refer to this template pack.  Note, this is first come,
37
+	 *                           first serve.  If there is already a template pack registered with this name then the
38
+	 *                           registry will assign a unique reference for it so it can still be activated (but this
39
+	 *                           makes it harder to deregister as it will be unique per load - so its best to try to
40
+	 *                           make this a unique string!)
41
+	 * @param array  $setup_args array {
42
+	 *                           An array of required values for registering the template pack.
43
+	 * @type string  $path       The path for the new template pack class.
44
+	 * @type string  $classname  The name of the new Template Pack Class.
45
+	 *                           }
46
+	 *
47
+	 * @return void
48
+	 * @throws EE_Error
49
+	 *
50
+	 * @see    core/libraries/messages/defaults/default/* for all the example templates the default template pack
51
+	 *         supports.
52
+	 *
53
+	 *
54
+	 * @since  4.5.0
55
+	 * @see    EE_Messages_Template_Pack_Default for an example class
56
+	 */
57
+	public static function register($identifier = '', array $setup_args = [])
58
+	{
59
+
60
+		// check for required params
61
+		if (empty($identifier) || empty($setup_args['path']) || empty($setup_args['classname'])) {
62
+			throw new EE_Error(
63
+				esc_html__(
64
+					'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. ',
65
+					'event_espresso'
66
+				)
67
+			);
68
+		}
69
+
70
+		// make sure we don't register twice
71
+		if (isset(self::$_registry[ $identifier ])) {
72
+			return;
73
+		}
74
+
75
+		// check that incoming $identifier doesn't already exist. If it does then we'll create a unique reference for this template pack.
76
+		if (isset(self::$_registry[ $identifier ])) {
77
+			$identifier = uniqid() . '_' . $identifier;
78
+		}
79
+
80
+
81
+		// make sure this was called in the right place!
82
+		if (
83
+			! did_action('EE_Brewing_Regular___messages_caf')
84
+			|| did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
85
+		) {
86
+			EE_Error::doing_it_wrong(
87
+				__METHOD__,
88
+				sprintf(
89
+					esc_html__(
90
+						'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.',
91
+						'event_espresso'
92
+					),
93
+					$identifier
94
+				),
95
+				'4.5.0'
96
+			);
97
+		}
98
+
99
+		if (self::_verify_class_not_exist($setup_args['classname'])) {
100
+			self::$_registry[ $identifier ] = [
101
+				'path'      => (string) $setup_args['path'],
102
+				'classname' => (string) $setup_args['classname'],
103
+			];
104
+		}
105
+
106
+		// hook into the system
107
+		add_filter(
108
+			'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
109
+			['EE_Register_Messages_Template_Pack', 'set_template_pack_path'],
110
+			10
111
+		);
112
+		add_filter(
113
+			'FHEE__EED_Messages__get_template_packs__template_packs',
114
+			['EE_Register_Messages_Template_Pack', 'set_template_pack'],
115
+			10
116
+		);
117
+	}
118
+
119
+
120
+	/**
121
+	 * Callback for the FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.  This adds this template packs path
122
+	 * to the messages autoloader paths.
123
+	 *
124
+	 * @param array $paths Array of paths already registered with the messages autoloader
125
+	 *
126
+	 * @return array
127
+	 * @since  4.5.0
128
+	 *
129
+	 */
130
+	public static function set_template_pack_path(array $paths)
131
+	{
132
+		foreach (self::$_registry as $args) {
133
+			$paths[] = $args['path'];
134
+		}
135
+		return $paths;
136
+	}
137
+
138
+
139
+	/**
140
+	 * Callback for the FHEE__EED_Messages__get_template_packs__template_packs filter. This adds the instantiated,
141
+	 * registered template pack to the template packs array when requested by client code.
142
+	 *
143
+	 * @param EE_Messages_Template_Pack[] $template_packs
144
+	 * @return EE_Messages_Template_Pack[]
145
+	 * @since 4.5.0
146
+	 *
147
+	 */
148
+	public static function set_template_pack(array $template_packs)
149
+	{
150
+		foreach (self::$_registry as $args) {
151
+			// verify class_exists
152
+			if (! class_exists($args['classname'])) {
153
+				require_once($args['path'] . '/' . $args['classname'] . '.class.php');
154
+			}
155
+
156
+			// check again!
157
+			if (class_exists($args['classname'])) {
158
+				$template_pack                           = new $args['classname']();
159
+				$template_packs[ $template_pack->dbref ] = $template_pack;
160
+			}
161
+		}
162
+
163
+		return $template_packs;
164
+	}
165
+
166
+
167
+	/**
168
+	 * This verifies that the classes for each registered template pack are unique  names.
169
+	 *
170
+	 * @param string $classname The classname being checked
171
+	 *
172
+	 * @return bool
173
+	 */
174
+	private static function _verify_class_not_exist($classname)
175
+	{
176
+		// loop through the existing registry and see if the classname is already present.
177
+		foreach (self::$_registry as $args) {
178
+			if ($args['classname'] == $classname) {
179
+				EE_Error::add_error(
180
+					sprintf(
181
+						esc_html__(
182
+							'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.',
183
+							'event_espresso'
184
+						),
185
+						$classname
186
+					),
187
+					__FILE__,
188
+					__LINE__,
189
+					__FUNCTION__
190
+				);
191
+				return false;
192
+			}
193
+		}
194
+		return true;
195
+	}
196
+
197
+
198
+	/**
199
+	 * This deregisters a variation set that was previously registered with the given slug.
200
+	 *
201
+	 * @param string $identifier The name for the variation set that was previously registered.
202
+	 *
203
+	 * @return void
204
+	 * @since 4.5.0
205
+	 *
206
+	 */
207
+	public static function deregister($identifier = '')
208
+	{
209
+		unset(self::$_registry[ $identifier ]);
210
+	}
211 211
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Message_Type.lib.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         }
61 61
 
62 62
         // make sure we don't register twice
63
-        if (isset(self::$_ee_message_type_registry[ $identifier ])) {
63
+        if (isset(self::$_ee_message_type_registry[$identifier])) {
64 64
             return;
65 65
         }
66 66
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             );
83 83
         }
84 84
         // setup $__ee_message_type_registry array from incoming values.
85
-        self::$_ee_message_type_registry[ $identifier ] = [
85
+        self::$_ee_message_type_registry[$identifier] = [
86 86
             /**
87 87
              * The file name for the message type being registered.
88 88
              * Required.
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
      */
266 266
     public static function deregister($identifier = '')
267 267
     {
268
-        if (! empty(self::$_ee_message_type_registry[ $identifier ])) {
268
+        if ( ! empty(self::$_ee_message_type_registry[$identifier])) {
269 269
             // let's make sure that we remove any place this message type was made active
270 270
             /** @var EE_Message_Resource_Manager $Message_Resource_Manager */
271 271
             $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
             );
278 278
             $Message_Resource_Manager->deactivate_message_type($identifier, false);
279 279
         }
280
-        unset(self::$_ee_message_type_registry[ $identifier ]);
280
+        unset(self::$_ee_message_type_registry[$identifier]);
281 281
     }
282 282
 
283 283
 
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
      */
313 313
     public static function register_msgs_autoload_paths(array $paths)
314 314
     {
315
-        if (! empty(self::$_ee_message_type_registry)) {
315
+        if ( ! empty(self::$_ee_message_type_registry)) {
316 316
             foreach (self::$_ee_message_type_registry as $mt_reg) {
317 317
                 if (empty($mt_reg['autoloadpaths'])) {
318 318
                     continue;
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
                 continue;
402 402
             }
403 403
             foreach ($mt_reg['messengers_supporting_default_template_pack_with'] as $messenger_slug) {
404
-                $supports[ $messenger_slug ][] = $identifier;
404
+                $supports[$messenger_slug][] = $identifier;
405 405
             }
406 406
         }
407 407
         return $supports;
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
         $file_extension,
474 474
         EE_Messages_Template_Pack $template_pack
475 475
     ) {
476
-        if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
476
+        if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) {
477 477
             return $base_path_or_url;
478 478
         }
479 479
         foreach (self::$_ee_message_type_registry as $identifier => $mt_reg) {
Please login to merge, or discard this patch.
Indentation   +457 added lines, -457 removed lines patch added patch discarded remove patch
@@ -10,487 +10,487 @@
 block discarded – undo
10 10
  */
11 11
 class EE_Register_Message_Type implements EEI_Plugin_API
12 12
 {
13
-    /**
14
-     * Holds values for registered message types
15
-     *
16
-     * @var array
17
-     */
18
-    protected static $_ee_message_type_registry = [];
13
+	/**
14
+	 * Holds values for registered message types
15
+	 *
16
+	 * @var array
17
+	 */
18
+	protected static $_ee_message_type_registry = [];
19 19
 
20 20
 
21
-    /**
22
-     * Method for registering new message types in the EE_messages system.
23
-     * Note:  All message types must have the following files in order to work:
24
-     * Template files for default templates getting setup.
25
-     * See /core/libraries/messages/defaults/default/ for examples
26
-     * (note that template files match a specific naming schema).
27
-     * These templates will need to be registered with the default template pack.
28
-     * - EE_Messages_Validator extended class(es).  See /core/libraries/messages/validators/email/
29
-     *      for examples.  Note for any new message types, there will need to be a validator for each
30
-     *      messenger combo this message type can activate with.
31
-     * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new
32
-     *      message type and its properties.
33
-     *
34
-     * @param string $identifier    Whatever is defined for the $name property of
35
-     *                              the message type you are registering (eg.
36
-     *                              declined_registration). Required.
37
-     * @param array  $setup_args    An array of arguments provided for registering the message type.
38
-     * @throws EE_Error
39
-     *                              }
40
-     * @see      inline docs in the register method for what can be passed in as arguments.
41
-     * @since    4.3.0
42
-     */
43
-    public static function register($identifier = '', array $setup_args = [])
44
-    {
45
-        // required fields MUST be present, so let's make sure they are.
46
-        if (
47
-            ! isset($identifier)
48
-            || ! is_array($setup_args)
49
-            || empty($setup_args['mtfilename'])
50
-            || empty($setup_args['autoloadpaths'])
51
-        ) {
52
-            throw new EE_Error(
53
-                esc_html__(
54
-                    '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"',
55
-                    'event_espresso'
56
-                )
57
-            );
58
-        }
21
+	/**
22
+	 * Method for registering new message types in the EE_messages system.
23
+	 * Note:  All message types must have the following files in order to work:
24
+	 * Template files for default templates getting setup.
25
+	 * See /core/libraries/messages/defaults/default/ for examples
26
+	 * (note that template files match a specific naming schema).
27
+	 * These templates will need to be registered with the default template pack.
28
+	 * - EE_Messages_Validator extended class(es).  See /core/libraries/messages/validators/email/
29
+	 *      for examples.  Note for any new message types, there will need to be a validator for each
30
+	 *      messenger combo this message type can activate with.
31
+	 * - And of course the main EE_{Message_Type_Name}_message_type class that defines the new
32
+	 *      message type and its properties.
33
+	 *
34
+	 * @param string $identifier    Whatever is defined for the $name property of
35
+	 *                              the message type you are registering (eg.
36
+	 *                              declined_registration). Required.
37
+	 * @param array  $setup_args    An array of arguments provided for registering the message type.
38
+	 * @throws EE_Error
39
+	 *                              }
40
+	 * @see      inline docs in the register method for what can be passed in as arguments.
41
+	 * @since    4.3.0
42
+	 */
43
+	public static function register($identifier = '', array $setup_args = [])
44
+	{
45
+		// required fields MUST be present, so let's make sure they are.
46
+		if (
47
+			! isset($identifier)
48
+			|| ! is_array($setup_args)
49
+			|| empty($setup_args['mtfilename'])
50
+			|| empty($setup_args['autoloadpaths'])
51
+		) {
52
+			throw new EE_Error(
53
+				esc_html__(
54
+					'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"',
55
+					'event_espresso'
56
+				)
57
+			);
58
+		}
59 59
 
60
-        // make sure we don't register twice
61
-        if (isset(self::$_ee_message_type_registry[ $identifier ])) {
62
-            return;
63
-        }
60
+		// make sure we don't register twice
61
+		if (isset(self::$_ee_message_type_registry[ $identifier ])) {
62
+			return;
63
+		}
64 64
 
65
-        // make sure this was called in the right place!
66
-        if (
67
-            ! 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
-                    esc_html__(
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 (
163
-            false === has_filter(
164
-                'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
165
-                ['EE_Register_Message_Type', 'register_msgs_autoload_paths']
166
-            )
167
-        ) {
168
-            add_filter(
169
-                'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
170
-                ['EE_Register_Message_Type', 'register_msgs_autoload_paths'],
171
-                10
172
-            );
173
-            add_filter(
174
-                'FHEE__EE_messages__get_installed__messagetype_files',
175
-                ['EE_Register_Message_Type', 'register_messagetype_files'],
176
-                10,
177
-                1
178
-            );
179
-            add_filter(
180
-                'FHEE__EE_messenger__get_default_message_types__default_types',
181
-                ['EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'],
182
-                10,
183
-                2
184
-            );
185
-            add_filter(
186
-                'FHEE__EE_messenger__get_valid_message_types__valid_types',
187
-                ['EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'],
188
-                10,
189
-                2
190
-            );
191
-            // actions
192
-            add_action(
193
-                'AHEE__EE_Addon__initialize_default_data__begin',
194
-                ['EE_Register_Message_Type', 'set_defaults']
195
-            );
65
+		// make sure this was called in the right place!
66
+		if (
67
+			! 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
+					esc_html__(
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 (
163
+			false === has_filter(
164
+				'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
165
+				['EE_Register_Message_Type', 'register_msgs_autoload_paths']
166
+			)
167
+		) {
168
+			add_filter(
169
+				'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
170
+				['EE_Register_Message_Type', 'register_msgs_autoload_paths'],
171
+				10
172
+			);
173
+			add_filter(
174
+				'FHEE__EE_messages__get_installed__messagetype_files',
175
+				['EE_Register_Message_Type', 'register_messagetype_files'],
176
+				10,
177
+				1
178
+			);
179
+			add_filter(
180
+				'FHEE__EE_messenger__get_default_message_types__default_types',
181
+				['EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'],
182
+				10,
183
+				2
184
+			);
185
+			add_filter(
186
+				'FHEE__EE_messenger__get_valid_message_types__valid_types',
187
+				['EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'],
188
+				10,
189
+				2
190
+			);
191
+			// actions
192
+			add_action(
193
+				'AHEE__EE_Addon__initialize_default_data__begin',
194
+				['EE_Register_Message_Type', 'set_defaults']
195
+			);
196 196
 
197
-            // default template packs and variations related
198
-            add_filter(
199
-                'FHEE__EE_Messages_Template_Pack_Default__get_supports',
200
-                ['EE_Register_Message_Type', 'register_default_template_pack_supports']
201
-            );
202
-            add_filter(
203
-                'FHEE__EE_Template_Pack___get_specific_template__filtered_base_path',
204
-                ['EE_Register_Message_Type', 'register_base_template_path'],
205
-                10,
206
-                6
207
-            );
208
-            add_filter(
209
-                'FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url',
210
-                ['EE_Register_Message_Type', 'register_variation_base_path_or_url'],
211
-                10,
212
-                8
213
-            );
214
-            add_filter(
215
-                'FHEE__EE_Messages_Template_Pack__get_variation__base_path',
216
-                ['EE_Register_Message_Type', 'register_variation_base_path_or_url'],
217
-                10,
218
-                8
219
-            );
220
-        }
221
-    }
197
+			// default template packs and variations related
198
+			add_filter(
199
+				'FHEE__EE_Messages_Template_Pack_Default__get_supports',
200
+				['EE_Register_Message_Type', 'register_default_template_pack_supports']
201
+			);
202
+			add_filter(
203
+				'FHEE__EE_Template_Pack___get_specific_template__filtered_base_path',
204
+				['EE_Register_Message_Type', 'register_base_template_path'],
205
+				10,
206
+				6
207
+			);
208
+			add_filter(
209
+				'FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url',
210
+				['EE_Register_Message_Type', 'register_variation_base_path_or_url'],
211
+				10,
212
+				8
213
+			);
214
+			add_filter(
215
+				'FHEE__EE_Messages_Template_Pack__get_variation__base_path',
216
+				['EE_Register_Message_Type', 'register_variation_base_path_or_url'],
217
+				10,
218
+				8
219
+			);
220
+		}
221
+	}
222 222
 
223 223
 
224
-    /**
225
-     * This just ensures that when an addon registers a message type that on initial activation/reactivation the
226
-     * defaults the addon sets are taken care of.
227
-     *
228
-     * @throws EE_Error
229
-     * @throws ReflectionException
230
-     */
231
-    public static function set_defaults()
232
-    {
233
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
234
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
224
+	/**
225
+	 * This just ensures that when an addon registers a message type that on initial activation/reactivation the
226
+	 * defaults the addon sets are taken care of.
227
+	 *
228
+	 * @throws EE_Error
229
+	 * @throws ReflectionException
230
+	 */
231
+	public static function set_defaults()
232
+	{
233
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
234
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
235 235
 
236
-        // for any message types with force activation, let's ensure they are activated
237
-        foreach (self::$_ee_message_type_registry as $identifier => $settings) {
238
-            if ($settings['force_activation']) {
239
-                foreach ($settings['messengers_to_activate_with'] as $messenger) {
240
-                    // DO not force activation if this message type has already been activated in the system
241
-                    if (
242
-                        ! $message_resource_manager->has_message_type_been_activated_for_messenger(
243
-                            $identifier,
244
-                            $messenger
245
-                        )
246
-                    ) {
247
-                        $message_resource_manager->ensure_message_type_is_active($identifier, $messenger);
248
-                    }
249
-                }
250
-            }
251
-        }
252
-    }
236
+		// for any message types with force activation, let's ensure they are activated
237
+		foreach (self::$_ee_message_type_registry as $identifier => $settings) {
238
+			if ($settings['force_activation']) {
239
+				foreach ($settings['messengers_to_activate_with'] as $messenger) {
240
+					// DO not force activation if this message type has already been activated in the system
241
+					if (
242
+						! $message_resource_manager->has_message_type_been_activated_for_messenger(
243
+							$identifier,
244
+							$messenger
245
+						)
246
+					) {
247
+						$message_resource_manager->ensure_message_type_is_active($identifier, $messenger);
248
+					}
249
+				}
250
+			}
251
+		}
252
+	}
253 253
 
254 254
 
255
-    /**
256
-     * This deregisters a message type that was previously registered with a specific message_type_name.
257
-     *
258
-     * @param string $identifier the name for the message type that was previously registered
259
-     * @return void
260
-     * @throws EE_Error
261
-     * @throws ReflectionException
262
-     * @since    4.3.0
263
-     */
264
-    public static function deregister($identifier = '')
265
-    {
266
-        if (! empty(self::$_ee_message_type_registry[ $identifier ])) {
267
-            // let's make sure that we remove any place this message type was made active
268
-            /** @var EE_Message_Resource_Manager $Message_Resource_Manager */
269
-            $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
270
-            // ensures that if this message type is registered again that it retains its previous active state vs
271
-            // remaining inactive.
272
-            $Message_Resource_Manager->remove_message_type_has_been_activated_from_all_messengers(
273
-                $identifier,
274
-                true
275
-            );
276
-            $Message_Resource_Manager->deactivate_message_type($identifier, false);
277
-        }
278
-        unset(self::$_ee_message_type_registry[ $identifier ]);
279
-    }
255
+	/**
256
+	 * This deregisters a message type that was previously registered with a specific message_type_name.
257
+	 *
258
+	 * @param string $identifier the name for the message type that was previously registered
259
+	 * @return void
260
+	 * @throws EE_Error
261
+	 * @throws ReflectionException
262
+	 * @since    4.3.0
263
+	 */
264
+	public static function deregister($identifier = '')
265
+	{
266
+		if (! empty(self::$_ee_message_type_registry[ $identifier ])) {
267
+			// let's make sure that we remove any place this message type was made active
268
+			/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
269
+			$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
270
+			// ensures that if this message type is registered again that it retains its previous active state vs
271
+			// remaining inactive.
272
+			$Message_Resource_Manager->remove_message_type_has_been_activated_from_all_messengers(
273
+				$identifier,
274
+				true
275
+			);
276
+			$Message_Resource_Manager->deactivate_message_type($identifier, false);
277
+		}
278
+		unset(self::$_ee_message_type_registry[ $identifier ]);
279
+	}
280 280
 
281 281
 
282
-    /**
283
-     * callback for FHEE__EE_messages__get_installed__messagetype_files filter.
284
-     *
285
-     * @param array $messagetype_files The current array of message type file names
286
-     * @return  array                                 Array of message type file names
287
-     * @since   4.3.0
288
-     */
289
-    public static function register_messagetype_files(array $messagetype_files)
290
-    {
291
-        if (empty(self::$_ee_message_type_registry)) {
292
-            return $messagetype_files;
293
-        }
294
-        foreach (self::$_ee_message_type_registry as $mt_reg) {
295
-            if (empty($mt_reg['mtfilename'])) {
296
-                continue;
297
-            }
298
-            $messagetype_files[] = $mt_reg['mtfilename'];
299
-        }
300
-        return $messagetype_files;
301
-    }
282
+	/**
283
+	 * callback for FHEE__EE_messages__get_installed__messagetype_files filter.
284
+	 *
285
+	 * @param array $messagetype_files The current array of message type file names
286
+	 * @return  array                                 Array of message type file names
287
+	 * @since   4.3.0
288
+	 */
289
+	public static function register_messagetype_files(array $messagetype_files)
290
+	{
291
+		if (empty(self::$_ee_message_type_registry)) {
292
+			return $messagetype_files;
293
+		}
294
+		foreach (self::$_ee_message_type_registry as $mt_reg) {
295
+			if (empty($mt_reg['mtfilename'])) {
296
+				continue;
297
+			}
298
+			$messagetype_files[] = $mt_reg['mtfilename'];
299
+		}
300
+		return $messagetype_files;
301
+	}
302 302
 
303 303
 
304
-    /**
305
-     * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
306
-     *
307
-     * @param array $paths array of paths to be checked by EE_messages autoloader.
308
-     * @return array
309
-     * @since    4.3.0
310
-     */
311
-    public static function register_msgs_autoload_paths(array $paths)
312
-    {
313
-        if (! empty(self::$_ee_message_type_registry)) {
314
-            foreach (self::$_ee_message_type_registry as $mt_reg) {
315
-                if (empty($mt_reg['autoloadpaths'])) {
316
-                    continue;
317
-                }
318
-                $paths = array_merge($paths, $mt_reg['autoloadpaths']);
319
-            }
320
-        }
321
-        return $paths;
322
-    }
304
+	/**
305
+	 * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
306
+	 *
307
+	 * @param array $paths array of paths to be checked by EE_messages autoloader.
308
+	 * @return array
309
+	 * @since    4.3.0
310
+	 */
311
+	public static function register_msgs_autoload_paths(array $paths)
312
+	{
313
+		if (! empty(self::$_ee_message_type_registry)) {
314
+			foreach (self::$_ee_message_type_registry as $mt_reg) {
315
+				if (empty($mt_reg['autoloadpaths'])) {
316
+					continue;
317
+				}
318
+				$paths = array_merge($paths, $mt_reg['autoloadpaths']);
319
+			}
320
+		}
321
+		return $paths;
322
+	}
323 323
 
324 324
 
325
-    /**
326
-     * callback for FHEE__EE_messenger__get_default_message_types__default_types filter.
327
-     *
328
-     * @param array        $default_types   array of message types activated with messenger (
329
-     *                                      corresponds to the $name property of message type)
330
-     * @param EE_messenger $messenger       The EE_messenger the filter is called from.
331
-     * @return array
332
-     * @since  4.3.0
333
-     */
334
-    public static function register_messengers_to_activate_mt_with(array $default_types, EE_messenger $messenger)
335
-    {
336
-        if (empty(self::$_ee_message_type_registry)) {
337
-            return $default_types;
338
-        }
339
-        foreach (self::$_ee_message_type_registry as $identifier => $mt_reg) {
340
-            if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) {
341
-                continue;
342
-            }
343
-            // loop through each of the messengers and if it matches the loaded class
344
-            // then we add this message type to the
345
-            foreach ($mt_reg['messengers_to_activate_with'] as $msgr) {
346
-                if ($messenger->name == $msgr) {
347
-                    $default_types[] = $identifier;
348
-                }
349
-            }
350
-        }
325
+	/**
326
+	 * callback for FHEE__EE_messenger__get_default_message_types__default_types filter.
327
+	 *
328
+	 * @param array        $default_types   array of message types activated with messenger (
329
+	 *                                      corresponds to the $name property of message type)
330
+	 * @param EE_messenger $messenger       The EE_messenger the filter is called from.
331
+	 * @return array
332
+	 * @since  4.3.0
333
+	 */
334
+	public static function register_messengers_to_activate_mt_with(array $default_types, EE_messenger $messenger)
335
+	{
336
+		if (empty(self::$_ee_message_type_registry)) {
337
+			return $default_types;
338
+		}
339
+		foreach (self::$_ee_message_type_registry as $identifier => $mt_reg) {
340
+			if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) {
341
+				continue;
342
+			}
343
+			// loop through each of the messengers and if it matches the loaded class
344
+			// then we add this message type to the
345
+			foreach ($mt_reg['messengers_to_activate_with'] as $msgr) {
346
+				if ($messenger->name == $msgr) {
347
+					$default_types[] = $identifier;
348
+				}
349
+			}
350
+		}
351 351
 
352
-        return $default_types;
353
-    }
352
+		return $default_types;
353
+	}
354 354
 
355 355
 
356
-    /**
357
-     * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter.
358
-     *
359
-     * @param array        $valid_types     array of message types valid with messenger (
360
-     *                                      corresponds to the $name property of message type)
361
-     * @param EE_messenger $messenger       The EE_messenger the filter is called from.
362
-     * @return  array
363
-     * @since   4.3.0
364
-     */
365
-    public static function register_messengers_to_validate_mt_with(array $valid_types, EE_messenger $messenger)
366
-    {
367
-        if (empty(self::$_ee_message_type_registry)) {
368
-            return $valid_types;
369
-        }
370
-        foreach (self::$_ee_message_type_registry as $identifier => $mt_reg) {
371
-            if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) {
372
-                continue;
373
-            }
374
-            // loop through each of the messengers and if it matches the loaded class
375
-            // then we add this message type to the
376
-            foreach ($mt_reg['messengers_to_validate_with'] as $msgr) {
377
-                if ($messenger->name == $msgr) {
378
-                    $valid_types[] = $identifier;
379
-                }
380
-            }
381
-        }
356
+	/**
357
+	 * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter.
358
+	 *
359
+	 * @param array        $valid_types     array of message types valid with messenger (
360
+	 *                                      corresponds to the $name property of message type)
361
+	 * @param EE_messenger $messenger       The EE_messenger the filter is called from.
362
+	 * @return  array
363
+	 * @since   4.3.0
364
+	 */
365
+	public static function register_messengers_to_validate_mt_with(array $valid_types, EE_messenger $messenger)
366
+	{
367
+		if (empty(self::$_ee_message_type_registry)) {
368
+			return $valid_types;
369
+		}
370
+		foreach (self::$_ee_message_type_registry as $identifier => $mt_reg) {
371
+			if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) {
372
+				continue;
373
+			}
374
+			// loop through each of the messengers and if it matches the loaded class
375
+			// then we add this message type to the
376
+			foreach ($mt_reg['messengers_to_validate_with'] as $msgr) {
377
+				if ($messenger->name == $msgr) {
378
+					$valid_types[] = $identifier;
379
+				}
380
+			}
381
+		}
382 382
 
383
-        return $valid_types;
384
-    }
383
+		return $valid_types;
384
+	}
385 385
 
386 386
 
387
-    /**
388
-     * Callback for `FHEE__EE_Messages_Template_Pack_Default__get_supports` filter to register this message type as
389
-     * supporting the default template pack
390
-     *
391
-     * @param array $supports
392
-     *
393
-     * @return array
394
-     */
395
-    public static function register_default_template_pack_supports(array $supports)
396
-    {
397
-        foreach (self::$_ee_message_type_registry as $identifier => $mt_reg) {
398
-            if (empty($mt_reg['messengers_supporting_default_template_pack_with'])) {
399
-                continue;
400
-            }
401
-            foreach ($mt_reg['messengers_supporting_default_template_pack_with'] as $messenger_slug) {
402
-                $supports[ $messenger_slug ][] = $identifier;
403
-            }
404
-        }
405
-        return $supports;
406
-    }
387
+	/**
388
+	 * Callback for `FHEE__EE_Messages_Template_Pack_Default__get_supports` filter to register this message type as
389
+	 * supporting the default template pack
390
+	 *
391
+	 * @param array $supports
392
+	 *
393
+	 * @return array
394
+	 */
395
+	public static function register_default_template_pack_supports(array $supports)
396
+	{
397
+		foreach (self::$_ee_message_type_registry as $identifier => $mt_reg) {
398
+			if (empty($mt_reg['messengers_supporting_default_template_pack_with'])) {
399
+				continue;
400
+			}
401
+			foreach ($mt_reg['messengers_supporting_default_template_pack_with'] as $messenger_slug) {
402
+				$supports[ $messenger_slug ][] = $identifier;
403
+			}
404
+		}
405
+		return $supports;
406
+	}
407 407
 
408 408
 
409
-    /**
410
-     * Callback for FHEE__EE_Template_Pack___get_specific_template__filtered_base_path
411
-     *
412
-     * @param string                    $base_path The original base path for message templates
413
-     * @param EE_messenger              $messenger
414
-     * @param EE_message_type           $message_type
415
-     * @param string                    $field     The field requesting a template
416
-     * @param string                    $context   The context requesting a template
417
-     * @param EE_Messages_Template_Pack $template_pack
418
-     *
419
-     * @return string
420
-     */
421
-    public static function register_base_template_path(
422
-        $base_path,
423
-        EE_messenger $messenger,
424
-        EE_message_type $message_type,
425
-        $field,
426
-        $context,
427
-        EE_Messages_Template_Pack $template_pack
428
-    ) {
429
-        if (
430
-            ! $template_pack instanceof EE_Messages_Template_Pack_Default
431
-            || ! $message_type instanceof EE_message_type
432
-        ) {
433
-            return $base_path;
434
-        }
435
-        foreach (self::$_ee_message_type_registry as $identifier => $mt_reg) {
436
-            if (
437
-                $message_type->name === $identifier
438
-                && ! empty($mt_reg['base_path_for_default_templates'])
439
-            ) {
440
-                return $mt_reg['base_path_for_default_templates'];
441
-            }
442
-        }
443
-        return $base_path;
444
-    }
409
+	/**
410
+	 * Callback for FHEE__EE_Template_Pack___get_specific_template__filtered_base_path
411
+	 *
412
+	 * @param string                    $base_path The original base path for message templates
413
+	 * @param EE_messenger              $messenger
414
+	 * @param EE_message_type           $message_type
415
+	 * @param string                    $field     The field requesting a template
416
+	 * @param string                    $context   The context requesting a template
417
+	 * @param EE_Messages_Template_Pack $template_pack
418
+	 *
419
+	 * @return string
420
+	 */
421
+	public static function register_base_template_path(
422
+		$base_path,
423
+		EE_messenger $messenger,
424
+		EE_message_type $message_type,
425
+		$field,
426
+		$context,
427
+		EE_Messages_Template_Pack $template_pack
428
+	) {
429
+		if (
430
+			! $template_pack instanceof EE_Messages_Template_Pack_Default
431
+			|| ! $message_type instanceof EE_message_type
432
+		) {
433
+			return $base_path;
434
+		}
435
+		foreach (self::$_ee_message_type_registry as $identifier => $mt_reg) {
436
+			if (
437
+				$message_type->name === $identifier
438
+				&& ! empty($mt_reg['base_path_for_default_templates'])
439
+			) {
440
+				return $mt_reg['base_path_for_default_templates'];
441
+			}
442
+		}
443
+		return $base_path;
444
+	}
445 445
 
446 446
 
447
-    /**
448
-     * Callback for FHEE__EE_Messages_Template_Pack__get_variation__base_path and
449
-     * FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url hooks
450
-     *
451
-     * @param string                    $base_path_or_url  The original incoming base url or path
452
-     * @param string                    $messenger_slug    The slug of the messenger the template is being generated
453
-     *                                                     for.
454
-     * @param string                    $message_type_slug The slug of the message type the template is being generated
455
-     *                                                     for.
456
-     * @param string                    $type              The "type" of css being requested.
457
-     * @param string                    $variation         The variation being requested.
458
-     * @param bool                      $url               whether a url or path is being requested.
459
-     * @param string                    $file_extension    What file extension is expected for the variation file.
460
-     * @param EE_Messages_Template_Pack $template_pack
461
-     *
462
-     * @return string
463
-     */
464
-    public static function register_variation_base_path_or_url(
465
-        $base_path_or_url,
466
-        $messenger_slug,
467
-        $message_type_slug,
468
-        $type,
469
-        $variation,
470
-        $url,
471
-        $file_extension,
472
-        EE_Messages_Template_Pack $template_pack
473
-    ) {
474
-        if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
475
-            return $base_path_or_url;
476
-        }
477
-        foreach (self::$_ee_message_type_registry as $identifier => $mt_reg) {
478
-            if (
479
-                $identifier === $message_type_slug
480
-            ) {
481
-                if (
482
-                    $url
483
-                    && ! empty($mt_reg['base_url_for_default_variation'])
484
-                ) {
485
-                    return $mt_reg['base_url_for_default_variation'];
486
-                } elseif (
487
-                    ! $url
488
-                          && ! empty($mt_reg['base_path_for_default_variation'])
489
-                ) {
490
-                    return $mt_reg['base_path_for_default_variation'];
491
-                }
492
-            }
493
-        }
494
-        return $base_path_or_url;
495
-    }
447
+	/**
448
+	 * Callback for FHEE__EE_Messages_Template_Pack__get_variation__base_path and
449
+	 * FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url hooks
450
+	 *
451
+	 * @param string                    $base_path_or_url  The original incoming base url or path
452
+	 * @param string                    $messenger_slug    The slug of the messenger the template is being generated
453
+	 *                                                     for.
454
+	 * @param string                    $message_type_slug The slug of the message type the template is being generated
455
+	 *                                                     for.
456
+	 * @param string                    $type              The "type" of css being requested.
457
+	 * @param string                    $variation         The variation being requested.
458
+	 * @param bool                      $url               whether a url or path is being requested.
459
+	 * @param string                    $file_extension    What file extension is expected for the variation file.
460
+	 * @param EE_Messages_Template_Pack $template_pack
461
+	 *
462
+	 * @return string
463
+	 */
464
+	public static function register_variation_base_path_or_url(
465
+		$base_path_or_url,
466
+		$messenger_slug,
467
+		$message_type_slug,
468
+		$type,
469
+		$variation,
470
+		$url,
471
+		$file_extension,
472
+		EE_Messages_Template_Pack $template_pack
473
+	) {
474
+		if (! $template_pack instanceof EE_Messages_Template_Pack_Default) {
475
+			return $base_path_or_url;
476
+		}
477
+		foreach (self::$_ee_message_type_registry as $identifier => $mt_reg) {
478
+			if (
479
+				$identifier === $message_type_slug
480
+			) {
481
+				if (
482
+					$url
483
+					&& ! empty($mt_reg['base_url_for_default_variation'])
484
+				) {
485
+					return $mt_reg['base_url_for_default_variation'];
486
+				} elseif (
487
+					! $url
488
+						  && ! empty($mt_reg['base_path_for_default_variation'])
489
+				) {
490
+					return $mt_reg['base_path_for_default_variation'];
491
+				}
492
+			}
493
+		}
494
+		return $base_path_or_url;
495
+	}
496 496
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Module.lib.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  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
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
             );
68 68
         }
69 69
         // setup $_settings array from incoming values.
70
-        self::$_settings[ $identifier ] = [
70
+        self::$_settings[$identifier] = [
71 71
             // array of full server paths to any EED_Modules used by the module
72 72
             'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : [],
73 73
         ];
@@ -105,6 +105,6 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public static function deregister($identifier = '')
107 107
     {
108
-        unset(self::$_settings[ $identifier ]);
108
+        unset(self::$_settings[$identifier]);
109 109
     }
110 110
 }
Please login to merge, or discard this patch.
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -14,96 +14,96 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Register_Module implements EEI_Plugin_API
16 16
 {
17
-    /**
18
-     * Holds values for registered modules
19
-     *
20
-     * @var array
21
-     */
22
-    protected static $_settings = [];
17
+	/**
18
+	 * Holds values for registered modules
19
+	 *
20
+	 * @var array
21
+	 */
22
+	protected static $_settings = [];
23 23
 
24 24
 
25
-    /**
26
-     *    Method for registering new EED_Modules
27
-     *
28
-     * @param string $identifier a unique identifier for this set of modules Required.
29
-     * @param array  $setup_args an array of full server paths to folders containing any EED_Modules, or to the
30
-     *                           EED_Module files themselves Required.
31
-     * @type    array module_paths    an array of full server paths to folders containing any EED_Modules, or to the
32
-     *                           EED_Module files themselves
33
-     * @return void
34
-     * @throws EE_Error
35
-     * @since    4.3.0
36
-     */
37
-    public static function register($identifier = '', array $setup_args = [])
38
-    {
39
-        // required fields MUST be present, so let's make sure they are.
40
-        if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['module_paths'])) {
41
-            throw new EE_Error(
42
-                esc_html__(
43
-                    '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)',
44
-                    'event_espresso'
45
-                )
46
-            );
47
-        }
25
+	/**
26
+	 *    Method for registering new EED_Modules
27
+	 *
28
+	 * @param string $identifier a unique identifier for this set of modules Required.
29
+	 * @param array  $setup_args an array of full server paths to folders containing any EED_Modules, or to the
30
+	 *                           EED_Module files themselves Required.
31
+	 * @type    array module_paths    an array of full server paths to folders containing any EED_Modules, or to the
32
+	 *                           EED_Module files themselves
33
+	 * @return void
34
+	 * @throws EE_Error
35
+	 * @since    4.3.0
36
+	 */
37
+	public static function register($identifier = '', array $setup_args = [])
38
+	{
39
+		// required fields MUST be present, so let's make sure they are.
40
+		if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['module_paths'])) {
41
+			throw new EE_Error(
42
+				esc_html__(
43
+					'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)',
44
+					'event_espresso'
45
+				)
46
+			);
47
+		}
48 48
 
49
-        // make sure we don't register twice
50
-        if (isset(self::$_settings[ $identifier ])) {
51
-            return;
52
-        }
49
+		// make sure we don't register twice
50
+		if (isset(self::$_settings[ $identifier ])) {
51
+			return;
52
+		}
53 53
 
54
-        // make sure this was called in the right place!
55
-        if (
56
-            ! 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
-                esc_html__(
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
-    }
54
+		// make sure this was called in the right place!
55
+		if (
56
+			! 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
+				esc_html__(
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.
core/libraries/plugin_api/EE_Register_Model.lib.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         }
59 59
 
60 60
         // make sure we don't register twice
61
-        if (isset(self::$_model_registry[ $identifier ])) {
61
+        if (isset(self::$_model_registry[$identifier])) {
62 62
             return;
63 63
         }
64 64
 
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
                 '4.5'
80 80
             );
81 81
         }
82
-        self::$_model_registry[ $identifier ] = $setup_args;
82
+        self::$_model_registry[$identifier] = $setup_args;
83 83
 
84 84
         if (
85 85
             (isset($setup_args['model_paths']) && ! isset($setup_args['class_paths']))
86
-            || (! isset($setup_args['model_paths']) && isset($setup_args['class_paths']))
86
+            || ( ! isset($setup_args['model_paths']) && isset($setup_args['class_paths']))
87 87
         ) {
88 88
             throw new EE_Error(
89 89
                 sprintf(
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
         }
98 98
         if (isset($setup_args['model_paths'])) {
99 99
             // make sure they passed in an array
100
-            if (! is_array($setup_args['model_paths'])) {
100
+            if ( ! is_array($setup_args['model_paths'])) {
101 101
                 $setup_args['model_paths'] = [$setup_args['model_paths']];
102 102
             }
103 103
             // we want to add this as a model folder
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
             EEH_Autoloader::register_autoloader($class_to_filepath_map);
107 107
             $model_name_to_classname_map = [];
108 108
             foreach (array_keys($class_to_filepath_map) as $classname) {
109
-                $model_name_to_classname_map[ str_replace("EEM_", "", $classname) ] = $classname;
109
+                $model_name_to_classname_map[str_replace("EEM_", "", $classname)] = $classname;
110 110
             }
111
-            self::$_model_name_to_classname_map[ $identifier ] = $model_name_to_classname_map;
111
+            self::$_model_name_to_classname_map[$identifier] = $model_name_to_classname_map;
112 112
             add_filter('FHEE__EE_System__parse_model_names', ['EE_Register_Model', 'add_addon_models']);
113 113
             add_filter(
114 114
                 'FHEE__EE_System__parse_implemented_model_names',
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         }
120 120
         if (isset($setup_args['class_paths'])) {
121 121
             // make sure they passed in an array
122
-            if (! is_array($setup_args['class_paths'])) {
122
+            if ( ! is_array($setup_args['class_paths'])) {
123 123
                 $setup_args['class_paths'] = [$setup_args['class_paths']];
124 124
             }
125 125
             $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_paths']);
@@ -192,6 +192,6 @@  discard block
 block discarded – undo
192 192
      */
193 193
     public static function deregister($identifier = '')
194 194
     {
195
-        unset(self::$_model_registry[ $identifier ], self::$_model_name_to_classname_map[ $identifier ]);
195
+        unset(self::$_model_registry[$identifier], self::$_model_name_to_classname_map[$identifier]);
196 196
     }
197 197
 }
Please login to merge, or discard this patch.
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -11,187 +11,187 @@
 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
-                esc_html__(
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
+				esc_html__(
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 (
66
-            ! did_action('AHEE__EE_System__load_espresso_addons')
67
-            || did_action('FHEE__EE_System__parse_model_names')
68
-            || did_action('FHEE__EE_System__parse_implemented_model_names')
69
-        ) {
70
-            EE_Error::doing_it_wrong(
71
-                __METHOD__,
72
-                sprintf(
73
-                    esc_html__(
74
-                        '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.',
75
-                        'event_espresso'
76
-                    ),
77
-                    $identifier
78
-                ),
79
-                '4.5'
80
-            );
81
-        }
82
-        self::$_model_registry[ $identifier ] = $setup_args;
65
+		if (
66
+			! did_action('AHEE__EE_System__load_espresso_addons')
67
+			|| did_action('FHEE__EE_System__parse_model_names')
68
+			|| did_action('FHEE__EE_System__parse_implemented_model_names')
69
+		) {
70
+			EE_Error::doing_it_wrong(
71
+				__METHOD__,
72
+				sprintf(
73
+					esc_html__(
74
+						'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.',
75
+						'event_espresso'
76
+					),
77
+					$identifier
78
+				),
79
+				'4.5'
80
+			);
81
+		}
82
+		self::$_model_registry[ $identifier ] = $setup_args;
83 83
 
84
-        if (
85
-            (isset($setup_args['model_paths']) && ! isset($setup_args['class_paths']))
86
-            || (! isset($setup_args['model_paths']) && isset($setup_args['class_paths']))
87
-        ) {
88
-            throw new EE_Error(
89
-                sprintf(
90
-                    esc_html__(
91
-                        'You must register both "model_paths" AND "class_paths", not just one or the other You provided %s',
92
-                        'event_espresso'
93
-                    ),
94
-                    implode(", ", array_keys($setup_args))
95
-                )
96
-            );
97
-        }
98
-        if (isset($setup_args['model_paths'])) {
99
-            // make sure they passed in an array
100
-            if (! is_array($setup_args['model_paths'])) {
101
-                $setup_args['model_paths'] = [$setup_args['model_paths']];
102
-            }
103
-            // we want to add this as a model folder
104
-            // and autoload them all
105
-            $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['model_paths']);
106
-            EEH_Autoloader::register_autoloader($class_to_filepath_map);
107
-            $model_name_to_classname_map = [];
108
-            foreach (array_keys($class_to_filepath_map) as $classname) {
109
-                $model_name_to_classname_map[ str_replace("EEM_", "", $classname) ] = $classname;
110
-            }
111
-            self::$_model_name_to_classname_map[ $identifier ] = $model_name_to_classname_map;
112
-            add_filter('FHEE__EE_System__parse_model_names', ['EE_Register_Model', 'add_addon_models']);
113
-            add_filter(
114
-                'FHEE__EE_System__parse_implemented_model_names',
115
-                ['EE_Register_Model', 'add_addon_models']
116
-            );
117
-            add_filter('FHEE__EE_Registry__load_model__paths', ['EE_Register_Model', 'add_model_folders']);
118
-            unset($setup_args['model_paths']);
119
-        }
120
-        if (isset($setup_args['class_paths'])) {
121
-            // make sure they passed in an array
122
-            if (! is_array($setup_args['class_paths'])) {
123
-                $setup_args['class_paths'] = [$setup_args['class_paths']];
124
-            }
125
-            $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_paths']);
126
-            EEH_Autoloader::register_autoloader($class_to_filepath_map);
127
-            add_filter('FHEE__EE_Registry__load_class__paths', ['EE_Register_Model', 'add_class_folders']);
128
-            unset($setup_args['class_paths']);
129
-        }
130
-        foreach ($setup_args as $unknown_key => $unknown_config) {
131
-            self::deregister($identifier);
132
-            throw new EE_Error(
133
-                sprintf(esc_html__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key)
134
-            );
135
-        }
136
-    }
84
+		if (
85
+			(isset($setup_args['model_paths']) && ! isset($setup_args['class_paths']))
86
+			|| (! isset($setup_args['model_paths']) && isset($setup_args['class_paths']))
87
+		) {
88
+			throw new EE_Error(
89
+				sprintf(
90
+					esc_html__(
91
+						'You must register both "model_paths" AND "class_paths", not just one or the other You provided %s',
92
+						'event_espresso'
93
+					),
94
+					implode(", ", array_keys($setup_args))
95
+				)
96
+			);
97
+		}
98
+		if (isset($setup_args['model_paths'])) {
99
+			// make sure they passed in an array
100
+			if (! is_array($setup_args['model_paths'])) {
101
+				$setup_args['model_paths'] = [$setup_args['model_paths']];
102
+			}
103
+			// we want to add this as a model folder
104
+			// and autoload them all
105
+			$class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['model_paths']);
106
+			EEH_Autoloader::register_autoloader($class_to_filepath_map);
107
+			$model_name_to_classname_map = [];
108
+			foreach (array_keys($class_to_filepath_map) as $classname) {
109
+				$model_name_to_classname_map[ str_replace("EEM_", "", $classname) ] = $classname;
110
+			}
111
+			self::$_model_name_to_classname_map[ $identifier ] = $model_name_to_classname_map;
112
+			add_filter('FHEE__EE_System__parse_model_names', ['EE_Register_Model', 'add_addon_models']);
113
+			add_filter(
114
+				'FHEE__EE_System__parse_implemented_model_names',
115
+				['EE_Register_Model', 'add_addon_models']
116
+			);
117
+			add_filter('FHEE__EE_Registry__load_model__paths', ['EE_Register_Model', 'add_model_folders']);
118
+			unset($setup_args['model_paths']);
119
+		}
120
+		if (isset($setup_args['class_paths'])) {
121
+			// make sure they passed in an array
122
+			if (! is_array($setup_args['class_paths'])) {
123
+				$setup_args['class_paths'] = [$setup_args['class_paths']];
124
+			}
125
+			$class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_paths']);
126
+			EEH_Autoloader::register_autoloader($class_to_filepath_map);
127
+			add_filter('FHEE__EE_Registry__load_class__paths', ['EE_Register_Model', 'add_class_folders']);
128
+			unset($setup_args['class_paths']);
129
+		}
130
+		foreach ($setup_args as $unknown_key => $unknown_config) {
131
+			self::deregister($identifier);
132
+			throw new EE_Error(
133
+				sprintf(esc_html__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key)
134
+			);
135
+		}
136
+	}
137 137
 
138 138
 
139
-    /**
140
-     * Filters the core list of models
141
-     *
142
-     * @param array $core_models
143
-     * @return array keys are model names (eg 'Event') and values are their classes (eg 'EE_Event')
144
-     */
145
-    public static function add_addon_models(array $core_models = [])
146
-    {
147
-        foreach (self::$_model_name_to_classname_map as $model_name_to_class_map) {
148
-            $core_models = array_merge($core_models, $model_name_to_class_map);
149
-        }
150
-        return $core_models;
151
-    }
139
+	/**
140
+	 * Filters the core list of models
141
+	 *
142
+	 * @param array $core_models
143
+	 * @return array keys are model names (eg 'Event') and values are their classes (eg 'EE_Event')
144
+	 */
145
+	public static function add_addon_models(array $core_models = [])
146
+	{
147
+		foreach (self::$_model_name_to_classname_map as $model_name_to_class_map) {
148
+			$core_models = array_merge($core_models, $model_name_to_class_map);
149
+		}
150
+		return $core_models;
151
+	}
152 152
 
153 153
 
154
-    /**
155
-     * Filters the list of model folders
156
-     *
157
-     * @param array $folders
158
-     * @return array of folder paths
159
-     */
160
-    public static function add_model_folders(array $folders = [])
161
-    {
162
-        foreach (self::$_model_registry as $setup_args) {
163
-            if (isset($setup_args['model_paths'])) {
164
-                $folders = array_merge($folders, $setup_args['model_paths']);
165
-            }
166
-        }
167
-        return $folders;
168
-    }
154
+	/**
155
+	 * Filters the list of model folders
156
+	 *
157
+	 * @param array $folders
158
+	 * @return array of folder paths
159
+	 */
160
+	public static function add_model_folders(array $folders = [])
161
+	{
162
+		foreach (self::$_model_registry as $setup_args) {
163
+			if (isset($setup_args['model_paths'])) {
164
+				$folders = array_merge($folders, $setup_args['model_paths']);
165
+			}
166
+		}
167
+		return $folders;
168
+	}
169 169
 
170 170
 
171
-    /**
172
-     * Filters the array of model class paths
173
-     *
174
-     * @param array $folders
175
-     * @return array of folder paths
176
-     */
177
-    public static function add_class_folders(array $folders = [])
178
-    {
179
-        foreach (self::$_model_registry as $setup_args) {
180
-            if (isset($setup_args['class_paths'])) {
181
-                $folders = array_merge($folders, $setup_args['class_paths']);
182
-            }
183
-        }
184
-        return $folders;
185
-    }
171
+	/**
172
+	 * Filters the array of model class paths
173
+	 *
174
+	 * @param array $folders
175
+	 * @return array of folder paths
176
+	 */
177
+	public static function add_class_folders(array $folders = [])
178
+	{
179
+		foreach (self::$_model_registry as $setup_args) {
180
+			if (isset($setup_args['class_paths'])) {
181
+				$folders = array_merge($folders, $setup_args['class_paths']);
182
+			}
183
+		}
184
+		return $folders;
185
+	}
186 186
 
187 187
 
188
-    /**
189
-     * deregister
190
-     *
191
-     * @param string $identifier
192
-     */
193
-    public static function deregister($identifier = '')
194
-    {
195
-        unset(self::$_model_registry[ $identifier ], self::$_model_name_to_classname_map[ $identifier ]);
196
-    }
188
+	/**
189
+	 * deregister
190
+	 *
191
+	 * @param string $identifier
192
+	 */
193
+	public static function deregister($identifier = '')
194
+	{
195
+		unset(self::$_model_registry[ $identifier ], self::$_model_name_to_classname_map[ $identifier ]);
196
+	}
197 197
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Widget.lib.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  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
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             );
69 69
         }
70 70
         // setup $_settings array from incoming values.
71
-        self::$_settings[ $identifier ] = [
71
+        self::$_settings[$identifier] = [
72 72
             // array of full server paths to any EED_Widgets used by the widget
73 73
             'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : [],
74 74
         ];
@@ -107,6 +107,6 @@  discard block
 block discarded – undo
107 107
      */
108 108
     public static function deregister($identifier = '')
109 109
     {
110
-        unset(self::$_settings[ $identifier ]);
110
+        unset(self::$_settings[$identifier]);
111 111
     }
112 112
 }
Please login to merge, or discard this patch.
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -14,98 +14,98 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Register_Widget implements EEI_Plugin_API
16 16
 {
17
-    /**
18
-     * Holds values for registered widgets
19
-     *
20
-     * @var array
21
-     */
22
-    protected static $_settings = [];
17
+	/**
18
+	 * Holds values for registered widgets
19
+	 *
20
+	 * @var array
21
+	 */
22
+	protected static $_settings = [];
23 23
 
24 24
 
25
-    /**
26
-     *    Method for registering new EED_Widgets
27
-     *
28
-     * @param string $identifier a unique identifier for this set of widgets
29
-     * @param array  $setup_args an array of arguments provided for registering widgets
30
-     * @type array widget_paths        an array of full server paths to folders containing any EED_Widgets, or to the
31
-     *                           EED_Widget files themselves
32
-     * @return void
33
-     * @throws EE_Error
34
-     * @since    4.3.0
35
-     */
36
-    public static function register($identifier = '', array $setup_args = [])
37
-    {
25
+	/**
26
+	 *    Method for registering new EED_Widgets
27
+	 *
28
+	 * @param string $identifier a unique identifier for this set of widgets
29
+	 * @param array  $setup_args an array of arguments provided for registering widgets
30
+	 * @type array widget_paths        an array of full server paths to folders containing any EED_Widgets, or to the
31
+	 *                           EED_Widget files themselves
32
+	 * @return void
33
+	 * @throws EE_Error
34
+	 * @since    4.3.0
35
+	 */
36
+	public static function register($identifier = '', array $setup_args = [])
37
+	{
38 38
 
39
-        // required fields MUST be present, so let's make sure they are.
40
-        if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['widget_paths'])) {
41
-            throw new EE_Error(
42
-                esc_html__(
43
-                    'In order to register Widgets with EE_Register_Widget::register(), you must include a "widget_id" (a unique identifier for this set of widgets), and an array containing the following keys: "widget_paths" (an array of full server paths to folders that contain widgets, or to the widget files themselves)',
44
-                    'event_espresso'
45
-                )
46
-            );
47
-        }
39
+		// required fields MUST be present, so let's make sure they are.
40
+		if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['widget_paths'])) {
41
+			throw new EE_Error(
42
+				esc_html__(
43
+					'In order to register Widgets with EE_Register_Widget::register(), you must include a "widget_id" (a unique identifier for this set of widgets), and an array containing the following keys: "widget_paths" (an array of full server paths to folders that contain widgets, or to the widget files themselves)',
44
+					'event_espresso'
45
+				)
46
+			);
47
+		}
48 48
 
49
-        // make sure we don't register twice
50
-        if (isset(self::$_settings[ $identifier ])) {
51
-            return;
52
-        }
49
+		// make sure we don't register twice
50
+		if (isset(self::$_settings[ $identifier ])) {
51
+			return;
52
+		}
53 53
 
54 54
 
55
-        // make sure this was called in the right place!
56
-        if (
57
-            ! did_action('AHEE__EE_System__load_espresso_addons')
58
-            || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
59
-        ) {
60
-            EE_Error::doing_it_wrong(
61
-                __METHOD__,
62
-                esc_html__(
63
-                    'An attempt to register widgets 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 widgets.',
64
-                    'event_espresso'
65
-                ),
66
-                '4.3.0'
67
-            );
68
-        }
69
-        // setup $_settings array from incoming values.
70
-        self::$_settings[ $identifier ] = [
71
-            // array of full server paths to any EED_Widgets used by the widget
72
-            'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : [],
73
-        ];
74
-        // add to list of widgets to be registered
75
-        add_filter(
76
-            'FHEE__EE_Config__register_widgets__widgets_to_register',
77
-            ['EE_Register_Widget', 'add_widgets']
78
-        );
79
-    }
55
+		// make sure this was called in the right place!
56
+		if (
57
+			! did_action('AHEE__EE_System__load_espresso_addons')
58
+			|| did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
59
+		) {
60
+			EE_Error::doing_it_wrong(
61
+				__METHOD__,
62
+				esc_html__(
63
+					'An attempt to register widgets 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 widgets.',
64
+					'event_espresso'
65
+				),
66
+				'4.3.0'
67
+			);
68
+		}
69
+		// setup $_settings array from incoming values.
70
+		self::$_settings[ $identifier ] = [
71
+			// array of full server paths to any EED_Widgets used by the widget
72
+			'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : [],
73
+		];
74
+		// add to list of widgets to be registered
75
+		add_filter(
76
+			'FHEE__EE_Config__register_widgets__widgets_to_register',
77
+			['EE_Register_Widget', 'add_widgets']
78
+		);
79
+	}
80 80
 
81 81
 
82
-    /**
83
-     * Filters the list of widgets to add ours.
84
-     * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg.
85
-     * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/widgets/espresso_monkey'...)
86
-     *
87
-     * @param array $widgets_to_register array of paths to all widgets that require registering
88
-     * @return array
89
-     */
90
-    public static function add_widgets(array $widgets_to_register = [])
91
-    {
92
-        foreach (self::$_settings as $settings) {
93
-            $widgets_to_register = array_merge($widgets_to_register, $settings['widget_paths']);
94
-        }
95
-        return $widgets_to_register;
96
-    }
82
+	/**
83
+	 * Filters the list of widgets to add ours.
84
+	 * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg.
85
+	 * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/widgets/espresso_monkey'...)
86
+	 *
87
+	 * @param array $widgets_to_register array of paths to all widgets that require registering
88
+	 * @return array
89
+	 */
90
+	public static function add_widgets(array $widgets_to_register = [])
91
+	{
92
+		foreach (self::$_settings as $settings) {
93
+			$widgets_to_register = array_merge($widgets_to_register, $settings['widget_paths']);
94
+		}
95
+		return $widgets_to_register;
96
+	}
97 97
 
98 98
 
99
-    /**
100
-     * This deregisters a widget that was previously registered with a specific $identifier.
101
-     *
102
-     * @param string $identifier the name for the widget that was previously registered
103
-     * @return void
104
-     * @since    4.3.0
105
-     *
106
-     */
107
-    public static function deregister($identifier = '')
108
-    {
109
-        unset(self::$_settings[ $identifier ]);
110
-    }
99
+	/**
100
+	 * This deregisters a widget that was previously registered with a specific $identifier.
101
+	 *
102
+	 * @param string $identifier the name for the widget that was previously registered
103
+	 * @return void
104
+	 * @since    4.3.0
105
+	 *
106
+	 */
107
+	public static function deregister($identifier = '')
108
+	{
109
+		unset(self::$_settings[ $identifier ]);
110
+	}
111 111
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Data_Migration_Scripts.lib.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             );
48 48
         }
49 49
         // make sure we don't register twice
50
-        if (isset(self::$_settings[ $identifier ])) {
50
+        if (isset(self::$_settings[$identifier])) {
51 51
             return;
52 52
         }
53 53
         // make sure this was called in the right place!
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             );
66 66
         }
67 67
         // setup $_settings array from incoming values.
68
-        self::$_settings[ $identifier ] = array(
68
+        self::$_settings[$identifier] = array(
69 69
             'dms_paths' => (array) $setup_args['dms_paths'],
70 70
         );
71 71
         // setup DMS
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                 // so if for some reason an addon has multiple dms paths,
91 91
                 // we append one or more * to the classname
92 92
                 // which will get stripped out later on
93
-                $dms_paths[ $identifier . str_repeat('*', $wildcards) ] = $dms_path;
93
+                $dms_paths[$identifier.str_repeat('*', $wildcards)] = $dms_path;
94 94
                 $wildcards++;
95 95
             }
96 96
         }
@@ -107,6 +107,6 @@  discard block
 block discarded – undo
107 107
      */
108 108
     public static function deregister($identifier = '')
109 109
     {
110
-        unset(self::$_settings[ $identifier ]);
110
+        unset(self::$_settings[$identifier]);
111 111
     }
112 112
 }
Please login to merge, or discard this patch.
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -14,98 +14,98 @@
 block discarded – undo
14 14
  */
15 15
 class EE_Register_Data_Migration_Scripts implements EEI_Plugin_API
16 16
 {
17
-    /**
18
-     * Holds values for registered DMSs
19
-     *
20
-     * @var array[][]
21
-     */
22
-    protected static $_settings = array();
17
+	/**
18
+	 * Holds values for registered DMSs
19
+	 *
20
+	 * @var array[][]
21
+	 */
22
+	protected static $_settings = array();
23 23
 
24 24
 
25
-    /**
26
-     * Method for registering new Data Migration Scripts
27
-     *
28
-     * @since 4.3.0
29
-     * @param string $identifier EE_Addon class name that this set of data migration scripts belongs to
30
-     *                           If EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name
31
-     * @param array  $setup_args {
32
-     * @type string  $dms_paths  an array of full server paths to folders that contain data migration scripts
33
-     *                           }
34
-     * @throws EE_Error
35
-     * @return void
36
-     */
37
-    public static function register($identifier = '', array $setup_args = [])
38
-    {
39
-        // required fields MUST be present, so let's make sure they are.
40
-        if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['dms_paths'])) {
41
-            throw new EE_Error(
42
-                esc_html__(
43
-                    'In order to register Data Migration Scripts with EE_Register_Data_Migration_Scripts::register(), you must include the EE_Addon class name (used as a unique identifier for this set of data migration scripts), and an array containing the following keys: "dms_paths" (an array of full server paths to folders that contain data migration scripts)',
44
-                    'event_espresso'
45
-                )
46
-            );
47
-        }
48
-        // make sure we don't register twice
49
-        if (isset(self::$_settings[ $identifier ])) {
50
-            return;
51
-        }
52
-        // make sure this was called in the right place!
53
-        if (
54
-            ! did_action('AHEE__EE_System__load_espresso_addons')
55
-            || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
56
-        ) {
57
-            EE_Error::doing_it_wrong(
58
-                __METHOD__,
59
-                esc_html__(
60
-                    'An attempt to register Data Migration Scripts has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register Data Migration Scripts.',
61
-                    'event_espresso'
62
-                ),
63
-                '4.3.0'
64
-            );
65
-        }
66
-        // setup $_settings array from incoming values.
67
-        self::$_settings[ $identifier ] = array(
68
-            'dms_paths' => (array) $setup_args['dms_paths'],
69
-        );
70
-        // setup DMS
71
-        add_filter(
72
-            'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',
73
-            array('EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders')
74
-        );
75
-    }
25
+	/**
26
+	 * Method for registering new Data Migration Scripts
27
+	 *
28
+	 * @since 4.3.0
29
+	 * @param string $identifier EE_Addon class name that this set of data migration scripts belongs to
30
+	 *                           If EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name
31
+	 * @param array  $setup_args {
32
+	 * @type string  $dms_paths  an array of full server paths to folders that contain data migration scripts
33
+	 *                           }
34
+	 * @throws EE_Error
35
+	 * @return void
36
+	 */
37
+	public static function register($identifier = '', array $setup_args = [])
38
+	{
39
+		// required fields MUST be present, so let's make sure they are.
40
+		if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['dms_paths'])) {
41
+			throw new EE_Error(
42
+				esc_html__(
43
+					'In order to register Data Migration Scripts with EE_Register_Data_Migration_Scripts::register(), you must include the EE_Addon class name (used as a unique identifier for this set of data migration scripts), and an array containing the following keys: "dms_paths" (an array of full server paths to folders that contain data migration scripts)',
44
+					'event_espresso'
45
+				)
46
+			);
47
+		}
48
+		// make sure we don't register twice
49
+		if (isset(self::$_settings[ $identifier ])) {
50
+			return;
51
+		}
52
+		// make sure this was called in the right place!
53
+		if (
54
+			! did_action('AHEE__EE_System__load_espresso_addons')
55
+			|| did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
56
+		) {
57
+			EE_Error::doing_it_wrong(
58
+				__METHOD__,
59
+				esc_html__(
60
+					'An attempt to register Data Migration Scripts has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register Data Migration Scripts.',
61
+					'event_espresso'
62
+				),
63
+				'4.3.0'
64
+			);
65
+		}
66
+		// setup $_settings array from incoming values.
67
+		self::$_settings[ $identifier ] = array(
68
+			'dms_paths' => (array) $setup_args['dms_paths'],
69
+		);
70
+		// setup DMS
71
+		add_filter(
72
+			'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',
73
+			array('EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders')
74
+		);
75
+	}
76 76
 
77 77
 
78
-    /**
79
-     * @param array $dms_paths
80
-     * @return array
81
-     */
82
-    public static function add_data_migration_script_folders(array $dms_paths = array())
83
-    {
84
-        foreach (self::$_settings as $identifier => $settings) {
85
-            $wildcards = 0;
86
-            foreach ($settings['dms_paths'] as $dms_path) {
87
-                // since we are using the addon name for the array key
88
-                // we need to ensure that the key is unique,
89
-                // so if for some reason an addon has multiple dms paths,
90
-                // we append one or more * to the classname
91
-                // which will get stripped out later on
92
-                $dms_paths[ $identifier . str_repeat('*', $wildcards) ] = $dms_path;
93
-                $wildcards++;
94
-            }
95
-        }
96
-        return $dms_paths;
97
-    }
78
+	/**
79
+	 * @param array $dms_paths
80
+	 * @return array
81
+	 */
82
+	public static function add_data_migration_script_folders(array $dms_paths = array())
83
+	{
84
+		foreach (self::$_settings as $identifier => $settings) {
85
+			$wildcards = 0;
86
+			foreach ($settings['dms_paths'] as $dms_path) {
87
+				// since we are using the addon name for the array key
88
+				// we need to ensure that the key is unique,
89
+				// so if for some reason an addon has multiple dms paths,
90
+				// we append one or more * to the classname
91
+				// which will get stripped out later on
92
+				$dms_paths[ $identifier . str_repeat('*', $wildcards) ] = $dms_path;
93
+				$wildcards++;
94
+			}
95
+		}
96
+		return $dms_paths;
97
+	}
98 98
 
99 99
 
100
-    /**
101
-     * This deregisters a set of Data Migration Scripts that were previously registered with a specific dms_id
102
-     *
103
-     * @since 4.3.0
104
-     * @param string $identifier EE_Addon class name that this set of data migration scripts belongs to
105
-     * @return void
106
-     */
107
-    public static function deregister($identifier = '')
108
-    {
109
-        unset(self::$_settings[ $identifier ]);
110
-    }
100
+	/**
101
+	 * This deregisters a set of Data Migration Scripts that were previously registered with a specific dms_id
102
+	 *
103
+	 * @since 4.3.0
104
+	 * @param string $identifier EE_Addon class name that this set of data migration scripts belongs to
105
+	 * @return void
106
+	 */
107
+	public static function deregister($identifier = '')
108
+	{
109
+		unset(self::$_settings[ $identifier ]);
110
+	}
111 111
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Messages_Shortcode_Library.lib.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         }
74 74
 
75 75
         // make sure we don't register twice
76
-        if (isset(self::$_ee_messages_shortcode_registry[ $identifier ])) {
76
+        if (isset(self::$_ee_messages_shortcode_registry[$identifier])) {
77 77
             return;
78 78
         }
79 79
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
             );
96 96
         }
97 97
 
98
-        self::$_ee_messages_shortcode_registry[ $identifier ] = [
98
+        self::$_ee_messages_shortcode_registry[$identifier] = [
99 99
             'autoloadpaths'        => (array) $setup_args['autoloadpaths'],
100 100
             'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes'])
101 101
                 ? (array) $setup_args['list_type_shortcodes'] : [],
@@ -109,19 +109,19 @@  discard block
 block discarded – undo
109 109
         );
110 110
 
111 111
         // add below filters if the required callback is provided.
112
-        if (! empty($setup_args['msgr_validator_callback'])) {
112
+        if ( ! empty($setup_args['msgr_validator_callback'])) {
113 113
             add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2);
114 114
         }
115 115
 
116
-        if (! empty($setup_args['msgr_template_fields_callback'])) {
116
+        if ( ! empty($setup_args['msgr_template_fields_callback'])) {
117 117
             add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2);
118 118
         }
119 119
 
120
-        if (! empty($setup_args['valid_shortcodes_callback'])) {
120
+        if ( ! empty($setup_args['valid_shortcodes_callback'])) {
121 121
             add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2);
122 122
         }
123 123
 
124
-        if (! empty($setup_args['list_type_shortcodes'])) {
124
+        if ( ! empty($setup_args['list_type_shortcodes'])) {
125 125
             add_filter(
126 126
                 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes',
127 127
                 ['EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'],
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
      */
141 141
     public static function deregister($identifier = '')
142 142
     {
143
-        unset(self::$_ee_messages_shortcode_registry[ $identifier ]);
143
+        unset(self::$_ee_messages_shortcode_registry[$identifier]);
144 144
     }
145 145
 
146 146
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
     public static function register_msgs_autoload_paths(array $paths)
156 156
     {
157 157
 
158
-        if (! empty(self::$_ee_messages_shortcode_registry)) {
158
+        if ( ! empty(self::$_ee_messages_shortcode_registry)) {
159 159
             foreach (self::$_ee_messages_shortcode_registry as $st_reg) {
160 160
                 if (empty($st_reg['autoloadpaths'])) {
161 161
                     continue;
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         }
185 185
 
186 186
         foreach (self::$_ee_messages_shortcode_registry as $sc_reg) {
187
-            if (! empty($sc_reg['list_type_shortcodes'])) {
187
+            if ( ! empty($sc_reg['list_type_shortcodes'])) {
188 188
                 $original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']);
189 189
             }
190 190
         }
Please login to merge, or discard this patch.
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -10,183 +10,183 @@
 block discarded – undo
10 10
  */
11 11
 class EE_Register_Messages_Shortcode_Library implements EEI_Plugin_API
12 12
 {
13
-    /**
14
-     * holds values for registered messages shortcode libraries
15
-     *
16
-     * @var array
17
-     */
18
-    protected static $_ee_messages_shortcode_registry = [];
19
-
20
-
21
-    /**
22
-     * Helper method for registering a new shortcodes library class for the messages system.
23
-     *
24
-     * Note this is not used for adding shortcodes to existing libraries.  It's for registering anything
25
-     * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class.
26
-     *
27
-     * @param string $identifier                                                    What is the name of this shortcode
28
-     *                                                                              library
29
-     *                                                                              (e.g. 'question_list');
30
-     * @param array  $setup_args                                                    {
31
-     *                                                                              An array of arguments provided for
32
-     *                                                                              registering the new messages
33
-     *                                                                              shortcode library.
34
-     *
35
-     * @type array   $autoloadpaths                                                 An array of paths to add to the
36
-     *       messages autoloader for the new shortcode library class file.
37
-     * @type string  $msgr_validator_callback                                       Callback for a method that will
38
-     *       register the library with the messenger
39
-     *                                                                              _validator_config. Optional.
40
-     * @type string  $msgr_template_fields_callback                                 Callback for changing adding the
41
-     *                                                                              _template_fields property for
42
-     *                                                                              messenger. For example, the
43
-     *                                                                              shortcode library may add a new
44
-     *                                                                              field to the message templates.
45
-     *                                                                              Optional.
46
-     * @type string  $valid_shortcodes_callback                                     Callback for message types
47
-     *                                                                              _valid_shortcodes array setup.
48
-     *                                                                              Optional.
49
-     * @type array   $list_type_shortcodes                                          If there are any specific
50
-     *       shortcodes with this message shortcode library that should be considered "list type" then include them in
51
-     *       an array.  List Type shortcodes are shortcodes that have a corresponding field that indicates how they are
52
-     *       parsed. Optional.
53
-     * }
54
-     * @return void
55
-     * @throws EE_Error
56
-     * @throws EE_Error
57
-     * @since    4.3.0
58
-     *
59
-     */
60
-    public static function register($identifier = '', array $setup_args = [])
61
-    {
62
-
63
-        // required fields MUST be present, so let's make sure they are.
64
-        if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) {
65
-            throw new EE_Error(
66
-                esc_html__(
67
-                    'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"',
68
-                    'event_espresso'
69
-                )
70
-            );
71
-        }
72
-
73
-        // make sure we don't register twice
74
-        if (isset(self::$_ee_messages_shortcode_registry[ $identifier ])) {
75
-            return;
76
-        }
77
-
78
-        // make sure this was called in the right place!
79
-        if (
80
-            ! did_action('EE_Brewing_Regular___messages_caf')
81
-            || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
82
-        ) {
83
-            EE_Error::doing_it_wrong(
84
-                __METHOD__,
85
-                sprintf(
86
-                    esc_html__(
87
-                        'Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).',
88
-                        'event_espresso'
89
-                    ),
90
-                    $identifier
91
-                ),
92
-                '4.3.0'
93
-            );
94
-        }
95
-
96
-        self::$_ee_messages_shortcode_registry[ $identifier ] = [
97
-            'autoloadpaths'        => (array) $setup_args['autoloadpaths'],
98
-            'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes'])
99
-                ? (array) $setup_args['list_type_shortcodes'] : [],
100
-        ];
101
-
102
-        // add filters
103
-        add_filter(
104
-            'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
105
-            ['EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'],
106
-            10
107
-        );
108
-
109
-        // add below filters if the required callback is provided.
110
-        if (! empty($setup_args['msgr_validator_callback'])) {
111
-            add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2);
112
-        }
113
-
114
-        if (! empty($setup_args['msgr_template_fields_callback'])) {
115
-            add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2);
116
-        }
117
-
118
-        if (! empty($setup_args['valid_shortcodes_callback'])) {
119
-            add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2);
120
-        }
121
-
122
-        if (! empty($setup_args['list_type_shortcodes'])) {
123
-            add_filter(
124
-                'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes',
125
-                ['EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'],
126
-                10
127
-            );
128
-        }
129
-    }
130
-
131
-
132
-    /**
133
-     * This deregisters any messages shortcode library previously registered with the given name.
134
-     *
135
-     * @param string $identifier name used to register the shortcode library.
136
-     * @return  void
137
-     * @since    4.3.0
138
-     */
139
-    public static function deregister($identifier = '')
140
-    {
141
-        unset(self::$_ee_messages_shortcode_registry[ $identifier ]);
142
-    }
143
-
144
-
145
-    /**
146
-     * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
147
-     *
148
-     * @param array $paths array of paths to be checked by EE_messages autoloader.
149
-     * @return array
150
-     * @since    4.3.0
151
-     *
152
-     */
153
-    public static function register_msgs_autoload_paths(array $paths)
154
-    {
155
-
156
-        if (! empty(self::$_ee_messages_shortcode_registry)) {
157
-            foreach (self::$_ee_messages_shortcode_registry as $st_reg) {
158
-                if (empty($st_reg['autoloadpaths'])) {
159
-                    continue;
160
-                }
161
-                $paths = array_merge($paths, $st_reg['autoloadpaths']);
162
-            }
163
-        }
164
-
165
-        return $paths;
166
-    }
167
-
168
-
169
-    /**
170
-     * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes
171
-     * filter which is used to add additional list type shortcodes.
172
-     *
173
-     * @param array $original_shortcodes
174
-     * @return  array                                   Modifications to original shortcodes.
175
-     * @since 4.3.0
176
-     *
177
-     */
178
-    public static function register_list_type_shortcodes(array $original_shortcodes)
179
-    {
180
-        if (empty(self::$_ee_messages_shortcode_registry)) {
181
-            return $original_shortcodes;
182
-        }
183
-
184
-        foreach (self::$_ee_messages_shortcode_registry as $sc_reg) {
185
-            if (! empty($sc_reg['list_type_shortcodes'])) {
186
-                $original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']);
187
-            }
188
-        }
189
-
190
-        return $original_shortcodes;
191
-    }
13
+	/**
14
+	 * holds values for registered messages shortcode libraries
15
+	 *
16
+	 * @var array
17
+	 */
18
+	protected static $_ee_messages_shortcode_registry = [];
19
+
20
+
21
+	/**
22
+	 * Helper method for registering a new shortcodes library class for the messages system.
23
+	 *
24
+	 * Note this is not used for adding shortcodes to existing libraries.  It's for registering anything
25
+	 * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class.
26
+	 *
27
+	 * @param string $identifier                                                    What is the name of this shortcode
28
+	 *                                                                              library
29
+	 *                                                                              (e.g. 'question_list');
30
+	 * @param array  $setup_args                                                    {
31
+	 *                                                                              An array of arguments provided for
32
+	 *                                                                              registering the new messages
33
+	 *                                                                              shortcode library.
34
+	 *
35
+	 * @type array   $autoloadpaths                                                 An array of paths to add to the
36
+	 *       messages autoloader for the new shortcode library class file.
37
+	 * @type string  $msgr_validator_callback                                       Callback for a method that will
38
+	 *       register the library with the messenger
39
+	 *                                                                              _validator_config. Optional.
40
+	 * @type string  $msgr_template_fields_callback                                 Callback for changing adding the
41
+	 *                                                                              _template_fields property for
42
+	 *                                                                              messenger. For example, the
43
+	 *                                                                              shortcode library may add a new
44
+	 *                                                                              field to the message templates.
45
+	 *                                                                              Optional.
46
+	 * @type string  $valid_shortcodes_callback                                     Callback for message types
47
+	 *                                                                              _valid_shortcodes array setup.
48
+	 *                                                                              Optional.
49
+	 * @type array   $list_type_shortcodes                                          If there are any specific
50
+	 *       shortcodes with this message shortcode library that should be considered "list type" then include them in
51
+	 *       an array.  List Type shortcodes are shortcodes that have a corresponding field that indicates how they are
52
+	 *       parsed. Optional.
53
+	 * }
54
+	 * @return void
55
+	 * @throws EE_Error
56
+	 * @throws EE_Error
57
+	 * @since    4.3.0
58
+	 *
59
+	 */
60
+	public static function register($identifier = '', array $setup_args = [])
61
+	{
62
+
63
+		// required fields MUST be present, so let's make sure they are.
64
+		if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) {
65
+			throw new EE_Error(
66
+				esc_html__(
67
+					'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"',
68
+					'event_espresso'
69
+				)
70
+			);
71
+		}
72
+
73
+		// make sure we don't register twice
74
+		if (isset(self::$_ee_messages_shortcode_registry[ $identifier ])) {
75
+			return;
76
+		}
77
+
78
+		// make sure this was called in the right place!
79
+		if (
80
+			! did_action('EE_Brewing_Regular___messages_caf')
81
+			|| did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
82
+		) {
83
+			EE_Error::doing_it_wrong(
84
+				__METHOD__,
85
+				sprintf(
86
+					esc_html__(
87
+						'Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).',
88
+						'event_espresso'
89
+					),
90
+					$identifier
91
+				),
92
+				'4.3.0'
93
+			);
94
+		}
95
+
96
+		self::$_ee_messages_shortcode_registry[ $identifier ] = [
97
+			'autoloadpaths'        => (array) $setup_args['autoloadpaths'],
98
+			'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes'])
99
+				? (array) $setup_args['list_type_shortcodes'] : [],
100
+		];
101
+
102
+		// add filters
103
+		add_filter(
104
+			'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
105
+			['EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'],
106
+			10
107
+		);
108
+
109
+		// add below filters if the required callback is provided.
110
+		if (! empty($setup_args['msgr_validator_callback'])) {
111
+			add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2);
112
+		}
113
+
114
+		if (! empty($setup_args['msgr_template_fields_callback'])) {
115
+			add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2);
116
+		}
117
+
118
+		if (! empty($setup_args['valid_shortcodes_callback'])) {
119
+			add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2);
120
+		}
121
+
122
+		if (! empty($setup_args['list_type_shortcodes'])) {
123
+			add_filter(
124
+				'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes',
125
+				['EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'],
126
+				10
127
+			);
128
+		}
129
+	}
130
+
131
+
132
+	/**
133
+	 * This deregisters any messages shortcode library previously registered with the given name.
134
+	 *
135
+	 * @param string $identifier name used to register the shortcode library.
136
+	 * @return  void
137
+	 * @since    4.3.0
138
+	 */
139
+	public static function deregister($identifier = '')
140
+	{
141
+		unset(self::$_ee_messages_shortcode_registry[ $identifier ]);
142
+	}
143
+
144
+
145
+	/**
146
+	 * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter.
147
+	 *
148
+	 * @param array $paths array of paths to be checked by EE_messages autoloader.
149
+	 * @return array
150
+	 * @since    4.3.0
151
+	 *
152
+	 */
153
+	public static function register_msgs_autoload_paths(array $paths)
154
+	{
155
+
156
+		if (! empty(self::$_ee_messages_shortcode_registry)) {
157
+			foreach (self::$_ee_messages_shortcode_registry as $st_reg) {
158
+				if (empty($st_reg['autoloadpaths'])) {
159
+					continue;
160
+				}
161
+				$paths = array_merge($paths, $st_reg['autoloadpaths']);
162
+			}
163
+		}
164
+
165
+		return $paths;
166
+	}
167
+
168
+
169
+	/**
170
+	 * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes
171
+	 * filter which is used to add additional list type shortcodes.
172
+	 *
173
+	 * @param array $original_shortcodes
174
+	 * @return  array                                   Modifications to original shortcodes.
175
+	 * @since 4.3.0
176
+	 *
177
+	 */
178
+	public static function register_list_type_shortcodes(array $original_shortcodes)
179
+	{
180
+		if (empty(self::$_ee_messages_shortcode_registry)) {
181
+			return $original_shortcodes;
182
+		}
183
+
184
+		foreach (self::$_ee_messages_shortcode_registry as $sc_reg) {
185
+			if (! empty($sc_reg['list_type_shortcodes'])) {
186
+				$original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']);
187
+			}
188
+		}
189
+
190
+		return $original_shortcodes;
191
+	}
192 192
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Shortcode.lib.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         }
62 62
 
63 63
         // make sure we don't register twice
64
-        if (isset(self::$_settings[ $identifier ])) {
64
+        if (isset(self::$_settings[$identifier])) {
65 65
             return;
66 66
         }
67 67
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
             );
81 81
         }
82 82
         // setup $_settings array from incoming values.
83
-        self::$_settings[ $identifier ] = [
83
+        self::$_settings[$identifier] = [
84 84
             // array of full server paths to any EES_Shortcodes used by the shortcode
85 85
             'shortcode_paths' => isset($setup_args['shortcode_paths'])
86 86
                 ? (array) $setup_args['shortcode_paths']
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
     public static function instantiateAndAddToShortcodeCollection(CollectionInterface $shortcodes_collection)
135 135
     {
136 136
         foreach (self::$_settings as $settings) {
137
-            if (! empty($settings['shortcode_fqcns'])) {
137
+            if ( ! empty($settings['shortcode_fqcns'])) {
138 138
                 foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) {
139
-                    if (! class_exists($shortcode_fqcn)) {
139
+                    if ( ! class_exists($shortcode_fqcn)) {
140 140
                         throw new InvalidClassException(
141 141
                             sprintf(
142 142
                                 esc_html__(
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                             )
148 148
                         );
149 149
                     }
150
-                    if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
150
+                    if ( ! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
151 151
                         // register dependencies
152 152
                         EE_Dependency_Map::register_dependencies(
153 153
                             $shortcode_fqcn,
@@ -173,6 +173,6 @@  discard block
 block discarded – undo
173 173
      */
174 174
     public static function deregister($identifier = '')
175 175
     {
176
-        unset(self::$_settings[ $identifier ]);
176
+        unset(self::$_settings[$identifier]);
177 177
     }
178 178
 }
Please login to merge, or discard this patch.
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -19,159 +19,159 @@
 block discarded – undo
19 19
  */
20 20
 class EE_Register_Shortcode implements EEI_Plugin_API
21 21
 {
22
-    /**
23
-     * Holds values for registered shortcodes
24
-     *
25
-     * @var array
26
-     */
27
-    protected static $_settings = [];
22
+	/**
23
+	 * Holds values for registered shortcodes
24
+	 *
25
+	 * @var array
26
+	 */
27
+	protected static $_settings = [];
28 28
 
29 29
 
30
-    /**
31
-     *    Method for registering new EE_Shortcodes
32
-     *
33
-     * @param string $identifier    a unique identifier for this set of modules Required.
34
-     * @param array  $setup_args    an array of arguments provided for registering shortcodes Required.
35
-     * @type array shortcode_paths  an array of full server paths to folders containing any EES_Shortcodes
36
-     * @type array shortcode_fqcns  an array of fully qualified class names for any new shortcode classes to register.
37
-     *                              Shortcode classes should extend EspressoShortcode
38
-     *                              and be properly namespaced so they are autoloaded.
39
-     * @return void
40
-     * @throws EE_Error
41
-     * @since    4.3.0
42
-     * @since    4.9.46.rc.025  for the new `shortcode_fqcns` array argument.
43
-     */
44
-    public static function register($identifier = '', array $setup_args = [])
45
-    {
46
-        // required fields MUST be present, so let's make sure they are.
47
-        if (
48
-            empty($identifier)
49
-            || ! is_array($setup_args)
50
-            || (
51
-               empty($setup_args['shortcode_paths']))
52
-               && empty($setup_args['shortcode_fqcns'])
53
-        ) {
54
-            throw new EE_Error(
55
-                esc_html__(
56
-                    'In order to register Modules with EE_Register_Shortcode::register(), you must include a "shortcode_id" (a unique identifier for this set of shortcodes), and an array containing the following keys: "shortcode_paths" (an array of full server paths to folders that contain shortcodes, or to the shortcode files themselves)',
57
-                    'event_espresso'
58
-                )
59
-            );
60
-        }
30
+	/**
31
+	 *    Method for registering new EE_Shortcodes
32
+	 *
33
+	 * @param string $identifier    a unique identifier for this set of modules Required.
34
+	 * @param array  $setup_args    an array of arguments provided for registering shortcodes Required.
35
+	 * @type array shortcode_paths  an array of full server paths to folders containing any EES_Shortcodes
36
+	 * @type array shortcode_fqcns  an array of fully qualified class names for any new shortcode classes to register.
37
+	 *                              Shortcode classes should extend EspressoShortcode
38
+	 *                              and be properly namespaced so they are autoloaded.
39
+	 * @return void
40
+	 * @throws EE_Error
41
+	 * @since    4.3.0
42
+	 * @since    4.9.46.rc.025  for the new `shortcode_fqcns` array argument.
43
+	 */
44
+	public static function register($identifier = '', array $setup_args = [])
45
+	{
46
+		// required fields MUST be present, so let's make sure they are.
47
+		if (
48
+			empty($identifier)
49
+			|| ! is_array($setup_args)
50
+			|| (
51
+			   empty($setup_args['shortcode_paths']))
52
+			   && empty($setup_args['shortcode_fqcns'])
53
+		) {
54
+			throw new EE_Error(
55
+				esc_html__(
56
+					'In order to register Modules with EE_Register_Shortcode::register(), you must include a "shortcode_id" (a unique identifier for this set of shortcodes), and an array containing the following keys: "shortcode_paths" (an array of full server paths to folders that contain shortcodes, or to the shortcode files themselves)',
57
+					'event_espresso'
58
+				)
59
+			);
60
+		}
61 61
 
62
-        // make sure we don't register twice
63
-        if (isset(self::$_settings[ $identifier ])) {
64
-            return;
65
-        }
62
+		// make sure we don't register twice
63
+		if (isset(self::$_settings[ $identifier ])) {
64
+			return;
65
+		}
66 66
 
67
-        // make sure this was called in the right place!
68
-        if (
69
-            ! did_action('AHEE__EE_System__load_espresso_addons')
70
-            || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
71
-        ) {
72
-            EE_Error::doing_it_wrong(
73
-                __METHOD__,
74
-                esc_html__(
75
-                    'An attempt to register shortcodes has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register shortcodes.',
76
-                    'event_espresso'
77
-                ),
78
-                '4.3.0'
79
-            );
80
-        }
81
-        // setup $_settings array from incoming values.
82
-        self::$_settings[ $identifier ] = [
83
-            // array of full server paths to any EES_Shortcodes used by the shortcode
84
-            'shortcode_paths' => isset($setup_args['shortcode_paths'])
85
-                ? (array) $setup_args['shortcode_paths']
86
-                : [],
87
-            'shortcode_fqcns' => isset($setup_args['shortcode_fqcns'])
88
-                ? (array) $setup_args['shortcode_fqcns']
89
-                : [],
90
-        ];
91
-        // add to list of shortcodes to be registered
92
-        add_filter(
93
-            'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
94
-            ['EE_Register_Shortcode', 'add_shortcodes']
95
-        );
67
+		// make sure this was called in the right place!
68
+		if (
69
+			! did_action('AHEE__EE_System__load_espresso_addons')
70
+			|| did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
71
+		) {
72
+			EE_Error::doing_it_wrong(
73
+				__METHOD__,
74
+				esc_html__(
75
+					'An attempt to register shortcodes has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register shortcodes.',
76
+					'event_espresso'
77
+				),
78
+				'4.3.0'
79
+			);
80
+		}
81
+		// setup $_settings array from incoming values.
82
+		self::$_settings[ $identifier ] = [
83
+			// array of full server paths to any EES_Shortcodes used by the shortcode
84
+			'shortcode_paths' => isset($setup_args['shortcode_paths'])
85
+				? (array) $setup_args['shortcode_paths']
86
+				: [],
87
+			'shortcode_fqcns' => isset($setup_args['shortcode_fqcns'])
88
+				? (array) $setup_args['shortcode_fqcns']
89
+				: [],
90
+		];
91
+		// add to list of shortcodes to be registered
92
+		add_filter(
93
+			'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
94
+			['EE_Register_Shortcode', 'add_shortcodes']
95
+		);
96 96
 
97
-        add_filter(
98
-            'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
99
-            ['EE_Register_Shortcode', 'instantiateAndAddToShortcodeCollection']
100
-        );
101
-    }
97
+		add_filter(
98
+			'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
99
+			['EE_Register_Shortcode', 'instantiateAndAddToShortcodeCollection']
100
+		);
101
+	}
102 102
 
103 103
 
104
-    /**
105
-     * Filters the list of shortcodes to add ours.
106
-     * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg.
107
-     * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey'...)
108
-     *
109
-     * @param array $shortcodes_to_register array of paths to all shortcodes that require registering
110
-     * @return array
111
-     */
112
-    public static function add_shortcodes(array $shortcodes_to_register)
113
-    {
114
-        foreach (self::$_settings as $settings) {
115
-            $shortcodes_to_register = array_merge($shortcodes_to_register, $settings['shortcode_paths']);
116
-        }
117
-        return $shortcodes_to_register;
118
-    }
104
+	/**
105
+	 * Filters the list of shortcodes to add ours.
106
+	 * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg.
107
+	 * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey'...)
108
+	 *
109
+	 * @param array $shortcodes_to_register array of paths to all shortcodes that require registering
110
+	 * @return array
111
+	 */
112
+	public static function add_shortcodes(array $shortcodes_to_register)
113
+	{
114
+		foreach (self::$_settings as $settings) {
115
+			$shortcodes_to_register = array_merge($shortcodes_to_register, $settings['shortcode_paths']);
116
+		}
117
+		return $shortcodes_to_register;
118
+	}
119 119
 
120 120
 
121
-    /**
122
-     * Hooks into
123
-     * FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection and
124
-     * registers any provided shortcode fully qualified class names.
125
-     *
126
-     * @param CollectionInterface $shortcodes_collection
127
-     * @return CollectionInterface
128
-     * @throws InvalidArgumentException
129
-     * @throws InvalidClassException
130
-     * @throws InvalidDataTypeException
131
-     * @throws InvalidInterfaceException
132
-     */
133
-    public static function instantiateAndAddToShortcodeCollection(CollectionInterface $shortcodes_collection)
134
-    {
135
-        foreach (self::$_settings as $settings) {
136
-            if (! empty($settings['shortcode_fqcns'])) {
137
-                foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) {
138
-                    if (! class_exists($shortcode_fqcn)) {
139
-                        throw new InvalidClassException(
140
-                            sprintf(
141
-                                esc_html__(
142
-                                    'Are you sure %s is the right fully qualified class name for the shortcode class?',
143
-                                    'event_espresso'
144
-                                ),
145
-                                $shortcode_fqcn
146
-                            )
147
-                        );
148
-                    }
149
-                    if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
150
-                        // register dependencies
151
-                        EE_Dependency_Map::register_dependencies(
152
-                            $shortcode_fqcn,
153
-                            [
154
-                                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
155
-                            ]
156
-                        );
157
-                    }
158
-                    $shortcodes_collection->add(LoaderFactory::getLoader()->getShared($shortcode_fqcn));
159
-                }
160
-            }
161
-        }
162
-        return $shortcodes_collection;
163
-    }
121
+	/**
122
+	 * Hooks into
123
+	 * FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection and
124
+	 * registers any provided shortcode fully qualified class names.
125
+	 *
126
+	 * @param CollectionInterface $shortcodes_collection
127
+	 * @return CollectionInterface
128
+	 * @throws InvalidArgumentException
129
+	 * @throws InvalidClassException
130
+	 * @throws InvalidDataTypeException
131
+	 * @throws InvalidInterfaceException
132
+	 */
133
+	public static function instantiateAndAddToShortcodeCollection(CollectionInterface $shortcodes_collection)
134
+	{
135
+		foreach (self::$_settings as $settings) {
136
+			if (! empty($settings['shortcode_fqcns'])) {
137
+				foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) {
138
+					if (! class_exists($shortcode_fqcn)) {
139
+						throw new InvalidClassException(
140
+							sprintf(
141
+								esc_html__(
142
+									'Are you sure %s is the right fully qualified class name for the shortcode class?',
143
+									'event_espresso'
144
+								),
145
+								$shortcode_fqcn
146
+							)
147
+						);
148
+					}
149
+					if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
150
+						// register dependencies
151
+						EE_Dependency_Map::register_dependencies(
152
+							$shortcode_fqcn,
153
+							[
154
+								'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
155
+							]
156
+						);
157
+					}
158
+					$shortcodes_collection->add(LoaderFactory::getLoader()->getShared($shortcode_fqcn));
159
+				}
160
+			}
161
+		}
162
+		return $shortcodes_collection;
163
+	}
164 164
 
165 165
 
166
-    /**
167
-     * This deregisters a shortcode that was previously registered with a specific $identifier.
168
-     *
169
-     * @param string $identifier the name for the shortcode that was previously registered
170
-     * @return void
171
-     * @since    4.3.0
172
-     */
173
-    public static function deregister($identifier = '')
174
-    {
175
-        unset(self::$_settings[ $identifier ]);
176
-    }
166
+	/**
167
+	 * This deregisters a shortcode that was previously registered with a specific $identifier.
168
+	 *
169
+	 * @param string $identifier the name for the shortcode that was previously registered
170
+	 * @return void
171
+	 * @since    4.3.0
172
+	 */
173
+	public static function deregister($identifier = '')
174
+	{
175
+		unset(self::$_settings[ $identifier ]);
176
+	}
177 177
 }
Please login to merge, or discard this patch.
core/EED_Module.module.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
     protected static function getRequest()
134 134
     {
135 135
         static $request;
136
-        if (! $request instanceof RequestInterface) {
136
+        if ( ! $request instanceof RequestInterface) {
137 137
             $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
138 138
         }
139 139
         return $request;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     protected static function getResponse()
148 148
     {
149 149
         static $response;
150
-        if (! $response instanceof RequestInterface) {
150
+        if ( ! $response instanceof RequestInterface) {
151 151
             $response = LoaderFactory::getLoader()->getShared(ResponseInterface::class);
152 152
         }
153 153
         return $response;
Please login to merge, or discard this patch.
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -14,141 +14,141 @@
 block discarded – undo
14 14
  */
15 15
 abstract class EED_Module extends EE_Configurable implements ResettableInterface
16 16
 {
17
-    /**
18
-     * rendered output to be returned to WP
19
-     *
20
-     * @var    string $output
21
-     */
22
-    protected $output = '';
23
-
24
-    /**
25
-     * the current active espresso template theme
26
-     *
27
-     * @var    string $theme
28
-     */
29
-    protected $theme = '';
30
-
31
-
32
-    /**
33
-     * @return void
34
-     */
35
-    public static function reset()
36
-    {
37
-        $module_name = get_called_class();
38
-        new $module_name();
39
-    }
40
-
41
-
42
-    /**
43
-     *    set_hooks - for hooking into EE Core, other modules, etc
44
-     *
45
-     * @access    public
46
-     * @return    void
47
-     */
48
-    public static function set_hooks()
49
-    {
50
-    }
51
-
52
-
53
-    /**
54
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
55
-     *
56
-     * @access    public
57
-     * @return    void
58
-     */
59
-    public static function set_hooks_admin()
60
-    {
61
-    }
62
-
63
-
64
-    /**
65
-     *    run - initial module setup
66
-     *    this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
67
-     *
68
-     * @access    public
69
-     * @var            WP $WP
70
-     * @return    void
71
-     */
72
-    abstract public function run($WP);
73
-
74
-
75
-    /**
76
-     * EED_Module constructor.
77
-     */
78
-    final public function __construct()
79
-    {
80
-        $this->theme = EE_Config::get_current_theme();
81
-        $module_name = $this->module_name();
82
-        EE_Registry::instance()->modules->{$module_name} = $this;
83
-    }
84
-
85
-
86
-    /**
87
-     * @param string $module_name
88
-     * @return EED_Module|mixed
89
-     * @throws EE_Error
90
-     * @throws ReflectionException
91
-     */
92
-    protected static function get_instance($module_name = '')
93
-    {
94
-        $module_name = ! empty($module_name)
95
-            ? $module_name
96
-            : get_called_class();
97
-        if (
98
-            ! isset(EE_Registry::instance()->modules->{$module_name})
99
-            || ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module
100
-        ) {
101
-            EE_Registry::instance()->add_module($module_name);
102
-        }
103
-        return EE_Registry::instance()->get_module($module_name);
104
-    }
105
-
106
-
107
-    /**
108
-     *    module_name
109
-     *
110
-     * @access    public
111
-     * @return    string
112
-     */
113
-    public function module_name()
114
-    {
115
-        return get_class($this);
116
-    }
117
-
118
-
119
-    /**
120
-     * @return string
121
-     */
122
-    public function theme()
123
-    {
124
-        return $this->theme;
125
-    }
126
-
127
-
128
-    /**
129
-     * @return RequestInterface
130
-     * @since   4.10.14.p
131
-     */
132
-    protected static function getRequest()
133
-    {
134
-        static $request;
135
-        if (! $request instanceof RequestInterface) {
136
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
137
-        }
138
-        return $request;
139
-    }
140
-
141
-
142
-    /**
143
-     * @return ResponseInterface
144
-     * @since   4.10.14.p
145
-     */
146
-    protected static function getResponse()
147
-    {
148
-        static $response;
149
-        if (! $response instanceof RequestInterface) {
150
-            $response = LoaderFactory::getLoader()->getShared(ResponseInterface::class);
151
-        }
152
-        return $response;
153
-    }
17
+	/**
18
+	 * rendered output to be returned to WP
19
+	 *
20
+	 * @var    string $output
21
+	 */
22
+	protected $output = '';
23
+
24
+	/**
25
+	 * the current active espresso template theme
26
+	 *
27
+	 * @var    string $theme
28
+	 */
29
+	protected $theme = '';
30
+
31
+
32
+	/**
33
+	 * @return void
34
+	 */
35
+	public static function reset()
36
+	{
37
+		$module_name = get_called_class();
38
+		new $module_name();
39
+	}
40
+
41
+
42
+	/**
43
+	 *    set_hooks - for hooking into EE Core, other modules, etc
44
+	 *
45
+	 * @access    public
46
+	 * @return    void
47
+	 */
48
+	public static function set_hooks()
49
+	{
50
+	}
51
+
52
+
53
+	/**
54
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
55
+	 *
56
+	 * @access    public
57
+	 * @return    void
58
+	 */
59
+	public static function set_hooks_admin()
60
+	{
61
+	}
62
+
63
+
64
+	/**
65
+	 *    run - initial module setup
66
+	 *    this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
67
+	 *
68
+	 * @access    public
69
+	 * @var            WP $WP
70
+	 * @return    void
71
+	 */
72
+	abstract public function run($WP);
73
+
74
+
75
+	/**
76
+	 * EED_Module constructor.
77
+	 */
78
+	final public function __construct()
79
+	{
80
+		$this->theme = EE_Config::get_current_theme();
81
+		$module_name = $this->module_name();
82
+		EE_Registry::instance()->modules->{$module_name} = $this;
83
+	}
84
+
85
+
86
+	/**
87
+	 * @param string $module_name
88
+	 * @return EED_Module|mixed
89
+	 * @throws EE_Error
90
+	 * @throws ReflectionException
91
+	 */
92
+	protected static function get_instance($module_name = '')
93
+	{
94
+		$module_name = ! empty($module_name)
95
+			? $module_name
96
+			: get_called_class();
97
+		if (
98
+			! isset(EE_Registry::instance()->modules->{$module_name})
99
+			|| ! EE_Registry::instance()->modules->{$module_name} instanceof EED_Module
100
+		) {
101
+			EE_Registry::instance()->add_module($module_name);
102
+		}
103
+		return EE_Registry::instance()->get_module($module_name);
104
+	}
105
+
106
+
107
+	/**
108
+	 *    module_name
109
+	 *
110
+	 * @access    public
111
+	 * @return    string
112
+	 */
113
+	public function module_name()
114
+	{
115
+		return get_class($this);
116
+	}
117
+
118
+
119
+	/**
120
+	 * @return string
121
+	 */
122
+	public function theme()
123
+	{
124
+		return $this->theme;
125
+	}
126
+
127
+
128
+	/**
129
+	 * @return RequestInterface
130
+	 * @since   4.10.14.p
131
+	 */
132
+	protected static function getRequest()
133
+	{
134
+		static $request;
135
+		if (! $request instanceof RequestInterface) {
136
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
137
+		}
138
+		return $request;
139
+	}
140
+
141
+
142
+	/**
143
+	 * @return ResponseInterface
144
+	 * @since   4.10.14.p
145
+	 */
146
+	protected static function getResponse()
147
+	{
148
+		static $response;
149
+		if (! $response instanceof RequestInterface) {
150
+			$response = LoaderFactory::getLoader()->getShared(ResponseInterface::class);
151
+		}
152
+		return $response;
153
+	}
154 154
 }
Please login to merge, or discard this patch.