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