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