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