Completed
Branch updates-from-cafe (85364e)
by
unknown
09:54 queued 02:28
created
caffeinated/core/domain/services/pue/RegisterAddonPUE.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -12,98 +12,98 @@
 block discarded – undo
12 12
 
13 13
 class RegisterAddonPUE
14 14
 {
15
-    /**
16
-     * @var array
17
-     */
18
-    private static $addon_api_settings;
15
+	/**
16
+	 * @var array
17
+	 */
18
+	private static $addon_api_settings;
19 19
 
20 20
 
21
-    public static function registerPUE(
22
-        array $addon_api_settings,
23
-        string $addon_name,
24
-        string $class_name,
25
-        array $addon_args
26
-    ): array {
27
-        if (! empty($addon_args['pue_options'])) {
28
-            $addon_api_settings[ $addon_name ]['pue_options'] = [
29
-                'pue_plugin_slug' => isset($addon_args['pue_options']['pue_plugin_slug'])
30
-                    ? (string) $addon_args['pue_options']['pue_plugin_slug']
31
-                    : 'espresso_' . strtolower($class_name),
32
-                'plugin_basename' => isset($addon_args['pue_options']['plugin_basename'])
33
-                    ? (string) $addon_args['pue_options']['plugin_basename']
34
-                    : plugin_basename($addon_args['main_file_path']),
35
-                'checkPeriod'     => isset($addon_args['pue_options']['checkPeriod'])
36
-                    ? (string) $addon_args['pue_options']['checkPeriod']
37
-                    : '24',
38
-                'use_wp_update'   => isset($addon_args['pue_options']['use_wp_update'])
39
-                    ? (string) $addon_args['pue_options']['use_wp_update']
40
-                    : false,
41
-            ];
42
-            add_action(
43
-                'AHEE__EE_System__brew_espresso__after_pue_init',
44
-                [RegisterAddonPUE::class, 'loadPueUpdate']
45
-            );
46
-        }
47
-        RegisterAddonPUE::$addon_api_settings = $addon_api_settings;
48
-        return $addon_api_settings;
49
-    }
21
+	public static function registerPUE(
22
+		array $addon_api_settings,
23
+		string $addon_name,
24
+		string $class_name,
25
+		array $addon_args
26
+	): array {
27
+		if (! empty($addon_args['pue_options'])) {
28
+			$addon_api_settings[ $addon_name ]['pue_options'] = [
29
+				'pue_plugin_slug' => isset($addon_args['pue_options']['pue_plugin_slug'])
30
+					? (string) $addon_args['pue_options']['pue_plugin_slug']
31
+					: 'espresso_' . strtolower($class_name),
32
+				'plugin_basename' => isset($addon_args['pue_options']['plugin_basename'])
33
+					? (string) $addon_args['pue_options']['plugin_basename']
34
+					: plugin_basename($addon_args['main_file_path']),
35
+				'checkPeriod'     => isset($addon_args['pue_options']['checkPeriod'])
36
+					? (string) $addon_args['pue_options']['checkPeriod']
37
+					: '24',
38
+				'use_wp_update'   => isset($addon_args['pue_options']['use_wp_update'])
39
+					? (string) $addon_args['pue_options']['use_wp_update']
40
+					: false,
41
+			];
42
+			add_action(
43
+				'AHEE__EE_System__brew_espresso__after_pue_init',
44
+				[RegisterAddonPUE::class, 'loadPueUpdate']
45
+			);
46
+		}
47
+		RegisterAddonPUE::$addon_api_settings = $addon_api_settings;
48
+		return $addon_api_settings;
49
+	}
50 50
 
51 51
 
52
-    public static function setAddonPueSlug(EE_Addon $addon, string $addon_name)
53
-    {
54
-        // setup the add-on's pue_slug if we have one.
55
-        if (! empty($addon_api_settings[ $addon_name ]['pue_options']['pue_plugin_slug'])) {
56
-            $addon->setPueSlug($addon_api_settings[ $addon_name ]['pue_options']['pue_plugin_slug']);
57
-        }
58
-    }
52
+	public static function setAddonPueSlug(EE_Addon $addon, string $addon_name)
53
+	{
54
+		// setup the add-on's pue_slug if we have one.
55
+		if (! empty($addon_api_settings[ $addon_name ]['pue_options']['pue_plugin_slug'])) {
56
+			$addon->setPueSlug($addon_api_settings[ $addon_name ]['pue_options']['pue_plugin_slug']);
57
+		}
58
+	}
59 59
 
60 60
 
61
-    /**
62
-     *    load_pue_update - Update notifications
63
-     *
64
-     * @return void
65
-     * @throws InvalidArgumentException
66
-     * @throws InvalidDataTypeException
67
-     * @throws InvalidInterfaceException
68
-     */
69
-    public static function loadPueUpdate()
70
-    {
71
-        // PUE client existence
72
-        if (! is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) {
73
-            return;
74
-        }
61
+	/**
62
+	 *    load_pue_update - Update notifications
63
+	 *
64
+	 * @return void
65
+	 * @throws InvalidArgumentException
66
+	 * @throws InvalidDataTypeException
67
+	 * @throws InvalidInterfaceException
68
+	 */
69
+	public static function loadPueUpdate()
70
+	{
71
+		// PUE client existence
72
+		if (! is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) {
73
+			return;
74
+		}
75 75
 
76
-        /** @var EE_Network_Config $network_config */
77
-        $network_config = LoaderFactory::getLoader()->getShared('EE_Network_Config');
78
-        // load PUE client
79
-        require_once EE_THIRD_PARTY . 'pue/pue-client.php';
80
-        $license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com';
81
-        // cycle thru settings
82
-        foreach (RegisterAddonPUE::$addon_api_settings as $settings) {
83
-            if (empty($settings['pue_options'])) {
84
-                continue;
85
-            }
86
-            // initiate the class and start the plugin update engine!
87
-            new PluginUpdateEngineChecker(
88
-            // host file URL
89
-                $license_server,
90
-                // plugin slug(s)
91
-                [
92
-                    'premium'    => ['p' => $settings['pue_options']['pue_plugin_slug']],
93
-                    'prerelease' => ['beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'],
94
-                ],
95
-                // options
96
-                [
97
-                    'apikey'            => $network_config->core->site_license_key,
98
-                    'lang_domain'       => 'event_espresso',
99
-                    'checkPeriod'       => $settings['pue_options']['checkPeriod'],
100
-                    'option_key'        => 'ee_site_license_key',
101
-                    'options_page_slug' => 'event_espresso',
102
-                    'plugin_basename'   => $settings['pue_options']['plugin_basename'],
103
-                    // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
104
-                    'use_wp_update'     => $settings['pue_options']['use_wp_update'],
105
-                ]
106
-            );
107
-        }
108
-    }
76
+		/** @var EE_Network_Config $network_config */
77
+		$network_config = LoaderFactory::getLoader()->getShared('EE_Network_Config');
78
+		// load PUE client
79
+		require_once EE_THIRD_PARTY . 'pue/pue-client.php';
80
+		$license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com';
81
+		// cycle thru settings
82
+		foreach (RegisterAddonPUE::$addon_api_settings as $settings) {
83
+			if (empty($settings['pue_options'])) {
84
+				continue;
85
+			}
86
+			// initiate the class and start the plugin update engine!
87
+			new PluginUpdateEngineChecker(
88
+			// host file URL
89
+				$license_server,
90
+				// plugin slug(s)
91
+				[
92
+					'premium'    => ['p' => $settings['pue_options']['pue_plugin_slug']],
93
+					'prerelease' => ['beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'],
94
+				],
95
+				// options
96
+				[
97
+					'apikey'            => $network_config->core->site_license_key,
98
+					'lang_domain'       => 'event_espresso',
99
+					'checkPeriod'       => $settings['pue_options']['checkPeriod'],
100
+					'option_key'        => 'ee_site_license_key',
101
+					'options_page_slug' => 'event_espresso',
102
+					'plugin_basename'   => $settings['pue_options']['plugin_basename'],
103
+					// if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
104
+					'use_wp_update'     => $settings['pue_options']['use_wp_update'],
105
+				]
106
+			);
107
+		}
108
+	}
109 109
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
         string $class_name,
25 25
         array $addon_args
26 26
     ): array {
27
-        if (! empty($addon_args['pue_options'])) {
28
-            $addon_api_settings[ $addon_name ]['pue_options'] = [
27
+        if ( ! empty($addon_args['pue_options'])) {
28
+            $addon_api_settings[$addon_name]['pue_options'] = [
29 29
                 'pue_plugin_slug' => isset($addon_args['pue_options']['pue_plugin_slug'])
30 30
                     ? (string) $addon_args['pue_options']['pue_plugin_slug']
31
-                    : 'espresso_' . strtolower($class_name),
31
+                    : 'espresso_'.strtolower($class_name),
32 32
                 'plugin_basename' => isset($addon_args['pue_options']['plugin_basename'])
33 33
                     ? (string) $addon_args['pue_options']['plugin_basename']
34 34
                     : plugin_basename($addon_args['main_file_path']),
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
     public static function setAddonPueSlug(EE_Addon $addon, string $addon_name)
53 53
     {
54 54
         // setup the add-on's pue_slug if we have one.
55
-        if (! empty($addon_api_settings[ $addon_name ]['pue_options']['pue_plugin_slug'])) {
56
-            $addon->setPueSlug($addon_api_settings[ $addon_name ]['pue_options']['pue_plugin_slug']);
55
+        if ( ! empty($addon_api_settings[$addon_name]['pue_options']['pue_plugin_slug'])) {
56
+            $addon->setPueSlug($addon_api_settings[$addon_name]['pue_options']['pue_plugin_slug']);
57 57
         }
58 58
     }
59 59
 
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
     public static function loadPueUpdate()
70 70
     {
71 71
         // PUE client existence
72
-        if (! is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) {
72
+        if ( ! is_readable(EE_THIRD_PARTY.'pue/pue-client.php')) {
73 73
             return;
74 74
         }
75 75
 
76 76
         /** @var EE_Network_Config $network_config */
77 77
         $network_config = LoaderFactory::getLoader()->getShared('EE_Network_Config');
78 78
         // load PUE client
79
-        require_once EE_THIRD_PARTY . 'pue/pue-client.php';
79
+        require_once EE_THIRD_PARTY.'pue/pue-client.php';
80 80
         $license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com';
81 81
         // cycle thru settings
82 82
         foreach (RegisterAddonPUE::$addon_api_settings as $settings) {
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                 // plugin slug(s)
91 91
                 [
92 92
                     'premium'    => ['p' => $settings['pue_options']['pue_plugin_slug']],
93
-                    'prerelease' => ['beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'],
93
+                    'prerelease' => ['beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'],
94 94
                 ],
95 95
                 // options
96 96
                 [
Please login to merge, or discard this patch.
caffeinated/core/domain/services/pue/StatsGatherer.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             ]
168 168
         );
169 169
         // remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
170
-        return array_filter($stats, function ($value) {
170
+        return array_filter($stats, function($value) {
171 171
             return $value !== null;
172 172
         });
173 173
     }
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
             );
274 274
             if ($active_payment_methods) {
275 275
                 foreach ($active_payment_methods as $payment_method) {
276
-                    $payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
276
+                    $payment_method_stats[$payment_method->name().'_active_payment_method'] = 1;
277 277
                 }
278 278
             }
279 279
         } catch (Exception $e) {
@@ -292,9 +292,9 @@  discard block
 block discarded – undo
292 292
     {
293 293
         $activeAddons = [];
294 294
         $addOns       = EE_Registry::instance()->addons;
295
-        if (! empty($addOns)) {
295
+        if ( ! empty($addOns)) {
296 296
             foreach ($addOns as $addon) {
297
-                $activeAddons[] = $addon->name() . '@' . $addon->version();
297
+                $activeAddons[] = $addon->name().'@'.$addon->version();
298 298
             }
299 299
         }
300 300
         return implode(',', $activeAddons);
Please login to merge, or discard this patch.
Indentation   +265 added lines, -265 removed lines patch added patch discarded remove patch
@@ -15,288 +15,288 @@
 block discarded – undo
15 15
 
16 16
 class StatsGatherer
17 17
 {
18
-    public const COUNT_ALL_EVENTS                 = 'event';
18
+	public const COUNT_ALL_EVENTS                 = 'event';
19 19
 
20
-    public const COUNT_ACTIVE_EVENTS              = 'active_event';
20
+	public const COUNT_ACTIVE_EVENTS              = 'active_event';
21 21
 
22
-    public const COUNT_DATETIMES                  = 'datetime';
22
+	public const COUNT_DATETIMES                  = 'datetime';
23 23
 
24
-    public const COUNT_TICKETS                    = 'ticket';
24
+	public const COUNT_TICKETS                    = 'ticket';
25 25
 
26
-    public const COUNT_DATETIMES_SOLD             = 'datetime_sold';
26
+	public const COUNT_DATETIMES_SOLD             = 'datetime_sold';
27 27
 
28
-    public const COUNT_TICKETS_FREE               = 'free_ticket';
28
+	public const COUNT_TICKETS_FREE               = 'free_ticket';
29 29
 
30
-    public const COUNT_TICKETS_PAID               = 'paid_ticket';
30
+	public const COUNT_TICKETS_PAID               = 'paid_ticket';
31 31
 
32
-    public const COUNT_TICKETS_SOLD               = 'ticket_sold';
32
+	public const COUNT_TICKETS_SOLD               = 'ticket_sold';
33 33
 
34
-    public const COUNT_REGISTRATIONS_APPROVED     = 'registrations_approved';
34
+	public const COUNT_REGISTRATIONS_APPROVED     = 'registrations_approved';
35 35
 
36
-    public const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved';
36
+	public const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved';
37 37
 
38
-    public const COUNT_REGISTRATIONS_PENDING      = 'registrations_pending';
38
+	public const COUNT_REGISTRATIONS_PENDING      = 'registrations_pending';
39 39
 
40
-    public const COUNT_REGISTRATIONS_INCOMPLETE   = 'registrations_incomplete';
40
+	public const COUNT_REGISTRATIONS_INCOMPLETE   = 'registrations_incomplete';
41 41
 
42
-    public const COUNT_REGISTRATIONS_ALL          = 'registrations_all';
42
+	public const COUNT_REGISTRATIONS_ALL          = 'registrations_all';
43 43
 
44
-    public const COUNT_REGISTRATIONS_CANCELLED    = 'registrations_cancelled';
44
+	public const COUNT_REGISTRATIONS_CANCELLED    = 'registrations_cancelled';
45 45
 
46
-    public const COUNT_REGISTRATIONS_DECLINED     = 'registrations_declined';
46
+	public const COUNT_REGISTRATIONS_DECLINED     = 'registrations_declined';
47 47
 
48
-    public const SUM_TRANSACTIONS_COMPLETE_TOTAL  = 'transactions_complete_total_sum';
48
+	public const SUM_TRANSACTIONS_COMPLETE_TOTAL  = 'transactions_complete_total_sum';
49 49
 
50
-    public const SUM_TRANSACTIONS_ALL_PAID        = 'transactions_all_paid';
50
+	public const SUM_TRANSACTIONS_ALL_PAID        = 'transactions_all_paid';
51 51
 
52
-    public const INFO_SITE_CURRENCY               = 'site_currency';
52
+	public const INFO_SITE_CURRENCY               = 'site_currency';
53 53
 
54 54
 
55
-    /**
56
-     * @var EEM_Payment_Method
57
-     */
58
-    private $payment_method_model;
59
-
60
-
61
-    /**
62
-     * @var EEM_Event
63
-     */
64
-    private $event_model;
65
-
66
-    /**
67
-     * @var EEM_Datetime
68
-     */
69
-    private $datetime_model;
70
-
71
-
72
-    /**
73
-     * @var EEM_Ticket
74
-     */
75
-    private $ticket_model;
76
-
77
-
78
-    /**
79
-     * @var EEM_Registration
80
-     */
81
-    private $registration_model;
82
-
83
-
84
-    /**
85
-     * @var EEM_Transaction
86
-     */
87
-    private $transaction_model;
88
-
89
-
90
-    /**
91
-     * @var EE_Config
92
-     */
93
-    private $config;
94
-
95
-
96
-    /**
97
-     * StatsGatherer constructor.
98
-     *
99
-     * @param EEM_Payment_Method $payment_method_model
100
-     * @param EEM_Event          $event_model
101
-     * @param EEM_Datetime       $datetime_model
102
-     * @param EEM_Ticket         $ticket_model
103
-     * @param EEM_Registration   $registration_model
104
-     * @param EEM_Transaction    $transaction_model
105
-     * @param EE_Config          $config
106
-     */
107
-    public function __construct(
108
-        EEM_Payment_Method $payment_method_model,
109
-        EEM_Event $event_model,
110
-        EEM_Datetime $datetime_model,
111
-        EEM_Ticket $ticket_model,
112
-        EEM_Registration $registration_model,
113
-        EEM_Transaction $transaction_model,
114
-        EE_Config $config
115
-    ) {
116
-        $this->payment_method_model = $payment_method_model;
117
-        $this->event_model          = $event_model;
118
-        $this->datetime_model       = $datetime_model;
119
-        $this->ticket_model         = $ticket_model;
120
-        $this->registration_model   = $registration_model;
121
-        $this->transaction_model    = $transaction_model;
122
-        $this->config               = $config;
123
-    }
124
-
125
-
126
-    /**
127
-     * Return the stats array for PUE UXIP stats.
128
-     *
129
-     * @return array
130
-     */
131
-    public function stats(): array
132
-    {
133
-        global $wp_version;
134
-        $stats = $this->paymentMethodStats();
135
-        // a-ok so let's setup our stats.
136
-        $stats = array_merge(
137
-            $stats,
138
-            [
139
-                'is_multisite'                    => is_multisite() && is_main_site(),
140
-                'active_theme'                    => $this->getActiveThemeStat(),
141
-                'ee4_all_events_count'            => $this->getCountFor(self::COUNT_ALL_EVENTS),
142
-                'ee4_active_events_count'         => $this->getCountFor(self::COUNT_ACTIVE_EVENTS),
143
-                'all_dtts_count'                  => $this->getCountFor(self::COUNT_DATETIMES),
144
-                'dtt_sold'                        => $this->getCountFor(self::COUNT_DATETIMES_SOLD),
145
-                'all_tkt_count'                   => $this->getCountFor(self::COUNT_TICKETS),
146
-                'free_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_FREE),
147
-                'paid_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_PAID),
148
-                'tkt_sold'                        => $this->getCountFor(self::COUNT_TICKETS_SOLD),
149
-                'approve_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED),
150
-                'pending_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING),
151
-                'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED),
152
-                'incomplete_registration_count'   => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE),
153
-                'cancelled_registration_count'    => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED),
154
-                'declined_registration_count'     => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED),
155
-                'all_registration_count'          => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL),
156
-                'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL),
157
-                'all_transaction_paid_sum'        => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID),
158
-                self::INFO_SITE_CURRENCY          => $this->config->currency instanceof EE_Currency_Config
159
-                    ? $this->config->currency->code
160
-                    : 'unknown',
161
-                'phpversion'                      => implode(
162
-                    '.',
163
-                    [PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION]
164
-                ),
165
-                'wpversion'                       => $wp_version,
166
-                'active_addons'                   => $this->getActiveAddons(),
167
-            ]
168
-        );
169
-        // remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
170
-        return array_filter($stats, function ($value) {
171
-            return $value !== null;
172
-        });
173
-    }
174
-
175
-
176
-    /**
177
-     * @param string $which enum (@see constants prefixed with COUNT)
178
-     * @return int|null
179
-     */
180
-    private function getCountFor(string $which): ?int
181
-    {
182
-        try {
183
-            switch ($which) {
184
-                case self::COUNT_ALL_EVENTS:
185
-                    $count = $this->event_model->count();
186
-                    break;
187
-                case self::COUNT_TICKETS:
188
-                    $count = $this->ticket_model->count();
189
-                    break;
190
-                case self::COUNT_DATETIMES:
191
-                    $count = $this->datetime_model->count();
192
-                    break;
193
-                case self::COUNT_ACTIVE_EVENTS:
194
-                    $count = $this->event_model->get_active_events([], true);
195
-                    break;
196
-                case self::COUNT_DATETIMES_SOLD:
197
-                    $count = $this->datetime_model->sum([], 'DTT_sold');
198
-                    break;
199
-                case self::COUNT_TICKETS_FREE:
200
-                    $count = $this->ticket_model->count([['TKT_price' => 0]]);
201
-                    break;
202
-                case self::COUNT_TICKETS_PAID:
203
-                    $count = $this->ticket_model->count([['TKT_price' => ['>', 0]]]);
204
-                    break;
205
-                case self::COUNT_TICKETS_SOLD:
206
-                    $count = $this->ticket_model->sum([], 'TKT_sold');
207
-                    break;
208
-                case self::COUNT_REGISTRATIONS_ALL:
209
-                    $count = $this->registration_model->count();
210
-                    break;
211
-                case self::COUNT_REGISTRATIONS_CANCELLED:
212
-                    $count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_cancelled]]);
213
-                    break;
214
-                case self::COUNT_REGISTRATIONS_INCOMPLETE:
215
-                    $count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_incomplete]]);
216
-                    break;
217
-                case self::COUNT_REGISTRATIONS_NOT_APPROVED:
218
-                    $count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_not_approved]]);
219
-                    break;
220
-                case self::COUNT_REGISTRATIONS_DECLINED:
221
-                    $count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_declined]]);
222
-                    break;
223
-                case self::COUNT_REGISTRATIONS_PENDING:
224
-                    $count = $this->registration_model->count(
225
-                        [['STS_ID' => EEM_Registration::status_id_pending_payment]]
226
-                    );
227
-                    break;
228
-                case self::COUNT_REGISTRATIONS_APPROVED:
229
-                    $count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_approved]]);
230
-                    break;
231
-                case self::SUM_TRANSACTIONS_COMPLETE_TOTAL:
232
-                    $count = $this->transaction_model->sum(
233
-                        [['STS_ID' => EEM_Transaction::complete_status_code]],
234
-                        'TXN_total'
235
-                    );
236
-                    break;
237
-                case self::SUM_TRANSACTIONS_ALL_PAID:
238
-                    $count = $this->transaction_model->sum([], 'TXN_paid');
239
-                    break;
240
-                default:
241
-                    $count = null;
242
-                    break;
243
-            }
244
-        } catch (Exception $e) {
245
-            $count = null;
246
-        }
247
-        return $count;
248
-    }
249
-
250
-
251
-    /**
252
-     * Return the active theme.
253
-     *
254
-     * @return false|string
255
-     */
256
-    private function getActiveThemeStat()
257
-    {
258
-        $theme = wp_get_theme();
259
-        return $theme->get('Name');
260
-    }
261
-
262
-
263
-    /**
264
-     * @return array
265
-     */
266
-    private function paymentMethodStats(): array
267
-    {
268
-        $payment_method_stats = [];
269
-        try {
270
-            $active_payment_methods = $this->payment_method_model->get_all_active(
271
-                null,
272
-                ['group_by' => 'PMD_type']
273
-            );
274
-            if ($active_payment_methods) {
275
-                foreach ($active_payment_methods as $payment_method) {
276
-                    $payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
277
-                }
278
-            }
279
-        } catch (Exception $e) {
280
-            // do nothing just prevents fatals.
281
-        }
282
-        return $payment_method_stats;
283
-    }
284
-
285
-
286
-    /**
287
-     * Return a list of active EE add-ons and their versions.
288
-     *
289
-     * @return string
290
-     */
291
-    private function getActiveAddons(): string
292
-    {
293
-        $activeAddons = [];
294
-        $addOns       = EE_Registry::instance()->addons;
295
-        if (! empty($addOns)) {
296
-            foreach ($addOns as $addon) {
297
-                $activeAddons[] = $addon->name() . '@' . $addon->version();
298
-            }
299
-        }
300
-        return implode(',', $activeAddons);
301
-    }
55
+	/**
56
+	 * @var EEM_Payment_Method
57
+	 */
58
+	private $payment_method_model;
59
+
60
+
61
+	/**
62
+	 * @var EEM_Event
63
+	 */
64
+	private $event_model;
65
+
66
+	/**
67
+	 * @var EEM_Datetime
68
+	 */
69
+	private $datetime_model;
70
+
71
+
72
+	/**
73
+	 * @var EEM_Ticket
74
+	 */
75
+	private $ticket_model;
76
+
77
+
78
+	/**
79
+	 * @var EEM_Registration
80
+	 */
81
+	private $registration_model;
82
+
83
+
84
+	/**
85
+	 * @var EEM_Transaction
86
+	 */
87
+	private $transaction_model;
88
+
89
+
90
+	/**
91
+	 * @var EE_Config
92
+	 */
93
+	private $config;
94
+
95
+
96
+	/**
97
+	 * StatsGatherer constructor.
98
+	 *
99
+	 * @param EEM_Payment_Method $payment_method_model
100
+	 * @param EEM_Event          $event_model
101
+	 * @param EEM_Datetime       $datetime_model
102
+	 * @param EEM_Ticket         $ticket_model
103
+	 * @param EEM_Registration   $registration_model
104
+	 * @param EEM_Transaction    $transaction_model
105
+	 * @param EE_Config          $config
106
+	 */
107
+	public function __construct(
108
+		EEM_Payment_Method $payment_method_model,
109
+		EEM_Event $event_model,
110
+		EEM_Datetime $datetime_model,
111
+		EEM_Ticket $ticket_model,
112
+		EEM_Registration $registration_model,
113
+		EEM_Transaction $transaction_model,
114
+		EE_Config $config
115
+	) {
116
+		$this->payment_method_model = $payment_method_model;
117
+		$this->event_model          = $event_model;
118
+		$this->datetime_model       = $datetime_model;
119
+		$this->ticket_model         = $ticket_model;
120
+		$this->registration_model   = $registration_model;
121
+		$this->transaction_model    = $transaction_model;
122
+		$this->config               = $config;
123
+	}
124
+
125
+
126
+	/**
127
+	 * Return the stats array for PUE UXIP stats.
128
+	 *
129
+	 * @return array
130
+	 */
131
+	public function stats(): array
132
+	{
133
+		global $wp_version;
134
+		$stats = $this->paymentMethodStats();
135
+		// a-ok so let's setup our stats.
136
+		$stats = array_merge(
137
+			$stats,
138
+			[
139
+				'is_multisite'                    => is_multisite() && is_main_site(),
140
+				'active_theme'                    => $this->getActiveThemeStat(),
141
+				'ee4_all_events_count'            => $this->getCountFor(self::COUNT_ALL_EVENTS),
142
+				'ee4_active_events_count'         => $this->getCountFor(self::COUNT_ACTIVE_EVENTS),
143
+				'all_dtts_count'                  => $this->getCountFor(self::COUNT_DATETIMES),
144
+				'dtt_sold'                        => $this->getCountFor(self::COUNT_DATETIMES_SOLD),
145
+				'all_tkt_count'                   => $this->getCountFor(self::COUNT_TICKETS),
146
+				'free_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_FREE),
147
+				'paid_tkt_count'                  => $this->getCountFor(self::COUNT_TICKETS_PAID),
148
+				'tkt_sold'                        => $this->getCountFor(self::COUNT_TICKETS_SOLD),
149
+				'approve_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED),
150
+				'pending_registration_count'      => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING),
151
+				'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED),
152
+				'incomplete_registration_count'   => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE),
153
+				'cancelled_registration_count'    => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED),
154
+				'declined_registration_count'     => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED),
155
+				'all_registration_count'          => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL),
156
+				'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL),
157
+				'all_transaction_paid_sum'        => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID),
158
+				self::INFO_SITE_CURRENCY          => $this->config->currency instanceof EE_Currency_Config
159
+					? $this->config->currency->code
160
+					: 'unknown',
161
+				'phpversion'                      => implode(
162
+					'.',
163
+					[PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION]
164
+				),
165
+				'wpversion'                       => $wp_version,
166
+				'active_addons'                   => $this->getActiveAddons(),
167
+			]
168
+		);
169
+		// remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
170
+		return array_filter($stats, function ($value) {
171
+			return $value !== null;
172
+		});
173
+	}
174
+
175
+
176
+	/**
177
+	 * @param string $which enum (@see constants prefixed with COUNT)
178
+	 * @return int|null
179
+	 */
180
+	private function getCountFor(string $which): ?int
181
+	{
182
+		try {
183
+			switch ($which) {
184
+				case self::COUNT_ALL_EVENTS:
185
+					$count = $this->event_model->count();
186
+					break;
187
+				case self::COUNT_TICKETS:
188
+					$count = $this->ticket_model->count();
189
+					break;
190
+				case self::COUNT_DATETIMES:
191
+					$count = $this->datetime_model->count();
192
+					break;
193
+				case self::COUNT_ACTIVE_EVENTS:
194
+					$count = $this->event_model->get_active_events([], true);
195
+					break;
196
+				case self::COUNT_DATETIMES_SOLD:
197
+					$count = $this->datetime_model->sum([], 'DTT_sold');
198
+					break;
199
+				case self::COUNT_TICKETS_FREE:
200
+					$count = $this->ticket_model->count([['TKT_price' => 0]]);
201
+					break;
202
+				case self::COUNT_TICKETS_PAID:
203
+					$count = $this->ticket_model->count([['TKT_price' => ['>', 0]]]);
204
+					break;
205
+				case self::COUNT_TICKETS_SOLD:
206
+					$count = $this->ticket_model->sum([], 'TKT_sold');
207
+					break;
208
+				case self::COUNT_REGISTRATIONS_ALL:
209
+					$count = $this->registration_model->count();
210
+					break;
211
+				case self::COUNT_REGISTRATIONS_CANCELLED:
212
+					$count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_cancelled]]);
213
+					break;
214
+				case self::COUNT_REGISTRATIONS_INCOMPLETE:
215
+					$count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_incomplete]]);
216
+					break;
217
+				case self::COUNT_REGISTRATIONS_NOT_APPROVED:
218
+					$count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_not_approved]]);
219
+					break;
220
+				case self::COUNT_REGISTRATIONS_DECLINED:
221
+					$count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_declined]]);
222
+					break;
223
+				case self::COUNT_REGISTRATIONS_PENDING:
224
+					$count = $this->registration_model->count(
225
+						[['STS_ID' => EEM_Registration::status_id_pending_payment]]
226
+					);
227
+					break;
228
+				case self::COUNT_REGISTRATIONS_APPROVED:
229
+					$count = $this->registration_model->count([['STS_ID' => EEM_Registration::status_id_approved]]);
230
+					break;
231
+				case self::SUM_TRANSACTIONS_COMPLETE_TOTAL:
232
+					$count = $this->transaction_model->sum(
233
+						[['STS_ID' => EEM_Transaction::complete_status_code]],
234
+						'TXN_total'
235
+					);
236
+					break;
237
+				case self::SUM_TRANSACTIONS_ALL_PAID:
238
+					$count = $this->transaction_model->sum([], 'TXN_paid');
239
+					break;
240
+				default:
241
+					$count = null;
242
+					break;
243
+			}
244
+		} catch (Exception $e) {
245
+			$count = null;
246
+		}
247
+		return $count;
248
+	}
249
+
250
+
251
+	/**
252
+	 * Return the active theme.
253
+	 *
254
+	 * @return false|string
255
+	 */
256
+	private function getActiveThemeStat()
257
+	{
258
+		$theme = wp_get_theme();
259
+		return $theme->get('Name');
260
+	}
261
+
262
+
263
+	/**
264
+	 * @return array
265
+	 */
266
+	private function paymentMethodStats(): array
267
+	{
268
+		$payment_method_stats = [];
269
+		try {
270
+			$active_payment_methods = $this->payment_method_model->get_all_active(
271
+				null,
272
+				['group_by' => 'PMD_type']
273
+			);
274
+			if ($active_payment_methods) {
275
+				foreach ($active_payment_methods as $payment_method) {
276
+					$payment_method_stats[ $payment_method->name() . '_active_payment_method' ] = 1;
277
+				}
278
+			}
279
+		} catch (Exception $e) {
280
+			// do nothing just prevents fatals.
281
+		}
282
+		return $payment_method_stats;
283
+	}
284
+
285
+
286
+	/**
287
+	 * Return a list of active EE add-ons and their versions.
288
+	 *
289
+	 * @return string
290
+	 */
291
+	private function getActiveAddons(): string
292
+	{
293
+		$activeAddons = [];
294
+		$addOns       = EE_Registry::instance()->addons;
295
+		if (! empty($addOns)) {
296
+			foreach ($addOns as $addon) {
297
+				$activeAddons[] = $addon->name() . '@' . $addon->version();
298
+			}
299
+		}
300
+		return implode(',', $activeAddons);
301
+	}
302 302
 }
Please login to merge, or discard this patch.
caffeinated/core/domain/services/pue/PueLicensingManager.php 2 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -11,104 +11,104 @@
 block discarded – undo
11 11
 
12 12
 class PueLicensingManager
13 13
 {
14
-    /**
15
-     * @var EE_Dependency_Map
16
-     */
17
-    protected $dependency_map;
14
+	/**
15
+	 * @var EE_Dependency_Map
16
+	 */
17
+	protected $dependency_map;
18 18
 
19
-    /**
20
-     * @var LoaderInterface
21
-     */
22
-    protected $loader;
19
+	/**
20
+	 * @var LoaderInterface
21
+	 */
22
+	protected $loader;
23 23
 
24 24
 
25
-    /**
26
-     * @param EE_Dependency_Map $dependency_map
27
-     * @param LoaderInterface   $loader
28
-     */
29
-    public function __construct(EE_Dependency_Map $dependency_map, LoaderInterface $loader)
30
-    {
31
-        $this->dependency_map = $dependency_map;
32
-        $this->loader         = $loader;
33
-    }
25
+	/**
26
+	 * @param EE_Dependency_Map $dependency_map
27
+	 * @param LoaderInterface   $loader
28
+	 */
29
+	public function __construct(EE_Dependency_Map $dependency_map, LoaderInterface $loader)
30
+	{
31
+		$this->dependency_map = $dependency_map;
32
+		$this->loader         = $loader;
33
+	}
34 34
 
35 35
 
36
-    public function registerDependencies()
37
-    {
38
-        $pue_dependencies = [
39
-            'EventEspresso\caffeinated\core\services\licensing\LicenseService'     => [
40
-                'EventEspresso\caffeinated\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
41
-                'EventEspresso\caffeinated\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
42
-            ],
43
-            'EventEspresso\caffeinated\core\domain\services\pue\Stats'             => [
44
-                'EventEspresso\caffeinated\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
45
-                'EE_Maintenance_Mode'                                              => EE_Dependency_Map::load_from_cache,
46
-                'EventEspresso\caffeinated\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
47
-            ],
48
-            'EventEspresso\caffeinated\core\domain\services\pue\Config'            => [
49
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
50
-                'EE_Config'         => EE_Dependency_Map::load_from_cache,
51
-            ],
52
-            'EventEspresso\caffeinated\core\domain\services\pue\StatsGatherer'     => [
53
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
54
-                'EEM_Event'          => EE_Dependency_Map::load_from_cache,
55
-                'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
56
-                'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
57
-                'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
58
-                'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
59
-                'EE_Config'          => EE_Dependency_Map::load_from_cache,
60
-            ],
61
-            'EventEspresso\caffeinated\core\services\licensing\UserExperienceForm' => [
62
-                'EE_Core_Config'         => EE_Dependency_Map::load_from_cache,
63
-                'EE_Network_Core_Config' => EE_Dependency_Map::load_from_cache,
64
-            ],
65
-        ];
66
-        foreach ($pue_dependencies as $class => $dependencies) {
67
-            $this->dependency_map->registerDependencies($class, $dependencies);
68
-        }
69
-    }
36
+	public function registerDependencies()
37
+	{
38
+		$pue_dependencies = [
39
+			'EventEspresso\caffeinated\core\services\licensing\LicenseService'     => [
40
+				'EventEspresso\caffeinated\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
41
+				'EventEspresso\caffeinated\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
42
+			],
43
+			'EventEspresso\caffeinated\core\domain\services\pue\Stats'             => [
44
+				'EventEspresso\caffeinated\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
45
+				'EE_Maintenance_Mode'                                              => EE_Dependency_Map::load_from_cache,
46
+				'EventEspresso\caffeinated\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
47
+			],
48
+			'EventEspresso\caffeinated\core\domain\services\pue\Config'            => [
49
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
50
+				'EE_Config'         => EE_Dependency_Map::load_from_cache,
51
+			],
52
+			'EventEspresso\caffeinated\core\domain\services\pue\StatsGatherer'     => [
53
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
54
+				'EEM_Event'          => EE_Dependency_Map::load_from_cache,
55
+				'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
56
+				'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
57
+				'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
58
+				'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
59
+				'EE_Config'          => EE_Dependency_Map::load_from_cache,
60
+			],
61
+			'EventEspresso\caffeinated\core\services\licensing\UserExperienceForm' => [
62
+				'EE_Core_Config'         => EE_Dependency_Map::load_from_cache,
63
+				'EE_Network_Core_Config' => EE_Dependency_Map::load_from_cache,
64
+			],
65
+		];
66
+		foreach ($pue_dependencies as $class => $dependencies) {
67
+			$this->dependency_map->registerDependencies($class, $dependencies);
68
+		}
69
+	}
70 70
 
71 71
 
72
-    public function registerHooks()
73
-    {
74
-        add_filter(
75
-            'FHEE__EE_Register_Addon__register',
76
-            [RegisterAddonPUE::class, 'registerPUE'],
77
-            10,
78
-            4
79
-        );
80
-        add_action(
81
-            'AHEE__EE_Register_Addon___load_and_init_addon_class',
82
-            [RegisterAddonPUE::class, 'setAddonPueSlug'],
83
-            10,
84
-            2
85
-        );
86
-        if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
87
-            add_action('AHEE__EE_System__brew_espresso__complete', [$this, 'loadLicenseService']);
88
-        }
89
-        add_filter(
90
-            'FHEE__EventEspresso_admin_pages_general_settings_OrganizationSettings__generate__form',
91
-            [$this, 'loadUserExperienceForm']
92
-        );
72
+	public function registerHooks()
73
+	{
74
+		add_filter(
75
+			'FHEE__EE_Register_Addon__register',
76
+			[RegisterAddonPUE::class, 'registerPUE'],
77
+			10,
78
+			4
79
+		);
80
+		add_action(
81
+			'AHEE__EE_Register_Addon___load_and_init_addon_class',
82
+			[RegisterAddonPUE::class, 'setAddonPueSlug'],
83
+			10,
84
+			2
85
+		);
86
+		if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
87
+			add_action('AHEE__EE_System__brew_espresso__complete', [$this, 'loadLicenseService']);
88
+		}
89
+		add_filter(
90
+			'FHEE__EventEspresso_admin_pages_general_settings_OrganizationSettings__generate__form',
91
+			[$this, 'loadUserExperienceForm']
92
+		);
93 93
 
94
-    }
94
+	}
95 95
 
96 96
 
97
-    public function loadLicenseService()
98
-    {
99
-        /** @var LicenseService $license_service */
100
-        $license_service = $this->loader->getShared(LicenseService::class );
101
-        $license_service->loadPueClient();
102
-    }
97
+	public function loadLicenseService()
98
+	{
99
+		/** @var LicenseService $license_service */
100
+		$license_service = $this->loader->getShared(LicenseService::class );
101
+		$license_service->loadPueClient();
102
+	}
103 103
 
104 104
 
105
-    /**
106
-     * @throws EE_Error
107
-     */
108
-    public function loadUserExperienceForm(EE_Form_Section_Proper $org_settings_form): EE_Form_Section_Proper
109
-    {
110
-        /** @var UserExperienceForm $uxip_form */
111
-        $uxip_form = $this->loader->getShared(UserExperienceForm::class);
112
-        return $uxip_form->uxipFormSections($org_settings_form);
113
-    }
105
+	/**
106
+	 * @throws EE_Error
107
+	 */
108
+	public function loadUserExperienceForm(EE_Form_Section_Proper $org_settings_form): EE_Form_Section_Proper
109
+	{
110
+		/** @var UserExperienceForm $uxip_form */
111
+		$uxip_form = $this->loader->getShared(UserExperienceForm::class);
112
+		return $uxip_form->uxipFormSections($org_settings_form);
113
+	}
114 114
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@
 block discarded – undo
97 97
     public function loadLicenseService()
98 98
     {
99 99
         /** @var LicenseService $license_service */
100
-        $license_service = $this->loader->getShared(LicenseService::class );
100
+        $license_service = $this->loader->getShared(LicenseService::class);
101 101
         $license_service->loadPueClient();
102 102
     }
103 103
 
Please login to merge, or discard this patch.
core/admin/EE_Admin_List_Table.core.php 1 patch
Indentation   +884 added lines, -884 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\services\request\sanitizers\AllowedTags;
4 4
 
5 5
 if (! class_exists('WP_List_Table')) {
6
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
+	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
7 7
 }
8 8
 
9 9
 
@@ -21,897 +21,897 @@  discard block
 block discarded – undo
21 21
  */
22 22
 abstract class EE_Admin_List_Table extends WP_List_Table
23 23
 {
24
-    const ACTION_COPY    = 'duplicate';
25
-
26
-    const ACTION_DELETE  = 'delete';
27
-
28
-    const ACTION_EDIT    = 'edit';
29
-
30
-    const ACTION_RESTORE = 'restore';
31
-
32
-    const ACTION_TRASH   = 'trash';
33
-
34
-    protected static $actions = [
35
-        self::ACTION_COPY,
36
-        self::ACTION_DELETE,
37
-        self::ACTION_EDIT,
38
-        self::ACTION_RESTORE,
39
-        self::ACTION_TRASH,
40
-    ];
41
-
42
-    /**
43
-     * holds the data that will be processed for the table
44
-     *
45
-     * @var array $_data
46
-     */
47
-    protected $_data;
48
-
49
-
50
-    /**
51
-     * This holds the value of all the data available for the given view (for all pages).
52
-     *
53
-     * @var int $_all_data_count
54
-     */
55
-    protected $_all_data_count;
56
-
57
-
58
-    /**
59
-     * Will contain the count of trashed items for the view label.
60
-     *
61
-     * @var int $_trashed_count
62
-     */
63
-    protected $_trashed_count;
64
-
65
-
66
-    /**
67
-     * This is what will be referenced as the slug for the current screen
68
-     *
69
-     * @var string $_screen
70
-     */
71
-    protected $_screen;
72
-
73
-
74
-    /**
75
-     * this is the EE_Admin_Page object
76
-     *
77
-     * @var EE_Admin_Page $_admin_page
78
-     */
79
-    protected $_admin_page;
80
-
81
-
82
-    /**
83
-     * The current view
84
-     *
85
-     * @var string $_view
86
-     */
87
-    protected $_view;
88
-
89
-
90
-    /**
91
-     * array of possible views for this table
92
-     *
93
-     * @var array $_views
94
-     */
95
-    protected $_views;
96
-
97
-
98
-    /**
99
-     * An array of key => value pairs containing information about the current table
100
-     * array(
101
-     *        'plural' => 'plural label',
102
-     *        'singular' => 'singular label',
103
-     *        'ajax' => false, //whether to use ajax or not
104
-     *        'screen' => null, //string used to reference what screen this is
105
-     *        (WP_List_table converts to screen object)
106
-     * )
107
-     *
108
-     * @var array $_wp_list_args
109
-     */
110
-    protected $_wp_list_args;
111
-
112
-    /**
113
-     * an array of column names
114
-     * array(
115
-     *    'internal-name' => 'Title'
116
-     * )
117
-     *
118
-     * @var array $_columns
119
-     */
120
-    protected $_columns;
121
-
122
-    /**
123
-     * An array of sortable columns
124
-     * array(
125
-     *    'internal-name' => 'orderby' //or
126
-     *    'internal-name' => array( 'orderby', true )
127
-     * )
128
-     *
129
-     * @var array $_sortable_columns
130
-     */
131
-    protected $_sortable_columns;
132
-
133
-    /**
134
-     * callback method used to perform AJAX row reordering
135
-     *
136
-     * @var string $_ajax_sorting_callback
137
-     */
138
-    protected $_ajax_sorting_callback;
139
-
140
-    /**
141
-     * An array of hidden columns (if needed)
142
-     * array('internal-name', 'internal-name')
143
-     *
144
-     * @var array $_hidden_columns
145
-     */
146
-    protected $_hidden_columns;
147
-
148
-    /**
149
-     * holds the per_page value
150
-     *
151
-     * @var int $_per_page
152
-     */
153
-    protected $_per_page;
154
-
155
-    /**
156
-     * holds what page number is currently being viewed
157
-     *
158
-     * @var int $_current_page
159
-     */
160
-    protected $_current_page;
161
-
162
-    /**
163
-     * the reference string for the nonce_action
164
-     *
165
-     * @var string $_nonce_action_ref
166
-     */
167
-    protected $_nonce_action_ref;
168
-
169
-    /**
170
-     * property to hold incoming request data (as set by the admin_page_core)
171
-     *
172
-     * @var array $_req_data
173
-     */
174
-    protected $_req_data;
175
-
176
-
177
-    /**
178
-     * yes / no array for admin form fields
179
-     *
180
-     * @var array $_yes_no
181
-     */
182
-    protected $_yes_no = [];
183
-
184
-    /**
185
-     * Array describing buttons that should appear at the bottom of the page
186
-     * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
187
-     * and the values are another array with the following keys
188
-     * array(
189
-     *    'route' => 'page_route',
190
-     *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
191
-     * )
192
-     *
193
-     * @var array $_bottom_buttons
194
-     */
195
-    protected $_bottom_buttons = [];
196
-
197
-
198
-    /**
199
-     * Used to indicate what should be the primary column for the list table.
200
-     * If not present then falls back to what WP calculates
201
-     * as the primary column.
202
-     *
203
-     * @type string $_primary_column
204
-     */
205
-    protected $_primary_column = '';
206
-
207
-
208
-    /**
209
-     * Used to indicate whether the table has a checkbox column or not.
210
-     *
211
-     * @type bool $_has_checkbox_column
212
-     */
213
-    protected $_has_checkbox_column = false;
214
-
215
-
216
-    /**
217
-     * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
218
-     */
219
-    public function __construct(EE_Admin_Page $admin_page)
220
-    {
221
-        $this->_admin_page   = $admin_page;
222
-        $this->_req_data     = $this->_admin_page->get_request_data();
223
-        $this->_view         = $this->_admin_page->get_view();
224
-        $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
225
-        $this->_current_page = $this->get_pagenum();
226
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
227
-        $this->_yes_no       = [
228
-            esc_html__('No', 'event_espresso'),
229
-            esc_html__('Yes', 'event_espresso')
230
-        ];
231
-
232
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
233
-
234
-        $this->_setup_data();
235
-        $this->_add_view_counts();
236
-
237
-        $this->_nonce_action_ref = $this->_view;
238
-
239
-        $this->_set_properties();
240
-
241
-        // set primary column
242
-        add_filter('list_table_primary_column', [$this, 'set_primary_column']);
243
-
244
-        // set parent defaults
245
-        parent::__construct($this->_wp_list_args);
246
-
247
-        $this->prepare_items();
248
-    }
249
-
250
-
251
-    /**
252
-     * _setup_data
253
-     * this method is used to setup the $_data, $_all_data_count, and _per_page properties
254
-     *
255
-     * @return void
256
-     * @uses $this->_admin_page
257
-     */
258
-    abstract protected function _setup_data();
259
-
260
-
261
-    /**
262
-     * set the properties that this class needs to be able to execute wp_list_table properly
263
-     * properties set:
264
-     * _wp_list_args = what the arguments required for the parent _wp_list_table.
265
-     * _columns = set the columns in an array.
266
-     * _sortable_columns = columns that are sortable (array).
267
-     * _hidden_columns = columns that are hidden (array)
268
-     * _default_orderby = the default orderby for sorting.
269
-     *
270
-     * @abstract
271
-     * @access protected
272
-     * @return void
273
-     */
274
-    abstract protected function _set_properties();
275
-
276
-
277
-    /**
278
-     * _get_table_filters
279
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
280
-     * gets shown in the table.
281
-     *
282
-     * @abstract
283
-     * @access protected
284
-     * @return string
285
-     */
286
-    abstract protected function _get_table_filters();
287
-
288
-
289
-    /**
290
-     * this is a method that child class will do to add counts to the views array so when views are displayed the
291
-     * counts of the views is accurate.
292
-     *
293
-     * @abstract
294
-     * @access protected
295
-     * @return void
296
-     */
297
-    abstract protected function _add_view_counts();
298
-
299
-
300
-    /**
301
-     * _get_hidden_fields
302
-     * returns a html string of hidden fields so if any table filters are used the current view will be respected.
303
-     *
304
-     * @return string
305
-     */
306
-    protected function _get_hidden_fields()
307
-    {
308
-        $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
309
-        $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
310
-        // if action is STILL empty, then we set it to default
311
-        $action = empty($action) ? 'default' : $action;
312
-        $field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
313
-        $field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
314
-        $field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
315
-
316
-        $bulk_actions = $this->_get_bulk_actions();
317
-        foreach ($bulk_actions as $bulk_action => $label) {
318
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
319
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
320
-        }
321
-
322
-        return $field;
323
-    }
324
-
325
-
326
-    /**
327
-     * _set_column_info
328
-     * we're using this to set the column headers property.
329
-     *
330
-     * @access protected
331
-     * @return void
332
-     */
333
-    protected function _set_column_info()
334
-    {
335
-        $columns   = $this->get_columns();
336
-        $hidden    = $this->get_hidden_columns();
337
-        $_sortable = $this->get_sortable_columns();
338
-
339
-        /**
340
-         * Dynamic hook allowing for adding sortable columns in this list table.
341
-         * Note that $this->screen->id is in the format
342
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
343
-         * table it is: event-espresso_page_espresso_messages.
344
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
345
-         * hook prefix ("event-espresso") will be different.
346
-         *
347
-         * @var array
348
-         */
349
-        $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
350
-
351
-        $sortable = [];
352
-        foreach ($_sortable as $id => $data) {
353
-            if (empty($data)) {
354
-                continue;
355
-            }
356
-            // fix for offset errors with WP_List_Table default get_columninfo()
357
-            if (is_array($data)) {
358
-                $_data[0] = key($data);
359
-                $_data[1] = isset($data[1]) ? $data[1] : false;
360
-            } else {
361
-                $_data[0] = $data;
362
-            }
363
-
364
-            $data = (array) $data;
365
-
366
-            if (! isset($data[1])) {
367
-                $_data[1] = false;
368
-            }
369
-
370
-            $sortable[ $id ] = $_data;
371
-        }
372
-        $primary               = $this->get_primary_column_name();
373
-        $this->_column_headers = [$columns, $hidden, $sortable, $primary];
374
-    }
375
-
376
-
377
-    /**
378
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
379
-     *
380
-     * @return string
381
-     */
382
-    protected function get_primary_column_name()
383
-    {
384
-        foreach (class_parents($this) as $parent) {
385
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
386
-                return parent::get_primary_column_name();
387
-            }
388
-        }
389
-        return $this->_primary_column;
390
-    }
391
-
392
-
393
-    /**
394
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
395
-     *
396
-     * @param EE_Base_Class $item
397
-     * @param string        $column_name
398
-     * @param string        $primary
399
-     * @return string
400
-     */
401
-    protected function handle_row_actions($item, $column_name, $primary)
402
-    {
403
-        foreach (class_parents($this) as $parent) {
404
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
405
-                return parent::handle_row_actions($item, $column_name, $primary);
406
-            }
407
-        }
408
-        return '';
409
-    }
410
-
411
-
412
-    /**
413
-     * _get_bulk_actions
414
-     * This is a wrapper called by WP_List_Table::get_bulk_actions()
415
-     *
416
-     * @access protected
417
-     * @return array bulk_actions
418
-     */
419
-    protected function _get_bulk_actions()
420
-    {
421
-        $actions = [];
422
-        // the _views property should have the bulk_actions, so let's go through and extract them into a properly
423
-        // formatted array for the wp_list_table();
424
-        foreach ($this->_views as $view => $args) {
425
-            if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
426
-                // each bulk action will correspond with a admin page route, so we can check whatever the capability is
427
-                // for that page route and skip adding the bulk action if no access for the current logged in user.
428
-                foreach ($args['bulk_action'] as $route => $label) {
429
-                    if ($this->_admin_page->check_user_access($route, true)) {
430
-                        $actions[ $route ] = $label;
431
-                    }
432
-                }
433
-            }
434
-        }
435
-        return $actions;
436
-    }
437
-
438
-
439
-    /**
440
-     * Generate the table navigation above or below the table.
441
-     * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
442
-     *
443
-     * @throws EE_Error
444
-     * @since 4.9.44.rc.001
445
-     */
446
-    public function display_tablenav($which)
447
-    {
448
-        if ('top' === $which) {
449
-            wp_nonce_field('bulk-' . $this->_args['plural']);
450
-        }
451
-        ?>
24
+	const ACTION_COPY    = 'duplicate';
25
+
26
+	const ACTION_DELETE  = 'delete';
27
+
28
+	const ACTION_EDIT    = 'edit';
29
+
30
+	const ACTION_RESTORE = 'restore';
31
+
32
+	const ACTION_TRASH   = 'trash';
33
+
34
+	protected static $actions = [
35
+		self::ACTION_COPY,
36
+		self::ACTION_DELETE,
37
+		self::ACTION_EDIT,
38
+		self::ACTION_RESTORE,
39
+		self::ACTION_TRASH,
40
+	];
41
+
42
+	/**
43
+	 * holds the data that will be processed for the table
44
+	 *
45
+	 * @var array $_data
46
+	 */
47
+	protected $_data;
48
+
49
+
50
+	/**
51
+	 * This holds the value of all the data available for the given view (for all pages).
52
+	 *
53
+	 * @var int $_all_data_count
54
+	 */
55
+	protected $_all_data_count;
56
+
57
+
58
+	/**
59
+	 * Will contain the count of trashed items for the view label.
60
+	 *
61
+	 * @var int $_trashed_count
62
+	 */
63
+	protected $_trashed_count;
64
+
65
+
66
+	/**
67
+	 * This is what will be referenced as the slug for the current screen
68
+	 *
69
+	 * @var string $_screen
70
+	 */
71
+	protected $_screen;
72
+
73
+
74
+	/**
75
+	 * this is the EE_Admin_Page object
76
+	 *
77
+	 * @var EE_Admin_Page $_admin_page
78
+	 */
79
+	protected $_admin_page;
80
+
81
+
82
+	/**
83
+	 * The current view
84
+	 *
85
+	 * @var string $_view
86
+	 */
87
+	protected $_view;
88
+
89
+
90
+	/**
91
+	 * array of possible views for this table
92
+	 *
93
+	 * @var array $_views
94
+	 */
95
+	protected $_views;
96
+
97
+
98
+	/**
99
+	 * An array of key => value pairs containing information about the current table
100
+	 * array(
101
+	 *        'plural' => 'plural label',
102
+	 *        'singular' => 'singular label',
103
+	 *        'ajax' => false, //whether to use ajax or not
104
+	 *        'screen' => null, //string used to reference what screen this is
105
+	 *        (WP_List_table converts to screen object)
106
+	 * )
107
+	 *
108
+	 * @var array $_wp_list_args
109
+	 */
110
+	protected $_wp_list_args;
111
+
112
+	/**
113
+	 * an array of column names
114
+	 * array(
115
+	 *    'internal-name' => 'Title'
116
+	 * )
117
+	 *
118
+	 * @var array $_columns
119
+	 */
120
+	protected $_columns;
121
+
122
+	/**
123
+	 * An array of sortable columns
124
+	 * array(
125
+	 *    'internal-name' => 'orderby' //or
126
+	 *    'internal-name' => array( 'orderby', true )
127
+	 * )
128
+	 *
129
+	 * @var array $_sortable_columns
130
+	 */
131
+	protected $_sortable_columns;
132
+
133
+	/**
134
+	 * callback method used to perform AJAX row reordering
135
+	 *
136
+	 * @var string $_ajax_sorting_callback
137
+	 */
138
+	protected $_ajax_sorting_callback;
139
+
140
+	/**
141
+	 * An array of hidden columns (if needed)
142
+	 * array('internal-name', 'internal-name')
143
+	 *
144
+	 * @var array $_hidden_columns
145
+	 */
146
+	protected $_hidden_columns;
147
+
148
+	/**
149
+	 * holds the per_page value
150
+	 *
151
+	 * @var int $_per_page
152
+	 */
153
+	protected $_per_page;
154
+
155
+	/**
156
+	 * holds what page number is currently being viewed
157
+	 *
158
+	 * @var int $_current_page
159
+	 */
160
+	protected $_current_page;
161
+
162
+	/**
163
+	 * the reference string for the nonce_action
164
+	 *
165
+	 * @var string $_nonce_action_ref
166
+	 */
167
+	protected $_nonce_action_ref;
168
+
169
+	/**
170
+	 * property to hold incoming request data (as set by the admin_page_core)
171
+	 *
172
+	 * @var array $_req_data
173
+	 */
174
+	protected $_req_data;
175
+
176
+
177
+	/**
178
+	 * yes / no array for admin form fields
179
+	 *
180
+	 * @var array $_yes_no
181
+	 */
182
+	protected $_yes_no = [];
183
+
184
+	/**
185
+	 * Array describing buttons that should appear at the bottom of the page
186
+	 * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
187
+	 * and the values are another array with the following keys
188
+	 * array(
189
+	 *    'route' => 'page_route',
190
+	 *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
191
+	 * )
192
+	 *
193
+	 * @var array $_bottom_buttons
194
+	 */
195
+	protected $_bottom_buttons = [];
196
+
197
+
198
+	/**
199
+	 * Used to indicate what should be the primary column for the list table.
200
+	 * If not present then falls back to what WP calculates
201
+	 * as the primary column.
202
+	 *
203
+	 * @type string $_primary_column
204
+	 */
205
+	protected $_primary_column = '';
206
+
207
+
208
+	/**
209
+	 * Used to indicate whether the table has a checkbox column or not.
210
+	 *
211
+	 * @type bool $_has_checkbox_column
212
+	 */
213
+	protected $_has_checkbox_column = false;
214
+
215
+
216
+	/**
217
+	 * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
218
+	 */
219
+	public function __construct(EE_Admin_Page $admin_page)
220
+	{
221
+		$this->_admin_page   = $admin_page;
222
+		$this->_req_data     = $this->_admin_page->get_request_data();
223
+		$this->_view         = $this->_admin_page->get_view();
224
+		$this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
225
+		$this->_current_page = $this->get_pagenum();
226
+		$this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
227
+		$this->_yes_no       = [
228
+			esc_html__('No', 'event_espresso'),
229
+			esc_html__('Yes', 'event_espresso')
230
+		];
231
+
232
+		$this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
233
+
234
+		$this->_setup_data();
235
+		$this->_add_view_counts();
236
+
237
+		$this->_nonce_action_ref = $this->_view;
238
+
239
+		$this->_set_properties();
240
+
241
+		// set primary column
242
+		add_filter('list_table_primary_column', [$this, 'set_primary_column']);
243
+
244
+		// set parent defaults
245
+		parent::__construct($this->_wp_list_args);
246
+
247
+		$this->prepare_items();
248
+	}
249
+
250
+
251
+	/**
252
+	 * _setup_data
253
+	 * this method is used to setup the $_data, $_all_data_count, and _per_page properties
254
+	 *
255
+	 * @return void
256
+	 * @uses $this->_admin_page
257
+	 */
258
+	abstract protected function _setup_data();
259
+
260
+
261
+	/**
262
+	 * set the properties that this class needs to be able to execute wp_list_table properly
263
+	 * properties set:
264
+	 * _wp_list_args = what the arguments required for the parent _wp_list_table.
265
+	 * _columns = set the columns in an array.
266
+	 * _sortable_columns = columns that are sortable (array).
267
+	 * _hidden_columns = columns that are hidden (array)
268
+	 * _default_orderby = the default orderby for sorting.
269
+	 *
270
+	 * @abstract
271
+	 * @access protected
272
+	 * @return void
273
+	 */
274
+	abstract protected function _set_properties();
275
+
276
+
277
+	/**
278
+	 * _get_table_filters
279
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
280
+	 * gets shown in the table.
281
+	 *
282
+	 * @abstract
283
+	 * @access protected
284
+	 * @return string
285
+	 */
286
+	abstract protected function _get_table_filters();
287
+
288
+
289
+	/**
290
+	 * this is a method that child class will do to add counts to the views array so when views are displayed the
291
+	 * counts of the views is accurate.
292
+	 *
293
+	 * @abstract
294
+	 * @access protected
295
+	 * @return void
296
+	 */
297
+	abstract protected function _add_view_counts();
298
+
299
+
300
+	/**
301
+	 * _get_hidden_fields
302
+	 * returns a html string of hidden fields so if any table filters are used the current view will be respected.
303
+	 *
304
+	 * @return string
305
+	 */
306
+	protected function _get_hidden_fields()
307
+	{
308
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
309
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
310
+		// if action is STILL empty, then we set it to default
311
+		$action = empty($action) ? 'default' : $action;
312
+		$field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
313
+		$field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
314
+		$field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
315
+
316
+		$bulk_actions = $this->_get_bulk_actions();
317
+		foreach ($bulk_actions as $bulk_action => $label) {
318
+			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
319
+					  . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
320
+		}
321
+
322
+		return $field;
323
+	}
324
+
325
+
326
+	/**
327
+	 * _set_column_info
328
+	 * we're using this to set the column headers property.
329
+	 *
330
+	 * @access protected
331
+	 * @return void
332
+	 */
333
+	protected function _set_column_info()
334
+	{
335
+		$columns   = $this->get_columns();
336
+		$hidden    = $this->get_hidden_columns();
337
+		$_sortable = $this->get_sortable_columns();
338
+
339
+		/**
340
+		 * Dynamic hook allowing for adding sortable columns in this list table.
341
+		 * Note that $this->screen->id is in the format
342
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
343
+		 * table it is: event-espresso_page_espresso_messages.
344
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
345
+		 * hook prefix ("event-espresso") will be different.
346
+		 *
347
+		 * @var array
348
+		 */
349
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
350
+
351
+		$sortable = [];
352
+		foreach ($_sortable as $id => $data) {
353
+			if (empty($data)) {
354
+				continue;
355
+			}
356
+			// fix for offset errors with WP_List_Table default get_columninfo()
357
+			if (is_array($data)) {
358
+				$_data[0] = key($data);
359
+				$_data[1] = isset($data[1]) ? $data[1] : false;
360
+			} else {
361
+				$_data[0] = $data;
362
+			}
363
+
364
+			$data = (array) $data;
365
+
366
+			if (! isset($data[1])) {
367
+				$_data[1] = false;
368
+			}
369
+
370
+			$sortable[ $id ] = $_data;
371
+		}
372
+		$primary               = $this->get_primary_column_name();
373
+		$this->_column_headers = [$columns, $hidden, $sortable, $primary];
374
+	}
375
+
376
+
377
+	/**
378
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
379
+	 *
380
+	 * @return string
381
+	 */
382
+	protected function get_primary_column_name()
383
+	{
384
+		foreach (class_parents($this) as $parent) {
385
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
386
+				return parent::get_primary_column_name();
387
+			}
388
+		}
389
+		return $this->_primary_column;
390
+	}
391
+
392
+
393
+	/**
394
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
395
+	 *
396
+	 * @param EE_Base_Class $item
397
+	 * @param string        $column_name
398
+	 * @param string        $primary
399
+	 * @return string
400
+	 */
401
+	protected function handle_row_actions($item, $column_name, $primary)
402
+	{
403
+		foreach (class_parents($this) as $parent) {
404
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
405
+				return parent::handle_row_actions($item, $column_name, $primary);
406
+			}
407
+		}
408
+		return '';
409
+	}
410
+
411
+
412
+	/**
413
+	 * _get_bulk_actions
414
+	 * This is a wrapper called by WP_List_Table::get_bulk_actions()
415
+	 *
416
+	 * @access protected
417
+	 * @return array bulk_actions
418
+	 */
419
+	protected function _get_bulk_actions()
420
+	{
421
+		$actions = [];
422
+		// the _views property should have the bulk_actions, so let's go through and extract them into a properly
423
+		// formatted array for the wp_list_table();
424
+		foreach ($this->_views as $view => $args) {
425
+			if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
426
+				// each bulk action will correspond with a admin page route, so we can check whatever the capability is
427
+				// for that page route and skip adding the bulk action if no access for the current logged in user.
428
+				foreach ($args['bulk_action'] as $route => $label) {
429
+					if ($this->_admin_page->check_user_access($route, true)) {
430
+						$actions[ $route ] = $label;
431
+					}
432
+				}
433
+			}
434
+		}
435
+		return $actions;
436
+	}
437
+
438
+
439
+	/**
440
+	 * Generate the table navigation above or below the table.
441
+	 * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
442
+	 *
443
+	 * @throws EE_Error
444
+	 * @since 4.9.44.rc.001
445
+	 */
446
+	public function display_tablenav($which)
447
+	{
448
+		if ('top' === $which) {
449
+			wp_nonce_field('bulk-' . $this->_args['plural']);
450
+		}
451
+		?>
452 452
         <div class="tablenav <?php echo esc_attr($which); ?>">
453 453
             <?php if ($this->_get_bulk_actions()) { ?>
454 454
                 <div class="alignleft actions bulkactions">
455 455
                     <?php $this->bulk_actions(); ?>
456 456
                 </div>
457 457
             <?php }
458
-            $this->extra_tablenav($which);
459
-            $this->pagination($which);
460
-            ?>
458
+			$this->extra_tablenav($which);
459
+			$this->pagination($which);
460
+			?>
461 461
 
462 462
             <br class="clear" />
463 463
         </div>
464 464
         <?php
465
-    }
466
-
467
-
468
-    /**
469
-     * _filters
470
-     * This receives the filters array from children _get_table_filters() and assembles the string including the filter
471
-     * button.
472
-     *
473
-     * @access private
474
-     * @return void  echos html showing filters
475
-     */
476
-    private function _filters()
477
-    {
478
-        $classname = get_class($this);
479
-        $filters   = apply_filters(
480
-            "FHEE__{$classname}__filters",
481
-            (array) $this->_get_table_filters(),
482
-            $this,
483
-            $this->_screen
484
-        );
485
-
486
-        if (empty($filters)) {
487
-            return;
488
-        }
489
-        $use_filters = isset($this->_req_data['use_filters'])
490
-                       && filter_var($this->_req_data['use_filters'], FILTER_VALIDATE_BOOLEAN)
491
-            ? 'yes'
492
-            : 'no';
493
-
494
-        echo '<div class="ee-list-table-filters actions alignleft">';
495
-        foreach ($filters as $filter) {
496
-            echo wp_kses($filter, AllowedTags::getWithFormTags());
497
-        }
498
-        // add filter button at end
499
-        echo '<input type="submit" class="ee-list-table-filter-submit button button--secondary" value="'
500
-             . esc_html__('Filter', 'event_espresso')
501
-             . '" id="post-query-submit" />';
502
-        echo '<input type="hidden" id="ee-list-table-use-filters" name="use_filters" value="' . $use_filters . '"/>';
503
-
504
-        // add reset filters button at end
505
-        echo '<a class="button button--secondary"  href="'
506
-             . esc_url_raw($this->_admin_page->get_current_page_view_url())
507
-             . '" style="display:inline-block">'
508
-             . esc_html__('Reset Filters', 'event_espresso')
509
-             . '</a>';
510
-        echo '</div>';
511
-    }
512
-
513
-
514
-    /**
515
-     * Callback for 'list_table_primary_column' WordPress filter
516
-     * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
517
-     * column when class is instantiated.
518
-     *
519
-     * @param string $column_name
520
-     * @return string
521
-     * @see WP_List_Table::get_primary_column_name
522
-     */
523
-    public function set_primary_column($column_name)
524
-    {
525
-        return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
526
-    }
527
-
528
-
529
-    /**
530
-     *
531
-     */
532
-    public function prepare_items()
533
-    {
534
-        $this->_set_column_info();
535
-        $this->process_bulk_action();
536
-
537
-        $this->items = $this->_data;
538
-        $this->set_pagination_args(
539
-            [
540
-                'total_items' => $this->_all_data_count,
541
-                'per_page'    => $this->_per_page,
542
-                'total_pages' => (int) ceil($this->_all_data_count / $this->_per_page),
543
-            ]
544
-        );
545
-    }
546
-
547
-
548
-    /**
549
-     * @param object|array $item
550
-     * @return string html content for the column
551
-     */
552
-    protected function column_cb($item)
553
-    {
554
-        return '';
555
-    }
556
-
557
-
558
-    /**
559
-     * This column is the default for when there is no defined column method for a registered column.
560
-     * This can be overridden by child classes, but allows for hooking in for custom columns.
561
-     *
562
-     * @param EE_Base_Class $item
563
-     * @param string        $column_name The column being called.
564
-     * @return string html content for the column
565
-     */
566
-    public function column_default($item, $column_name)
567
-    {
568
-        /**
569
-         * Dynamic hook allowing for adding additional column content in this list table.
570
-         * Note that $this->screen->id is in the format
571
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
572
-         * table it is: event-espresso_page_espresso_messages.
573
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
574
-         * hook prefix ("event-espresso") will be different.
575
-         */
576
-        ob_start();
577
-        do_action(
578
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
579
-            $item,
580
-            $this->_screen
581
-        );
582
-        return ob_get_clean();
583
-    }
584
-
585
-
586
-    /**
587
-     * Get a list of columns. The format is:
588
-     * 'internal-name' => 'Title'
589
-     *
590
-     * @return array
591
-     * @since  3.1.0
592
-     * @access public
593
-     * @abstract
594
-     */
595
-    public function get_columns()
596
-    {
597
-        /**
598
-         * Dynamic hook allowing for adding additional columns in this list table.
599
-         * Note that $this->screen->id is in the format
600
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
601
-         * table it is: event-espresso_page_espresso_messages.
602
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
603
-         * hook prefix ("event-espresso") will be different.
604
-         *
605
-         * @var array
606
-         */
607
-        return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
608
-    }
609
-
610
-
611
-    /**
612
-     * Get an associative array ( id => link ) with the list
613
-     * of views available on this table.
614
-     *
615
-     * @return array
616
-     * @since  3.1.0
617
-     * @access protected
618
-     */
619
-    public function get_views()
620
-    {
621
-        return $this->_views;
622
-    }
623
-
624
-
625
-    /**
626
-     * Generate the views html.
627
-     */
628
-    public function display_views()
629
-    {
630
-        $views           = $this->get_views();
631
-        $assembled_views = [];
632
-
633
-        if (empty($views)) {
634
-            return;
635
-        }
636
-        echo "<ul class='subsubsub'>\n";
637
-        foreach ($views as $view) {
638
-            $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
639
-            if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
640
-                $filter = "<li";
641
-                $filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
642
-                $filter .= ">";
643
-                $filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
644
-                $filter .= '<span class="count">(' . $count . ')</span>';
645
-                $filter .= '</li>';
646
-                $assembled_views[ $view['slug'] ] = $filter;
647
-            }
648
-        }
649
-
650
-        echo ! empty($assembled_views)
651
-            ? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
652
-            : '';
653
-        echo "</ul>";
654
-    }
655
-
656
-
657
-    /**
658
-     * Generates content for a single row of the table
659
-     *
660
-     * @param EE_Base_Class $item The current item
661
-     * @since  4.1
662
-     * @access public
663
-     */
664
-    public function single_row($item)
665
-    {
666
-        $row_class = $this->_get_row_class($item);
667
-        echo '<tr class="' . esc_attr($row_class) . '">';
668
-        $this->single_row_columns($item); // already escaped
669
-        echo '</tr>';
670
-    }
671
-
672
-
673
-    /**
674
-     * This simply sets up the row class for the table rows.
675
-     * Allows for easier overriding of child methods for setting up sorting.
676
-     *
677
-     * @param EE_Base_Class $item the current item
678
-     * @return string
679
-     */
680
-    protected function _get_row_class($item)
681
-    {
682
-        static $row_class = '';
683
-        $row_class = ($row_class === '' ? 'alternate' : '');
684
-
685
-        $new_row_class = $row_class;
686
-
687
-        if (! empty($this->_ajax_sorting_callback)) {
688
-            $new_row_class .= ' rowsortable';
689
-        }
690
-
691
-        return $new_row_class;
692
-    }
693
-
694
-
695
-    /**
696
-     * @return array
697
-     */
698
-    public function get_sortable_columns()
699
-    {
700
-        return (array) $this->_sortable_columns;
701
-    }
702
-
703
-
704
-    /**
705
-     * @return string
706
-     */
707
-    public function get_ajax_sorting_callback()
708
-    {
709
-        return $this->_ajax_sorting_callback;
710
-    }
711
-
712
-
713
-    /**
714
-     * @return array
715
-     */
716
-    public function get_hidden_columns()
717
-    {
718
-        $user_id     = get_current_user_id();
719
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
720
-        if (empty($has_default) && ! empty($this->_hidden_columns)) {
721
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
722
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
723
-        }
724
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
725
-        return (array) get_user_option($ref, $user_id);
726
-    }
727
-
728
-
729
-    /**
730
-     * Generates the columns for a single row of the table.
731
-     * Overridden from wp_list_table so as to allow us to filter the column content for a given
732
-     * column.
733
-     *
734
-     * @param EE_Base_Class $item The current item
735
-     * @since 3.1.0
736
-     */
737
-    public function single_row_columns($item)
738
-    {
739
-        [$columns, $hidden, $sortable, $primary] = $this->get_column_info();
740
-
741
-        foreach ($columns as $column_name => $column_display_name) {
742
-
743
-            /**
744
-             * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
745
-             * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
746
-             */
747
-            $hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
748
-
749
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
750
-            if ($primary === $column_name) {
751
-                $classes .= ' has-row-actions column-primary';
752
-            }
753
-
754
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
755
-
756
-            $class = 'class="' . esc_attr($classes) . '"';
757
-
758
-            $attributes = "{$class}{$data}";
759
-
760
-            if ($column_name === 'cb') {
761
-                echo '<th scope="row" class="check-column">';
762
-                echo apply_filters(
763
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
764
-                    $this->column_cb($item), // already escaped
765
-                    $item,
766
-                    $this
767
-                );
768
-                echo '</th>';
769
-            } elseif (method_exists($this, 'column_' . $column_name)) {
770
-                echo "<td $attributes>"; // already escaped
771
-                echo apply_filters(
772
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
773
-                    call_user_func([$this, 'column_' . $column_name], $item),
774
-                    $item,
775
-                    $this
776
-                );
777
-                echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
778
-                echo "</td>";
779
-            } else {
780
-                echo "<td $attributes>"; // already escaped
781
-                echo apply_filters(
782
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
783
-                    $this->column_default($item, $column_name),
784
-                    $item,
785
-                    $column_name,
786
-                    $this
787
-                );
788
-                echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
789
-                echo "</td>";
790
-            }
791
-        }
792
-    }
793
-
794
-
795
-    /**
796
-     * Extra controls to be displayed between bulk actions and pagination
797
-     *
798
-     * @access public
799
-     * @param string $which
800
-     * @throws EE_Error
801
-     */
802
-    public function extra_tablenav($which)
803
-    {
804
-        if ($which === 'top') {
805
-            $this->_filters();
806
-            echo wp_kses($this->_get_hidden_fields(), AllowedTags::getWithFormTags());
807
-        } else {
808
-            echo '<div class="list-table-bottom-buttons alignleft actions">';
809
-            foreach ($this->_bottom_buttons as $type => $action) {
810
-                $route         = isset($action['route']) ? $action['route'] : '';
811
-                $extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
812
-                // already escaped
813
-                echo wp_kses($this->_admin_page->get_action_link_or_button(
814
-                    $route,
815
-                    $type,
816
-                    $extra_request,
817
-                    'button button--secondary'
818
-                ), AllowedTags::getWithFormTags());
819
-            }
820
-            do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
821
-            echo '</div>';
822
-        }
823
-    }
824
-
825
-
826
-    /**
827
-     * Get an associative array ( option_name => option_title ) with the list
828
-     * of bulk actions available on this table.
829
-     *
830
-     * @return array
831
-     * @since  3.1.0
832
-     * @access protected
833
-     */
834
-    public function get_bulk_actions()
835
-    {
836
-        return (array) $this->_get_bulk_actions();
837
-    }
838
-
839
-
840
-    /**
841
-     * Processing bulk actions.
842
-     */
843
-    public function process_bulk_action()
844
-    {
845
-        // this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
846
-        // reference in case there is a case where it gets used.
847
-    }
848
-
849
-
850
-    /**
851
-     * returns the EE admin page this list table is associated with
852
-     *
853
-     * @return EE_Admin_Page
854
-     */
855
-    public function get_admin_page()
856
-    {
857
-        return $this->_admin_page;
858
-    }
859
-
860
-
861
-    /**
862
-     * A "helper" function for all children to provide an html string of
863
-     * actions to output in their content.  It is preferable for child classes
864
-     * to use this method for generating their actions content so that it's
865
-     * filterable by plugins
866
-     *
867
-     * @param string        $action_container           what are the html container
868
-     *                                                  elements for this actions string?
869
-     * @param string        $action_class               What class is for the container
870
-     *                                                  element.
871
-     * @param string        $action_items               The contents for the action items
872
-     *                                                  container.  This is filtered before
873
-     *                                                  returned.
874
-     * @param string        $action_id                  What id (optional) is used for the
875
-     *                                                  container element.
876
-     * @param EE_Base_Class $item                       The object for the column displaying
877
-     *                                                  the actions.
878
-     * @return string The assembled action elements container.
879
-     */
880
-    protected function _action_string(
881
-        $action_items,
882
-        $item,
883
-        $action_container = 'ul',
884
-        $action_class = '',
885
-        $action_id = ''
886
-    ) {
887
-        $action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
888
-        $action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
889
-        $open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
890
-        $close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
891
-        try {
892
-            $content = apply_filters(
893
-                'FHEE__EE_Admin_List_Table___action_string__action_items',
894
-                $action_items,
895
-                $item,
896
-                $this
897
-            );
898
-        } catch (Exception $e) {
899
-            if (WP_DEBUG) {
900
-                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
901
-            }
902
-            $content = $action_items;
903
-        }
904
-        return "{$open_tag}{$content}{$close_tag}";
905
-    }
906
-
907
-
908
-    /**
909
-     * @return string
910
-     */
911
-    protected function getReturnUrl()
912
-    {
913
-        $host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
914
-        $uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
915
-        return urlencode(esc_url_raw("//{$host}{$uri}"));
916
-    }
465
+	}
466
+
467
+
468
+	/**
469
+	 * _filters
470
+	 * This receives the filters array from children _get_table_filters() and assembles the string including the filter
471
+	 * button.
472
+	 *
473
+	 * @access private
474
+	 * @return void  echos html showing filters
475
+	 */
476
+	private function _filters()
477
+	{
478
+		$classname = get_class($this);
479
+		$filters   = apply_filters(
480
+			"FHEE__{$classname}__filters",
481
+			(array) $this->_get_table_filters(),
482
+			$this,
483
+			$this->_screen
484
+		);
485
+
486
+		if (empty($filters)) {
487
+			return;
488
+		}
489
+		$use_filters = isset($this->_req_data['use_filters'])
490
+					   && filter_var($this->_req_data['use_filters'], FILTER_VALIDATE_BOOLEAN)
491
+			? 'yes'
492
+			: 'no';
493
+
494
+		echo '<div class="ee-list-table-filters actions alignleft">';
495
+		foreach ($filters as $filter) {
496
+			echo wp_kses($filter, AllowedTags::getWithFormTags());
497
+		}
498
+		// add filter button at end
499
+		echo '<input type="submit" class="ee-list-table-filter-submit button button--secondary" value="'
500
+			 . esc_html__('Filter', 'event_espresso')
501
+			 . '" id="post-query-submit" />';
502
+		echo '<input type="hidden" id="ee-list-table-use-filters" name="use_filters" value="' . $use_filters . '"/>';
503
+
504
+		// add reset filters button at end
505
+		echo '<a class="button button--secondary"  href="'
506
+			 . esc_url_raw($this->_admin_page->get_current_page_view_url())
507
+			 . '" style="display:inline-block">'
508
+			 . esc_html__('Reset Filters', 'event_espresso')
509
+			 . '</a>';
510
+		echo '</div>';
511
+	}
512
+
513
+
514
+	/**
515
+	 * Callback for 'list_table_primary_column' WordPress filter
516
+	 * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
517
+	 * column when class is instantiated.
518
+	 *
519
+	 * @param string $column_name
520
+	 * @return string
521
+	 * @see WP_List_Table::get_primary_column_name
522
+	 */
523
+	public function set_primary_column($column_name)
524
+	{
525
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
526
+	}
527
+
528
+
529
+	/**
530
+	 *
531
+	 */
532
+	public function prepare_items()
533
+	{
534
+		$this->_set_column_info();
535
+		$this->process_bulk_action();
536
+
537
+		$this->items = $this->_data;
538
+		$this->set_pagination_args(
539
+			[
540
+				'total_items' => $this->_all_data_count,
541
+				'per_page'    => $this->_per_page,
542
+				'total_pages' => (int) ceil($this->_all_data_count / $this->_per_page),
543
+			]
544
+		);
545
+	}
546
+
547
+
548
+	/**
549
+	 * @param object|array $item
550
+	 * @return string html content for the column
551
+	 */
552
+	protected function column_cb($item)
553
+	{
554
+		return '';
555
+	}
556
+
557
+
558
+	/**
559
+	 * This column is the default for when there is no defined column method for a registered column.
560
+	 * This can be overridden by child classes, but allows for hooking in for custom columns.
561
+	 *
562
+	 * @param EE_Base_Class $item
563
+	 * @param string        $column_name The column being called.
564
+	 * @return string html content for the column
565
+	 */
566
+	public function column_default($item, $column_name)
567
+	{
568
+		/**
569
+		 * Dynamic hook allowing for adding additional column content in this list table.
570
+		 * Note that $this->screen->id is in the format
571
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
572
+		 * table it is: event-espresso_page_espresso_messages.
573
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
574
+		 * hook prefix ("event-espresso") will be different.
575
+		 */
576
+		ob_start();
577
+		do_action(
578
+			'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
579
+			$item,
580
+			$this->_screen
581
+		);
582
+		return ob_get_clean();
583
+	}
584
+
585
+
586
+	/**
587
+	 * Get a list of columns. The format is:
588
+	 * 'internal-name' => 'Title'
589
+	 *
590
+	 * @return array
591
+	 * @since  3.1.0
592
+	 * @access public
593
+	 * @abstract
594
+	 */
595
+	public function get_columns()
596
+	{
597
+		/**
598
+		 * Dynamic hook allowing for adding additional columns in this list table.
599
+		 * Note that $this->screen->id is in the format
600
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
601
+		 * table it is: event-espresso_page_espresso_messages.
602
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
603
+		 * hook prefix ("event-espresso") will be different.
604
+		 *
605
+		 * @var array
606
+		 */
607
+		return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
608
+	}
609
+
610
+
611
+	/**
612
+	 * Get an associative array ( id => link ) with the list
613
+	 * of views available on this table.
614
+	 *
615
+	 * @return array
616
+	 * @since  3.1.0
617
+	 * @access protected
618
+	 */
619
+	public function get_views()
620
+	{
621
+		return $this->_views;
622
+	}
623
+
624
+
625
+	/**
626
+	 * Generate the views html.
627
+	 */
628
+	public function display_views()
629
+	{
630
+		$views           = $this->get_views();
631
+		$assembled_views = [];
632
+
633
+		if (empty($views)) {
634
+			return;
635
+		}
636
+		echo "<ul class='subsubsub'>\n";
637
+		foreach ($views as $view) {
638
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
639
+			if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
640
+				$filter = "<li";
641
+				$filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
642
+				$filter .= ">";
643
+				$filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
644
+				$filter .= '<span class="count">(' . $count . ')</span>';
645
+				$filter .= '</li>';
646
+				$assembled_views[ $view['slug'] ] = $filter;
647
+			}
648
+		}
649
+
650
+		echo ! empty($assembled_views)
651
+			? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
652
+			: '';
653
+		echo "</ul>";
654
+	}
655
+
656
+
657
+	/**
658
+	 * Generates content for a single row of the table
659
+	 *
660
+	 * @param EE_Base_Class $item The current item
661
+	 * @since  4.1
662
+	 * @access public
663
+	 */
664
+	public function single_row($item)
665
+	{
666
+		$row_class = $this->_get_row_class($item);
667
+		echo '<tr class="' . esc_attr($row_class) . '">';
668
+		$this->single_row_columns($item); // already escaped
669
+		echo '</tr>';
670
+	}
671
+
672
+
673
+	/**
674
+	 * This simply sets up the row class for the table rows.
675
+	 * Allows for easier overriding of child methods for setting up sorting.
676
+	 *
677
+	 * @param EE_Base_Class $item the current item
678
+	 * @return string
679
+	 */
680
+	protected function _get_row_class($item)
681
+	{
682
+		static $row_class = '';
683
+		$row_class = ($row_class === '' ? 'alternate' : '');
684
+
685
+		$new_row_class = $row_class;
686
+
687
+		if (! empty($this->_ajax_sorting_callback)) {
688
+			$new_row_class .= ' rowsortable';
689
+		}
690
+
691
+		return $new_row_class;
692
+	}
693
+
694
+
695
+	/**
696
+	 * @return array
697
+	 */
698
+	public function get_sortable_columns()
699
+	{
700
+		return (array) $this->_sortable_columns;
701
+	}
702
+
703
+
704
+	/**
705
+	 * @return string
706
+	 */
707
+	public function get_ajax_sorting_callback()
708
+	{
709
+		return $this->_ajax_sorting_callback;
710
+	}
711
+
712
+
713
+	/**
714
+	 * @return array
715
+	 */
716
+	public function get_hidden_columns()
717
+	{
718
+		$user_id     = get_current_user_id();
719
+		$has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
720
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
721
+			update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
722
+			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
723
+		}
724
+		$ref = 'manage' . $this->screen->id . 'columnshidden';
725
+		return (array) get_user_option($ref, $user_id);
726
+	}
727
+
728
+
729
+	/**
730
+	 * Generates the columns for a single row of the table.
731
+	 * Overridden from wp_list_table so as to allow us to filter the column content for a given
732
+	 * column.
733
+	 *
734
+	 * @param EE_Base_Class $item The current item
735
+	 * @since 3.1.0
736
+	 */
737
+	public function single_row_columns($item)
738
+	{
739
+		[$columns, $hidden, $sortable, $primary] = $this->get_column_info();
740
+
741
+		foreach ($columns as $column_name => $column_display_name) {
742
+
743
+			/**
744
+			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
745
+			 * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
746
+			 */
747
+			$hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
748
+
749
+			$classes = $column_name . ' column-' . $column_name . $hidden_class;
750
+			if ($primary === $column_name) {
751
+				$classes .= ' has-row-actions column-primary';
752
+			}
753
+
754
+			$data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
755
+
756
+			$class = 'class="' . esc_attr($classes) . '"';
757
+
758
+			$attributes = "{$class}{$data}";
759
+
760
+			if ($column_name === 'cb') {
761
+				echo '<th scope="row" class="check-column">';
762
+				echo apply_filters(
763
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
764
+					$this->column_cb($item), // already escaped
765
+					$item,
766
+					$this
767
+				);
768
+				echo '</th>';
769
+			} elseif (method_exists($this, 'column_' . $column_name)) {
770
+				echo "<td $attributes>"; // already escaped
771
+				echo apply_filters(
772
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
773
+					call_user_func([$this, 'column_' . $column_name], $item),
774
+					$item,
775
+					$this
776
+				);
777
+				echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
778
+				echo "</td>";
779
+			} else {
780
+				echo "<td $attributes>"; // already escaped
781
+				echo apply_filters(
782
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
783
+					$this->column_default($item, $column_name),
784
+					$item,
785
+					$column_name,
786
+					$this
787
+				);
788
+				echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
789
+				echo "</td>";
790
+			}
791
+		}
792
+	}
793
+
794
+
795
+	/**
796
+	 * Extra controls to be displayed between bulk actions and pagination
797
+	 *
798
+	 * @access public
799
+	 * @param string $which
800
+	 * @throws EE_Error
801
+	 */
802
+	public function extra_tablenav($which)
803
+	{
804
+		if ($which === 'top') {
805
+			$this->_filters();
806
+			echo wp_kses($this->_get_hidden_fields(), AllowedTags::getWithFormTags());
807
+		} else {
808
+			echo '<div class="list-table-bottom-buttons alignleft actions">';
809
+			foreach ($this->_bottom_buttons as $type => $action) {
810
+				$route         = isset($action['route']) ? $action['route'] : '';
811
+				$extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
812
+				// already escaped
813
+				echo wp_kses($this->_admin_page->get_action_link_or_button(
814
+					$route,
815
+					$type,
816
+					$extra_request,
817
+					'button button--secondary'
818
+				), AllowedTags::getWithFormTags());
819
+			}
820
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
821
+			echo '</div>';
822
+		}
823
+	}
824
+
825
+
826
+	/**
827
+	 * Get an associative array ( option_name => option_title ) with the list
828
+	 * of bulk actions available on this table.
829
+	 *
830
+	 * @return array
831
+	 * @since  3.1.0
832
+	 * @access protected
833
+	 */
834
+	public function get_bulk_actions()
835
+	{
836
+		return (array) $this->_get_bulk_actions();
837
+	}
838
+
839
+
840
+	/**
841
+	 * Processing bulk actions.
842
+	 */
843
+	public function process_bulk_action()
844
+	{
845
+		// this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
846
+		// reference in case there is a case where it gets used.
847
+	}
848
+
849
+
850
+	/**
851
+	 * returns the EE admin page this list table is associated with
852
+	 *
853
+	 * @return EE_Admin_Page
854
+	 */
855
+	public function get_admin_page()
856
+	{
857
+		return $this->_admin_page;
858
+	}
859
+
860
+
861
+	/**
862
+	 * A "helper" function for all children to provide an html string of
863
+	 * actions to output in their content.  It is preferable for child classes
864
+	 * to use this method for generating their actions content so that it's
865
+	 * filterable by plugins
866
+	 *
867
+	 * @param string        $action_container           what are the html container
868
+	 *                                                  elements for this actions string?
869
+	 * @param string        $action_class               What class is for the container
870
+	 *                                                  element.
871
+	 * @param string        $action_items               The contents for the action items
872
+	 *                                                  container.  This is filtered before
873
+	 *                                                  returned.
874
+	 * @param string        $action_id                  What id (optional) is used for the
875
+	 *                                                  container element.
876
+	 * @param EE_Base_Class $item                       The object for the column displaying
877
+	 *                                                  the actions.
878
+	 * @return string The assembled action elements container.
879
+	 */
880
+	protected function _action_string(
881
+		$action_items,
882
+		$item,
883
+		$action_container = 'ul',
884
+		$action_class = '',
885
+		$action_id = ''
886
+	) {
887
+		$action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
888
+		$action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
889
+		$open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
890
+		$close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
891
+		try {
892
+			$content = apply_filters(
893
+				'FHEE__EE_Admin_List_Table___action_string__action_items',
894
+				$action_items,
895
+				$item,
896
+				$this
897
+			);
898
+		} catch (Exception $e) {
899
+			if (WP_DEBUG) {
900
+				EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
901
+			}
902
+			$content = $action_items;
903
+		}
904
+		return "{$open_tag}{$content}{$close_tag}";
905
+	}
906
+
907
+
908
+	/**
909
+	 * @return string
910
+	 */
911
+	protected function getReturnUrl()
912
+	{
913
+		$host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
914
+		$uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
915
+		return urlencode(esc_url_raw("//{$host}{$uri}"));
916
+	}
917 917
 }
Please login to merge, or discard this patch.
core/EE_Deprecated.core.php 1 patch
Indentation   +1222 added lines, -1222 removed lines patch added patch discarded remove patch
@@ -39,31 +39,31 @@  discard block
 block discarded – undo
39 39
  * @param string $action_or_filter
40 40
  */
41 41
 function deprecated_espresso_action_or_filter_doing_it_wrong(
42
-    $deprecated_filter,
43
-    $replacement,
44
-    $replacement_location,
45
-    $version_deprecated,
46
-    $version_applies,
47
-    $action_or_filter = 'action'
42
+	$deprecated_filter,
43
+	$replacement,
44
+	$replacement_location,
45
+	$version_deprecated,
46
+	$version_applies,
47
+	$action_or_filter = 'action'
48 48
 ) {
49
-    $action_or_filter = $action_or_filter === 'action'
50
-        ? esc_html__('action', 'event_espresso')
51
-        : esc_html__('filter', 'event_espresso');
52
-    EE_Error::doing_it_wrong(
53
-        $deprecated_filter,
54
-        sprintf(
55
-            esc_html__(
56
-                'This %1$s is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"',
57
-                'event_espresso'
58
-            ),
59
-            $action_or_filter,
60
-            $replacement,
61
-            $replacement_location,
62
-            '<br />'
63
-        ),
64
-        $version_deprecated,
65
-        $version_applies
66
-    );
49
+	$action_or_filter = $action_or_filter === 'action'
50
+		? esc_html__('action', 'event_espresso')
51
+		: esc_html__('filter', 'event_espresso');
52
+	EE_Error::doing_it_wrong(
53
+		$deprecated_filter,
54
+		sprintf(
55
+			esc_html__(
56
+				'This %1$s is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new %1$s: %4$s"%2$s" found in "%3$s"',
57
+				'event_espresso'
58
+			),
59
+			$action_or_filter,
60
+			$replacement,
61
+			$replacement_location,
62
+			'<br />'
63
+		),
64
+		$version_deprecated,
65
+		$version_applies
66
+	);
67 67
 }
68 68
 
69 69
 /**
@@ -75,90 +75,90 @@  discard block
 block discarded – undo
75 75
  */
76 76
 function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout)
77 77
 {
78
-    // list of old filters
79
-    $deprecated_filters = array(
80
-        'update_registration_details' => true,
81
-        'process_payment'             => true,
82
-        'finalize_registration'       => true,
83
-        'and_proceed_to_payment'      => true,
84
-        'proceed_to'                  => true,
85
-    );
86
-    // loop thru and call doing_it_wrong() or remove any that aren't being used
87
-    foreach ($deprecated_filters as $deprecated_filter => $on) {
88
-        // was this filter called ?
89
-        if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) {
90
-            // only display doing_it_wrong() notice to Event Admins during non-AJAX requests
91
-            if (EE_Registry::instance()->CAP->current_user_can(
92
-                    'ee_read_ee',
93
-                    'hide_doing_it_wrong_for_deprecated_SPCO_filter'
94
-                ) && ! defined('DOING_AJAX')) {
95
-                EE_Error::doing_it_wrong(
96
-                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
97
-                    sprintf(
98
-                        esc_html__(
99
-                            'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"',
100
-                            'event_espresso'
101
-                        ),
102
-                        'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
103
-                        '<br />',
104
-                        'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
105
-                        '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
106
-                    ),
107
-                    '4.6.10'
108
-                );
109
-            }
110
-        } else {
111
-            unset($deprecated_filters[ $deprecated_filter ]);
112
-        }
113
-    }
114
-    if (! empty($deprecated_filters)) {
115
-
116
-        if ($checkout->current_step->slug(
117
-            ) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
118
-            $submit_button_text = apply_filters(
119
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details',
120
-                $submit_button_text
121
-            );
122
-        } elseif ($checkout->current_step->slug(
123
-            ) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) {
124
-            $submit_button_text = apply_filters(
125
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment',
126
-                $submit_button_text
127
-            );
128
-        } elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug(
129
-            ) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) {
130
-            $submit_button_text = apply_filters(
131
-                'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration',
132
-                $submit_button_text
133
-            );
134
-        }
135
-        if ($checkout->next_step instanceof EE_SPCO_Reg_Step) {
136
-            if ($checkout->payment_required() && $checkout->next_step->slug(
137
-                ) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) {
138
-                $submit_button_text .= apply_filters(
139
-                    'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment',
140
-                    $submit_button_text
141
-                );
142
-            }
143
-            if ($checkout->next_step->slug(
144
-                ) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) {
145
-                $submit_button_text = apply_filters(
146
-                                          'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to',
147
-                                          $submit_button_text
148
-                                      ) . $checkout->next_step->name();
149
-            }
150
-        }
151
-
152
-    }
153
-    return $submit_button_text;
78
+	// list of old filters
79
+	$deprecated_filters = array(
80
+		'update_registration_details' => true,
81
+		'process_payment'             => true,
82
+		'finalize_registration'       => true,
83
+		'and_proceed_to_payment'      => true,
84
+		'proceed_to'                  => true,
85
+	);
86
+	// loop thru and call doing_it_wrong() or remove any that aren't being used
87
+	foreach ($deprecated_filters as $deprecated_filter => $on) {
88
+		// was this filter called ?
89
+		if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter)) {
90
+			// only display doing_it_wrong() notice to Event Admins during non-AJAX requests
91
+			if (EE_Registry::instance()->CAP->current_user_can(
92
+					'ee_read_ee',
93
+					'hide_doing_it_wrong_for_deprecated_SPCO_filter'
94
+				) && ! defined('DOING_AJAX')) {
95
+				EE_Error::doing_it_wrong(
96
+					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
97
+					sprintf(
98
+						esc_html__(
99
+							'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"',
100
+							'event_espresso'
101
+						),
102
+						'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
103
+						'<br />',
104
+						'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
105
+						'/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
106
+					),
107
+					'4.6.10'
108
+				);
109
+			}
110
+		} else {
111
+			unset($deprecated_filters[ $deprecated_filter ]);
112
+		}
113
+	}
114
+	if (! empty($deprecated_filters)) {
115
+
116
+		if ($checkout->current_step->slug(
117
+			) == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
118
+			$submit_button_text = apply_filters(
119
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details',
120
+				$submit_button_text
121
+			);
122
+		} elseif ($checkout->current_step->slug(
123
+			) == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) {
124
+			$submit_button_text = apply_filters(
125
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment',
126
+				$submit_button_text
127
+			);
128
+		} elseif ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug(
129
+			) == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) {
130
+			$submit_button_text = apply_filters(
131
+				'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration',
132
+				$submit_button_text
133
+			);
134
+		}
135
+		if ($checkout->next_step instanceof EE_SPCO_Reg_Step) {
136
+			if ($checkout->payment_required() && $checkout->next_step->slug(
137
+				) == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) {
138
+				$submit_button_text .= apply_filters(
139
+					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment',
140
+					$submit_button_text
141
+				);
142
+			}
143
+			if ($checkout->next_step->slug(
144
+				) != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) {
145
+				$submit_button_text = apply_filters(
146
+										  'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to',
147
+										  $submit_button_text
148
+									  ) . $checkout->next_step->name();
149
+			}
150
+		}
151
+
152
+	}
153
+	return $submit_button_text;
154 154
 
155 155
 }
156 156
 
157 157
 add_filter(
158
-    'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
159
-    'ee_deprecated__registration_checkout__button_text',
160
-    10,
161
-    2
158
+	'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
159
+	'ee_deprecated__registration_checkout__button_text',
160
+	10,
161
+	2
162 162
 );
163 163
 
164 164
 
@@ -170,54 +170,54 @@  discard block
 block discarded – undo
170 170
  */
171 171
 function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates)
172 172
 {
173
-    $action_ref = null;
174
-    $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction')
175
-        ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
176
-    $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction')
177
-        ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
178
-    if ($action_ref) {
179
-
180
-        EE_Error::doing_it_wrong(
181
-            $action_ref,
182
-            sprintf(
183
-                esc_html__(
184
-                    'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"',
185
-                    'event_espresso'
186
-                ),
187
-                '<br />',
188
-                '/core/business/EE_Transaction_Processor.class.php',
189
-                'AHEE__EE_Transaction_Processor__finalize',
190
-                'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
191
-                'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events',
192
-                'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing'
193
-            ),
194
-            '4.6.0'
195
-        );
196
-        switch ($action_ref) {
197
-            case 'AHEE__EE_Transaction__finalize__new_transaction' :
198
-                do_action(
199
-                    'AHEE__EE_Transaction__finalize__new_transaction',
200
-                    $checkout->transaction,
201
-                    $checkout->admin_request
202
-                );
203
-                break;
204
-            case 'AHEE__EE_Transaction__finalize__all_transaction' :
205
-                do_action(
206
-                    'AHEE__EE_Transaction__finalize__new_transaction',
207
-                    $checkout->transaction,
208
-                    array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates),
209
-                    $checkout->admin_request
210
-                );
211
-                break;
212
-        }
213
-    }
173
+	$action_ref = null;
174
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction')
175
+		? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
176
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction')
177
+		? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
178
+	if ($action_ref) {
179
+
180
+		EE_Error::doing_it_wrong(
181
+			$action_ref,
182
+			sprintf(
183
+				esc_html__(
184
+					'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"',
185
+					'event_espresso'
186
+				),
187
+				'<br />',
188
+				'/core/business/EE_Transaction_Processor.class.php',
189
+				'AHEE__EE_Transaction_Processor__finalize',
190
+				'AHEE__EE_Transaction_Processor__manually_update_registration_statuses',
191
+				'AHEE__EE_Transaction_Processor__toggle_registration_statuses_for_default_approved_events',
192
+				'AHEE__EE_Transaction_Processor__toggle_registration_statuses_if_no_monies_owing'
193
+			),
194
+			'4.6.0'
195
+		);
196
+		switch ($action_ref) {
197
+			case 'AHEE__EE_Transaction__finalize__new_transaction' :
198
+				do_action(
199
+					'AHEE__EE_Transaction__finalize__new_transaction',
200
+					$checkout->transaction,
201
+					$checkout->admin_request
202
+				);
203
+				break;
204
+			case 'AHEE__EE_Transaction__finalize__all_transaction' :
205
+				do_action(
206
+					'AHEE__EE_Transaction__finalize__new_transaction',
207
+					$checkout->transaction,
208
+					array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates),
209
+					$checkout->admin_request
210
+				);
211
+				break;
212
+		}
213
+	}
214 214
 }
215 215
 
216 216
 add_action(
217
-    'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed',
218
-    'ee_deprecated_finalize_transaction',
219
-    10,
220
-    2
217
+	'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed',
218
+	'ee_deprecated_finalize_transaction',
219
+	10,
220
+	2
221 221
 );
222 222
 /**
223 223
  * ee_deprecated_finalize_registration
@@ -226,35 +226,35 @@  discard block
 block discarded – undo
226 226
  */
227 227
 function ee_deprecated_finalize_registration(EE_Registration $registration)
228 228
 {
229
-    $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg')
230
-        ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null;
231
-    if ($action_ref) {
232
-        EE_Error::doing_it_wrong(
233
-            $action_ref,
234
-            sprintf(
235
-                esc_html__(
236
-                    'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"',
237
-                    'event_espresso'
238
-                ),
239
-                '<br />',
240
-                '/core/business/EE_Registration_Processor.class.php',
241
-                'AHEE__EE_Registration_Processor__trigger_registration_update_notifications'
242
-            ),
243
-            '4.6.0'
244
-        );
245
-        do_action(
246
-            'AHEE__EE_Registration__finalize__update_and_new_reg',
247
-            $registration,
248
-            (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))
249
-        );
250
-    }
229
+	$action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg')
230
+		? 'AHEE__EE_Registration__finalize__update_and_new_reg' : null;
231
+	if ($action_ref) {
232
+		EE_Error::doing_it_wrong(
233
+			$action_ref,
234
+			sprintf(
235
+				esc_html__(
236
+					'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"',
237
+					'event_espresso'
238
+				),
239
+				'<br />',
240
+				'/core/business/EE_Registration_Processor.class.php',
241
+				'AHEE__EE_Registration_Processor__trigger_registration_update_notifications'
242
+			),
243
+			'4.6.0'
244
+		);
245
+		do_action(
246
+			'AHEE__EE_Registration__finalize__update_and_new_reg',
247
+			$registration,
248
+			(is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))
249
+		);
250
+	}
251 251
 }
252 252
 
253 253
 add_action(
254
-    'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
255
-    'ee_deprecated_finalize_registration',
256
-    10,
257
-    1
254
+	'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
255
+	'ee_deprecated_finalize_registration',
256
+	10,
257
+	1
258 258
 );
259 259
 
260 260
 
@@ -264,44 +264,44 @@  discard block
 block discarded – undo
264 264
  */
265 265
 function ee_deprecated_hooks()
266 266
 {
267
-    /**
268
-     * @var          $hooks       array where keys are hook names, and their values are array{
269
-     * @type string  $version     when deprecated
270
-     * @type string  $alternative saying what to use instead
271
-     * @type boolean $still_works whether or not the hook still works
272
-     *        }
273
-     */
274
-    $hooks = array(
275
-        'AHEE__EE_System___do_setup_validations' => array(
276
-            'version'     => '4.6.0',
277
-            'alternative' => esc_html__(
278
-                'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)',
279
-                'event_espresso'
280
-            ),
281
-            'still_works' => false,
282
-        ),
283
-    );
284
-    foreach ($hooks as $name => $deprecation_info) {
285
-        if (has_action($name)) {
286
-            EE_Error::doing_it_wrong(
287
-                $name,
288
-                sprintf(
289
-                    esc_html__('This filter is deprecated. %1$s%2$s', 'event_espresso'),
290
-                    $deprecation_info['still_works'] ? esc_html__(
291
-                        'It *may* work as an attempt to build in backwards compatibility.',
292
-                        'event_espresso'
293
-                    ) : esc_html__('It has been completely removed.', 'event_espresso'),
294
-                    isset($deprecation_info['alternative'])
295
-                        ? $deprecation_info['alternative']
296
-                        : esc_html__(
297
-                        'Please read the current EE4 documentation further or contact Support.',
298
-                        'event_espresso'
299
-                    )
300
-                ),
301
-                isset($deprecation_info['version']) ? $deprecation_info['version'] : esc_html__('recently', 'event_espresso')
302
-            );
303
-        }
304
-    }
267
+	/**
268
+	 * @var          $hooks       array where keys are hook names, and their values are array{
269
+	 * @type string  $version     when deprecated
270
+	 * @type string  $alternative saying what to use instead
271
+	 * @type boolean $still_works whether or not the hook still works
272
+	 *        }
273
+	 */
274
+	$hooks = array(
275
+		'AHEE__EE_System___do_setup_validations' => array(
276
+			'version'     => '4.6.0',
277
+			'alternative' => esc_html__(
278
+				'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)',
279
+				'event_espresso'
280
+			),
281
+			'still_works' => false,
282
+		),
283
+	);
284
+	foreach ($hooks as $name => $deprecation_info) {
285
+		if (has_action($name)) {
286
+			EE_Error::doing_it_wrong(
287
+				$name,
288
+				sprintf(
289
+					esc_html__('This filter is deprecated. %1$s%2$s', 'event_espresso'),
290
+					$deprecation_info['still_works'] ? esc_html__(
291
+						'It *may* work as an attempt to build in backwards compatibility.',
292
+						'event_espresso'
293
+					) : esc_html__('It has been completely removed.', 'event_espresso'),
294
+					isset($deprecation_info['alternative'])
295
+						? $deprecation_info['alternative']
296
+						: esc_html__(
297
+						'Please read the current EE4 documentation further or contact Support.',
298
+						'event_espresso'
299
+					)
300
+				),
301
+				isset($deprecation_info['version']) ? $deprecation_info['version'] : esc_html__('recently', 'event_espresso')
302
+			);
303
+		}
304
+	}
305 305
 }
306 306
 
307 307
 add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks');
@@ -316,34 +316,34 @@  discard block
 block discarded – undo
316 316
  */
317 317
 function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
318 318
 {
319
-    $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns')
320
-              || has_action(
321
-                  'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'
322
-              );
323
-    if ($in_use) {
324
-        $msg = esc_html__(
325
-            'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
326
-            . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
327
-            . 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end '
328
-            . 'to add other actions after a form submission has been received.',
329
-            'event_espresso'
330
-        );
331
-        EE_Error::doing_it_wrong(
332
-            __CLASS__ . '::' . __FUNCTION__,
333
-            $msg,
334
-            '4.8.32.rc.000'
335
-        );
336
-        // it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
337
-        if (is_admin() && ! defined('DOING_AJAX')) {
338
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
339
-        }
340
-    }
341
-    return $in_use;
319
+	$in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns')
320
+			  || has_action(
321
+				  'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'
322
+			  );
323
+	if ($in_use) {
324
+		$msg = esc_html__(
325
+			'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
326
+			. 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
327
+			. 'use FHEE__EE_Form_Section_Proper__receive_form_submission__req_data to customize the submission data, or AHEE__EE_Form_Section_Proper__receive_form_submission__end '
328
+			. 'to add other actions after a form submission has been received.',
329
+			'event_espresso'
330
+		);
331
+		EE_Error::doing_it_wrong(
332
+			__CLASS__ . '::' . __FUNCTION__,
333
+			$msg,
334
+			'4.8.32.rc.000'
335
+		);
336
+		// it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
337
+		if (is_admin() && ! defined('DOING_AJAX')) {
338
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
339
+		}
340
+	}
341
+	return $in_use;
342 342
 }
343 343
 
344 344
 add_action(
345
-    'AHEE__Registrations_Admin_Page___registration_details_metabox__start',
346
-    'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'
345
+	'AHEE__Registrations_Admin_Page___registration_details_metabox__start',
346
+	'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'
347 347
 );
348 348
 
349 349
 /**
@@ -355,82 +355,82 @@  discard block
 block discarded – undo
355 355
  */
356 356
 function ee_deprecated_update_attendee_registration_form_old($admin_page)
357 357
 {
358
-    // check if the old hooks are in use. If not, do the default
359
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
360
-        || ! $admin_page instanceof EE_Admin_Page) {
361
-        return;
362
-    }
363
-    $req_data = $admin_page->get_request_data();
364
-    $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false;
365
-    $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false;
366
-    $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
367
-    if (! $REG_ID || ! $qstns) {
368
-        EE_Error::add_error(
369
-            esc_html__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'),
370
-            __FILE__,
371
-            __FUNCTION__,
372
-            __LINE__
373
-        );
374
-    }
375
-    $success = true;
376
-
377
-    // allow others to get in on this awesome fun   :D
378
-    do_action(
379
-        'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save',
380
-        $REG_ID,
381
-        $qstns
382
-    );
383
-    // loop thru questions... FINALLY!!!
384
-
385
-    foreach ($qstns as $QST_ID => $qstn) {
386
-        // if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
387
-        if (! is_array($qstn)) {
388
-            $set_values = [
389
-                'QST_ID'    => $QST_ID,
390
-                'REG_ID'    => $REG_ID,
391
-                'ANS_value' => $qstn,
392
-            ];
393
-            $success    = EEM_Answer::instance()->insert($set_values);
394
-            continue;
395
-        }
396
-
397
-
398
-        foreach ($qstn as $ANS_ID => $ANS_value) {
399
-            // get answer
400
-            $query_params = array(
401
-                0 => array(
402
-                    'ANS_ID' => $ANS_ID,
403
-                    'REG_ID' => $REG_ID,
404
-                    'QST_ID' => $QST_ID,
405
-                ),
406
-            );
407
-            $answer = EEM_Answer::instance()->get_one($query_params);
408
-            // this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
409
-            if (! $answer instanceof EE_Answer) {
410
-                $set_values = array(
411
-                    'QST_ID'    => $QST_ID,
412
-                    'REG_ID'    => $REG_ID,
413
-                    'ANS_value' => $qstn,
414
-                );
415
-                $success = EEM_Answer::instance()->insert($set_values);
416
-                continue 2;
417
-            }
418
-
419
-            $answer->set('ANS_value', $ANS_value);
420
-            $success = $answer->save();
421
-        }
422
-    }
423
-    $what = esc_html__('Registration Form', 'event_espresso');
424
-    $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
425
-    $admin_page->redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
426
-    exit;
358
+	// check if the old hooks are in use. If not, do the default
359
+	if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
360
+		|| ! $admin_page instanceof EE_Admin_Page) {
361
+		return;
362
+	}
363
+	$req_data = $admin_page->get_request_data();
364
+	$qstns = isset($req_data['qstn']) ? $req_data['qstn'] : false;
365
+	$REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : false;
366
+	$qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
367
+	if (! $REG_ID || ! $qstns) {
368
+		EE_Error::add_error(
369
+			esc_html__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'),
370
+			__FILE__,
371
+			__FUNCTION__,
372
+			__LINE__
373
+		);
374
+	}
375
+	$success = true;
376
+
377
+	// allow others to get in on this awesome fun   :D
378
+	do_action(
379
+		'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save',
380
+		$REG_ID,
381
+		$qstns
382
+	);
383
+	// loop thru questions... FINALLY!!!
384
+
385
+	foreach ($qstns as $QST_ID => $qstn) {
386
+		// if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
387
+		if (! is_array($qstn)) {
388
+			$set_values = [
389
+				'QST_ID'    => $QST_ID,
390
+				'REG_ID'    => $REG_ID,
391
+				'ANS_value' => $qstn,
392
+			];
393
+			$success    = EEM_Answer::instance()->insert($set_values);
394
+			continue;
395
+		}
396
+
397
+
398
+		foreach ($qstn as $ANS_ID => $ANS_value) {
399
+			// get answer
400
+			$query_params = array(
401
+				0 => array(
402
+					'ANS_ID' => $ANS_ID,
403
+					'REG_ID' => $REG_ID,
404
+					'QST_ID' => $QST_ID,
405
+				),
406
+			);
407
+			$answer = EEM_Answer::instance()->get_one($query_params);
408
+			// this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
409
+			if (! $answer instanceof EE_Answer) {
410
+				$set_values = array(
411
+					'QST_ID'    => $QST_ID,
412
+					'REG_ID'    => $REG_ID,
413
+					'ANS_value' => $qstn,
414
+				);
415
+				$success = EEM_Answer::instance()->insert($set_values);
416
+				continue 2;
417
+			}
418
+
419
+			$answer->set('ANS_value', $ANS_value);
420
+			$success = $answer->save();
421
+		}
422
+	}
423
+	$what = esc_html__('Registration Form', 'event_espresso');
424
+	$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
425
+	$admin_page->redirect_after_action($success, $what, esc_html__('updated', 'event_espresso'), $route);
426
+	exit;
427 427
 }
428 428
 
429 429
 add_action(
430
-    'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start',
431
-    'ee_deprecated_update_attendee_registration_form_old',
432
-    10,
433
-    1
430
+	'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start',
431
+	'ee_deprecated_update_attendee_registration_form_old',
432
+	10,
433
+	1
434 434
 );
435 435
 /**
436 436
  * Render the registration admin page's custom questions area in the old fashion
@@ -446,50 +446,50 @@  discard block
 block discarded – undo
446 446
  */
447 447
 function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration)
448 448
 {
449
-    // check if the old hooks are in use. If not, do the default
450
-    if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
451
-        || ! $admin_page instanceof EE_Admin_Page) {
452
-        return $do_default_action;
453
-    }
454
-    add_filter(
455
-        'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
456
-        array($admin_page, 'form_before_question_group'),
457
-        10,
458
-        1
459
-    );
460
-    add_filter(
461
-        'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
462
-        array($admin_page, 'form_after_question_group'),
463
-        10,
464
-        1
465
-    );
466
-    add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1);
467
-    add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1);
468
-
469
-    $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options(
470
-        $registration,
471
-        $registration->get(
472
-            'EVT_ID'
473
-        )
474
-    );
475
-
476
-    EE_Registry::instance()->load_helper('Form_Fields');
477
-    $template_args = array(
478
-        'att_questions'             => EEH_Form_Fields::generate_question_groups_html($question_groups),
479
-        'reg_questions_form_action' => 'edit_registration',
480
-        'REG_ID'                    => $registration->ID(),
481
-    );
482
-    $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
483
-    echo EEH_Template::display_template($template_path, $template_args, true);
484
-    // indicate that we should not do the default admin page code
485
-    return false;
449
+	// check if the old hooks are in use. If not, do the default
450
+	if (! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
451
+		|| ! $admin_page instanceof EE_Admin_Page) {
452
+		return $do_default_action;
453
+	}
454
+	add_filter(
455
+		'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions',
456
+		array($admin_page, 'form_before_question_group'),
457
+		10,
458
+		1
459
+	);
460
+	add_filter(
461
+		'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions',
462
+		array($admin_page, 'form_after_question_group'),
463
+		10,
464
+		1
465
+	);
466
+	add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1);
467
+	add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1);
468
+
469
+	$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options(
470
+		$registration,
471
+		$registration->get(
472
+			'EVT_ID'
473
+		)
474
+	);
475
+
476
+	EE_Registry::instance()->load_helper('Form_Fields');
477
+	$template_args = array(
478
+		'att_questions'             => EEH_Form_Fields::generate_question_groups_html($question_groups),
479
+		'reg_questions_form_action' => 'edit_registration',
480
+		'REG_ID'                    => $registration->ID(),
481
+	);
482
+	$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
483
+	echo EEH_Template::display_template($template_path, $template_args, true);
484
+	// indicate that we should not do the default admin page code
485
+	return false;
486 486
 }
487 487
 
488 488
 add_action(
489
-    'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
490
-    'ee_deprecated_reg_questions_meta_box_old',
491
-    10,
492
-    3
489
+	'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default',
490
+	'ee_deprecated_reg_questions_meta_box_old',
491
+	10,
492
+	3
493 493
 );
494 494
 
495 495
 
@@ -506,42 +506,42 @@  discard block
 block discarded – undo
506 506
 class EE_Message_Template_Defaults extends EE_Base
507 507
 {
508 508
 
509
-    /**
510
-     * EE_Message_Template_Defaults constructor.
511
-     *
512
-     * @param EE_messages $messages
513
-     * @param             $messenger_name
514
-     * @param             $message_type_name
515
-     * @param int         $GRP_ID
516
-     * @return EE_Messages_Template_Defaults
517
-     */
518
-    public function __construct(
519
-        EE_messages $messages,
520
-        $messenger_name,
521
-        $message_type_name,
522
-        $GRP_ID = 0
523
-    ) {
524
-        EE_Error::doing_it_wrong(
525
-            __FUNCTION__,
526
-            esc_html__(
527
-                'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.',
528
-                'event_espresso'
529
-            ),
530
-            '4.9.0'
531
-        );
532
-        /** @var EE_Message_Resource_Manager $message_resource_manager */
533
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
534
-        $messenger = $message_resource_manager->get_messenger($messenger_name);
535
-        $message_type = $message_resource_manager->get_message_type($message_type_name);
536
-        return EE_Registry::instance()->load_lib(
537
-            'Messages_Template_Defaults',
538
-            array(
539
-                $messenger,
540
-                $message_type,
541
-                $GRP_ID,
542
-            )
543
-        );
544
-    }
509
+	/**
510
+	 * EE_Message_Template_Defaults constructor.
511
+	 *
512
+	 * @param EE_messages $messages
513
+	 * @param             $messenger_name
514
+	 * @param             $message_type_name
515
+	 * @param int         $GRP_ID
516
+	 * @return EE_Messages_Template_Defaults
517
+	 */
518
+	public function __construct(
519
+		EE_messages $messages,
520
+		$messenger_name,
521
+		$message_type_name,
522
+		$GRP_ID = 0
523
+	) {
524
+		EE_Error::doing_it_wrong(
525
+			__FUNCTION__,
526
+			esc_html__(
527
+				'The class EE_Message_Template_Defaults has been deprecated and replaced by EE_Messages_Template_Defaults.',
528
+				'event_espresso'
529
+			),
530
+			'4.9.0'
531
+		);
532
+		/** @var EE_Message_Resource_Manager $message_resource_manager */
533
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
534
+		$messenger = $message_resource_manager->get_messenger($messenger_name);
535
+		$message_type = $message_resource_manager->get_message_type($message_type_name);
536
+		return EE_Registry::instance()->load_lib(
537
+			'Messages_Template_Defaults',
538
+			array(
539
+				$messenger,
540
+				$message_type,
541
+				$GRP_ID,
542
+			)
543
+		);
544
+	}
545 545
 }
546 546
 
547 547
 
@@ -559,525 +559,525 @@  discard block
 block discarded – undo
559 559
 class EE_messages
560 560
 {
561 561
 
562
-    /** @type EE_messenger[] */
563
-    protected $_active_messengers = array();
564
-
565
-    /** @type array */
566
-    protected $_active_message_types = array();
567
-
568
-    /** @type EE_message_type[] */
569
-    protected $_installed_message_types = array();
570
-
571
-    /** @type EE_messenger */
572
-    protected $_messenger;
573
-
574
-    /** @type EE_message_type */
575
-    protected $_message_type;
576
-
577
-    /** @type array */
578
-    protected $_contexts = array();
579
-
580
-    /** @type EE_Message_Resource_Manager $_message_resource_manager */
581
-    protected $_message_resource_manager;
582
-
583
-
584
-    /**
585
-     * EE_messages constructor.
586
-     *
587
-     * @deprecated 4.9.0
588
-     */
589
-    public function __construct()
590
-    {
591
-    }
592
-
593
-
594
-    /**
595
-     * @param string $method
596
-     */
597
-    public function _class_is_deprecated($method)
598
-    {
599
-        EE_Error::doing_it_wrong(
600
-            'EE_messages::' . $method,
601
-            esc_html__('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
602
-            '4.9.0',
603
-            '4.10.0.p'
604
-        );
605
-        // Please use EE_Message_Resource_Manager instead
606
-        $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
607
-    }
608
-
609
-
610
-    /**
611
-     * @deprecated 4.9.0
612
-     * @param string $messenger_name
613
-     * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
614
-     */
615
-    public function ensure_messenger_is_active($messenger_name)
616
-    {
617
-        // EE_messages has been deprecated
618
-        $this->_class_is_deprecated(__FUNCTION__);
619
-        return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name);
620
-    }
621
-
622
-
623
-    /**
624
-     * @deprecated 4.9.0
625
-     * @param string $message_type message type name
626
-     * @param        $messenger
627
-     * @return bool true if it got activated (or was active) and false if not.
628
-     * @throws \EE_Error
629
-     */
630
-    public function ensure_message_type_is_active($message_type, $messenger)
631
-    {
632
-        // EE_messages has been deprecated
633
-        $this->_class_is_deprecated(__FUNCTION__);
634
-        return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger);
635
-    }
636
-
637
-
638
-    /**
639
-     * @deprecated 4.9.0
640
-     * @param string $messenger_name
641
-     * @param array  $mts_to_activate             (optional) An array of message types to activate with this messenger.
642
-     *                                             If included we do NOT setup the default message types (assuming they
643
-     *                                             are already setup.)
644
-     * @return boolean an array of generated templates or false if nothing generated/activated.
645
-     */
646
-    public function activate_messenger($messenger_name, $mts_to_activate = array())
647
-    {
648
-        // EE_messages has been deprecated
649
-        $this->_class_is_deprecated(__FUNCTION__);
650
-        return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate);
651
-    }
652
-
653
-
654
-    /**
655
-     * @deprecated 4.9.0
656
-     * @param EE_messenger    $messenger    messenger used in trigger
657
-     * @param EE_message_type $message_type message type used in trigger
658
-     *
659
-     * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
660
-     */
661
-    public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type)
662
-    {
663
-        // EE_messages has been deprecated
664
-        $this->_class_is_deprecated(__FUNCTION__);
665
-        return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type);
666
-    }
667
-
668
-
669
-    /**
670
-     * @deprecated 4.9.0
671
-     * @param string $messenger
672
-     * @return EE_messenger | null
673
-     */
674
-    public function get_messenger_if_active($messenger)
675
-    {
676
-        // EE_messages has been deprecated
677
-        $this->_class_is_deprecated(__FUNCTION__);
678
-        return $this->_message_resource_manager->get_active_messenger($messenger);
679
-    }
680
-
681
-
682
-    /**
683
-     * @deprecated 4.9.0
684
-     * @param EE_Message $message
685
-     * @return array  An array with 'messenger' and 'message_type' as the index and the corresponding valid object if
686
-     *                  available.
687
-     *                  Eg. Valid Messenger and Message Type:
688
-     *                  array(
689
-     *                  'messenger' => new EE_Email_messenger(),
690
-     *                  'message_type' => new EE_Registration_Approved_message_type()
691
-     *                  )
692
-     *                  Valid Messenger and Invalid Message Type:
693
-     *                  array(
694
-     *                  'messenger' => new EE_Email_messenger(),
695
-     *                  'message_type' => null
696
-     *                  )
697
-     */
698
-    public function validate_for_use(EE_Message $message)
699
-    {
700
-        // EE_messages has been deprecated
701
-        $this->_class_is_deprecated(__FUNCTION__);
702
-        return array(
703
-            'messenger'    => $message->messenger_object(),
704
-            'message_type' => $message->message_type_object(),
705
-        );
706
-    }
707
-
708
-
709
-    /**
710
-     * @deprecated 4.9.0
711
-     * @param  string $type                 What type of message are we sending (corresponds to message types)
712
-     * @param  mixed  $vars                 Data being sent for parsing in the message
713
-     * @param  string $sending_messenger    if included then we ONLY use the specified messenger for delivery.
714
-     *                                      Otherwise we cycle through all active messengers.
715
-     * @param string  $generating_messenger if included then this messenger is used for generating the message
716
-     *                                      templates (but not for sending).
717
-     * @param string  $context              If included then only a message type for a specific context will be
718
-     *                                      generated.
719
-     * @param bool    $send                 Default TRUE.  If false, then this will just return the generated
720
-     *                                      EE_messages objects which might be used by the trigger to setup a batch
721
-     *                                      message (typically html messenger uses it).
722
-     * @return bool
723
-     */
724
-    public function send_message(
725
-        $type,
726
-        $vars,
727
-        $sending_messenger = '',
728
-        $generating_messenger = '',
729
-        $context = '',
730
-        $send = true
731
-    ) {
732
-        // EE_messages has been deprecated
733
-        $this->_class_is_deprecated(__FUNCTION__);
734
-        /** @type EE_Messages_Processor $processor */
735
-        $processor = EE_Registry::instance()->load_lib('Messages_Processor');
736
-        $error = false;
737
-        // try to intelligently determine what method we'll call based on the incoming data.
738
-        // if generating and sending are different then generate and send immediately.
739
-        if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
740
-            // in the legacy system, when generating and sending were different, that means all the
741
-            // vars are already in the request object.  So let's just use that.
742
-            try {
743
-                /** @type EE_Message_To_Generate_From_Request $mtg */
744
-                $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
745
-                $processor->generate_and_send_now($mtg);
746
-            } catch (EE_Error $e) {
747
-                $error_msg = esc_html__(
748
-                    'Please note that a system message failed to send due to a technical issue.',
749
-                    'event_espresso'
750
-                );
751
-                // add specific message for developers if WP_DEBUG in on
752
-                $error_msg .= '||' . $e->getMessage();
753
-                EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
754
-                $error = true;
755
-            }
756
-        } else {
757
-            $processor->generate_for_all_active_messengers($type, $vars, $send);
758
-            // let's find out if there were any errors and how many successfully were queued.
759
-            $count_errors = $processor->get_queue()->count_STS_in_queue(
760
-                array(EEM_Message::status_failed, EEM_Message::status_debug_only)
761
-            );
762
-            $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
763
-            $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry);
764
-            $count_errors = $count_errors + $count_retry;
765
-            if ($count_errors > 0) {
766
-                $error = true;
767
-                if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) {
768
-                    $message = sprintf(
769
-                        esc_html__(
770
-                            'There were %d errors and %d messages successfully queued for generation and sending',
771
-                            'event_espresso'
772
-                        ),
773
-                        $count_errors,
774
-                        $count_queued
775
-                    );
776
-                } elseif ($count_errors > 1 && $count_queued === 1) {
777
-                    $message = sprintf(
778
-                        esc_html__(
779
-                            'There were %d errors and %d message successfully queued for generation.',
780
-                            'event_espresso'
781
-                        ),
782
-                        $count_errors,
783
-                        $count_queued
784
-                    );
785
-                } elseif ($count_errors === 1 && $count_queued > 1) {
786
-                    $message = sprintf(
787
-                        esc_html__(
788
-                            'There was %d error and %d messages successfully queued for generation.',
789
-                            'event_espresso'
790
-                        ),
791
-                        $count_errors,
792
-                        $count_queued
793
-                    );
794
-                } else {
795
-                    $message = sprintf(
796
-                        esc_html__(
797
-                            'There was %d message that failed to be queued for generation.',
798
-                            'event_espresso'
799
-                        ),
800
-                        $count_errors
801
-                    );
802
-                }
803
-                EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__);
804
-            } else {
805
-                if ($count_queued === 1) {
806
-                    $message = sprintf(
807
-                        esc_html__(
808
-                            '%d message successfully queued for generation.',
809
-                            'event_espresso'
810
-                        ),
811
-                        $count_queued
812
-                    );
813
-                } else {
814
-                    $message = sprintf(
815
-                        esc_html__(
816
-                            '%d messages were successfully queued for generation.',
817
-                            'event_espresso'
818
-                        ),
819
-                        $count_queued
820
-                    );
821
-                }
822
-                EE_Error::add_success($message);
823
-            }
824
-        }
825
-        // if no error then return the generated message(s).
826
-        if (! $error && ! $send) {
827
-            $generated_queue = $processor->generate_queue(false);
828
-            // get message and return.
829
-            $generated_queue->get_message_repository()->rewind();
830
-            $messages = array();
831
-            while ($generated_queue->get_message_repository()->valid()) {
832
-                $message = $generated_queue->get_message_repository()->current();
833
-                if ($message instanceof EE_Message) {
834
-                    // set properties that might be expected by add-ons (backward compat)
835
-                    $message->content = $message->content();
836
-                    $message->template_pack = $message->get_template_pack();
837
-                    $message->template_variation = $message->get_template_pack_variation();
838
-                    $messages[] = $message;
839
-                }
840
-                $generated_queue->get_message_repository()->next();
841
-            }
842
-            return $messages;
843
-        }
844
-        return $error ? false
845
-            : true; // yeah backwards eh?  Really what we're returning is if there is a total success for all the messages or not.  We'll modify this once we get message recording in place.
846
-    }
847
-
848
-
849
-    /**
850
-     * @deprecated 4.9.0
851
-     * @param  string $type      This should correspond with a valid message type
852
-     * @param  string $context   This should correspond with a valid context for the message type
853
-     * @param  string $messenger This should correspond with a valid messenger.
854
-     * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
855
-     *                           preview
856
-     * @return string          The body of the message.
857
-     */
858
-    public function preview_message($type, $context, $messenger, $send = false)
859
-    {
860
-        // EE_messages has been deprecated
861
-        $this->_class_is_deprecated(__FUNCTION__);
862
-        return EED_Messages::preview_message($type, $context, $messenger, $send);
863
-    }
864
-
865
-
866
-    /**
867
-     * @since      4.5.0
868
-     * @deprecated 4.9.0   Moved to EED_Messages Module
869
-     * @param string   $messenger    a string matching a valid active messenger in the system
870
-     * @param string   $message_type Although it seems contrary to the name of the method, a message type name is still
871
-     *                               required to send along the message type to the messenger because this is used for
872
-     *                               determining what specific variations might be loaded for the generated message.
873
-     * @param stdClass $message      a stdClass object in the format expected by the messenger.
874
-     *
875
-     * @return bool          success or fail.
876
-     */
877
-    public function send_message_with_messenger_only($messenger, $message_type, $message)
878
-    {
879
-        // EE_messages has been deprecated
880
-        $this->_class_is_deprecated(__FUNCTION__);
881
-        // setup for sending to new method.
882
-        /** @type EE_Messages_Queue $queue */
883
-        $queue = EE_Registry::instance()->load_lib('Messages_Queue');
884
-        // make sure we have a proper message object
885
-        if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
886
-            $msg = EE_Message_Factory::create(
887
-                array(
888
-                    'MSG_messenger'    => $messenger,
889
-                    'MSG_message_type' => $message_type,
890
-                    'MSG_content'      => $message->content,
891
-                    'MSG_subject'      => $message->subject,
892
-                )
893
-            );
894
-        } else {
895
-            $msg = $message;
896
-        }
897
-        if (! $msg instanceof EE_Message) {
898
-            return false;
899
-        }
900
-        // make sure any content in a content property (if not empty) is set on the MSG_content.
901
-        if (! empty($msg->content)) {
902
-            $msg->set('MSG_content', $msg->content);
903
-        }
904
-        $queue->add($msg);
905
-        return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue);
906
-    }
907
-
908
-
909
-    /**
910
-     * @deprecated 4.9.0
911
-     * @param         $messenger
912
-     * @param  string $message_type message type that the templates are being created for
913
-     * @param int     $GRP_ID
914
-     * @param bool    $is_global
915
-     * @return array|object if creation is successful then we return an array of info, otherwise an error_object is
916
-     *                      returned.
917
-     * @throws \EE_Error
918
-     */
919
-    public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false)
920
-    {
921
-        // EE_messages has been deprecated
922
-        $this->_class_is_deprecated(__FUNCTION__);
923
-        EE_Registry::instance()->load_helper('MSG_Template');
924
-        return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global);
925
-    }
926
-
927
-
928
-    /**
929
-     * @deprecated 4.9.0
930
-     * @param  string $messenger_name    name of EE_messenger
931
-     * @param  string $message_type_name name of EE_message_type
932
-     * @return array
933
-     */
934
-    public function get_fields($messenger_name, $message_type_name)
935
-    {
936
-        // EE_messages has been deprecated
937
-        $this->_class_is_deprecated(__FUNCTION__);
938
-        EE_Registry::instance()->load_helper('MSG_Template');
939
-        return EEH_MSG_Template::get_fields($messenger_name, $message_type_name);
940
-    }
941
-
942
-
943
-    /**
944
-     * @deprecated 4.9.0
945
-     * @access     public
946
-     * @param string $type                we can indicate just returning installed message types
947
-     *                                    or messengers (or both) via this parameter.
948
-     * @param bool   $skip_cache          if true then we skip the cache and retrieve via files.
949
-     * @return array                    multidimensional array of messenger and message_type objects
950
-     *                                    (messengers index, and message_type index);
951
-     */
952
-    public function get_installed($type = 'all', $skip_cache = false)
953
-    {
954
-        // EE_messages has been deprecated
955
-        $this->_class_is_deprecated(__FUNCTION__);
956
-        if ($skip_cache) {
957
-            $this->_message_resource_manager->reset_active_messengers_and_message_types();
958
-        }
959
-        switch ($type) {
960
-            case 'messengers' :
961
-                return array(
962
-                    'messenger' => $this->_message_resource_manager->installed_messengers(),
963
-                );
964
-                break;
965
-            case 'message_types' :
966
-                return array(
967
-                    'message_type' => $this->_message_resource_manager->installed_message_types(),
968
-                );
969
-                break;
970
-            case 'all' :
971
-            default :
972
-                return array(
973
-                    'messenger'    => $this->_message_resource_manager->installed_messengers(),
974
-                    'message_type' => $this->_message_resource_manager->installed_message_types(),
975
-                );
976
-                break;
977
-        }
978
-    }
979
-
980
-
981
-    /**
982
-     * @deprecated 4.9.0
983
-     * @return \EE_messenger[]
984
-     */
985
-    public function get_active_messengers()
986
-    {
987
-        // EE_messages has been deprecated
988
-        $this->_class_is_deprecated(__FUNCTION__);
989
-        return $this->_message_resource_manager->active_messengers();
990
-    }
991
-
992
-
993
-    /**
994
-     * @deprecated 4.9.0
995
-     * @return array array of message_type references (string)
996
-     */
997
-    public function get_active_message_types()
998
-    {
999
-        // EE_messages has been deprecated
1000
-        $this->_class_is_deprecated(__FUNCTION__);
1001
-        return $this->_message_resource_manager->list_of_active_message_types();
1002
-    }
1003
-
1004
-
1005
-    /**
1006
-     * @deprecated 4.9.0
1007
-     * @return EE_message_type[]
1008
-     */
1009
-    public function get_active_message_type_objects()
1010
-    {
1011
-        // EE_messages has been deprecated
1012
-        $this->_class_is_deprecated(__FUNCTION__);
1013
-        return $this->_message_resource_manager->get_active_message_type_objects();
1014
-    }
1015
-
1016
-
1017
-    /**
1018
-     * @deprecated 4.9.0
1019
-     * @since      4.5.0
1020
-     * @param string $messenger The messenger being checked
1021
-     * @return EE_message_type[]    (or empty array if none present)
1022
-     */
1023
-    public function get_active_message_types_per_messenger($messenger)
1024
-    {
1025
-        // EE_messages has been deprecated
1026
-        $this->_class_is_deprecated(__FUNCTION__);
1027
-        return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger);
1028
-    }
1029
-
1030
-
1031
-    /**
1032
-     * @deprecated 4.9.0
1033
-     * @param string $messenger    The string should correspond to the messenger (message types are
1034
-     * @param string $message_type The string should correspond to a message type.
1035
-     * @return EE_message_type|null
1036
-     */
1037
-    public function get_active_message_type($messenger, $message_type)
1038
-    {
1039
-        // EE_messages has been deprecated
1040
-        $this->_class_is_deprecated(__FUNCTION__);
1041
-        return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type);
1042
-    }
1043
-
1044
-
1045
-    /**
1046
-     * @deprecated 4.9.0
1047
-     * @return array|\EE_message_type[]
1048
-     */
1049
-    public function get_installed_message_types()
1050
-    {
1051
-        // EE_messages has been deprecated
1052
-        $this->_class_is_deprecated(__FUNCTION__);
1053
-        return $this->_message_resource_manager->installed_message_types();
1054
-    }
1055
-
1056
-
1057
-    /**
1058
-     * @deprecated 4.9.0
1059
-     * @return array
1060
-     */
1061
-    public function get_installed_messengers()
1062
-    {
1063
-        // EE_messages has been deprecated
1064
-        $this->_class_is_deprecated(__FUNCTION__);
1065
-        return $this->_message_resource_manager->installed_messengers();
1066
-    }
1067
-
1068
-
1069
-    /**
1070
-     * @deprecated 4.9.0
1071
-     * @param   bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by
1072
-     *                           message type.
1073
-     * @return array
1074
-     */
1075
-    public function get_all_contexts($slugs_only = true)
1076
-    {
1077
-        // EE_messages has been deprecated
1078
-        $this->_class_is_deprecated(__FUNCTION__);
1079
-        return $this->_message_resource_manager->get_all_contexts($slugs_only);
1080
-    }
562
+	/** @type EE_messenger[] */
563
+	protected $_active_messengers = array();
564
+
565
+	/** @type array */
566
+	protected $_active_message_types = array();
567
+
568
+	/** @type EE_message_type[] */
569
+	protected $_installed_message_types = array();
570
+
571
+	/** @type EE_messenger */
572
+	protected $_messenger;
573
+
574
+	/** @type EE_message_type */
575
+	protected $_message_type;
576
+
577
+	/** @type array */
578
+	protected $_contexts = array();
579
+
580
+	/** @type EE_Message_Resource_Manager $_message_resource_manager */
581
+	protected $_message_resource_manager;
582
+
583
+
584
+	/**
585
+	 * EE_messages constructor.
586
+	 *
587
+	 * @deprecated 4.9.0
588
+	 */
589
+	public function __construct()
590
+	{
591
+	}
592
+
593
+
594
+	/**
595
+	 * @param string $method
596
+	 */
597
+	public function _class_is_deprecated($method)
598
+	{
599
+		EE_Error::doing_it_wrong(
600
+			'EE_messages::' . $method,
601
+			esc_html__('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
602
+			'4.9.0',
603
+			'4.10.0.p'
604
+		);
605
+		// Please use EE_Message_Resource_Manager instead
606
+		$this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
607
+	}
608
+
609
+
610
+	/**
611
+	 * @deprecated 4.9.0
612
+	 * @param string $messenger_name
613
+	 * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
614
+	 */
615
+	public function ensure_messenger_is_active($messenger_name)
616
+	{
617
+		// EE_messages has been deprecated
618
+		$this->_class_is_deprecated(__FUNCTION__);
619
+		return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name);
620
+	}
621
+
622
+
623
+	/**
624
+	 * @deprecated 4.9.0
625
+	 * @param string $message_type message type name
626
+	 * @param        $messenger
627
+	 * @return bool true if it got activated (or was active) and false if not.
628
+	 * @throws \EE_Error
629
+	 */
630
+	public function ensure_message_type_is_active($message_type, $messenger)
631
+	{
632
+		// EE_messages has been deprecated
633
+		$this->_class_is_deprecated(__FUNCTION__);
634
+		return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger);
635
+	}
636
+
637
+
638
+	/**
639
+	 * @deprecated 4.9.0
640
+	 * @param string $messenger_name
641
+	 * @param array  $mts_to_activate             (optional) An array of message types to activate with this messenger.
642
+	 *                                             If included we do NOT setup the default message types (assuming they
643
+	 *                                             are already setup.)
644
+	 * @return boolean an array of generated templates or false if nothing generated/activated.
645
+	 */
646
+	public function activate_messenger($messenger_name, $mts_to_activate = array())
647
+	{
648
+		// EE_messages has been deprecated
649
+		$this->_class_is_deprecated(__FUNCTION__);
650
+		return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate);
651
+	}
652
+
653
+
654
+	/**
655
+	 * @deprecated 4.9.0
656
+	 * @param EE_messenger    $messenger    messenger used in trigger
657
+	 * @param EE_message_type $message_type message type used in trigger
658
+	 *
659
+	 * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
660
+	 */
661
+	public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type)
662
+	{
663
+		// EE_messages has been deprecated
664
+		$this->_class_is_deprecated(__FUNCTION__);
665
+		return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type);
666
+	}
667
+
668
+
669
+	/**
670
+	 * @deprecated 4.9.0
671
+	 * @param string $messenger
672
+	 * @return EE_messenger | null
673
+	 */
674
+	public function get_messenger_if_active($messenger)
675
+	{
676
+		// EE_messages has been deprecated
677
+		$this->_class_is_deprecated(__FUNCTION__);
678
+		return $this->_message_resource_manager->get_active_messenger($messenger);
679
+	}
680
+
681
+
682
+	/**
683
+	 * @deprecated 4.9.0
684
+	 * @param EE_Message $message
685
+	 * @return array  An array with 'messenger' and 'message_type' as the index and the corresponding valid object if
686
+	 *                  available.
687
+	 *                  Eg. Valid Messenger and Message Type:
688
+	 *                  array(
689
+	 *                  'messenger' => new EE_Email_messenger(),
690
+	 *                  'message_type' => new EE_Registration_Approved_message_type()
691
+	 *                  )
692
+	 *                  Valid Messenger and Invalid Message Type:
693
+	 *                  array(
694
+	 *                  'messenger' => new EE_Email_messenger(),
695
+	 *                  'message_type' => null
696
+	 *                  )
697
+	 */
698
+	public function validate_for_use(EE_Message $message)
699
+	{
700
+		// EE_messages has been deprecated
701
+		$this->_class_is_deprecated(__FUNCTION__);
702
+		return array(
703
+			'messenger'    => $message->messenger_object(),
704
+			'message_type' => $message->message_type_object(),
705
+		);
706
+	}
707
+
708
+
709
+	/**
710
+	 * @deprecated 4.9.0
711
+	 * @param  string $type                 What type of message are we sending (corresponds to message types)
712
+	 * @param  mixed  $vars                 Data being sent for parsing in the message
713
+	 * @param  string $sending_messenger    if included then we ONLY use the specified messenger for delivery.
714
+	 *                                      Otherwise we cycle through all active messengers.
715
+	 * @param string  $generating_messenger if included then this messenger is used for generating the message
716
+	 *                                      templates (but not for sending).
717
+	 * @param string  $context              If included then only a message type for a specific context will be
718
+	 *                                      generated.
719
+	 * @param bool    $send                 Default TRUE.  If false, then this will just return the generated
720
+	 *                                      EE_messages objects which might be used by the trigger to setup a batch
721
+	 *                                      message (typically html messenger uses it).
722
+	 * @return bool
723
+	 */
724
+	public function send_message(
725
+		$type,
726
+		$vars,
727
+		$sending_messenger = '',
728
+		$generating_messenger = '',
729
+		$context = '',
730
+		$send = true
731
+	) {
732
+		// EE_messages has been deprecated
733
+		$this->_class_is_deprecated(__FUNCTION__);
734
+		/** @type EE_Messages_Processor $processor */
735
+		$processor = EE_Registry::instance()->load_lib('Messages_Processor');
736
+		$error = false;
737
+		// try to intelligently determine what method we'll call based on the incoming data.
738
+		// if generating and sending are different then generate and send immediately.
739
+		if (! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
740
+			// in the legacy system, when generating and sending were different, that means all the
741
+			// vars are already in the request object.  So let's just use that.
742
+			try {
743
+				/** @type EE_Message_To_Generate_From_Request $mtg */
744
+				$mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
745
+				$processor->generate_and_send_now($mtg);
746
+			} catch (EE_Error $e) {
747
+				$error_msg = esc_html__(
748
+					'Please note that a system message failed to send due to a technical issue.',
749
+					'event_espresso'
750
+				);
751
+				// add specific message for developers if WP_DEBUG in on
752
+				$error_msg .= '||' . $e->getMessage();
753
+				EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
754
+				$error = true;
755
+			}
756
+		} else {
757
+			$processor->generate_for_all_active_messengers($type, $vars, $send);
758
+			// let's find out if there were any errors and how many successfully were queued.
759
+			$count_errors = $processor->get_queue()->count_STS_in_queue(
760
+				array(EEM_Message::status_failed, EEM_Message::status_debug_only)
761
+			);
762
+			$count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
763
+			$count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry);
764
+			$count_errors = $count_errors + $count_retry;
765
+			if ($count_errors > 0) {
766
+				$error = true;
767
+				if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) {
768
+					$message = sprintf(
769
+						esc_html__(
770
+							'There were %d errors and %d messages successfully queued for generation and sending',
771
+							'event_espresso'
772
+						),
773
+						$count_errors,
774
+						$count_queued
775
+					);
776
+				} elseif ($count_errors > 1 && $count_queued === 1) {
777
+					$message = sprintf(
778
+						esc_html__(
779
+							'There were %d errors and %d message successfully queued for generation.',
780
+							'event_espresso'
781
+						),
782
+						$count_errors,
783
+						$count_queued
784
+					);
785
+				} elseif ($count_errors === 1 && $count_queued > 1) {
786
+					$message = sprintf(
787
+						esc_html__(
788
+							'There was %d error and %d messages successfully queued for generation.',
789
+							'event_espresso'
790
+						),
791
+						$count_errors,
792
+						$count_queued
793
+					);
794
+				} else {
795
+					$message = sprintf(
796
+						esc_html__(
797
+							'There was %d message that failed to be queued for generation.',
798
+							'event_espresso'
799
+						),
800
+						$count_errors
801
+					);
802
+				}
803
+				EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__);
804
+			} else {
805
+				if ($count_queued === 1) {
806
+					$message = sprintf(
807
+						esc_html__(
808
+							'%d message successfully queued for generation.',
809
+							'event_espresso'
810
+						),
811
+						$count_queued
812
+					);
813
+				} else {
814
+					$message = sprintf(
815
+						esc_html__(
816
+							'%d messages were successfully queued for generation.',
817
+							'event_espresso'
818
+						),
819
+						$count_queued
820
+					);
821
+				}
822
+				EE_Error::add_success($message);
823
+			}
824
+		}
825
+		// if no error then return the generated message(s).
826
+		if (! $error && ! $send) {
827
+			$generated_queue = $processor->generate_queue(false);
828
+			// get message and return.
829
+			$generated_queue->get_message_repository()->rewind();
830
+			$messages = array();
831
+			while ($generated_queue->get_message_repository()->valid()) {
832
+				$message = $generated_queue->get_message_repository()->current();
833
+				if ($message instanceof EE_Message) {
834
+					// set properties that might be expected by add-ons (backward compat)
835
+					$message->content = $message->content();
836
+					$message->template_pack = $message->get_template_pack();
837
+					$message->template_variation = $message->get_template_pack_variation();
838
+					$messages[] = $message;
839
+				}
840
+				$generated_queue->get_message_repository()->next();
841
+			}
842
+			return $messages;
843
+		}
844
+		return $error ? false
845
+			: true; // yeah backwards eh?  Really what we're returning is if there is a total success for all the messages or not.  We'll modify this once we get message recording in place.
846
+	}
847
+
848
+
849
+	/**
850
+	 * @deprecated 4.9.0
851
+	 * @param  string $type      This should correspond with a valid message type
852
+	 * @param  string $context   This should correspond with a valid context for the message type
853
+	 * @param  string $messenger This should correspond with a valid messenger.
854
+	 * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
855
+	 *                           preview
856
+	 * @return string          The body of the message.
857
+	 */
858
+	public function preview_message($type, $context, $messenger, $send = false)
859
+	{
860
+		// EE_messages has been deprecated
861
+		$this->_class_is_deprecated(__FUNCTION__);
862
+		return EED_Messages::preview_message($type, $context, $messenger, $send);
863
+	}
864
+
865
+
866
+	/**
867
+	 * @since      4.5.0
868
+	 * @deprecated 4.9.0   Moved to EED_Messages Module
869
+	 * @param string   $messenger    a string matching a valid active messenger in the system
870
+	 * @param string   $message_type Although it seems contrary to the name of the method, a message type name is still
871
+	 *                               required to send along the message type to the messenger because this is used for
872
+	 *                               determining what specific variations might be loaded for the generated message.
873
+	 * @param stdClass $message      a stdClass object in the format expected by the messenger.
874
+	 *
875
+	 * @return bool          success or fail.
876
+	 */
877
+	public function send_message_with_messenger_only($messenger, $message_type, $message)
878
+	{
879
+		// EE_messages has been deprecated
880
+		$this->_class_is_deprecated(__FUNCTION__);
881
+		// setup for sending to new method.
882
+		/** @type EE_Messages_Queue $queue */
883
+		$queue = EE_Registry::instance()->load_lib('Messages_Queue');
884
+		// make sure we have a proper message object
885
+		if (! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
886
+			$msg = EE_Message_Factory::create(
887
+				array(
888
+					'MSG_messenger'    => $messenger,
889
+					'MSG_message_type' => $message_type,
890
+					'MSG_content'      => $message->content,
891
+					'MSG_subject'      => $message->subject,
892
+				)
893
+			);
894
+		} else {
895
+			$msg = $message;
896
+		}
897
+		if (! $msg instanceof EE_Message) {
898
+			return false;
899
+		}
900
+		// make sure any content in a content property (if not empty) is set on the MSG_content.
901
+		if (! empty($msg->content)) {
902
+			$msg->set('MSG_content', $msg->content);
903
+		}
904
+		$queue->add($msg);
905
+		return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue);
906
+	}
907
+
908
+
909
+	/**
910
+	 * @deprecated 4.9.0
911
+	 * @param         $messenger
912
+	 * @param  string $message_type message type that the templates are being created for
913
+	 * @param int     $GRP_ID
914
+	 * @param bool    $is_global
915
+	 * @return array|object if creation is successful then we return an array of info, otherwise an error_object is
916
+	 *                      returned.
917
+	 * @throws \EE_Error
918
+	 */
919
+	public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false)
920
+	{
921
+		// EE_messages has been deprecated
922
+		$this->_class_is_deprecated(__FUNCTION__);
923
+		EE_Registry::instance()->load_helper('MSG_Template');
924
+		return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global);
925
+	}
926
+
927
+
928
+	/**
929
+	 * @deprecated 4.9.0
930
+	 * @param  string $messenger_name    name of EE_messenger
931
+	 * @param  string $message_type_name name of EE_message_type
932
+	 * @return array
933
+	 */
934
+	public function get_fields($messenger_name, $message_type_name)
935
+	{
936
+		// EE_messages has been deprecated
937
+		$this->_class_is_deprecated(__FUNCTION__);
938
+		EE_Registry::instance()->load_helper('MSG_Template');
939
+		return EEH_MSG_Template::get_fields($messenger_name, $message_type_name);
940
+	}
941
+
942
+
943
+	/**
944
+	 * @deprecated 4.9.0
945
+	 * @access     public
946
+	 * @param string $type                we can indicate just returning installed message types
947
+	 *                                    or messengers (or both) via this parameter.
948
+	 * @param bool   $skip_cache          if true then we skip the cache and retrieve via files.
949
+	 * @return array                    multidimensional array of messenger and message_type objects
950
+	 *                                    (messengers index, and message_type index);
951
+	 */
952
+	public function get_installed($type = 'all', $skip_cache = false)
953
+	{
954
+		// EE_messages has been deprecated
955
+		$this->_class_is_deprecated(__FUNCTION__);
956
+		if ($skip_cache) {
957
+			$this->_message_resource_manager->reset_active_messengers_and_message_types();
958
+		}
959
+		switch ($type) {
960
+			case 'messengers' :
961
+				return array(
962
+					'messenger' => $this->_message_resource_manager->installed_messengers(),
963
+				);
964
+				break;
965
+			case 'message_types' :
966
+				return array(
967
+					'message_type' => $this->_message_resource_manager->installed_message_types(),
968
+				);
969
+				break;
970
+			case 'all' :
971
+			default :
972
+				return array(
973
+					'messenger'    => $this->_message_resource_manager->installed_messengers(),
974
+					'message_type' => $this->_message_resource_manager->installed_message_types(),
975
+				);
976
+				break;
977
+		}
978
+	}
979
+
980
+
981
+	/**
982
+	 * @deprecated 4.9.0
983
+	 * @return \EE_messenger[]
984
+	 */
985
+	public function get_active_messengers()
986
+	{
987
+		// EE_messages has been deprecated
988
+		$this->_class_is_deprecated(__FUNCTION__);
989
+		return $this->_message_resource_manager->active_messengers();
990
+	}
991
+
992
+
993
+	/**
994
+	 * @deprecated 4.9.0
995
+	 * @return array array of message_type references (string)
996
+	 */
997
+	public function get_active_message_types()
998
+	{
999
+		// EE_messages has been deprecated
1000
+		$this->_class_is_deprecated(__FUNCTION__);
1001
+		return $this->_message_resource_manager->list_of_active_message_types();
1002
+	}
1003
+
1004
+
1005
+	/**
1006
+	 * @deprecated 4.9.0
1007
+	 * @return EE_message_type[]
1008
+	 */
1009
+	public function get_active_message_type_objects()
1010
+	{
1011
+		// EE_messages has been deprecated
1012
+		$this->_class_is_deprecated(__FUNCTION__);
1013
+		return $this->_message_resource_manager->get_active_message_type_objects();
1014
+	}
1015
+
1016
+
1017
+	/**
1018
+	 * @deprecated 4.9.0
1019
+	 * @since      4.5.0
1020
+	 * @param string $messenger The messenger being checked
1021
+	 * @return EE_message_type[]    (or empty array if none present)
1022
+	 */
1023
+	public function get_active_message_types_per_messenger($messenger)
1024
+	{
1025
+		// EE_messages has been deprecated
1026
+		$this->_class_is_deprecated(__FUNCTION__);
1027
+		return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger);
1028
+	}
1029
+
1030
+
1031
+	/**
1032
+	 * @deprecated 4.9.0
1033
+	 * @param string $messenger    The string should correspond to the messenger (message types are
1034
+	 * @param string $message_type The string should correspond to a message type.
1035
+	 * @return EE_message_type|null
1036
+	 */
1037
+	public function get_active_message_type($messenger, $message_type)
1038
+	{
1039
+		// EE_messages has been deprecated
1040
+		$this->_class_is_deprecated(__FUNCTION__);
1041
+		return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type);
1042
+	}
1043
+
1044
+
1045
+	/**
1046
+	 * @deprecated 4.9.0
1047
+	 * @return array|\EE_message_type[]
1048
+	 */
1049
+	public function get_installed_message_types()
1050
+	{
1051
+		// EE_messages has been deprecated
1052
+		$this->_class_is_deprecated(__FUNCTION__);
1053
+		return $this->_message_resource_manager->installed_message_types();
1054
+	}
1055
+
1056
+
1057
+	/**
1058
+	 * @deprecated 4.9.0
1059
+	 * @return array
1060
+	 */
1061
+	public function get_installed_messengers()
1062
+	{
1063
+		// EE_messages has been deprecated
1064
+		$this->_class_is_deprecated(__FUNCTION__);
1065
+		return $this->_message_resource_manager->installed_messengers();
1066
+	}
1067
+
1068
+
1069
+	/**
1070
+	 * @deprecated 4.9.0
1071
+	 * @param   bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by
1072
+	 *                           message type.
1073
+	 * @return array
1074
+	 */
1075
+	public function get_all_contexts($slugs_only = true)
1076
+	{
1077
+		// EE_messages has been deprecated
1078
+		$this->_class_is_deprecated(__FUNCTION__);
1079
+		return $this->_message_resource_manager->get_all_contexts($slugs_only);
1080
+	}
1081 1081
 
1082 1082
 
1083 1083
 }
@@ -1136,88 +1136,88 @@  discard block
 block discarded – undo
1136 1136
 
1137 1137
 
1138 1138
 add_filter(
1139
-    'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1140
-    function ($event_list_iframe_css) {
1141
-        if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1142
-            return $event_list_iframe_css;
1143
-        }
1144
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1145
-            'FHEE__EventsArchiveIframe__event_list_iframe__css',
1146
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1147
-            '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1148
-            '4.9.14',
1149
-            '5.0.0',
1150
-            'filter'
1151
-        );
1152
-        return apply_filters(
1153
-            'FHEE__EventsArchiveIframe__event_list_iframe__css',
1154
-            $event_list_iframe_css
1155
-        );
1156
-    }
1139
+	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1140
+	function ($event_list_iframe_css) {
1141
+		if (! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1142
+			return $event_list_iframe_css;
1143
+		}
1144
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1145
+			'FHEE__EventsArchiveIframe__event_list_iframe__css',
1146
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1147
+			'\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1148
+			'4.9.14',
1149
+			'5.0.0',
1150
+			'filter'
1151
+		);
1152
+		return apply_filters(
1153
+			'FHEE__EventsArchiveIframe__event_list_iframe__css',
1154
+			$event_list_iframe_css
1155
+		);
1156
+	}
1157 1157
 );
1158 1158
 add_filter(
1159
-    'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1160
-    function ($event_list_iframe_js) {
1161
-        if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1162
-            return $event_list_iframe_js;
1163
-        }
1164
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1165
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1166
-            'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1167
-            '\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1168
-            '4.9.14',
1169
-            '5.0.0',
1170
-            'filter'
1171
-        );
1172
-        return apply_filters(
1173
-            'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1174
-            $event_list_iframe_js
1175
-        );
1176
-    }
1159
+	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1160
+	function ($event_list_iframe_js) {
1161
+		if (! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1162
+			return $event_list_iframe_js;
1163
+		}
1164
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1165
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1166
+			'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1167
+			'\EventEspresso\modules\events_archive\EventsArchiveIframe::display()',
1168
+			'4.9.14',
1169
+			'5.0.0',
1170
+			'filter'
1171
+		);
1172
+		return apply_filters(
1173
+			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
1174
+			$event_list_iframe_js
1175
+		);
1176
+	}
1177 1177
 );
1178 1178
 add_action(
1179
-    'AHEE__EE_Capabilities__addCaps__complete',
1180
-    function ($capabilities_map) {
1181
-        if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1182
-            return;
1183
-        }
1184
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1185
-            'AHEE__EE_Capabilities__init_role_caps__complete',
1186
-            'AHEE__EE_Capabilities__addCaps__complete',
1187
-            '\EE_Capabilities::addCaps()',
1188
-            '4.9.42',
1189
-            '5.0.0'
1190
-        );
1191
-        do_action(
1192
-            'AHEE__EE_Capabilities__init_role_caps__complete',
1193
-            $capabilities_map
1194
-        );
1195
-    }
1179
+	'AHEE__EE_Capabilities__addCaps__complete',
1180
+	function ($capabilities_map) {
1181
+		if (! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1182
+			return;
1183
+		}
1184
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1185
+			'AHEE__EE_Capabilities__init_role_caps__complete',
1186
+			'AHEE__EE_Capabilities__addCaps__complete',
1187
+			'\EE_Capabilities::addCaps()',
1188
+			'4.9.42',
1189
+			'5.0.0'
1190
+		);
1191
+		do_action(
1192
+			'AHEE__EE_Capabilities__init_role_caps__complete',
1193
+			$capabilities_map
1194
+		);
1195
+	}
1196 1196
 );
1197 1197
 
1198 1198
 add_filter(
1199
-    'FHEE_EventEspresso_core_domain_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1200
-    function($existing_attendee, $registration, $attendee_data) {
1201
-        if ( ! has_filter( 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee' )) {
1202
-            return $existing_attendee;
1203
-        }
1204
-        deprecated_espresso_action_or_filter_doing_it_wrong(
1205
-            'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1206
-            'FHEE_EventEspresso_core_domain_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1207
-            '\EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()',
1208
-            '4.9.34',
1209
-            '5.0.0',
1210
-            'filter'
1211
-        );
1212
-        return apply_filters(
1213
-            'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1214
-            $existing_attendee,
1215
-            $registration,
1216
-            $attendee_data
1217
-        );
1218
-    },
1219
-    10,
1220
-    3
1199
+	'FHEE_EventEspresso_core_domain_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1200
+	function($existing_attendee, $registration, $attendee_data) {
1201
+		if ( ! has_filter( 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee' )) {
1202
+			return $existing_attendee;
1203
+		}
1204
+		deprecated_espresso_action_or_filter_doing_it_wrong(
1205
+			'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1206
+			'FHEE_EventEspresso_core_domain_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1207
+			'\EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommandHandler::findExistingAttendee()',
1208
+			'4.9.34',
1209
+			'5.0.0',
1210
+			'filter'
1211
+		);
1212
+		return apply_filters(
1213
+			'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1214
+			$existing_attendee,
1215
+			$registration,
1216
+			$attendee_data
1217
+		);
1218
+	},
1219
+	10,
1220
+	3
1221 1221
 );
1222 1222
 
1223 1223
 /**
@@ -1228,88 +1228,88 @@  discard block
 block discarded – undo
1228 1228
 class EE_Event_List_Query extends WP_Query
1229 1229
 {
1230 1230
 
1231
-    private $title;
1232
-
1233
-    private $css_class;
1234
-
1235
-    private $category_slug;
1236
-
1237
-    /**
1238
-     * EE_Event_List_Query constructor.
1239
-     *
1240
-     * @param array $args
1241
-     */
1242
-    public function __construct($args = array())
1243
-    {
1244
-        \EE_Error::doing_it_wrong(
1245
-            __METHOD__,
1246
-            esc_html__(
1247
-                'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1248
-                'event_espresso'
1249
-            ),
1250
-            '4.9.27',
1251
-            '5.0.0'
1252
-        );
1253
-        $this->title = isset($args['title']) ? $args['title'] : '';
1254
-        $this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1255
-        $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1256
-        $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1257
-        // the current "page" we are viewing
1258
-        $paged = max(1, get_query_var('paged'));
1259
-        // Force these args
1260
-        $args = array_merge(
1261
-            $args,
1262
-            array(
1263
-                'post_type'              => 'espresso_events',
1264
-                'posts_per_page'         => $limit,
1265
-                'update_post_term_cache' => false,
1266
-                'update_post_meta_cache' => false,
1267
-                'paged'                  => $paged,
1268
-                'offset'                 => ($paged - 1) * $limit,
1269
-            )
1270
-        );
1271
-        // run the query
1272
-        parent::__construct($args);
1273
-    }
1274
-
1275
-
1276
-    /**
1277
-     * event_list_title
1278
-     *
1279
-     * @param string $event_list_title
1280
-     * @return string
1281
-     */
1282
-    public function event_list_title($event_list_title = '')
1283
-    {
1284
-        if (! empty($this->title)) {
1285
-            return $this->title;
1286
-        }
1287
-        return $event_list_title;
1288
-    }
1289
-
1290
-
1291
-    /**
1292
-     * event_list_css
1293
-     *
1294
-     * @param string $event_list_css
1295
-     * @return string
1296
-     */
1297
-    public function event_list_css($event_list_css = '')
1298
-    {
1299
-        $event_list_css .= ! empty($event_list_css)
1300
-            ? ' '
1301
-            : '';
1302
-        $event_list_css .= ! empty($this->css_class)
1303
-            ? $this->css_class
1304
-            : '';
1305
-        $event_list_css .= ! empty($event_list_css)
1306
-            ? ' '
1307
-            : '';
1308
-        $event_list_css .= ! empty($this->category_slug)
1309
-            ? $this->category_slug
1310
-            : '';
1311
-        return $event_list_css;
1312
-    }
1231
+	private $title;
1232
+
1233
+	private $css_class;
1234
+
1235
+	private $category_slug;
1236
+
1237
+	/**
1238
+	 * EE_Event_List_Query constructor.
1239
+	 *
1240
+	 * @param array $args
1241
+	 */
1242
+	public function __construct($args = array())
1243
+	{
1244
+		\EE_Error::doing_it_wrong(
1245
+			__METHOD__,
1246
+			esc_html__(
1247
+				'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1248
+				'event_espresso'
1249
+			),
1250
+			'4.9.27',
1251
+			'5.0.0'
1252
+		);
1253
+		$this->title = isset($args['title']) ? $args['title'] : '';
1254
+		$this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1255
+		$this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1256
+		$limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1257
+		// the current "page" we are viewing
1258
+		$paged = max(1, get_query_var('paged'));
1259
+		// Force these args
1260
+		$args = array_merge(
1261
+			$args,
1262
+			array(
1263
+				'post_type'              => 'espresso_events',
1264
+				'posts_per_page'         => $limit,
1265
+				'update_post_term_cache' => false,
1266
+				'update_post_meta_cache' => false,
1267
+				'paged'                  => $paged,
1268
+				'offset'                 => ($paged - 1) * $limit,
1269
+			)
1270
+		);
1271
+		// run the query
1272
+		parent::__construct($args);
1273
+	}
1274
+
1275
+
1276
+	/**
1277
+	 * event_list_title
1278
+	 *
1279
+	 * @param string $event_list_title
1280
+	 * @return string
1281
+	 */
1282
+	public function event_list_title($event_list_title = '')
1283
+	{
1284
+		if (! empty($this->title)) {
1285
+			return $this->title;
1286
+		}
1287
+		return $event_list_title;
1288
+	}
1289
+
1290
+
1291
+	/**
1292
+	 * event_list_css
1293
+	 *
1294
+	 * @param string $event_list_css
1295
+	 * @return string
1296
+	 */
1297
+	public function event_list_css($event_list_css = '')
1298
+	{
1299
+		$event_list_css .= ! empty($event_list_css)
1300
+			? ' '
1301
+			: '';
1302
+		$event_list_css .= ! empty($this->css_class)
1303
+			? $this->css_class
1304
+			: '';
1305
+		$event_list_css .= ! empty($event_list_css)
1306
+			? ' '
1307
+			: '';
1308
+		$event_list_css .= ! empty($this->category_slug)
1309
+			? $this->category_slug
1310
+			: '';
1311
+		return $event_list_css;
1312
+	}
1313 1313
 
1314 1314
 }
1315 1315
 
@@ -1326,75 +1326,75 @@  discard block
 block discarded – undo
1326 1326
 {
1327 1327
 
1328 1328
 
1329
-    /**
1330
-     *    class constructor
1331
-     *
1332
-     * @deprecated 4.9.59.p
1333
-     */
1334
-    public function __construct()
1335
-    {
1336
-        EE_Error::doing_it_wrong(
1337
-            __METHOD__,
1338
-            sprintf(
1339
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1340
-                __CLASS__,
1341
-                'EventEspresso\core\services\licensing\LicenseServices'
1342
-            ),
1343
-            '4.9.59.p'
1344
-        );
1345
-    }
1346
-
1347
-
1348
-    /**
1349
-     * The purpose of this function is to display information about Event Espresso data collection
1350
-     * and a optin selection for extra data collecting by users.
1351
-     *
1352
-     * @param bool $extra
1353
-     * @return string html.
1354
-     * @deprecated 4.9.59.p
1355
-     */
1356
-    public static function espresso_data_collection_optin_text($extra = true)
1357
-    {
1358
-        EE_Error::doing_it_wrong(
1359
-            __METHOD__,
1360
-            sprintf(
1361
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1362
-                __METHOD__,
1363
-                'EventEspresso\core\domain\services\Stats::optinText'
1364
-            ),
1365
-            '4.9.59.p'
1366
-        );
1367
-        Stats::optinText($extra);
1368
-    }
1369
-
1370
-    /**
1371
-     * This is a handy helper method for retrieving whether there is an update available for the given plugin.
1372
-     *
1373
-     * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
1374
-     *                          identify plugins. Defaults to core update
1375
-     * @return boolean           True if update available, false if not.
1376
-     * @deprecated 4.9.59.p
1377
-     */
1378
-    public static function is_update_available($basename = '')
1379
-    {
1380
-        EE_Error::doing_it_wrong(
1381
-            __METHOD__,
1382
-            sprintf(
1383
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1384
-                __METHOD__,
1385
-                'EventEspresso\caffeinated\core\services\licensing\LicenseService::isUpdateAvailable'
1386
-            ),
1387
-            '4.9.59.p'
1388
-        );
1389
-        return LicenseService::isUpdateAvailable($basename);
1390
-    }
1329
+	/**
1330
+	 *    class constructor
1331
+	 *
1332
+	 * @deprecated 4.9.59.p
1333
+	 */
1334
+	public function __construct()
1335
+	{
1336
+		EE_Error::doing_it_wrong(
1337
+			__METHOD__,
1338
+			sprintf(
1339
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1340
+				__CLASS__,
1341
+				'EventEspresso\core\services\licensing\LicenseServices'
1342
+			),
1343
+			'4.9.59.p'
1344
+		);
1345
+	}
1346
+
1347
+
1348
+	/**
1349
+	 * The purpose of this function is to display information about Event Espresso data collection
1350
+	 * and a optin selection for extra data collecting by users.
1351
+	 *
1352
+	 * @param bool $extra
1353
+	 * @return string html.
1354
+	 * @deprecated 4.9.59.p
1355
+	 */
1356
+	public static function espresso_data_collection_optin_text($extra = true)
1357
+	{
1358
+		EE_Error::doing_it_wrong(
1359
+			__METHOD__,
1360
+			sprintf(
1361
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1362
+				__METHOD__,
1363
+				'EventEspresso\core\domain\services\Stats::optinText'
1364
+			),
1365
+			'4.9.59.p'
1366
+		);
1367
+		Stats::optinText($extra);
1368
+	}
1369
+
1370
+	/**
1371
+	 * This is a handy helper method for retrieving whether there is an update available for the given plugin.
1372
+	 *
1373
+	 * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
1374
+	 *                          identify plugins. Defaults to core update
1375
+	 * @return boolean           True if update available, false if not.
1376
+	 * @deprecated 4.9.59.p
1377
+	 */
1378
+	public static function is_update_available($basename = '')
1379
+	{
1380
+		EE_Error::doing_it_wrong(
1381
+			__METHOD__,
1382
+			sprintf(
1383
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1384
+				__METHOD__,
1385
+				'EventEspresso\caffeinated\core\services\licensing\LicenseService::isUpdateAvailable'
1386
+			),
1387
+			'4.9.59.p'
1388
+		);
1389
+		return LicenseService::isUpdateAvailable($basename);
1390
+	}
1391 1391
 }
1392 1392
 
1393 1393
 add_filter(
1394
-    'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
1395
-    'ee_deprecated_registrations_report_csv_legacy_fields',
1396
-    10,
1397
-    2
1394
+	'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
1395
+	'ee_deprecated_registrations_report_csv_legacy_fields',
1396
+	10,
1397
+	2
1398 1398
 );
1399 1399
 /**
1400 1400
  * Filters the CSV row to make it appear like the old labels (which were "$pretty_name[$field_name]").
@@ -1411,96 +1411,96 @@  discard block
 block discarded – undo
1411 1411
  */
1412 1412
 function ee_deprecated_registrations_report_csv_legacy_fields($csv_row_data, $reg_row)
1413 1413
 {
1414
-    // no need for all this if nobody is using the deprecated filter
1415
-    if (has_filter('FHEE__EE_Export__report_registrations__reg_csv_array')) {
1416
-        EE_Error::doing_it_wrong(
1417
-            __FUNCTION__,
1418
-            sprintf(
1419
-                // EE_Error::doing_it_wrong with escape HTML, so don't escape it twice by doing it here too.
1420
-                _x(
1421
-                    'The filter "%1$s" has been deprecated. Please use "%2$s" instead.',
1422
-                    'The filter "FHEE__EE_Export__report_registrations__reg_csv_array" has been deprecated. Please use "FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array" instead.',
1423
-                    'event_espresso'
1424
-                ),
1425
-                'FHEE__EE_Export__report_registrations__reg_csv_array',
1426
-                'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array'
1427
-            ),
1428
-            '4.9.69.p',
1429
-            '4.9.75.p'
1430
-        );
1431
-        // there's code that expected the old csv column headers/labels. Let's oblige. Put it back in the old format!
1432
-        // first: what model fields might be used as column headers? (whose format we need to change)
1433
-        $model_fields = array_merge(
1434
-            EEM_Registration::instance()->field_settings(),
1435
-            EEM_Attendee::instance()->field_settings()
1436
-        );
1437
-        // create an array that uses the legacy column headers/labels.
1438
-        $new_csv_row = array();
1439
-        foreach ($csv_row_data as $label => $value) {
1440
-            $new_label = $label;
1441
-            foreach ($model_fields as $field) {
1442
-                if ($label === EEH_Export::get_column_name_for_field($field)) {
1443
-                    // re-add the old field name
1444
-                    $new_label = $label . '[' . $field->get_name() . ']';
1445
-                    break;
1446
-                }
1447
-            }
1448
-            $new_csv_row[$new_label] = $value;
1449
-        }
1450
-        // before we run it through the deprecated filter, set the method `EEH_Export::get_column_name_for_field()`
1451
-        // to create the old column names, because that's what's in the row temporarily
1452
-        add_filter(
1453
-            'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
1454
-            '__return_true',
1455
-            777
1456
-        );
1457
-        // now, those old filters can be run on this data. Have fun!
1458
-        /**
1459
-         * Deprecated. Use FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array instead.
1460
-         *
1461
-         * Filter to change the contents of each row of the registrations report CSV file.
1462
-         * This can be used to add or remote columns from the CSV file, or change their values.                 *
1463
-         * Note: it has this name because originally that's where this filter resided,
1464
-         * and we've left its name as-is for backward compatibility.
1465
-         * Note when using: all rows in the CSV should have the same columns.
1466
-         *
1467
-         * @param array $reg_csv_array keys are column-header names, and values are that columns' value
1468
-         *                             in this row
1469
-         * @param array $reg_row is the row from the database's wp_esp_registration table
1470
-         */
1471
-        $updated_row = apply_filters(
1472
-            'FHEE__EE_Export__report_registrations__reg_csv_array',
1473
-            $new_csv_row,
1474
-            $reg_row
1475
-        );
1476
-
1477
-        // ok now we can revert to normal for EEH_Export::get_column_name_for_field().
1478
-        remove_filter(
1479
-            'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
1480
-            '__return_true',
1481
-            777
1482
-        );
1483
-
1484
-        // great. Now that the old filters are done, we can remove the ugly square brackets from column headers/labels.
1485
-        $updated_and_restored_row = array();
1486
-        foreach ($updated_row as $label => $value) {
1487
-            $matches = array();
1488
-            if (preg_match(
1489
-                    '~([^\[]*)\[(.*)\]~',
1490
-                    $label,
1491
-                    $matches
1492
-                )
1493
-                && isset(
1494
-                    $matches[0],
1495
-                    $matches[1],
1496
-                    $matches[2]
1497
-                )
1498
-            ) {
1499
-                $label = $matches[1];
1500
-            }
1501
-            $updated_and_restored_row[$label] = $value;
1502
-        }
1503
-        $csv_row_data = $updated_and_restored_row;
1504
-    }
1505
-    return $csv_row_data;
1414
+	// no need for all this if nobody is using the deprecated filter
1415
+	if (has_filter('FHEE__EE_Export__report_registrations__reg_csv_array')) {
1416
+		EE_Error::doing_it_wrong(
1417
+			__FUNCTION__,
1418
+			sprintf(
1419
+				// EE_Error::doing_it_wrong with escape HTML, so don't escape it twice by doing it here too.
1420
+				_x(
1421
+					'The filter "%1$s" has been deprecated. Please use "%2$s" instead.',
1422
+					'The filter "FHEE__EE_Export__report_registrations__reg_csv_array" has been deprecated. Please use "FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array" instead.',
1423
+					'event_espresso'
1424
+				),
1425
+				'FHEE__EE_Export__report_registrations__reg_csv_array',
1426
+				'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array'
1427
+			),
1428
+			'4.9.69.p',
1429
+			'4.9.75.p'
1430
+		);
1431
+		// there's code that expected the old csv column headers/labels. Let's oblige. Put it back in the old format!
1432
+		// first: what model fields might be used as column headers? (whose format we need to change)
1433
+		$model_fields = array_merge(
1434
+			EEM_Registration::instance()->field_settings(),
1435
+			EEM_Attendee::instance()->field_settings()
1436
+		);
1437
+		// create an array that uses the legacy column headers/labels.
1438
+		$new_csv_row = array();
1439
+		foreach ($csv_row_data as $label => $value) {
1440
+			$new_label = $label;
1441
+			foreach ($model_fields as $field) {
1442
+				if ($label === EEH_Export::get_column_name_for_field($field)) {
1443
+					// re-add the old field name
1444
+					$new_label = $label . '[' . $field->get_name() . ']';
1445
+					break;
1446
+				}
1447
+			}
1448
+			$new_csv_row[$new_label] = $value;
1449
+		}
1450
+		// before we run it through the deprecated filter, set the method `EEH_Export::get_column_name_for_field()`
1451
+		// to create the old column names, because that's what's in the row temporarily
1452
+		add_filter(
1453
+			'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
1454
+			'__return_true',
1455
+			777
1456
+		);
1457
+		// now, those old filters can be run on this data. Have fun!
1458
+		/**
1459
+		 * Deprecated. Use FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array instead.
1460
+		 *
1461
+		 * Filter to change the contents of each row of the registrations report CSV file.
1462
+		 * This can be used to add or remote columns from the CSV file, or change their values.                 *
1463
+		 * Note: it has this name because originally that's where this filter resided,
1464
+		 * and we've left its name as-is for backward compatibility.
1465
+		 * Note when using: all rows in the CSV should have the same columns.
1466
+		 *
1467
+		 * @param array $reg_csv_array keys are column-header names, and values are that columns' value
1468
+		 *                             in this row
1469
+		 * @param array $reg_row is the row from the database's wp_esp_registration table
1470
+		 */
1471
+		$updated_row = apply_filters(
1472
+			'FHEE__EE_Export__report_registrations__reg_csv_array',
1473
+			$new_csv_row,
1474
+			$reg_row
1475
+		);
1476
+
1477
+		// ok now we can revert to normal for EEH_Export::get_column_name_for_field().
1478
+		remove_filter(
1479
+			'FHEE__EEH_Export__get_column_name_for_field__add_field_name',
1480
+			'__return_true',
1481
+			777
1482
+		);
1483
+
1484
+		// great. Now that the old filters are done, we can remove the ugly square brackets from column headers/labels.
1485
+		$updated_and_restored_row = array();
1486
+		foreach ($updated_row as $label => $value) {
1487
+			$matches = array();
1488
+			if (preg_match(
1489
+					'~([^\[]*)\[(.*)\]~',
1490
+					$label,
1491
+					$matches
1492
+				)
1493
+				&& isset(
1494
+					$matches[0],
1495
+					$matches[1],
1496
+					$matches[2]
1497
+				)
1498
+			) {
1499
+				$label = $matches[1];
1500
+			}
1501
+			$updated_and_restored_row[$label] = $value;
1502
+		}
1503
+		$csv_row_data = $updated_and_restored_row;
1504
+	}
1505
+	return $csv_row_data;
1506 1506
 }
Please login to merge, or discard this patch.
core/services/request/RequestParams.php 1 patch
Indentation   +345 added lines, -345 removed lines patch added patch discarded remove patch
@@ -13,349 +13,349 @@
 block discarded – undo
13 13
  */
14 14
 class RequestParams
15 15
 {
16
-    /**
17
-     * Used for matches() and parameterDrillDown()
18
-     * 'bool' will return true or false if match is found or not
19
-     */
20
-    const RETURN_BOOL  = 'bool';
21
-
22
-    /**
23
-     * Used for matches() and parameterDrillDown()
24
-     * 'key' will return the first key found that matches the supplied pattern
25
-     */
26
-    const RETURN_KEY   = 'key';
27
-
28
-    /**
29
-     * Used for matches() and parameterDrillDown()
30
-     * 'value' will return the value for the first request parameter
31
-     */
32
-    const RETURN_VALUE = 'value';
33
-
34
-    /**
35
-     * $_GET parameters
36
-     *
37
-     * @var array
38
-     */
39
-    protected $get;
40
-
41
-    /**
42
-     * $_POST parameters
43
-     *
44
-     * @var array
45
-     */
46
-    protected $post;
47
-
48
-    /**
49
-     * $_REQUEST parameters
50
-     *
51
-     * @var array
52
-     */
53
-    protected $request;
54
-
55
-    /**
56
-     * @var RequestSanitizer
57
-     */
58
-    protected $sanitizer;
59
-
60
-
61
-    /**
62
-     * RequestParams constructor.
63
-     *
64
-     * @param RequestSanitizer $sanitizer
65
-     * @param array            $get
66
-     * @param array            $post
67
-     */
68
-    public function __construct(RequestSanitizer $sanitizer, array $get = [], array $post = [])
69
-    {
70
-        $this->sanitizer = $sanitizer;
71
-        $this->get       = $get;
72
-        $this->post      = $post;
73
-        $this->request   = array_merge($this->get, $this->post);
74
-    }
75
-
76
-
77
-    /**
78
-     * @return array
79
-     */
80
-    public function getParams()
81
-    {
82
-        return $this->get;
83
-    }
84
-
85
-
86
-    /**
87
-     * @return array
88
-     */
89
-    public function postParams()
90
-    {
91
-        return $this->post;
92
-    }
93
-
94
-
95
-    /**
96
-     * returns contents of $_REQUEST
97
-     *
98
-     * @return array
99
-     */
100
-    public function requestParams()
101
-    {
102
-        return $this->request;
103
-    }
104
-
105
-
106
-    /**
107
-     * @param string     $key
108
-     * @param mixed|null $value
109
-     * @param bool       $override_ee
110
-     * @return    void
111
-     */
112
-    public function setRequestParam($key, $value, $override_ee = false)
113
-    {
114
-        // don't allow "ee" to be overwritten unless explicitly instructed to do so
115
-        if ($override_ee || $key !== 'ee' || empty($this->request['ee'])) {
116
-            $this->request[ $key ] = $value;
117
-        }
118
-    }
119
-
120
-
121
-    /**
122
-     * merges the incoming array of parameters into the existing request parameters
123
-     *
124
-     * @param array $request_params
125
-     * @return void
126
-     * @since   4.10.24.p
127
-     */
128
-    public function mergeRequestParams(array $request_params)
129
-    {
130
-        $this->request = array_merge($this->request, $request_params);
131
-    }
132
-
133
-
134
-    /**
135
-     * returns   the value for a request param if the given key exists
136
-     *
137
-     * @param string     $key
138
-     * @param mixed|null $default
139
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
140
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
141
-     * @param string     $delimiter for CSV type strings that should be returned as an array
142
-     * @return array|bool|float|int|string
143
-     */
144
-    public function getRequestParam($key, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '')
145
-    {
146
-        $param = $this->sanitizer->clean(
147
-            $this->parameterDrillDown($key, $default, 'get'),
148
-            $type,
149
-            $is_array,
150
-            $delimiter
151
-        );
152
-        $type = $is_array ? 'array' : $type;
153
-        return DataType::setDataType($param, $type);
154
-    }
155
-
156
-
157
-    /**
158
-     * check if param exists
159
-     *
160
-     * @param string $key
161
-     * @return bool
162
-     */
163
-    public function requestParamIsSet($key)
164
-    {
165
-        return (bool) $this->parameterDrillDown($key);
166
-    }
167
-
168
-
169
-    /**
170
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
171
-     * and return the value for the first match found
172
-     * wildcards can be either of the following:
173
-     *      ? to represent a single character of any type
174
-     *      * to represent one or more characters of any type
175
-     *
176
-     * @param string     $pattern
177
-     * @param mixed|null $default
178
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
179
-     * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
180
-     * @param string     $delimiter for CSV type strings that should be returned as an array
181
-     * @return array|bool|float|int|string
182
-     */
183
-    public function getMatch($pattern, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '')
184
-    {
185
-        $param = $this->sanitizer->clean(
186
-            $this->parameterDrillDown($pattern, $default, 'match'),
187
-            $type,
188
-            $is_array,
189
-            $delimiter
190
-        );
191
-        $type = $is_array ? 'array' : $type;
192
-        return DataType::setDataType($param, $type);
193
-    }
194
-
195
-
196
-    /**
197
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
198
-     * wildcards can be either of the following:
199
-     *      ? to represent a single character of any type
200
-     *      * to represent one or more characters of any type
201
-     * returns true if a match is found or false if not
202
-     *
203
-     * @param string $pattern
204
-     * @return bool
205
-     */
206
-    public function matches($pattern)
207
-    {
208
-        return (bool) $this->parameterDrillDown($pattern, false, 'match', self::RETURN_BOOL);
209
-    }
210
-
211
-
212
-    /**
213
-     * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
214
-     * @param string $pattern               A string including wildcards to be converted to a regex pattern
215
-     *                                      and used to search through the current request's parameter keys
216
-     * @param array  $request_params        The array of request parameters to search through
217
-     * @param mixed  $default               [optional] The value to be returned if no match is found.
218
-     *                                      Default is null
219
-     * @param string $return                [optional] Controls what kind of value is returned.
220
-     *                                      Options are the RETURN_* constants:
221
-     *                                      RETURN_BOOL will return true or false if match is found or not
222
-     *                                      RETURN_KEY will return the first key found that matches the supplied pattern
223
-     *                                      RETURN_VALUE will return the value for the first request parameter
224
-     *                                      whose key matches the supplied pattern
225
-     *                                      Default is 'value'
226
-     * @return boolean|string
227
-     */
228
-    private function match($pattern, array $request_params, $default = null, $return = self::RETURN_VALUE)
229
-    {
230
-        $return = in_array($return, [self::RETURN_BOOL, self::RETURN_KEY, self::RETURN_VALUE], true)
231
-            ? $return
232
-            : 'is_set';
233
-        // replace wildcard chars with regex chars
234
-        $pattern = str_replace(
235
-            ['\*', '\?'],
236
-            ['.*', '.'],
237
-            preg_quote($pattern, '/')
238
-        );
239
-        foreach ($request_params as $key => $request_param) {
240
-            if (preg_match('/^' . $pattern . '$/is', $key)) {
241
-                // return value for request param
242
-                if ($return === self::RETURN_VALUE) {
243
-                    return $request_param;
244
-                }
245
-                // or actual key or true just to indicate it was found
246
-                return $return === self::RETURN_KEY ? $key : true;
247
-            }
248
-        }
249
-        // match not found so return default value or false
250
-        return $return === self::RETURN_VALUE ? $default : false;
251
-    }
252
-
253
-
254
-    /**
255
-     * the supplied key can be a simple string to represent a "top-level" request parameter
256
-     * or represent a key for a request parameter that is nested deeper within the request parameter array,
257
-     * by using square brackets to surround keys for deeper array elements.
258
-     * For example :
259
-     * if the supplied $key was: "first[second][third]"
260
-     * then this will attempt to drill down into the request parameter array to find a value.
261
-     * Given the following request parameters:
262
-     *  array(
263
-     *      'first' => array(
264
-     *          'second' => array(
265
-     *              'third' => 'has a value'
266
-     *          )
267
-     *      )
268
-     *  )
269
-     * would return true if default parameters were set
270
-     *
271
-     * @param string $callback
272
-     * @param        $key
273
-     * @param null   $default
274
-     * @param string $return
275
-     * @param mixed  $request_params
276
-     * @return bool|mixed|null
277
-     */
278
-    private function parameterDrillDown(
279
-        $key,
280
-        $default = null,
281
-        $callback = 'is_set',
282
-        $return = self::RETURN_VALUE,
283
-        $request_params = []
284
-    ) {
285
-        $callback       = in_array($callback, ['is_set', 'get', 'match'], true)
286
-            ? $callback
287
-            : 'is_set';
288
-        $request_params = ! empty($request_params)
289
-            ? $request_params
290
-            : $this->request;
291
-        // does incoming key represent an array like 'first[second][third]'  ?
292
-        if (strpos($key, '[') !== false) {
293
-            // turn it into an actual array
294
-            $key  = str_replace(']', '', $key);
295
-            $keys = explode('[', $key);
296
-            $key  = array_shift($keys);
297
-            if ($callback === 'match') {
298
-                $real_key = $this->match($key, $request_params, $default, self::RETURN_KEY);
299
-                $key      = $real_key ?: $key;
300
-            }
301
-            // check if top level key exists
302
-            if (isset($request_params[ $key ])) {
303
-                // build a new key to pass along like: 'second[third]'
304
-                // or just 'second' depending on depth of keys
305
-                $key_string = array_shift($keys);
306
-                if (! empty($keys)) {
307
-                    $key_string .= '[' . implode('][', $keys) . ']';
308
-                }
309
-                return $this->parameterDrillDown(
310
-                    $key_string,
311
-                    $default,
312
-                    $callback,
313
-                    $return,
314
-                    $request_params[ $key ]
315
-                );
316
-            }
317
-        }
318
-        if ($callback === 'is_set') {
319
-            return isset($request_params[ $key ]);
320
-        }
321
-        if ($callback === 'match') {
322
-            return $this->match($key, $request_params, $default, $return);
323
-        }
324
-        return isset($request_params[ $key ])
325
-            ? $request_params[ $key ]
326
-            : $default;
327
-    }
328
-
329
-
330
-    /**
331
-     * remove param
332
-     *
333
-     * @param      $key
334
-     * @param bool $unset_from_global_too
335
-     */
336
-    public function unSetRequestParam($key, $unset_from_global_too = false)
337
-    {
338
-        // because unset may not actually remove var
339
-        $this->get[ $key ]     = null;
340
-        $this->post[ $key ]    = null;
341
-        $this->request[ $key ] = null;
342
-        unset($this->get[ $key ], $this->post[ $key ], $this->request[ $key ]);
343
-        if ($unset_from_global_too) {
344
-            unset($_GET[ $key ], $_POST[ $key ], $_REQUEST[ $key ]);
345
-        }
346
-    }
347
-
348
-
349
-    /**
350
-     * remove params
351
-     *
352
-     * @param array $keys
353
-     * @param bool  $unset_from_global_too
354
-     */
355
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false)
356
-    {
357
-        foreach ($keys as $key) {
358
-            $this->unSetRequestParam($key, $unset_from_global_too);
359
-        }
360
-    }
16
+	/**
17
+	 * Used for matches() and parameterDrillDown()
18
+	 * 'bool' will return true or false if match is found or not
19
+	 */
20
+	const RETURN_BOOL  = 'bool';
21
+
22
+	/**
23
+	 * Used for matches() and parameterDrillDown()
24
+	 * 'key' will return the first key found that matches the supplied pattern
25
+	 */
26
+	const RETURN_KEY   = 'key';
27
+
28
+	/**
29
+	 * Used for matches() and parameterDrillDown()
30
+	 * 'value' will return the value for the first request parameter
31
+	 */
32
+	const RETURN_VALUE = 'value';
33
+
34
+	/**
35
+	 * $_GET parameters
36
+	 *
37
+	 * @var array
38
+	 */
39
+	protected $get;
40
+
41
+	/**
42
+	 * $_POST parameters
43
+	 *
44
+	 * @var array
45
+	 */
46
+	protected $post;
47
+
48
+	/**
49
+	 * $_REQUEST parameters
50
+	 *
51
+	 * @var array
52
+	 */
53
+	protected $request;
54
+
55
+	/**
56
+	 * @var RequestSanitizer
57
+	 */
58
+	protected $sanitizer;
59
+
60
+
61
+	/**
62
+	 * RequestParams constructor.
63
+	 *
64
+	 * @param RequestSanitizer $sanitizer
65
+	 * @param array            $get
66
+	 * @param array            $post
67
+	 */
68
+	public function __construct(RequestSanitizer $sanitizer, array $get = [], array $post = [])
69
+	{
70
+		$this->sanitizer = $sanitizer;
71
+		$this->get       = $get;
72
+		$this->post      = $post;
73
+		$this->request   = array_merge($this->get, $this->post);
74
+	}
75
+
76
+
77
+	/**
78
+	 * @return array
79
+	 */
80
+	public function getParams()
81
+	{
82
+		return $this->get;
83
+	}
84
+
85
+
86
+	/**
87
+	 * @return array
88
+	 */
89
+	public function postParams()
90
+	{
91
+		return $this->post;
92
+	}
93
+
94
+
95
+	/**
96
+	 * returns contents of $_REQUEST
97
+	 *
98
+	 * @return array
99
+	 */
100
+	public function requestParams()
101
+	{
102
+		return $this->request;
103
+	}
104
+
105
+
106
+	/**
107
+	 * @param string     $key
108
+	 * @param mixed|null $value
109
+	 * @param bool       $override_ee
110
+	 * @return    void
111
+	 */
112
+	public function setRequestParam($key, $value, $override_ee = false)
113
+	{
114
+		// don't allow "ee" to be overwritten unless explicitly instructed to do so
115
+		if ($override_ee || $key !== 'ee' || empty($this->request['ee'])) {
116
+			$this->request[ $key ] = $value;
117
+		}
118
+	}
119
+
120
+
121
+	/**
122
+	 * merges the incoming array of parameters into the existing request parameters
123
+	 *
124
+	 * @param array $request_params
125
+	 * @return void
126
+	 * @since   4.10.24.p
127
+	 */
128
+	public function mergeRequestParams(array $request_params)
129
+	{
130
+		$this->request = array_merge($this->request, $request_params);
131
+	}
132
+
133
+
134
+	/**
135
+	 * returns   the value for a request param if the given key exists
136
+	 *
137
+	 * @param string     $key
138
+	 * @param mixed|null $default
139
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
140
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
141
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
142
+	 * @return array|bool|float|int|string
143
+	 */
144
+	public function getRequestParam($key, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '')
145
+	{
146
+		$param = $this->sanitizer->clean(
147
+			$this->parameterDrillDown($key, $default, 'get'),
148
+			$type,
149
+			$is_array,
150
+			$delimiter
151
+		);
152
+		$type = $is_array ? 'array' : $type;
153
+		return DataType::setDataType($param, $type);
154
+	}
155
+
156
+
157
+	/**
158
+	 * check if param exists
159
+	 *
160
+	 * @param string $key
161
+	 * @return bool
162
+	 */
163
+	public function requestParamIsSet($key)
164
+	{
165
+		return (bool) $this->parameterDrillDown($key);
166
+	}
167
+
168
+
169
+	/**
170
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
171
+	 * and return the value for the first match found
172
+	 * wildcards can be either of the following:
173
+	 *      ? to represent a single character of any type
174
+	 *      * to represent one or more characters of any type
175
+	 *
176
+	 * @param string     $pattern
177
+	 * @param mixed|null $default
178
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
179
+	 * @param bool       $is_array  if true, then parameter value will be treated as an array of $type
180
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
181
+	 * @return array|bool|float|int|string
182
+	 */
183
+	public function getMatch($pattern, $default = null, $type = DataType::STRING, $is_array = false, $delimiter = '')
184
+	{
185
+		$param = $this->sanitizer->clean(
186
+			$this->parameterDrillDown($pattern, $default, 'match'),
187
+			$type,
188
+			$is_array,
189
+			$delimiter
190
+		);
191
+		$type = $is_array ? 'array' : $type;
192
+		return DataType::setDataType($param, $type);
193
+	}
194
+
195
+
196
+	/**
197
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
198
+	 * wildcards can be either of the following:
199
+	 *      ? to represent a single character of any type
200
+	 *      * to represent one or more characters of any type
201
+	 * returns true if a match is found or false if not
202
+	 *
203
+	 * @param string $pattern
204
+	 * @return bool
205
+	 */
206
+	public function matches($pattern)
207
+	{
208
+		return (bool) $this->parameterDrillDown($pattern, false, 'match', self::RETURN_BOOL);
209
+	}
210
+
211
+
212
+	/**
213
+	 * @see https://stackoverflow.com/questions/6163055/php-string-matching-with-wildcard
214
+	 * @param string $pattern               A string including wildcards to be converted to a regex pattern
215
+	 *                                      and used to search through the current request's parameter keys
216
+	 * @param array  $request_params        The array of request parameters to search through
217
+	 * @param mixed  $default               [optional] The value to be returned if no match is found.
218
+	 *                                      Default is null
219
+	 * @param string $return                [optional] Controls what kind of value is returned.
220
+	 *                                      Options are the RETURN_* constants:
221
+	 *                                      RETURN_BOOL will return true or false if match is found or not
222
+	 *                                      RETURN_KEY will return the first key found that matches the supplied pattern
223
+	 *                                      RETURN_VALUE will return the value for the first request parameter
224
+	 *                                      whose key matches the supplied pattern
225
+	 *                                      Default is 'value'
226
+	 * @return boolean|string
227
+	 */
228
+	private function match($pattern, array $request_params, $default = null, $return = self::RETURN_VALUE)
229
+	{
230
+		$return = in_array($return, [self::RETURN_BOOL, self::RETURN_KEY, self::RETURN_VALUE], true)
231
+			? $return
232
+			: 'is_set';
233
+		// replace wildcard chars with regex chars
234
+		$pattern = str_replace(
235
+			['\*', '\?'],
236
+			['.*', '.'],
237
+			preg_quote($pattern, '/')
238
+		);
239
+		foreach ($request_params as $key => $request_param) {
240
+			if (preg_match('/^' . $pattern . '$/is', $key)) {
241
+				// return value for request param
242
+				if ($return === self::RETURN_VALUE) {
243
+					return $request_param;
244
+				}
245
+				// or actual key or true just to indicate it was found
246
+				return $return === self::RETURN_KEY ? $key : true;
247
+			}
248
+		}
249
+		// match not found so return default value or false
250
+		return $return === self::RETURN_VALUE ? $default : false;
251
+	}
252
+
253
+
254
+	/**
255
+	 * the supplied key can be a simple string to represent a "top-level" request parameter
256
+	 * or represent a key for a request parameter that is nested deeper within the request parameter array,
257
+	 * by using square brackets to surround keys for deeper array elements.
258
+	 * For example :
259
+	 * if the supplied $key was: "first[second][third]"
260
+	 * then this will attempt to drill down into the request parameter array to find a value.
261
+	 * Given the following request parameters:
262
+	 *  array(
263
+	 *      'first' => array(
264
+	 *          'second' => array(
265
+	 *              'third' => 'has a value'
266
+	 *          )
267
+	 *      )
268
+	 *  )
269
+	 * would return true if default parameters were set
270
+	 *
271
+	 * @param string $callback
272
+	 * @param        $key
273
+	 * @param null   $default
274
+	 * @param string $return
275
+	 * @param mixed  $request_params
276
+	 * @return bool|mixed|null
277
+	 */
278
+	private function parameterDrillDown(
279
+		$key,
280
+		$default = null,
281
+		$callback = 'is_set',
282
+		$return = self::RETURN_VALUE,
283
+		$request_params = []
284
+	) {
285
+		$callback       = in_array($callback, ['is_set', 'get', 'match'], true)
286
+			? $callback
287
+			: 'is_set';
288
+		$request_params = ! empty($request_params)
289
+			? $request_params
290
+			: $this->request;
291
+		// does incoming key represent an array like 'first[second][third]'  ?
292
+		if (strpos($key, '[') !== false) {
293
+			// turn it into an actual array
294
+			$key  = str_replace(']', '', $key);
295
+			$keys = explode('[', $key);
296
+			$key  = array_shift($keys);
297
+			if ($callback === 'match') {
298
+				$real_key = $this->match($key, $request_params, $default, self::RETURN_KEY);
299
+				$key      = $real_key ?: $key;
300
+			}
301
+			// check if top level key exists
302
+			if (isset($request_params[ $key ])) {
303
+				// build a new key to pass along like: 'second[third]'
304
+				// or just 'second' depending on depth of keys
305
+				$key_string = array_shift($keys);
306
+				if (! empty($keys)) {
307
+					$key_string .= '[' . implode('][', $keys) . ']';
308
+				}
309
+				return $this->parameterDrillDown(
310
+					$key_string,
311
+					$default,
312
+					$callback,
313
+					$return,
314
+					$request_params[ $key ]
315
+				);
316
+			}
317
+		}
318
+		if ($callback === 'is_set') {
319
+			return isset($request_params[ $key ]);
320
+		}
321
+		if ($callback === 'match') {
322
+			return $this->match($key, $request_params, $default, $return);
323
+		}
324
+		return isset($request_params[ $key ])
325
+			? $request_params[ $key ]
326
+			: $default;
327
+	}
328
+
329
+
330
+	/**
331
+	 * remove param
332
+	 *
333
+	 * @param      $key
334
+	 * @param bool $unset_from_global_too
335
+	 */
336
+	public function unSetRequestParam($key, $unset_from_global_too = false)
337
+	{
338
+		// because unset may not actually remove var
339
+		$this->get[ $key ]     = null;
340
+		$this->post[ $key ]    = null;
341
+		$this->request[ $key ] = null;
342
+		unset($this->get[ $key ], $this->post[ $key ], $this->request[ $key ]);
343
+		if ($unset_from_global_too) {
344
+			unset($_GET[ $key ], $_POST[ $key ], $_REQUEST[ $key ]);
345
+		}
346
+	}
347
+
348
+
349
+	/**
350
+	 * remove params
351
+	 *
352
+	 * @param array $keys
353
+	 * @param bool  $unset_from_global_too
354
+	 */
355
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false)
356
+	{
357
+		foreach ($keys as $key) {
358
+			$this->unSetRequestParam($key, $unset_from_global_too);
359
+		}
360
+	}
361 361
 }
Please login to merge, or discard this patch.
core/services/request/ServerParams.php 2 patches
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -6,203 +6,203 @@
 block discarded – undo
6 6
 
7 7
 class ServerParams
8 8
 {
9
-    /**
10
-     * IP address for request
11
-     *
12
-     * @var string
13
-     */
14
-    protected $ip_address;
15
-
16
-
17
-    /**
18
-     * @var ServerSanitizer
19
-     */
20
-    protected $sanitizer;
21
-
22
-    /**
23
-     * sanitized $_SERVER parameters
24
-     *
25
-     * @var array
26
-     */
27
-    protected $server;
28
-
29
-    /**
30
-     * @var string
31
-     */
32
-    protected $request_uri;
33
-
34
-    /**
35
-     * @var string
36
-     */
37
-    protected $user_agent;
38
-
39
-
40
-    /**
41
-     * ServerParams constructor.
42
-     *
43
-     * @param ServerSanitizer $sanitizer
44
-     * @param array           $server
45
-     */
46
-    public function __construct(ServerSanitizer $sanitizer, array $server = [])
47
-    {
48
-        $this->sanitizer  = $sanitizer;
49
-        $this->server     = $this->cleanServerParams($server);
50
-        $this->ip_address = $this->setVisitorIp();
51
-    }
52
-
53
-
54
-    /**
55
-     * @return array
56
-     */
57
-    private function cleanServerParams(array $server)
58
-    {
59
-        $cleaned = [];
60
-        foreach ($server as $key => $value) {
61
-            $cleaned[ $key ] = $this->sanitizer->clean($key, $value);
62
-        }
63
-        return $cleaned;
64
-    }
65
-
66
-
67
-    /**
68
-     * @return array
69
-     */
70
-    public function getAllServerParams()
71
-    {
72
-        return $this->server;
73
-    }
74
-
75
-
76
-    /**
77
-     * @param string $key
78
-     * @param mixed|null $default
79
-     * @return array|int|float|string
80
-     */
81
-    public function getServerParam($key, $default = null)
82
-    {
83
-        return $this->serverParamIsSet($key) ? $this->server[ $key ] : $default;
84
-    }
85
-
86
-
87
-    /**
88
-     * @param string                 $key
89
-     * @param array|int|float|string $value
90
-     * @return void
91
-     */
92
-    public function setServerParam($key, $value)
93
-    {
94
-        $clean_value = $this->sanitizer->clean($key, $value);
95
-        $this->server[ $key ] = $clean_value;
96
-        // modify global too
97
-        $_SERVER[ $key ] = $clean_value;
98
-    }
99
-
100
-
101
-    /**
102
-     * @return bool
103
-     */
104
-    public function serverParamIsSet($key)
105
-    {
106
-        return isset($this->server[ $key ]);
107
-    }
108
-
109
-
110
-    /**
111
-     * remove param
112
-     *
113
-     * @param string $key
114
-     * @param bool   $unset_from_global_too
115
-     */
116
-    public function unSetServerParam($key, $unset_from_global_too = false)
117
-    {
118
-        // because unset may not actually remove var
119
-        $this->server[ $key ] = null;
120
-        unset($this->server[ $key ]);
121
-        if ($unset_from_global_too) {
122
-            unset($_SERVER[ $key ]);
123
-        }
124
-    }
125
-
126
-
127
-    /**
128
-     * @return string
129
-     */
130
-    public function ipAddress()
131
-    {
132
-        return $this->ip_address;
133
-    }
134
-
135
-
136
-    /**
137
-     * attempt to get IP address of current visitor from server
138
-     * plz see: http://stackoverflow.com/a/2031935/1475279
139
-     *
140
-     * @access public
141
-     * @return string
142
-     */
143
-    private function setVisitorIp()
144
-    {
145
-        $visitor_ip  = '0.0.0.0';
146
-        $server_keys = [
147
-            'HTTP_CLIENT_IP',
148
-            'HTTP_FORWARDED',
149
-            'HTTP_FORWARDED_FOR',
150
-            'HTTP_X_CLUSTER_CLIENT_IP',
151
-            'HTTP_X_FORWARDED',
152
-            'HTTP_X_FORWARDED_FOR',
153
-            'REMOTE_ADDR',
154
-        ];
155
-        foreach ($server_keys as $key) {
156
-            if (isset($this->server[ $key ])) {
157
-                $potential_ip = array_map('trim', explode(',', $this->server[ $key ]));
158
-                foreach ($potential_ip as $ip) {
159
-                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
160
-                        $visitor_ip = $ip;
161
-                    }
162
-                }
163
-            }
164
-        }
165
-        return $visitor_ip;
166
-    }
167
-
168
-
169
-    /**
170
-     * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
171
-     *
172
-     * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
173
-     *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
174
-     *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
175
-     * @return string
176
-     */
177
-    public function requestUri($relativeToWpRoot = false)
178
-    {
179
-        if ($relativeToWpRoot) {
180
-            $home_path = untrailingslashit(parse_url(home_url(), PHP_URL_PATH));
181
-            return str_replace($home_path, '', $this->server['REQUEST_URI']);
182
-        }
183
-        return $this->server['REQUEST_URI'];
184
-    }
185
-
186
-
187
-    /**
188
-     * @return string
189
-     */
190
-    public function userAgent()
191
-    {
192
-        if (empty($this->user_agent)) {
193
-            $this->setUserAgent();
194
-        }
195
-        return $this->user_agent;
196
-    }
197
-
198
-
199
-    /**
200
-     * @param string $user_agent
201
-     */
202
-    public function setUserAgent($user_agent = '')
203
-    {
204
-        $this->user_agent = $user_agent === '' || ! is_string($user_agent)
205
-            ? $this->getServerParam('HTTP_USER_AGENT')
206
-            : esc_attr($user_agent);
207
-    }
9
+	/**
10
+	 * IP address for request
11
+	 *
12
+	 * @var string
13
+	 */
14
+	protected $ip_address;
15
+
16
+
17
+	/**
18
+	 * @var ServerSanitizer
19
+	 */
20
+	protected $sanitizer;
21
+
22
+	/**
23
+	 * sanitized $_SERVER parameters
24
+	 *
25
+	 * @var array
26
+	 */
27
+	protected $server;
28
+
29
+	/**
30
+	 * @var string
31
+	 */
32
+	protected $request_uri;
33
+
34
+	/**
35
+	 * @var string
36
+	 */
37
+	protected $user_agent;
38
+
39
+
40
+	/**
41
+	 * ServerParams constructor.
42
+	 *
43
+	 * @param ServerSanitizer $sanitizer
44
+	 * @param array           $server
45
+	 */
46
+	public function __construct(ServerSanitizer $sanitizer, array $server = [])
47
+	{
48
+		$this->sanitizer  = $sanitizer;
49
+		$this->server     = $this->cleanServerParams($server);
50
+		$this->ip_address = $this->setVisitorIp();
51
+	}
52
+
53
+
54
+	/**
55
+	 * @return array
56
+	 */
57
+	private function cleanServerParams(array $server)
58
+	{
59
+		$cleaned = [];
60
+		foreach ($server as $key => $value) {
61
+			$cleaned[ $key ] = $this->sanitizer->clean($key, $value);
62
+		}
63
+		return $cleaned;
64
+	}
65
+
66
+
67
+	/**
68
+	 * @return array
69
+	 */
70
+	public function getAllServerParams()
71
+	{
72
+		return $this->server;
73
+	}
74
+
75
+
76
+	/**
77
+	 * @param string $key
78
+	 * @param mixed|null $default
79
+	 * @return array|int|float|string
80
+	 */
81
+	public function getServerParam($key, $default = null)
82
+	{
83
+		return $this->serverParamIsSet($key) ? $this->server[ $key ] : $default;
84
+	}
85
+
86
+
87
+	/**
88
+	 * @param string                 $key
89
+	 * @param array|int|float|string $value
90
+	 * @return void
91
+	 */
92
+	public function setServerParam($key, $value)
93
+	{
94
+		$clean_value = $this->sanitizer->clean($key, $value);
95
+		$this->server[ $key ] = $clean_value;
96
+		// modify global too
97
+		$_SERVER[ $key ] = $clean_value;
98
+	}
99
+
100
+
101
+	/**
102
+	 * @return bool
103
+	 */
104
+	public function serverParamIsSet($key)
105
+	{
106
+		return isset($this->server[ $key ]);
107
+	}
108
+
109
+
110
+	/**
111
+	 * remove param
112
+	 *
113
+	 * @param string $key
114
+	 * @param bool   $unset_from_global_too
115
+	 */
116
+	public function unSetServerParam($key, $unset_from_global_too = false)
117
+	{
118
+		// because unset may not actually remove var
119
+		$this->server[ $key ] = null;
120
+		unset($this->server[ $key ]);
121
+		if ($unset_from_global_too) {
122
+			unset($_SERVER[ $key ]);
123
+		}
124
+	}
125
+
126
+
127
+	/**
128
+	 * @return string
129
+	 */
130
+	public function ipAddress()
131
+	{
132
+		return $this->ip_address;
133
+	}
134
+
135
+
136
+	/**
137
+	 * attempt to get IP address of current visitor from server
138
+	 * plz see: http://stackoverflow.com/a/2031935/1475279
139
+	 *
140
+	 * @access public
141
+	 * @return string
142
+	 */
143
+	private function setVisitorIp()
144
+	{
145
+		$visitor_ip  = '0.0.0.0';
146
+		$server_keys = [
147
+			'HTTP_CLIENT_IP',
148
+			'HTTP_FORWARDED',
149
+			'HTTP_FORWARDED_FOR',
150
+			'HTTP_X_CLUSTER_CLIENT_IP',
151
+			'HTTP_X_FORWARDED',
152
+			'HTTP_X_FORWARDED_FOR',
153
+			'REMOTE_ADDR',
154
+		];
155
+		foreach ($server_keys as $key) {
156
+			if (isset($this->server[ $key ])) {
157
+				$potential_ip = array_map('trim', explode(',', $this->server[ $key ]));
158
+				foreach ($potential_ip as $ip) {
159
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
160
+						$visitor_ip = $ip;
161
+					}
162
+				}
163
+			}
164
+		}
165
+		return $visitor_ip;
166
+	}
167
+
168
+
169
+	/**
170
+	 * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
171
+	 *
172
+	 * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
173
+	 *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
174
+	 *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
175
+	 * @return string
176
+	 */
177
+	public function requestUri($relativeToWpRoot = false)
178
+	{
179
+		if ($relativeToWpRoot) {
180
+			$home_path = untrailingslashit(parse_url(home_url(), PHP_URL_PATH));
181
+			return str_replace($home_path, '', $this->server['REQUEST_URI']);
182
+		}
183
+		return $this->server['REQUEST_URI'];
184
+	}
185
+
186
+
187
+	/**
188
+	 * @return string
189
+	 */
190
+	public function userAgent()
191
+	{
192
+		if (empty($this->user_agent)) {
193
+			$this->setUserAgent();
194
+		}
195
+		return $this->user_agent;
196
+	}
197
+
198
+
199
+	/**
200
+	 * @param string $user_agent
201
+	 */
202
+	public function setUserAgent($user_agent = '')
203
+	{
204
+		$this->user_agent = $user_agent === '' || ! is_string($user_agent)
205
+			? $this->getServerParam('HTTP_USER_AGENT')
206
+			: esc_attr($user_agent);
207
+	}
208 208
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
     {
59 59
         $cleaned = [];
60 60
         foreach ($server as $key => $value) {
61
-            $cleaned[ $key ] = $this->sanitizer->clean($key, $value);
61
+            $cleaned[$key] = $this->sanitizer->clean($key, $value);
62 62
         }
63 63
         return $cleaned;
64 64
     }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function getServerParam($key, $default = null)
82 82
     {
83
-        return $this->serverParamIsSet($key) ? $this->server[ $key ] : $default;
83
+        return $this->serverParamIsSet($key) ? $this->server[$key] : $default;
84 84
     }
85 85
 
86 86
 
@@ -92,9 +92,9 @@  discard block
 block discarded – undo
92 92
     public function setServerParam($key, $value)
93 93
     {
94 94
         $clean_value = $this->sanitizer->clean($key, $value);
95
-        $this->server[ $key ] = $clean_value;
95
+        $this->server[$key] = $clean_value;
96 96
         // modify global too
97
-        $_SERVER[ $key ] = $clean_value;
97
+        $_SERVER[$key] = $clean_value;
98 98
     }
99 99
 
100 100
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function serverParamIsSet($key)
105 105
     {
106
-        return isset($this->server[ $key ]);
106
+        return isset($this->server[$key]);
107 107
     }
108 108
 
109 109
 
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
     public function unSetServerParam($key, $unset_from_global_too = false)
117 117
     {
118 118
         // because unset may not actually remove var
119
-        $this->server[ $key ] = null;
120
-        unset($this->server[ $key ]);
119
+        $this->server[$key] = null;
120
+        unset($this->server[$key]);
121 121
         if ($unset_from_global_too) {
122
-            unset($_SERVER[ $key ]);
122
+            unset($_SERVER[$key]);
123 123
         }
124 124
     }
125 125
 
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
             'REMOTE_ADDR',
154 154
         ];
155 155
         foreach ($server_keys as $key) {
156
-            if (isset($this->server[ $key ])) {
157
-                $potential_ip = array_map('trim', explode(',', $this->server[ $key ]));
156
+            if (isset($this->server[$key])) {
157
+                $potential_ip = array_map('trim', explode(',', $this->server[$key]));
158 158
                 foreach ($potential_ip as $ip) {
159 159
                     if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
160 160
                         $visitor_ip = $ip;
Please login to merge, or discard this patch.
core/services/bootstrap/BootstrapRequestResponseObjects.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -28,84 +28,84 @@
 block discarded – undo
28 28
  */
29 29
 class BootstrapRequestResponseObjects
30 30
 {
31
-    /**
32
-     * @type LegacyRequestInterface $legacy_request
33
-     */
34
-    protected $legacy_request;
31
+	/**
32
+	 * @type LegacyRequestInterface $legacy_request
33
+	 */
34
+	protected $legacy_request;
35 35
 
36
-    /**
37
-     * @type LoaderInterface $loader
38
-     */
39
-    protected $loader;
36
+	/**
37
+	 * @type LoaderInterface $loader
38
+	 */
39
+	protected $loader;
40 40
 
41
-    /**
42
-     * @var RequestInterface $request
43
-     */
44
-    protected $request;
41
+	/**
42
+	 * @var RequestInterface $request
43
+	 */
44
+	protected $request;
45 45
 
46
-    /**
47
-     * @var ResponseInterface $response
48
-     */
49
-    protected $response;
46
+	/**
47
+	 * @var ResponseInterface $response
48
+	 */
49
+	protected $response;
50 50
 
51 51
 
52
-    /**
53
-     * BootstrapRequestResponseObjects constructor.
54
-     *
55
-     * @param LoaderInterface $loader
56
-     */
57
-    public function __construct(LoaderInterface $loader)
58
-    {
59
-        $this->loader = $loader;
60
-    }
52
+	/**
53
+	 * BootstrapRequestResponseObjects constructor.
54
+	 *
55
+	 * @param LoaderInterface $loader
56
+	 */
57
+	public function __construct(LoaderInterface $loader)
58
+	{
59
+		$this->loader = $loader;
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * @return void
65
-     */
66
-    public function buildRequestResponse()
67
-    {
68
-        $request_params = new RequestParams(new RequestSanitizer(), $_GET, $_POST);
69
-        $server_params = new ServerParams(new ServerSanitizer(), $_SERVER);
70
-        // load our Request and Response objects
71
-        $this->request = new Request($request_params, $server_params);
72
-        $this->response = new Response();
73
-        $this->loader->share(RequestParams::class, $request_params);
74
-        $this->loader->share(ServerParams::class, $server_params);
75
-    }
63
+	/**
64
+	 * @return void
65
+	 */
66
+	public function buildRequestResponse()
67
+	{
68
+		$request_params = new RequestParams(new RequestSanitizer(), $_GET, $_POST);
69
+		$server_params = new ServerParams(new ServerSanitizer(), $_SERVER);
70
+		// load our Request and Response objects
71
+		$this->request = new Request($request_params, $server_params);
72
+		$this->response = new Response();
73
+		$this->loader->share(RequestParams::class, $request_params);
74
+		$this->loader->share(ServerParams::class, $server_params);
75
+	}
76 76
 
77 77
 
78
-    /**
79
-     * @return void
80
-     * @throws InvalidArgumentException
81
-     */
82
-    public function shareRequestResponse()
83
-    {
84
-        $this->loader->share('EventEspresso\core\services\request\Request', $this->request);
85
-        $this->loader->share('EventEspresso\core\services\request\Response', $this->response);
86
-        EE_Dependency_Map::instance()->setRequest($this->request);
87
-        EE_Dependency_Map::instance()->setResponse($this->response);
88
-    }
78
+	/**
79
+	 * @return void
80
+	 * @throws InvalidArgumentException
81
+	 */
82
+	public function shareRequestResponse()
83
+	{
84
+		$this->loader->share('EventEspresso\core\services\request\Request', $this->request);
85
+		$this->loader->share('EventEspresso\core\services\request\Response', $this->response);
86
+		EE_Dependency_Map::instance()->setRequest($this->request);
87
+		EE_Dependency_Map::instance()->setResponse($this->response);
88
+	}
89 89
 
90 90
 
91
-    /**
92
-     * @return void
93
-     * @throws InvalidArgumentException
94
-     * @throws EE_Error
95
-     */
96
-    public function setupLegacyRequest()
97
-    {
98
-        espresso_load_required(
99
-            'EE_Request',
100
-            EE_CORE . 'request_stack/EE_Request.core.php'
101
-        );
102
-        $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
103
-        $this->legacy_request->setRequest($this->request);
104
-        $this->legacy_request->admin = $this->request->isAdmin();
105
-        $this->legacy_request->ajax = $this->request->isAjax();
106
-        $this->legacy_request->front_ajax = $this->request->isFrontAjax();
107
-        EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
108
-        $this->loader->share('EE_Request', $this->legacy_request);
109
-        $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
110
-    }
91
+	/**
92
+	 * @return void
93
+	 * @throws InvalidArgumentException
94
+	 * @throws EE_Error
95
+	 */
96
+	public function setupLegacyRequest()
97
+	{
98
+		espresso_load_required(
99
+			'EE_Request',
100
+			EE_CORE . 'request_stack/EE_Request.core.php'
101
+		);
102
+		$this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER);
103
+		$this->legacy_request->setRequest($this->request);
104
+		$this->legacy_request->admin = $this->request->isAdmin();
105
+		$this->legacy_request->ajax = $this->request->isAjax();
106
+		$this->legacy_request->front_ajax = $this->request->isFrontAjax();
107
+		EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request);
108
+		$this->loader->share('EE_Request', $this->legacy_request);
109
+		$this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request);
110
+	}
111 111
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Addon.lib.php 2 patches
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
         // offsets:    0 . 1 . 2 . 3 . 4
71 71
         $version_parts = explode('.', $min_core_version);
72 72
         // check they specified the micro version (after 2nd period)
73
-        if (! isset($version_parts[2])) {
73
+        if ( ! isset($version_parts[2])) {
74 74
             $version_parts[2] = '0';
75 75
         }
76 76
         // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
77 77
         // soon we can assume that's 'rc', but this current version is 'alpha'
78
-        if (! isset($version_parts[3])) {
78
+        if ( ! isset($version_parts[3])) {
79 79
             $version_parts[3] = 'dev';
80 80
         }
81
-        if (! isset($version_parts[4])) {
81
+        if ( ! isset($version_parts[4])) {
82 82
             $version_parts[4] = '000';
83 83
         }
84 84
         return implode('.', $version_parts);
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
         );
271 271
         // does this addon work with this version of core or WordPress ?
272 272
         // does this addon work with this version of core or WordPress ?
273
-        if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
273
+        if ( ! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
274 274
             return;
275 275
         }
276 276
         // register namespaces
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
             );
347 347
         }
348 348
         // check that addon has not already been registered with that name
349
-        if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
349
+        if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) {
350 350
             throw new EE_Error(
351 351
                 sprintf(
352 352
                     esc_html__(
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
         // check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
379 379
         return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
380 380
             ? $class_name
381
-            : 'EE_' . $class_name;
381
+            : 'EE_'.$class_name;
382 382
     }
383 383
 
384 384
 
@@ -540,9 +540,9 @@  discard block
 block discarded – undo
540 540
         $incompatibility_message = '';
541 541
         // check whether this addon version is compatible with EE core
542 542
         if (
543
-            isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
543
+            isset(EE_Register_Addon::$_incompatible_addons[$addon_name])
544 544
             && ! self::_meets_min_core_version_requirement(
545
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
545
+                EE_Register_Addon::$_incompatible_addons[$addon_name],
546 546
                 $addon_settings['version']
547 547
             )
548 548
         ) {
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
                 ),
554 554
                 $addon_name,
555 555
                 '<br />',
556
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
556
+                EE_Register_Addon::$_incompatible_addons[$addon_name],
557 557
                 '<span style="font-weight: bold; color: #D54E21;">',
558 558
                 '</span><br />'
559 559
             );
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
                 '</span><br />'
586 586
             );
587 587
         }
588
-        if (! empty($incompatibility_message)) {
588
+        if ( ! empty($incompatibility_message)) {
589 589
             // remove 'activate' from the REQUEST
590 590
             // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
591 591
             /** @var RequestInterface $request */
@@ -596,8 +596,8 @@  discard block
 block discarded – undo
596 596
                 EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
597 597
             }
598 598
             unset($_GET['activate'], $_REQUEST['activate']);
599
-            if (! function_exists('deactivate_plugins')) {
600
-                require_once ABSPATH . 'wp-admin/includes/plugin.php';
599
+            if ( ! function_exists('deactivate_plugins')) {
600
+                require_once ABSPATH.'wp-admin/includes/plugin.php';
601 601
             }
602 602
             deactivate_plugins(plugin_basename($addon_settings['main_file_path']));
603 603
             // BAIL FROM THE ADDON REGISTRATION PROCESS
@@ -648,12 +648,12 @@  discard block
 block discarded – undo
648 648
             // Note: the presence of pue_options in the addon registration options will initialize the $_settings
649 649
             // property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
650 650
             if (
651
-                ! isset(self::$_settings[ $addon_name ])
652
-                || (isset(self::$_settings[ $addon_name ])
653
-                    && ! isset(self::$_settings[ $addon_name ]['class_name'])
651
+                ! isset(self::$_settings[$addon_name])
652
+                || (isset(self::$_settings[$addon_name])
653
+                    && ! isset(self::$_settings[$addon_name]['class_name'])
654 654
                 )
655 655
             ) {
656
-                self::$_settings[ $addon_name ] = $addon_settings;
656
+                self::$_settings[$addon_name] = $addon_settings;
657 657
                 $addon                          = self::_load_and_init_addon_class($addon_name);
658 658
                 $addon->set_activation_indicator_option();
659 659
                 // dont bother setting up the rest of the addon.
@@ -679,10 +679,10 @@  discard block
 block discarded – undo
679 679
             );
680 680
         }
681 681
         // make sure addon settings are set correctly without overwriting anything existing
682
-        if (isset(self::$_settings[ $addon_name ])) {
683
-            self::$_settings[ $addon_name ] += $addon_settings;
682
+        if (isset(self::$_settings[$addon_name])) {
683
+            self::$_settings[$addon_name] += $addon_settings;
684 684
         } else {
685
-            self::$_settings[ $addon_name ] = $addon_settings;
685
+            self::$_settings[$addon_name] = $addon_settings;
686 686
         }
687 687
         return false;
688 688
     }
@@ -695,13 +695,13 @@  discard block
 block discarded – undo
695 695
      */
696 696
     private static function _setup_autoloaders(string $addon_name)
697 697
     {
698
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
698
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
699 699
             // setup autoloader for single file
700
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
700
+            EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
701 701
         }
702 702
         // setup autoloaders for folders
703
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
704
-            foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
703
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
704
+            foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
705 705
                 EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
706 706
             }
707 707
         }
@@ -719,27 +719,27 @@  discard block
 block discarded – undo
719 719
     {
720 720
         // register new models
721 721
         if (
722
-            ! empty(self::$_settings[ $addon_name ]['model_paths'])
723
-            || ! empty(self::$_settings[ $addon_name ]['class_paths'])
722
+            ! empty(self::$_settings[$addon_name]['model_paths'])
723
+            || ! empty(self::$_settings[$addon_name]['class_paths'])
724 724
         ) {
725 725
             EE_Register_Model::register(
726 726
                 $addon_name,
727 727
                 [
728
-                    'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
729
-                    'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
728
+                    'model_paths' => self::$_settings[$addon_name]['model_paths'],
729
+                    'class_paths' => self::$_settings[$addon_name]['class_paths'],
730 730
                 ]
731 731
             );
732 732
         }
733 733
         // register model extensions
734 734
         if (
735
-            ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
736
-            || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
735
+            ! empty(self::$_settings[$addon_name]['model_extension_paths'])
736
+            || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
737 737
         ) {
738 738
             EE_Register_Model_Extensions::register(
739 739
                 $addon_name,
740 740
                 [
741
-                    'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
742
-                    'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
741
+                    'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'],
742
+                    'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'],
743 743
                 ]
744 744
             );
745 745
         }
@@ -754,10 +754,10 @@  discard block
 block discarded – undo
754 754
     private static function _register_data_migration_scripts(string $addon_name)
755 755
     {
756 756
         // setup DMS
757
-        if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
757
+        if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
758 758
             EE_Register_Data_Migration_Scripts::register(
759 759
                 $addon_name,
760
-                ['dms_paths' => self::$_settings[ $addon_name ]['dms_paths']]
760
+                ['dms_paths' => self::$_settings[$addon_name]['dms_paths']]
761 761
             );
762 762
         }
763 763
     }
@@ -771,12 +771,12 @@  discard block
 block discarded – undo
771 771
     private static function _register_config(string $addon_name)
772 772
     {
773 773
         // if config_class is present let's register config.
774
-        if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
774
+        if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
775 775
             EE_Register_Config::register(
776
-                self::$_settings[ $addon_name ]['config_class'],
776
+                self::$_settings[$addon_name]['config_class'],
777 777
                 [
778
-                    'config_section' => self::$_settings[ $addon_name ]['config_section'],
779
-                    'config_name'    => self::$_settings[ $addon_name ]['config_name'],
778
+                    'config_section' => self::$_settings[$addon_name]['config_section'],
779
+                    'config_name'    => self::$_settings[$addon_name]['config_name'],
780 780
                 ]
781 781
             );
782 782
         }
@@ -790,10 +790,10 @@  discard block
 block discarded – undo
790 790
      */
791 791
     private static function _register_admin_pages(string $addon_name)
792 792
     {
793
-        if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
793
+        if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
794 794
             EE_Register_Admin_Page::register(
795 795
                 $addon_name,
796
-                ['page_path' => self::$_settings[ $addon_name ]['admin_path']]
796
+                ['page_path' => self::$_settings[$addon_name]['admin_path']]
797 797
             );
798 798
         }
799 799
     }
@@ -806,10 +806,10 @@  discard block
 block discarded – undo
806 806
      */
807 807
     private static function _register_modules(string $addon_name)
808 808
     {
809
-        if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
809
+        if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
810 810
             EE_Register_Module::register(
811 811
                 $addon_name,
812
-                ['module_paths' => self::$_settings[ $addon_name ]['module_paths']]
812
+                ['module_paths' => self::$_settings[$addon_name]['module_paths']]
813 813
             );
814 814
         }
815 815
     }
@@ -823,14 +823,14 @@  discard block
 block discarded – undo
823 823
     private static function _register_shortcodes(string $addon_name)
824 824
     {
825 825
         if (
826
-            ! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
827
-            || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
826
+            ! empty(self::$_settings[$addon_name]['shortcode_paths'])
827
+            || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
828 828
         ) {
829 829
             EE_Register_Shortcode::register(
830 830
                 $addon_name,
831 831
                 [
832
-                    'shortcode_paths' => self::$_settings[ $addon_name ]['shortcode_paths'] ?? [],
833
-                    'shortcode_fqcns' => self::$_settings[ $addon_name ]['shortcode_fqcns'] ?? [],
832
+                    'shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths'] ?? [],
833
+                    'shortcode_fqcns' => self::$_settings[$addon_name]['shortcode_fqcns'] ?? [],
834 834
                 ]
835 835
             );
836 836
         }
@@ -844,10 +844,10 @@  discard block
 block discarded – undo
844 844
      */
845 845
     private static function _register_widgets(string $addon_name)
846 846
     {
847
-        if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
847
+        if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
848 848
             EE_Register_Widget::register(
849 849
                 $addon_name,
850
-                ['widget_paths' => self::$_settings[ $addon_name ]['widget_paths']]
850
+                ['widget_paths' => self::$_settings[$addon_name]['widget_paths']]
851 851
             );
852 852
         }
853 853
     }
@@ -860,12 +860,12 @@  discard block
 block discarded – undo
860 860
      */
861 861
     private static function _register_capabilities(string $addon_name)
862 862
     {
863
-        if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
863
+        if ( ! empty(self::$_settings[$addon_name]['capabilities'])) {
864 864
             EE_Register_Capabilities::register(
865 865
                 $addon_name,
866 866
                 [
867
-                    'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
868
-                    'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
867
+                    'capabilities'    => self::$_settings[$addon_name]['capabilities'],
868
+                    'capability_maps' => self::$_settings[$addon_name]['capability_maps'],
869 869
                 ]
870 870
             );
871 871
         }
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
      */
879 879
     private static function _register_message_types(string $addon_name)
880 880
     {
881
-        if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
881
+        if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
882 882
             add_action(
883 883
                 'EE_Brewing_Regular___messages_caf',
884 884
                 ['EE_Register_Addon', 'register_message_types']
@@ -895,15 +895,15 @@  discard block
 block discarded – undo
895 895
     private static function _register_custom_post_types(string $addon_name)
896 896
     {
897 897
         if (
898
-            ! empty(self::$_settings[ $addon_name ]['custom_post_types'])
899
-            || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
898
+            ! empty(self::$_settings[$addon_name]['custom_post_types'])
899
+            || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])
900 900
         ) {
901 901
             EE_Register_CPT::register(
902 902
                 $addon_name,
903 903
                 [
904
-                    'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
905
-                    'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
906
-                    'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
904
+                    'cpts'          => self::$_settings[$addon_name]['custom_post_types'],
905
+                    'cts'           => self::$_settings[$addon_name]['custom_taxonomies'],
906
+                    'default_terms' => self::$_settings[$addon_name]['default_terms'],
907 907
                 ]
908 908
             );
909 909
         }
@@ -921,10 +921,10 @@  discard block
 block discarded – undo
921 921
      */
922 922
     private static function _register_payment_methods(string $addon_name)
923 923
     {
924
-        if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
924
+        if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
925 925
             EE_Register_Payment_Method::register(
926 926
                 $addon_name,
927
-                ['payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths']]
927
+                ['payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']]
928 928
             );
929 929
         }
930 930
     }
@@ -940,10 +940,10 @@  discard block
 block discarded – undo
940 940
      */
941 941
     private static function registerPrivacyPolicies(string $addon_name)
942 942
     {
943
-        if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) {
943
+        if ( ! empty(self::$_settings[$addon_name]['privacy_policies'])) {
944 944
             EE_Register_Privacy_Policy::register(
945 945
                 $addon_name,
946
-                self::$_settings[ $addon_name ]['privacy_policies']
946
+                self::$_settings[$addon_name]['privacy_policies']
947 947
             );
948 948
         }
949 949
     }
@@ -955,10 +955,10 @@  discard block
 block discarded – undo
955 955
      */
956 956
     private static function registerPersonalDataExporters(string $addon_name)
957 957
     {
958
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) {
958
+        if ( ! empty(self::$_settings[$addon_name]['personal_data_exporters'])) {
959 959
             EE_Register_Personal_Data_Eraser::register(
960 960
                 $addon_name,
961
-                self::$_settings[ $addon_name ]['personal_data_exporters']
961
+                self::$_settings[$addon_name]['personal_data_exporters']
962 962
             );
963 963
         }
964 964
     }
@@ -970,10 +970,10 @@  discard block
 block discarded – undo
970 970
      */
971 971
     private static function registerPersonalDataErasers(string $addon_name)
972 972
     {
973
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) {
973
+        if ( ! empty(self::$_settings[$addon_name]['personal_data_erasers'])) {
974 974
             EE_Register_Personal_Data_Eraser::register(
975 975
                 $addon_name,
976
-                self::$_settings[ $addon_name ]['personal_data_erasers']
976
+                self::$_settings[$addon_name]['personal_data_erasers']
977 977
             );
978 978
         }
979 979
     }
@@ -991,10 +991,10 @@  discard block
 block discarded – undo
991 991
     private static function _load_and_init_addon_class(string $addon_name): EE_Addon
992 992
     {
993 993
         $addon = LoaderFactory::getLoader()->getShared(
994
-            self::$_settings[ $addon_name ]['class_name'],
994
+            self::$_settings[$addon_name]['class_name'],
995 995
             ['EE_Registry::create(addon)' => true]
996 996
         );
997
-        if (! $addon instanceof EE_Addon) {
997
+        if ( ! $addon instanceof EE_Addon) {
998 998
             throw new DomainException(
999 999
                 sprintf(
1000 1000
                     esc_html__(
@@ -1013,16 +1013,16 @@  discard block
 block discarded – undo
1013 1013
         EE_Register_Addon::injectAddonDomain($addon_name, $addon);
1014 1014
 
1015 1015
         $addon->set_name($addon_name);
1016
-        $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
1017
-        $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
1018
-        $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
1019
-        $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
1020
-        $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
1021
-        $addon->set_version(self::$_settings[ $addon_name ]['version']);
1022
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
1023
-        $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
1024
-        $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
1025
-        $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
1016
+        $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']);
1017
+        $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']);
1018
+        $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']);
1019
+        $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']);
1020
+        $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']);
1021
+        $addon->set_version(self::$_settings[$addon_name]['version']);
1022
+        $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version']));
1023
+        $addon->set_config_section(self::$_settings[$addon_name]['config_section']);
1024
+        $addon->set_config_class(self::$_settings[$addon_name]['config_class']);
1025
+        $addon->set_config_name(self::$_settings[$addon_name]['config_name']);
1026 1026
         do_action(
1027 1027
             'AHEE__EE_Register_Addon___load_and_init_addon_class',
1028 1028
             $addon,
@@ -1033,10 +1033,10 @@  discard block
 block discarded – undo
1033 1033
         // because we don't have the plugin's mainfile path upon construction.
1034 1034
         register_deactivation_hook($addon->get_main_plugin_file(), [$addon, 'deactivation']);
1035 1035
         // call any additional admin_callback functions during load_admin_controller hook
1036
-        if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1036
+        if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) {
1037 1037
             add_action(
1038 1038
                 'AHEE__EE_System__load_controllers__load_admin_controllers',
1039
-                [$addon, self::$_settings[ $addon_name ]['admin_callback']]
1039
+                [$addon, self::$_settings[$addon_name]['admin_callback']]
1040 1040
             );
1041 1041
         }
1042 1042
         return $addon;
@@ -1052,19 +1052,19 @@  discard block
 block discarded – undo
1052 1052
     {
1053 1053
         if ($addon instanceof RequiresDomainInterface && $addon->domain() === null) {
1054 1054
             // using supplied Domain object
1055
-            $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
1056
-                ? self::$_settings[ $addon_name ]['domain']
1055
+            $domain = self::$_settings[$addon_name]['domain'] instanceof DomainInterface
1056
+                ? self::$_settings[$addon_name]['domain']
1057 1057
                 : null;
1058 1058
             // or construct one using Domain FQCN
1059
-            if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
1059
+            if ($domain === null && self::$_settings[$addon_name]['domain_fqcn'] !== '') {
1060 1060
                 $domain = LoaderFactory::getLoader()->getShared(
1061
-                    self::$_settings[ $addon_name ]['domain_fqcn'],
1061
+                    self::$_settings[$addon_name]['domain_fqcn'],
1062 1062
                     [
1063 1063
                         new EventEspresso\core\domain\values\FilePath(
1064
-                            self::$_settings[ $addon_name ]['main_file_path']
1064
+                            self::$_settings[$addon_name]['main_file_path']
1065 1065
                         ),
1066 1066
                         EventEspresso\core\domain\values\Version::fromString(
1067
-                            self::$_settings[ $addon_name ]['version']
1067
+                            self::$_settings[$addon_name]['version']
1068 1068
                         ),
1069 1069
                     ]
1070 1070
                 );
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
     public static function register_message_types()
1096 1096
     {
1097 1097
         foreach (self::$_settings as $settings) {
1098
-            if (! empty($settings['message_types'])) {
1098
+            if ( ! empty($settings['message_types'])) {
1099 1099
                 foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1100 1100
                     EE_Register_Message_Type::register($message_type, $message_type_settings);
1101 1101
                 }
@@ -1116,74 +1116,74 @@  discard block
 block discarded – undo
1116 1116
      */
1117 1117
     public static function deregister($addon_name = '')
1118 1118
     {
1119
-        if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1119
+        if (isset(self::$_settings[$addon_name]['class_name'])) {
1120 1120
             try {
1121 1121
                 do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1122
-                $class_name = self::$_settings[ $addon_name ]['class_name'];
1123
-                if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1122
+                $class_name = self::$_settings[$addon_name]['class_name'];
1123
+                if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
1124 1124
                     // setup DMS
1125 1125
                     EE_Register_Data_Migration_Scripts::deregister($addon_name);
1126 1126
                 }
1127
-                if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1127
+                if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
1128 1128
                     // register admin page
1129 1129
                     EE_Register_Admin_Page::deregister($addon_name);
1130 1130
                 }
1131
-                if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1131
+                if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
1132 1132
                     // add to list of modules to be registered
1133 1133
                     EE_Register_Module::deregister($addon_name);
1134 1134
                 }
1135 1135
                 if (
1136
-                    ! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1137
-                    || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1136
+                    ! empty(self::$_settings[$addon_name]['shortcode_paths'])
1137
+                    || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
1138 1138
                 ) {
1139 1139
                     // add to list of shortcodes to be registered
1140 1140
                     EE_Register_Shortcode::deregister($addon_name);
1141 1141
                 }
1142
-                if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1142
+                if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
1143 1143
                     // if config_class present let's register config.
1144
-                    EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1144
+                    EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1145 1145
                 }
1146
-                if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1146
+                if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
1147 1147
                     // add to list of widgets to be registered
1148 1148
                     EE_Register_Widget::deregister($addon_name);
1149 1149
                 }
1150 1150
                 if (
1151
-                    ! empty(self::$_settings[ $addon_name ]['model_paths'])
1152
-                    || ! empty(self::$_settings[ $addon_name ]['class_paths'])
1151
+                    ! empty(self::$_settings[$addon_name]['model_paths'])
1152
+                    || ! empty(self::$_settings[$addon_name]['class_paths'])
1153 1153
                 ) {
1154 1154
                     // add to list of shortcodes to be registered
1155 1155
                     EE_Register_Model::deregister($addon_name);
1156 1156
                 }
1157 1157
                 if (
1158
-                    ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1159
-                    || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1158
+                    ! empty(self::$_settings[$addon_name]['model_extension_paths'])
1159
+                    || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
1160 1160
                 ) {
1161 1161
                     // add to list of shortcodes to be registered
1162 1162
                     EE_Register_Model_Extensions::deregister($addon_name);
1163 1163
                 }
1164
-                if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1165
-                    foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1164
+                if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
1165
+                    foreach ((array) self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
1166 1166
                         EE_Register_Message_Type::deregister($message_type);
1167 1167
                     }
1168 1168
                 }
1169 1169
                 // deregister capabilities for addon
1170 1170
                 if (
1171
-                    ! empty(self::$_settings[ $addon_name ]['capabilities'])
1172
-                    || ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1171
+                    ! empty(self::$_settings[$addon_name]['capabilities'])
1172
+                    || ! empty(self::$_settings[$addon_name]['capability_maps'])
1173 1173
                 ) {
1174 1174
                     EE_Register_Capabilities::deregister($addon_name);
1175 1175
                 }
1176 1176
                 // deregister custom_post_types for addon
1177
-                if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1177
+                if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1178 1178
                     EE_Register_CPT::deregister($addon_name);
1179 1179
                 }
1180
-                if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1180
+                if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1181 1181
                     EE_Register_Payment_Method::deregister($addon_name);
1182 1182
                 }
1183 1183
                 $addon = EE_Registry::instance()->getAddon($class_name);
1184 1184
                 if ($addon instanceof EE_Addon) {
1185 1185
                     remove_action(
1186
-                        'deactivate_' . $addon->get_main_plugin_file_basename(),
1186
+                        'deactivate_'.$addon->get_main_plugin_file_basename(),
1187 1187
                         [$addon, 'deactivation']
1188 1188
                     );
1189 1189
                     remove_action(
@@ -1207,7 +1207,7 @@  discard block
 block discarded – undo
1207 1207
             } catch (Exception $e) {
1208 1208
                 new ExceptionLogger($e);
1209 1209
             }
1210
-            unset(self::$_settings[ $addon_name ]);
1210
+            unset(self::$_settings[$addon_name]);
1211 1211
             do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1212 1212
         }
1213 1213
     }
Please login to merge, or discard this patch.
Indentation   +1127 added lines, -1127 removed lines patch added patch discarded remove patch
@@ -23,1192 +23,1192 @@
 block discarded – undo
23 23
  */
24 24
 class EE_Register_Addon implements EEI_Plugin_API
25 25
 {
26
-    /**
27
-     * possibly truncated version of the EE core version string
28
-     *
29
-     * @var string
30
-     */
31
-    protected static $_core_version = '';
26
+	/**
27
+	 * possibly truncated version of the EE core version string
28
+	 *
29
+	 * @var string
30
+	 */
31
+	protected static $_core_version = '';
32 32
 
33
-    /**
34
-     * Holds values for registered addons
35
-     *
36
-     * @var array
37
-     */
38
-    protected static $_settings = [];
33
+	/**
34
+	 * Holds values for registered addons
35
+	 *
36
+	 * @var array
37
+	 */
38
+	protected static $_settings = [];
39 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
49
-     *                                   high value for its 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
-    ];
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
49
+	 *                                   high value for its 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 56
 
57 57
 
58
-    /**
59
-     * We should always be comparing core to a version like '4.3.0.rc.000',
60
-     * not just '4.3.0'.
61
-     * So if the addon developer doesn't provide that full version string,
62
-     * fill in the blanks for them
63
-     *
64
-     * @param string $min_core_version
65
-     * @return string always like '4.3.0.rc.000'
66
-     */
67
-    protected static function _effective_version(string $min_core_version): string
68
-    {
69
-        // versions: 4 . 3 . 1 . p . 123
70
-        // offsets:    0 . 1 . 2 . 3 . 4
71
-        $version_parts = explode('.', $min_core_version);
72
-        // check they specified the micro version (after 2nd period)
73
-        if (! isset($version_parts[2])) {
74
-            $version_parts[2] = '0';
75
-        }
76
-        // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
77
-        // soon we can assume that's 'rc', but this current version is 'alpha'
78
-        if (! isset($version_parts[3])) {
79
-            $version_parts[3] = 'dev';
80
-        }
81
-        if (! isset($version_parts[4])) {
82
-            $version_parts[4] = '000';
83
-        }
84
-        return implode('.', $version_parts);
85
-    }
58
+	/**
59
+	 * We should always be comparing core to a version like '4.3.0.rc.000',
60
+	 * not just '4.3.0'.
61
+	 * So if the addon developer doesn't provide that full version string,
62
+	 * fill in the blanks for them
63
+	 *
64
+	 * @param string $min_core_version
65
+	 * @return string always like '4.3.0.rc.000'
66
+	 */
67
+	protected static function _effective_version(string $min_core_version): string
68
+	{
69
+		// versions: 4 . 3 . 1 . p . 123
70
+		// offsets:    0 . 1 . 2 . 3 . 4
71
+		$version_parts = explode('.', $min_core_version);
72
+		// check they specified the micro version (after 2nd period)
73
+		if (! isset($version_parts[2])) {
74
+			$version_parts[2] = '0';
75
+		}
76
+		// if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
77
+		// soon we can assume that's 'rc', but this current version is 'alpha'
78
+		if (! isset($version_parts[3])) {
79
+			$version_parts[3] = 'dev';
80
+		}
81
+		if (! isset($version_parts[4])) {
82
+			$version_parts[4] = '000';
83
+		}
84
+		return implode('.', $version_parts);
85
+	}
86 86
 
87 87
 
88
-    /**
89
-     * Returns whether or not the min core version requirement of the addon is met
90
-     *
91
-     * @param string $min_core_version    the minimum core version required by the addon
92
-     * @param string $actual_core_version the actual core version, optional
93
-     * @return bool
94
-     */
95
-    public static function _meets_min_core_version_requirement(
96
-        string $min_core_version,
97
-        string $actual_core_version = EVENT_ESPRESSO_VERSION
98
-    ): bool {
99
-        return version_compare(
100
-            self::_effective_version($actual_core_version),
101
-            self::_effective_version($min_core_version),
102
-            '>='
103
-        );
104
-    }
88
+	/**
89
+	 * Returns whether or not the min core version requirement of the addon is met
90
+	 *
91
+	 * @param string $min_core_version    the minimum core version required by the addon
92
+	 * @param string $actual_core_version the actual core version, optional
93
+	 * @return bool
94
+	 */
95
+	public static function _meets_min_core_version_requirement(
96
+		string $min_core_version,
97
+		string $actual_core_version = EVENT_ESPRESSO_VERSION
98
+	): bool {
99
+		return version_compare(
100
+			self::_effective_version($actual_core_version),
101
+			self::_effective_version($min_core_version),
102
+			'>='
103
+		);
104
+	}
105 105
 
106 106
 
107
-    /**
108
-     * Method for registering new EE_Addons.
109
-     * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
110
-     * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
111
-     * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
112
-     * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
113
-     * 'activate_plugin', it registers the addon still, but its components are not registered
114
-     * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
115
-     * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
116
-     * (so that we can detect that the addon has activated on the subsequent request)
117
-     *
118
-     * @param string                  $addon_name                       [Required] the EE_Addon's name.
119
-     * @param array                   $setup_args                       {
120
-     *                                                                  An array of arguments provided for registering
121
-     *                                                                  the message type.
122
-     * @type  string                  $class_name                       the addon's main file name.
123
-     *                                                                  If left blank, generated from the addon name,
124
-     *                                                                  changes something like "calendar" to
125
-     *                                                                  "EE_Calendar"
126
-     * @type string                   $min_core_version                 the minimum version of EE Core that the
127
-     *                                                                  addon will work with. eg "4.8.1.rc.084"
128
-     * @type string                   $version                          the "software" version for the addon. eg
129
-     *                                                                  "1.0.0.p" for a first stable release, or
130
-     *                                                                  "1.0.0.rc.043" for a version in progress
131
-     * @type string                   $main_file_path                   the full server path to the main file
132
-     *                                                                  loaded directly by WP
133
-     * @type DomainInterface          $domain                           child class of
134
-     *                                                                  EventEspresso\core\domain\DomainBase
135
-     * @type string                   $domain_fqcn                      Fully Qualified Class Name
136
-     *                                                                  for the addon's Domain class
137
-     *                                                                  (see EventEspresso\core\domain\Domain)
138
-     * @type string                   $admin_path                       full server path to the folder where the
139
-     *                                                                  addon\'s admin files reside
140
-     * @type string                   $admin_callback                   a method to be called when the EE Admin is
141
-     *                                                                  first invoked, can be used for hooking into
142
-     *                                                                  any admin page
143
-     * @type string                   $config_section                   the section name for this addon's
144
-     *                                                                  configuration settings section
145
-     *                                                                  (defaults to "addons")
146
-     * @type string                   $config_class                     the class name for this addon's
147
-     *                                                                  configuration settings object
148
-     * @type string                   $config_name                      the class name for this addon's
149
-     *                                                                  configuration settings object
150
-     * @type string                   $autoloader_paths                 [Required] an array of class names and the full
151
-     *                                                                  server paths to those files.
152
-     * @type string                   $autoloader_folders               an array of  "full server paths" for any
153
-     *                                                                  folders containing classes that might be
154
-     *                                                                  invoked by the addon
155
-     * @type string                   $dms_paths                        [Required] an array of full server paths to
156
-     *                                                                  folders that contain data migration scripts.
157
-     *                                                                  The key should be the EE_Addon class name that
158
-     *                                                                  this set of data migration scripts belongs to.
159
-     *                                                                  If the EE_Addon class is namespaced, then this
160
-     *                                                                  needs to be the Fully Qualified Class Name
161
-     * @type string                   $module_paths                     an array of full server paths to any
162
-     *                                                                  EED_Modules used by the addon
163
-     * @type string                   $shortcode_paths                  an array of full server paths to folders
164
-     *                                                                  that contain EES_Shortcodes
165
-     * @type string                   $widget_paths                     an array of full server paths to folders
166
-     *                                                                  that contain WP_Widgets
167
-     * @type array                    $capabilities                     an array indexed by role name
168
-     *                                                                  (i.e administrator,author ) and the values
169
-     *                                                                  are an array of caps to add to the role.
170
-     *                                                                  'administrator' => array(
171
-     *                                                                  'read_addon',
172
-     *                                                                  'edit_addon',
173
-     *                                                                  etc.
174
-     *                                                                  ).
175
-     * @type EE_Meta_Capability_Map[] $capability_maps                  an array of EE_Meta_Capability_Map object
176
-     *                                                                  for any addons that need to register any
177
-     *                                                                  special meta mapped capabilities.  Should
178
-     *                                                                  be indexed where the key is the
179
-     *                                                                  EE_Meta_Capability_Map class name and the
180
-     *                                                                  values are the arguments sent to the class.
181
-     * @type array                    $model_paths                      array of folders containing DB models
182
-     * @return void
183
-     * @throws DomainException
184
-     * @throws EE_Error
185
-     * @throws InvalidArgumentException
186
-     * @throws InvalidDataTypeException
187
-     * @throws InvalidInterfaceException
188
-     * @since    4.3.0
189
-     * @see      EE_Register_Model
190
-     * @type array                    $class_paths                      array of folders containing DB classes
191
-     * @see      EE_Register_Model
192
-     * @type array                    $model_extension_paths            array of folders containing DB model
193
-     *                                                                  extensions
194
-     * @see      EE_Register_Model_Extension
195
-     * @type array                    $class_extension_paths            array of folders containing DB class
196
-     *                                                                  extensions
197
-     * @see      EE_Register_Model_Extension
198
-     * @type array message_types {
199
-     *                                                                  An array of message types with the key as
200
-     *                                                                  the message type name and the values as
201
-     *                                                                  below:
202
-     * @type string                   $mtfilename                       [Required] The filename of the message type
203
-     *                                                                  being registered. This will be the main
204
-     *                                                                  EE_{Message Type Name}_message_type class.
205
-     *                                                                  for example:
206
-     *                                                                  EE_Declined_Registration_message_type.class.php
207
-     * @type array                    $autoloadpaths                    [Required] An array of paths to add to the
208
-     *                                                                  messages autoloader for the new message type.
209
-     * @type array                    $messengers_to_activate_with      An array of messengers that this message
210
-     *                                                                  type should activate with. Each value in
211
-     *                                                                  the
212
-     *                                                                  array
213
-     *                                                                  should match the name property of a
214
-     *                                                                  EE_messenger. Optional.
215
-     * @type array                    $messengers_to_validate_with      An array of messengers that this message
216
-     *                                                                  type should validate with. Each value in
217
-     *                                                                  the
218
-     *                                                                  array
219
-     *                                                                  should match the name property of an
220
-     *                                                                  EE_messenger.
221
-     *                                                                  Optional.
222
-     *                                                                  }
223
-     * @type array                    $custom_post_types
224
-     * @type array                    $custom_taxonomies
225
-     * @type array                    $payment_method_paths             each element is the folder containing the
226
-     *                                                                  EE_PMT_Base child class
227
-     *                                                                  (eg,
228
-     *                                                                  '/wp-content/plugins/my_plugin/Payomatic/'
229
-     *                                                                  which contains the files
230
-     *                                                                  EE_PMT_Payomatic.pm.php)
231
-     * @type array                    $default_terms
232
-     * @type array                    $namespace                        {
233
-     *                                                                  An array with two items for registering the
234
-     *                                                                  addon's namespace. (If, for some reason, you
235
-     *                                                                  require additional namespaces,
236
-     *                                                                  use
237
-     *                                                                  EventEspresso\core\Psr4Autoloader::addNamespace()
238
-     *                                                                  directly)
239
-     * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
240
-     * @type string                   $FQNS                             the namespace prefix
241
-     * @type string                   $DIR                              a base directory for class files in the
242
-     *                                                                  namespace.
243
-     *                                                                  }
244
-     *                                                                  }
245
-     * @type string                   $privacy_policies                 FQNSs (namespaces, each of which contains only
246
-     *                                                                  privacy policy classes) or FQCNs (specific
247
-     *                                                                  classnames of privacy policy classes)
248
-     * @type string                   $personal_data_exporters          FQNSs (namespaces, each of which contains only
249
-     *                                                                  privacy policy classes) or FQCNs (specific
250
-     *                                                                  classnames of privacy policy classes)
251
-     * @type string                   $personal_data_erasers            FQNSs (namespaces, each of which contains only
252
-     *                                                                  privacy policy classes) or FQCNs (specific
253
-     *                                                                  classnames of privacy policy classes)
254
-     */
255
-    public static function register($addon_name = '', array $setup_args = [])
256
-    {
257
-        // required fields MUST be present, so let's make sure they are.
258
-        EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
259
-        // get class name for addon
260
-        $class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
261
-        // setup $_settings array from incoming values.
262
-        $addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
263
-        // allow early addon setup or modification of addon api settings
264
-        self::$_settings = (array) apply_filters(
265
-            'FHEE__EE_Register_Addon__register',
266
-            self::$_settings,
267
-            $addon_name,
268
-            $class_name,
269
-            $setup_args
270
-        );
271
-        // does this addon work with this version of core or WordPress ?
272
-        // does this addon work with this version of core or WordPress ?
273
-        if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
274
-            return;
275
-        }
276
-        // register namespaces
277
-        EE_Register_Addon::_setup_namespaces($addon_settings);
278
-        // check if this is an activation request
279
-        if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
280
-            // dont bother setting up the rest of the addon atm
281
-            return;
282
-        }
283
-        // we need cars
284
-        EE_Register_Addon::_setup_autoloaders($addon_name);
285
-        // register new models and extensions
286
-        EE_Register_Addon::_register_models_and_extensions($addon_name);
287
-        // setup DMS
288
-        EE_Register_Addon::_register_data_migration_scripts($addon_name);
289
-        // if config_class is present let's register config.
290
-        EE_Register_Addon::_register_config($addon_name);
291
-        // register admin pages
292
-        EE_Register_Addon::_register_admin_pages($addon_name);
293
-        // add to list of modules to be registered
294
-        EE_Register_Addon::_register_modules($addon_name);
295
-        // add to list of shortcodes to be registered
296
-        EE_Register_Addon::_register_shortcodes($addon_name);
297
-        // add to list of widgets to be registered
298
-        EE_Register_Addon::_register_widgets($addon_name);
299
-        // register capability related stuff.
300
-        EE_Register_Addon::_register_capabilities($addon_name);
301
-        // any message type to register?
302
-        EE_Register_Addon::_register_message_types($addon_name);
303
-        // any custom post type/ custom capabilities or default terms to register
304
-        EE_Register_Addon::_register_custom_post_types($addon_name);
305
-        // and any payment methods
306
-        EE_Register_Addon::_register_payment_methods($addon_name);
307
-        // and privacy policy generators
308
-        EE_Register_Addon::registerPrivacyPolicies($addon_name);
309
-        // and privacy policy generators
310
-        EE_Register_Addon::registerPersonalDataExporters($addon_name);
311
-        // and privacy policy generators
312
-        EE_Register_Addon::registerPersonalDataErasers($addon_name);
313
-        // load and instantiate main addon class
314
-        $addon = EE_Register_Addon::_load_and_init_addon_class($addon_name);
315
-        // delay calling after_registration hook on each addon until after all add-ons have been registered.
316
-        add_action('AHEE__EE_System__load_espresso_addons__complete', [$addon, 'after_registration'], 999);
317
-    }
107
+	/**
108
+	 * Method for registering new EE_Addons.
109
+	 * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
110
+	 * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
111
+	 * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
112
+	 * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
113
+	 * 'activate_plugin', it registers the addon still, but its components are not registered
114
+	 * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
115
+	 * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
116
+	 * (so that we can detect that the addon has activated on the subsequent request)
117
+	 *
118
+	 * @param string                  $addon_name                       [Required] the EE_Addon's name.
119
+	 * @param array                   $setup_args                       {
120
+	 *                                                                  An array of arguments provided for registering
121
+	 *                                                                  the message type.
122
+	 * @type  string                  $class_name                       the addon's main file name.
123
+	 *                                                                  If left blank, generated from the addon name,
124
+	 *                                                                  changes something like "calendar" to
125
+	 *                                                                  "EE_Calendar"
126
+	 * @type string                   $min_core_version                 the minimum version of EE Core that the
127
+	 *                                                                  addon will work with. eg "4.8.1.rc.084"
128
+	 * @type string                   $version                          the "software" version for the addon. eg
129
+	 *                                                                  "1.0.0.p" for a first stable release, or
130
+	 *                                                                  "1.0.0.rc.043" for a version in progress
131
+	 * @type string                   $main_file_path                   the full server path to the main file
132
+	 *                                                                  loaded directly by WP
133
+	 * @type DomainInterface          $domain                           child class of
134
+	 *                                                                  EventEspresso\core\domain\DomainBase
135
+	 * @type string                   $domain_fqcn                      Fully Qualified Class Name
136
+	 *                                                                  for the addon's Domain class
137
+	 *                                                                  (see EventEspresso\core\domain\Domain)
138
+	 * @type string                   $admin_path                       full server path to the folder where the
139
+	 *                                                                  addon\'s admin files reside
140
+	 * @type string                   $admin_callback                   a method to be called when the EE Admin is
141
+	 *                                                                  first invoked, can be used for hooking into
142
+	 *                                                                  any admin page
143
+	 * @type string                   $config_section                   the section name for this addon's
144
+	 *                                                                  configuration settings section
145
+	 *                                                                  (defaults to "addons")
146
+	 * @type string                   $config_class                     the class name for this addon's
147
+	 *                                                                  configuration settings object
148
+	 * @type string                   $config_name                      the class name for this addon's
149
+	 *                                                                  configuration settings object
150
+	 * @type string                   $autoloader_paths                 [Required] an array of class names and the full
151
+	 *                                                                  server paths to those files.
152
+	 * @type string                   $autoloader_folders               an array of  "full server paths" for any
153
+	 *                                                                  folders containing classes that might be
154
+	 *                                                                  invoked by the addon
155
+	 * @type string                   $dms_paths                        [Required] an array of full server paths to
156
+	 *                                                                  folders that contain data migration scripts.
157
+	 *                                                                  The key should be the EE_Addon class name that
158
+	 *                                                                  this set of data migration scripts belongs to.
159
+	 *                                                                  If the EE_Addon class is namespaced, then this
160
+	 *                                                                  needs to be the Fully Qualified Class Name
161
+	 * @type string                   $module_paths                     an array of full server paths to any
162
+	 *                                                                  EED_Modules used by the addon
163
+	 * @type string                   $shortcode_paths                  an array of full server paths to folders
164
+	 *                                                                  that contain EES_Shortcodes
165
+	 * @type string                   $widget_paths                     an array of full server paths to folders
166
+	 *                                                                  that contain WP_Widgets
167
+	 * @type array                    $capabilities                     an array indexed by role name
168
+	 *                                                                  (i.e administrator,author ) and the values
169
+	 *                                                                  are an array of caps to add to the role.
170
+	 *                                                                  'administrator' => array(
171
+	 *                                                                  'read_addon',
172
+	 *                                                                  'edit_addon',
173
+	 *                                                                  etc.
174
+	 *                                                                  ).
175
+	 * @type EE_Meta_Capability_Map[] $capability_maps                  an array of EE_Meta_Capability_Map object
176
+	 *                                                                  for any addons that need to register any
177
+	 *                                                                  special meta mapped capabilities.  Should
178
+	 *                                                                  be indexed where the key is the
179
+	 *                                                                  EE_Meta_Capability_Map class name and the
180
+	 *                                                                  values are the arguments sent to the class.
181
+	 * @type array                    $model_paths                      array of folders containing DB models
182
+	 * @return void
183
+	 * @throws DomainException
184
+	 * @throws EE_Error
185
+	 * @throws InvalidArgumentException
186
+	 * @throws InvalidDataTypeException
187
+	 * @throws InvalidInterfaceException
188
+	 * @since    4.3.0
189
+	 * @see      EE_Register_Model
190
+	 * @type array                    $class_paths                      array of folders containing DB classes
191
+	 * @see      EE_Register_Model
192
+	 * @type array                    $model_extension_paths            array of folders containing DB model
193
+	 *                                                                  extensions
194
+	 * @see      EE_Register_Model_Extension
195
+	 * @type array                    $class_extension_paths            array of folders containing DB class
196
+	 *                                                                  extensions
197
+	 * @see      EE_Register_Model_Extension
198
+	 * @type array message_types {
199
+	 *                                                                  An array of message types with the key as
200
+	 *                                                                  the message type name and the values as
201
+	 *                                                                  below:
202
+	 * @type string                   $mtfilename                       [Required] The filename of the message type
203
+	 *                                                                  being registered. This will be the main
204
+	 *                                                                  EE_{Message Type Name}_message_type class.
205
+	 *                                                                  for example:
206
+	 *                                                                  EE_Declined_Registration_message_type.class.php
207
+	 * @type array                    $autoloadpaths                    [Required] An array of paths to add to the
208
+	 *                                                                  messages autoloader for the new message type.
209
+	 * @type array                    $messengers_to_activate_with      An array of messengers that this message
210
+	 *                                                                  type should activate with. Each value in
211
+	 *                                                                  the
212
+	 *                                                                  array
213
+	 *                                                                  should match the name property of a
214
+	 *                                                                  EE_messenger. Optional.
215
+	 * @type array                    $messengers_to_validate_with      An array of messengers that this message
216
+	 *                                                                  type should validate with. Each value in
217
+	 *                                                                  the
218
+	 *                                                                  array
219
+	 *                                                                  should match the name property of an
220
+	 *                                                                  EE_messenger.
221
+	 *                                                                  Optional.
222
+	 *                                                                  }
223
+	 * @type array                    $custom_post_types
224
+	 * @type array                    $custom_taxonomies
225
+	 * @type array                    $payment_method_paths             each element is the folder containing the
226
+	 *                                                                  EE_PMT_Base child class
227
+	 *                                                                  (eg,
228
+	 *                                                                  '/wp-content/plugins/my_plugin/Payomatic/'
229
+	 *                                                                  which contains the files
230
+	 *                                                                  EE_PMT_Payomatic.pm.php)
231
+	 * @type array                    $default_terms
232
+	 * @type array                    $namespace                        {
233
+	 *                                                                  An array with two items for registering the
234
+	 *                                                                  addon's namespace. (If, for some reason, you
235
+	 *                                                                  require additional namespaces,
236
+	 *                                                                  use
237
+	 *                                                                  EventEspresso\core\Psr4Autoloader::addNamespace()
238
+	 *                                                                  directly)
239
+	 * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
240
+	 * @type string                   $FQNS                             the namespace prefix
241
+	 * @type string                   $DIR                              a base directory for class files in the
242
+	 *                                                                  namespace.
243
+	 *                                                                  }
244
+	 *                                                                  }
245
+	 * @type string                   $privacy_policies                 FQNSs (namespaces, each of which contains only
246
+	 *                                                                  privacy policy classes) or FQCNs (specific
247
+	 *                                                                  classnames of privacy policy classes)
248
+	 * @type string                   $personal_data_exporters          FQNSs (namespaces, each of which contains only
249
+	 *                                                                  privacy policy classes) or FQCNs (specific
250
+	 *                                                                  classnames of privacy policy classes)
251
+	 * @type string                   $personal_data_erasers            FQNSs (namespaces, each of which contains only
252
+	 *                                                                  privacy policy classes) or FQCNs (specific
253
+	 *                                                                  classnames of privacy policy classes)
254
+	 */
255
+	public static function register($addon_name = '', array $setup_args = [])
256
+	{
257
+		// required fields MUST be present, so let's make sure they are.
258
+		EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
259
+		// get class name for addon
260
+		$class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
261
+		// setup $_settings array from incoming values.
262
+		$addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
263
+		// allow early addon setup or modification of addon api settings
264
+		self::$_settings = (array) apply_filters(
265
+			'FHEE__EE_Register_Addon__register',
266
+			self::$_settings,
267
+			$addon_name,
268
+			$class_name,
269
+			$setup_args
270
+		);
271
+		// does this addon work with this version of core or WordPress ?
272
+		// does this addon work with this version of core or WordPress ?
273
+		if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
274
+			return;
275
+		}
276
+		// register namespaces
277
+		EE_Register_Addon::_setup_namespaces($addon_settings);
278
+		// check if this is an activation request
279
+		if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
280
+			// dont bother setting up the rest of the addon atm
281
+			return;
282
+		}
283
+		// we need cars
284
+		EE_Register_Addon::_setup_autoloaders($addon_name);
285
+		// register new models and extensions
286
+		EE_Register_Addon::_register_models_and_extensions($addon_name);
287
+		// setup DMS
288
+		EE_Register_Addon::_register_data_migration_scripts($addon_name);
289
+		// if config_class is present let's register config.
290
+		EE_Register_Addon::_register_config($addon_name);
291
+		// register admin pages
292
+		EE_Register_Addon::_register_admin_pages($addon_name);
293
+		// add to list of modules to be registered
294
+		EE_Register_Addon::_register_modules($addon_name);
295
+		// add to list of shortcodes to be registered
296
+		EE_Register_Addon::_register_shortcodes($addon_name);
297
+		// add to list of widgets to be registered
298
+		EE_Register_Addon::_register_widgets($addon_name);
299
+		// register capability related stuff.
300
+		EE_Register_Addon::_register_capabilities($addon_name);
301
+		// any message type to register?
302
+		EE_Register_Addon::_register_message_types($addon_name);
303
+		// any custom post type/ custom capabilities or default terms to register
304
+		EE_Register_Addon::_register_custom_post_types($addon_name);
305
+		// and any payment methods
306
+		EE_Register_Addon::_register_payment_methods($addon_name);
307
+		// and privacy policy generators
308
+		EE_Register_Addon::registerPrivacyPolicies($addon_name);
309
+		// and privacy policy generators
310
+		EE_Register_Addon::registerPersonalDataExporters($addon_name);
311
+		// and privacy policy generators
312
+		EE_Register_Addon::registerPersonalDataErasers($addon_name);
313
+		// load and instantiate main addon class
314
+		$addon = EE_Register_Addon::_load_and_init_addon_class($addon_name);
315
+		// delay calling after_registration hook on each addon until after all add-ons have been registered.
316
+		add_action('AHEE__EE_System__load_espresso_addons__complete', [$addon, 'after_registration'], 999);
317
+	}
318 318
 
319 319
 
320
-    /**
321
-     * @param string $addon_name
322
-     * @param array  $setup_args
323
-     * @return void
324
-     * @throws EE_Error
325
-     */
326
-    private static function _verify_parameters(string $addon_name, array $setup_args)
327
-    {
328
-        // required fields MUST be present, so let's make sure they are.
329
-        if (empty($addon_name) || empty($setup_args)) {
330
-            throw new EE_Error(
331
-                esc_html__(
332
-                    '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.',
333
-                    'event_espresso'
334
-                )
335
-            );
336
-        }
337
-        if (empty($setup_args['main_file_path'])) {
338
-            throw new EE_Error(
339
-                sprintf(
340
-                    esc_html__(
341
-                        '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',
342
-                        'event_espresso'
343
-                    ),
344
-                    implode(',', array_keys($setup_args))
345
-                )
346
-            );
347
-        }
348
-        // check that addon has not already been registered with that name
349
-        if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
350
-            throw new EE_Error(
351
-                sprintf(
352
-                    esc_html__(
353
-                        'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
354
-                        'event_espresso'
355
-                    ),
356
-                    $addon_name
357
-                )
358
-            );
359
-        }
360
-    }
320
+	/**
321
+	 * @param string $addon_name
322
+	 * @param array  $setup_args
323
+	 * @return void
324
+	 * @throws EE_Error
325
+	 */
326
+	private static function _verify_parameters(string $addon_name, array $setup_args)
327
+	{
328
+		// required fields MUST be present, so let's make sure they are.
329
+		if (empty($addon_name) || empty($setup_args)) {
330
+			throw new EE_Error(
331
+				esc_html__(
332
+					'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.',
333
+					'event_espresso'
334
+				)
335
+			);
336
+		}
337
+		if (empty($setup_args['main_file_path'])) {
338
+			throw new EE_Error(
339
+				sprintf(
340
+					esc_html__(
341
+						'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',
342
+						'event_espresso'
343
+					),
344
+					implode(',', array_keys($setup_args))
345
+				)
346
+			);
347
+		}
348
+		// check that addon has not already been registered with that name
349
+		if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
350
+			throw new EE_Error(
351
+				sprintf(
352
+					esc_html__(
353
+						'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
354
+						'event_espresso'
355
+					),
356
+					$addon_name
357
+				)
358
+			);
359
+		}
360
+	}
361 361
 
362 362
 
363
-    /**
364
-     * @param string $addon_name
365
-     * @param array  $setup_args
366
-     * @return string
367
-     */
368
-    private static function _parse_class_name(string $addon_name, array $setup_args): string
369
-    {
370
-        if (empty($setup_args['class_name'])) {
371
-            // generate one by first separating name with spaces
372
-            $class_name = str_replace(['-', '_'], ' ', trim($addon_name));
373
-            // capitalize, then replace spaces with underscores
374
-            $class_name = str_replace(' ', '_', ucwords($class_name));
375
-        } else {
376
-            $class_name = $setup_args['class_name'];
377
-        }
378
-        // check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
379
-        return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
380
-            ? $class_name
381
-            : 'EE_' . $class_name;
382
-    }
363
+	/**
364
+	 * @param string $addon_name
365
+	 * @param array  $setup_args
366
+	 * @return string
367
+	 */
368
+	private static function _parse_class_name(string $addon_name, array $setup_args): string
369
+	{
370
+		if (empty($setup_args['class_name'])) {
371
+			// generate one by first separating name with spaces
372
+			$class_name = str_replace(['-', '_'], ' ', trim($addon_name));
373
+			// capitalize, then replace spaces with underscores
374
+			$class_name = str_replace(' ', '_', ucwords($class_name));
375
+		} else {
376
+			$class_name = $setup_args['class_name'];
377
+		}
378
+		// check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
379
+		return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
380
+			? $class_name
381
+			: 'EE_' . $class_name;
382
+	}
383 383
 
384 384
 
385
-    /**
386
-     * @param string $class_name
387
-     * @param array  $setup_args
388
-     * @return array
389
-     */
390
-    private static function _get_addon_settings(string $class_name, array $setup_args): array
391
-    {
392
-        // setup $_settings array from incoming values.
393
-        $addon_settings = [
394
-            // generated from the addon name, changes something like "calendar" to "EE_Calendar"
395
-            'class_name'            => $class_name,
396
-            // the addon slug for use in URLs, etc
397
-            'plugin_slug'           => isset($setup_args['plugin_slug'])
398
-                ? (string) $setup_args['plugin_slug']
399
-                : '',
400
-            // page slug to be used when generating the "Settings" link on the WP plugin page
401
-            'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
402
-                ? (string) $setup_args['plugin_action_slug']
403
-                : '',
404
-            // the "software" version for the addon
405
-            'version'               => isset($setup_args['version'])
406
-                ? (string) $setup_args['version']
407
-                : '',
408
-            // the minimum version of EE Core that the addon will work with
409
-            'min_core_version'      => isset($setup_args['min_core_version'])
410
-                ? (string) $setup_args['min_core_version']
411
-                : '',
412
-            // the minimum version of WordPress that the addon will work with
413
-            'min_wp_version'        => isset($setup_args['min_wp_version'])
414
-                ? (string) $setup_args['min_wp_version']
415
-                : EE_MIN_WP_VER_REQUIRED,
416
-            // full server path to main file (file loaded directly by WP)
417
-            'main_file_path'        => isset($setup_args['main_file_path'])
418
-                ? (string) $setup_args['main_file_path']
419
-                : '',
420
-            // instance of \EventEspresso\core\domain\DomainInterface
421
-            'domain'                => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface
422
-                ? $setup_args['domain']
423
-                : null,
424
-            // Fully Qualified Class Name for the addon's Domain class
425
-            'domain_fqcn'           => isset($setup_args['domain_fqcn'])
426
-                ? (string) $setup_args['domain_fqcn']
427
-                : '',
428
-            // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
429
-            'admin_path'            => isset($setup_args['admin_path'])
430
-                ? (string) $setup_args['admin_path'] : '',
431
-            // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
432
-            'admin_callback'        => isset($setup_args['admin_callback'])
433
-                ? (string) $setup_args['admin_callback']
434
-                : '',
435
-            // the section name for this addon's configuration settings section (defaults to "addons")
436
-            'config_section'        => isset($setup_args['config_section'])
437
-                ? (string) $setup_args['config_section']
438
-                : 'addons',
439
-            // the class name for this addon's configuration settings object
440
-            'config_class'          => isset($setup_args['config_class'])
441
-                ? (string) $setup_args['config_class'] : '',
442
-            // the name given to the config for this addons' configuration settings object (optional)
443
-            'config_name'           => isset($setup_args['config_name'])
444
-                ? (string) $setup_args['config_name'] : '',
445
-            // an array of "class names" => "full server paths" for any classes that might be invoked by the addon
446
-            'autoloader_paths'      => isset($setup_args['autoloader_paths'])
447
-                ? (array) $setup_args['autoloader_paths']
448
-                : [],
449
-            // an array of  "full server paths" for any folders containing classes that might be invoked by the addon
450
-            'autoloader_folders'    => isset($setup_args['autoloader_folders'])
451
-                ? (array) $setup_args['autoloader_folders']
452
-                : [],
453
-            // array of full server paths to any EE_DMS data migration scripts used by the addon.
454
-            // The key should be the EE_Addon class name that this set of data migration scripts belongs to.
455
-            // If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name
456
-            'dms_paths'             => isset($setup_args['dms_paths'])
457
-                ? (array) $setup_args['dms_paths']
458
-                : [],
459
-            // array of full server paths to any EED_Modules used by the addon
460
-            'module_paths'          => isset($setup_args['module_paths'])
461
-                ? (array) $setup_args['module_paths']
462
-                : [],
463
-            // array of full server paths to any EES_Shortcodes used by the addon
464
-            'shortcode_paths'       => isset($setup_args['shortcode_paths'])
465
-                ? (array) $setup_args['shortcode_paths']
466
-                : [],
467
-            'shortcode_fqcns'       => isset($setup_args['shortcode_fqcns'])
468
-                ? (array) $setup_args['shortcode_fqcns']
469
-                : [],
470
-            // array of full server paths to any WP_Widgets used by the addon
471
-            'widget_paths'          => isset($setup_args['widget_paths'])
472
-                ? (array) $setup_args['widget_paths']
473
-                : [],
474
-            'message_types'         => isset($setup_args['message_types'])
475
-                ? (array) $setup_args['message_types']
476
-                : [],
477
-            'capabilities'          => isset($setup_args['capabilities'])
478
-                ? (array) $setup_args['capabilities']
479
-                : [],
480
-            'capability_maps'       => isset($setup_args['capability_maps'])
481
-                ? (array) $setup_args['capability_maps']
482
-                : [],
483
-            'model_paths'           => isset($setup_args['model_paths'])
484
-                ? (array) $setup_args['model_paths']
485
-                : [],
486
-            'class_paths'           => isset($setup_args['class_paths'])
487
-                ? (array) $setup_args['class_paths']
488
-                : [],
489
-            'model_extension_paths' => isset($setup_args['model_extension_paths'])
490
-                ? (array) $setup_args['model_extension_paths']
491
-                : [],
492
-            'class_extension_paths' => isset($setup_args['class_extension_paths'])
493
-                ? (array) $setup_args['class_extension_paths']
494
-                : [],
495
-            'custom_post_types'     => isset($setup_args['custom_post_types'])
496
-                ? (array) $setup_args['custom_post_types']
497
-                : [],
498
-            'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
499
-                ? (array) $setup_args['custom_taxonomies']
500
-                : [],
501
-            'payment_method_paths'  => isset($setup_args['payment_method_paths'])
502
-                ? (array) $setup_args['payment_method_paths']
503
-                : [],
504
-            'default_terms'         => isset($setup_args['default_terms'])
505
-                ? (array) $setup_args['default_terms']
506
-                : [],
507
-            // if not empty, inserts a new table row after this plugin's row on the WP Plugins page
508
-            // that can be used for adding upgrading/marketing info
509
-            'plugins_page_row'      => $setup_args['plugins_page_row'] ?? '',
510
-            'namespace'             => isset(
511
-                $setup_args['namespace']['FQNS'],
512
-                $setup_args['namespace']['DIR']
513
-            )
514
-                ? (array) $setup_args['namespace']
515
-                : [],
516
-            'privacy_policies'      => isset($setup_args['privacy_policies'])
517
-                ? (array) $setup_args['privacy_policies']
518
-                : '',
519
-        ];
520
-        // if plugin_action_slug is NOT set, but an admin page path IS set,
521
-        // then let's just use the plugin_slug since that will be used for linking to the admin page
522
-        $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
523
-                                                && ! empty($addon_settings['admin_path'])
524
-            ? $addon_settings['plugin_slug']
525
-            : $addon_settings['plugin_action_slug'];
526
-        // full server path to main file (file loaded directly by WP)
527
-        $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
528
-        return $addon_settings;
529
-    }
385
+	/**
386
+	 * @param string $class_name
387
+	 * @param array  $setup_args
388
+	 * @return array
389
+	 */
390
+	private static function _get_addon_settings(string $class_name, array $setup_args): array
391
+	{
392
+		// setup $_settings array from incoming values.
393
+		$addon_settings = [
394
+			// generated from the addon name, changes something like "calendar" to "EE_Calendar"
395
+			'class_name'            => $class_name,
396
+			// the addon slug for use in URLs, etc
397
+			'plugin_slug'           => isset($setup_args['plugin_slug'])
398
+				? (string) $setup_args['plugin_slug']
399
+				: '',
400
+			// page slug to be used when generating the "Settings" link on the WP plugin page
401
+			'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
402
+				? (string) $setup_args['plugin_action_slug']
403
+				: '',
404
+			// the "software" version for the addon
405
+			'version'               => isset($setup_args['version'])
406
+				? (string) $setup_args['version']
407
+				: '',
408
+			// the minimum version of EE Core that the addon will work with
409
+			'min_core_version'      => isset($setup_args['min_core_version'])
410
+				? (string) $setup_args['min_core_version']
411
+				: '',
412
+			// the minimum version of WordPress that the addon will work with
413
+			'min_wp_version'        => isset($setup_args['min_wp_version'])
414
+				? (string) $setup_args['min_wp_version']
415
+				: EE_MIN_WP_VER_REQUIRED,
416
+			// full server path to main file (file loaded directly by WP)
417
+			'main_file_path'        => isset($setup_args['main_file_path'])
418
+				? (string) $setup_args['main_file_path']
419
+				: '',
420
+			// instance of \EventEspresso\core\domain\DomainInterface
421
+			'domain'                => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface
422
+				? $setup_args['domain']
423
+				: null,
424
+			// Fully Qualified Class Name for the addon's Domain class
425
+			'domain_fqcn'           => isset($setup_args['domain_fqcn'])
426
+				? (string) $setup_args['domain_fqcn']
427
+				: '',
428
+			// path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
429
+			'admin_path'            => isset($setup_args['admin_path'])
430
+				? (string) $setup_args['admin_path'] : '',
431
+			// a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
432
+			'admin_callback'        => isset($setup_args['admin_callback'])
433
+				? (string) $setup_args['admin_callback']
434
+				: '',
435
+			// the section name for this addon's configuration settings section (defaults to "addons")
436
+			'config_section'        => isset($setup_args['config_section'])
437
+				? (string) $setup_args['config_section']
438
+				: 'addons',
439
+			// the class name for this addon's configuration settings object
440
+			'config_class'          => isset($setup_args['config_class'])
441
+				? (string) $setup_args['config_class'] : '',
442
+			// the name given to the config for this addons' configuration settings object (optional)
443
+			'config_name'           => isset($setup_args['config_name'])
444
+				? (string) $setup_args['config_name'] : '',
445
+			// an array of "class names" => "full server paths" for any classes that might be invoked by the addon
446
+			'autoloader_paths'      => isset($setup_args['autoloader_paths'])
447
+				? (array) $setup_args['autoloader_paths']
448
+				: [],
449
+			// an array of  "full server paths" for any folders containing classes that might be invoked by the addon
450
+			'autoloader_folders'    => isset($setup_args['autoloader_folders'])
451
+				? (array) $setup_args['autoloader_folders']
452
+				: [],
453
+			// array of full server paths to any EE_DMS data migration scripts used by the addon.
454
+			// The key should be the EE_Addon class name that this set of data migration scripts belongs to.
455
+			// If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name
456
+			'dms_paths'             => isset($setup_args['dms_paths'])
457
+				? (array) $setup_args['dms_paths']
458
+				: [],
459
+			// array of full server paths to any EED_Modules used by the addon
460
+			'module_paths'          => isset($setup_args['module_paths'])
461
+				? (array) $setup_args['module_paths']
462
+				: [],
463
+			// array of full server paths to any EES_Shortcodes used by the addon
464
+			'shortcode_paths'       => isset($setup_args['shortcode_paths'])
465
+				? (array) $setup_args['shortcode_paths']
466
+				: [],
467
+			'shortcode_fqcns'       => isset($setup_args['shortcode_fqcns'])
468
+				? (array) $setup_args['shortcode_fqcns']
469
+				: [],
470
+			// array of full server paths to any WP_Widgets used by the addon
471
+			'widget_paths'          => isset($setup_args['widget_paths'])
472
+				? (array) $setup_args['widget_paths']
473
+				: [],
474
+			'message_types'         => isset($setup_args['message_types'])
475
+				? (array) $setup_args['message_types']
476
+				: [],
477
+			'capabilities'          => isset($setup_args['capabilities'])
478
+				? (array) $setup_args['capabilities']
479
+				: [],
480
+			'capability_maps'       => isset($setup_args['capability_maps'])
481
+				? (array) $setup_args['capability_maps']
482
+				: [],
483
+			'model_paths'           => isset($setup_args['model_paths'])
484
+				? (array) $setup_args['model_paths']
485
+				: [],
486
+			'class_paths'           => isset($setup_args['class_paths'])
487
+				? (array) $setup_args['class_paths']
488
+				: [],
489
+			'model_extension_paths' => isset($setup_args['model_extension_paths'])
490
+				? (array) $setup_args['model_extension_paths']
491
+				: [],
492
+			'class_extension_paths' => isset($setup_args['class_extension_paths'])
493
+				? (array) $setup_args['class_extension_paths']
494
+				: [],
495
+			'custom_post_types'     => isset($setup_args['custom_post_types'])
496
+				? (array) $setup_args['custom_post_types']
497
+				: [],
498
+			'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
499
+				? (array) $setup_args['custom_taxonomies']
500
+				: [],
501
+			'payment_method_paths'  => isset($setup_args['payment_method_paths'])
502
+				? (array) $setup_args['payment_method_paths']
503
+				: [],
504
+			'default_terms'         => isset($setup_args['default_terms'])
505
+				? (array) $setup_args['default_terms']
506
+				: [],
507
+			// if not empty, inserts a new table row after this plugin's row on the WP Plugins page
508
+			// that can be used for adding upgrading/marketing info
509
+			'plugins_page_row'      => $setup_args['plugins_page_row'] ?? '',
510
+			'namespace'             => isset(
511
+				$setup_args['namespace']['FQNS'],
512
+				$setup_args['namespace']['DIR']
513
+			)
514
+				? (array) $setup_args['namespace']
515
+				: [],
516
+			'privacy_policies'      => isset($setup_args['privacy_policies'])
517
+				? (array) $setup_args['privacy_policies']
518
+				: '',
519
+		];
520
+		// if plugin_action_slug is NOT set, but an admin page path IS set,
521
+		// then let's just use the plugin_slug since that will be used for linking to the admin page
522
+		$addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
523
+												&& ! empty($addon_settings['admin_path'])
524
+			? $addon_settings['plugin_slug']
525
+			: $addon_settings['plugin_action_slug'];
526
+		// full server path to main file (file loaded directly by WP)
527
+		$addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
528
+		return $addon_settings;
529
+	}
530 530
 
531 531
 
532
-    /**
533
-     * @param string $addon_name
534
-     * @param array  $addon_settings
535
-     * @return bool
536
-     */
537
-    private static function _addon_is_compatible(string $addon_name, array $addon_settings): bool
538
-    {
539
-        global $wp_version;
540
-        $incompatibility_message = '';
541
-        // check whether this addon version is compatible with EE core
542
-        if (
543
-            isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
544
-            && ! self::_meets_min_core_version_requirement(
545
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
546
-                $addon_settings['version']
547
-            )
548
-        ) {
549
-            $incompatibility_message = sprintf(
550
-                esc_html__(
551
-                    '%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.',
552
-                    'event_espresso'
553
-                ),
554
-                $addon_name,
555
-                '<br />',
556
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
557
-                '<span style="font-weight: bold; color: #D54E21;">',
558
-                '</span><br />'
559
-            );
560
-        } elseif (
561
-            ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
562
-        ) {
563
-            $incompatibility_message = sprintf(
564
-                esc_html__(
565
-                    '%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".',
566
-                    'event_espresso'
567
-                ),
568
-                $addon_name,
569
-                self::_effective_version($addon_settings['min_core_version']),
570
-                self::_effective_version(espresso_version()),
571
-                '<br />',
572
-                '<span style="font-weight: bold; color: #D54E21;">',
573
-                '</span><br />'
574
-            );
575
-        } elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
576
-            $incompatibility_message = sprintf(
577
-                esc_html__(
578
-                    '%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.',
579
-                    'event_espresso'
580
-                ),
581
-                $addon_name,
582
-                $addon_settings['min_wp_version'],
583
-                '<br />',
584
-                '<span style="font-weight: bold; color: #D54E21;">',
585
-                '</span><br />'
586
-            );
587
-        }
588
-        if (! empty($incompatibility_message)) {
589
-            // remove 'activate' from the REQUEST
590
-            // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
591
-            /** @var RequestInterface $request */
592
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
593
-            $request->unSetRequestParam('activate', true);
594
-            if (current_user_can('activate_plugins')) {
595
-                // show an error message indicating the plugin didn't activate properly
596
-                EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
597
-            }
598
-            unset($_GET['activate'], $_REQUEST['activate']);
599
-            if (! function_exists('deactivate_plugins')) {
600
-                require_once ABSPATH . 'wp-admin/includes/plugin.php';
601
-            }
602
-            deactivate_plugins(plugin_basename($addon_settings['main_file_path']));
603
-            // BAIL FROM THE ADDON REGISTRATION PROCESS
604
-            return false;
605
-        }
606
-        // addon IS compatible
607
-        return true;
608
-    }
532
+	/**
533
+	 * @param string $addon_name
534
+	 * @param array  $addon_settings
535
+	 * @return bool
536
+	 */
537
+	private static function _addon_is_compatible(string $addon_name, array $addon_settings): bool
538
+	{
539
+		global $wp_version;
540
+		$incompatibility_message = '';
541
+		// check whether this addon version is compatible with EE core
542
+		if (
543
+			isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
544
+			&& ! self::_meets_min_core_version_requirement(
545
+				EE_Register_Addon::$_incompatible_addons[ $addon_name ],
546
+				$addon_settings['version']
547
+			)
548
+		) {
549
+			$incompatibility_message = sprintf(
550
+				esc_html__(
551
+					'%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.',
552
+					'event_espresso'
553
+				),
554
+				$addon_name,
555
+				'<br />',
556
+				EE_Register_Addon::$_incompatible_addons[ $addon_name ],
557
+				'<span style="font-weight: bold; color: #D54E21;">',
558
+				'</span><br />'
559
+			);
560
+		} elseif (
561
+			! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
562
+		) {
563
+			$incompatibility_message = sprintf(
564
+				esc_html__(
565
+					'%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".',
566
+					'event_espresso'
567
+				),
568
+				$addon_name,
569
+				self::_effective_version($addon_settings['min_core_version']),
570
+				self::_effective_version(espresso_version()),
571
+				'<br />',
572
+				'<span style="font-weight: bold; color: #D54E21;">',
573
+				'</span><br />'
574
+			);
575
+		} elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
576
+			$incompatibility_message = sprintf(
577
+				esc_html__(
578
+					'%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.',
579
+					'event_espresso'
580
+				),
581
+				$addon_name,
582
+				$addon_settings['min_wp_version'],
583
+				'<br />',
584
+				'<span style="font-weight: bold; color: #D54E21;">',
585
+				'</span><br />'
586
+			);
587
+		}
588
+		if (! empty($incompatibility_message)) {
589
+			// remove 'activate' from the REQUEST
590
+			// so WP doesn't erroneously tell the user the plugin activated fine when it didn't
591
+			/** @var RequestInterface $request */
592
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
593
+			$request->unSetRequestParam('activate', true);
594
+			if (current_user_can('activate_plugins')) {
595
+				// show an error message indicating the plugin didn't activate properly
596
+				EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
597
+			}
598
+			unset($_GET['activate'], $_REQUEST['activate']);
599
+			if (! function_exists('deactivate_plugins')) {
600
+				require_once ABSPATH . 'wp-admin/includes/plugin.php';
601
+			}
602
+			deactivate_plugins(plugin_basename($addon_settings['main_file_path']));
603
+			// BAIL FROM THE ADDON REGISTRATION PROCESS
604
+			return false;
605
+		}
606
+		// addon IS compatible
607
+		return true;
608
+	}
609 609
 
610 610
 
611
-    /**
612
-     * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
613
-     *
614
-     * @param array $addon_settings
615
-     * @return void
616
-     */
617
-    private static function _setup_namespaces(array $addon_settings)
618
-    {
619
-        //
620
-        if (
621
-            isset(
622
-                $addon_settings['namespace']['FQNS'],
623
-                $addon_settings['namespace']['DIR']
624
-            )
625
-        ) {
626
-            EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
627
-                $addon_settings['namespace']['FQNS'],
628
-                $addon_settings['namespace']['DIR']
629
-            );
630
-        }
631
-    }
611
+	/**
612
+	 * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
613
+	 *
614
+	 * @param array $addon_settings
615
+	 * @return void
616
+	 */
617
+	private static function _setup_namespaces(array $addon_settings)
618
+	{
619
+		//
620
+		if (
621
+			isset(
622
+				$addon_settings['namespace']['FQNS'],
623
+				$addon_settings['namespace']['DIR']
624
+			)
625
+		) {
626
+			EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
627
+				$addon_settings['namespace']['FQNS'],
628
+				$addon_settings['namespace']['DIR']
629
+			);
630
+		}
631
+	}
632 632
 
633 633
 
634
-    /**
635
-     * @param string $addon_name
636
-     * @param array  $addon_settings
637
-     * @return bool
638
-     * @throws InvalidArgumentException
639
-     * @throws InvalidDataTypeException
640
-     * @throws InvalidInterfaceException
641
-     */
642
-    private static function _addon_activation(string $addon_name, array $addon_settings): bool
643
-    {
644
-        // this is an activation request
645
-        if (did_action('activate_plugin')) {
646
-            // to find if THIS is the addon that was activated, just check if we have already registered it or not
647
-            // (as the newly-activated addon wasn't around the first time addons were registered).
648
-            // Note: the presence of pue_options in the addon registration options will initialize the $_settings
649
-            // property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
650
-            if (
651
-                ! isset(self::$_settings[ $addon_name ])
652
-                || (isset(self::$_settings[ $addon_name ])
653
-                    && ! isset(self::$_settings[ $addon_name ]['class_name'])
654
-                )
655
-            ) {
656
-                self::$_settings[ $addon_name ] = $addon_settings;
657
-                $addon                          = self::_load_and_init_addon_class($addon_name);
658
-                $addon->set_activation_indicator_option();
659
-                // dont bother setting up the rest of the addon.
660
-                // we know it was just activated and the request will end soon
661
-            }
662
-            return true;
663
-        }
664
-        // make sure this was called in the right place!
665
-        if (
666
-            ! did_action('AHEE__EE_System__load_espresso_addons')
667
-            || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
668
-        ) {
669
-            EE_Error::doing_it_wrong(
670
-                __METHOD__,
671
-                sprintf(
672
-                    esc_html__(
673
-                        '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.',
674
-                        'event_espresso'
675
-                    ),
676
-                    $addon_name
677
-                ),
678
-                '4.3.0'
679
-            );
680
-        }
681
-        // make sure addon settings are set correctly without overwriting anything existing
682
-        if (isset(self::$_settings[ $addon_name ])) {
683
-            self::$_settings[ $addon_name ] += $addon_settings;
684
-        } else {
685
-            self::$_settings[ $addon_name ] = $addon_settings;
686
-        }
687
-        return false;
688
-    }
634
+	/**
635
+	 * @param string $addon_name
636
+	 * @param array  $addon_settings
637
+	 * @return bool
638
+	 * @throws InvalidArgumentException
639
+	 * @throws InvalidDataTypeException
640
+	 * @throws InvalidInterfaceException
641
+	 */
642
+	private static function _addon_activation(string $addon_name, array $addon_settings): bool
643
+	{
644
+		// this is an activation request
645
+		if (did_action('activate_plugin')) {
646
+			// to find if THIS is the addon that was activated, just check if we have already registered it or not
647
+			// (as the newly-activated addon wasn't around the first time addons were registered).
648
+			// Note: the presence of pue_options in the addon registration options will initialize the $_settings
649
+			// property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
650
+			if (
651
+				! isset(self::$_settings[ $addon_name ])
652
+				|| (isset(self::$_settings[ $addon_name ])
653
+					&& ! isset(self::$_settings[ $addon_name ]['class_name'])
654
+				)
655
+			) {
656
+				self::$_settings[ $addon_name ] = $addon_settings;
657
+				$addon                          = self::_load_and_init_addon_class($addon_name);
658
+				$addon->set_activation_indicator_option();
659
+				// dont bother setting up the rest of the addon.
660
+				// we know it was just activated and the request will end soon
661
+			}
662
+			return true;
663
+		}
664
+		// make sure this was called in the right place!
665
+		if (
666
+			! did_action('AHEE__EE_System__load_espresso_addons')
667
+			|| did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
668
+		) {
669
+			EE_Error::doing_it_wrong(
670
+				__METHOD__,
671
+				sprintf(
672
+					esc_html__(
673
+						'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.',
674
+						'event_espresso'
675
+					),
676
+					$addon_name
677
+				),
678
+				'4.3.0'
679
+			);
680
+		}
681
+		// make sure addon settings are set correctly without overwriting anything existing
682
+		if (isset(self::$_settings[ $addon_name ])) {
683
+			self::$_settings[ $addon_name ] += $addon_settings;
684
+		} else {
685
+			self::$_settings[ $addon_name ] = $addon_settings;
686
+		}
687
+		return false;
688
+	}
689 689
 
690 690
 
691
-    /**
692
-     * @param string $addon_name
693
-     * @return void
694
-     * @throws EE_Error
695
-     */
696
-    private static function _setup_autoloaders(string $addon_name)
697
-    {
698
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
699
-            // setup autoloader for single file
700
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
701
-        }
702
-        // setup autoloaders for folders
703
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
704
-            foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
705
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
706
-            }
707
-        }
708
-    }
691
+	/**
692
+	 * @param string $addon_name
693
+	 * @return void
694
+	 * @throws EE_Error
695
+	 */
696
+	private static function _setup_autoloaders(string $addon_name)
697
+	{
698
+		if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
699
+			// setup autoloader for single file
700
+			EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
701
+		}
702
+		// setup autoloaders for folders
703
+		if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
704
+			foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
705
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
706
+			}
707
+		}
708
+	}
709 709
 
710 710
 
711
-    /**
712
-     * register new models and extensions
713
-     *
714
-     * @param string $addon_name
715
-     * @return void
716
-     * @throws EE_Error
717
-     */
718
-    private static function _register_models_and_extensions(string $addon_name)
719
-    {
720
-        // register new models
721
-        if (
722
-            ! empty(self::$_settings[ $addon_name ]['model_paths'])
723
-            || ! empty(self::$_settings[ $addon_name ]['class_paths'])
724
-        ) {
725
-            EE_Register_Model::register(
726
-                $addon_name,
727
-                [
728
-                    'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
729
-                    'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
730
-                ]
731
-            );
732
-        }
733
-        // register model extensions
734
-        if (
735
-            ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
736
-            || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
737
-        ) {
738
-            EE_Register_Model_Extensions::register(
739
-                $addon_name,
740
-                [
741
-                    'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
742
-                    'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
743
-                ]
744
-            );
745
-        }
746
-    }
711
+	/**
712
+	 * register new models and extensions
713
+	 *
714
+	 * @param string $addon_name
715
+	 * @return void
716
+	 * @throws EE_Error
717
+	 */
718
+	private static function _register_models_and_extensions(string $addon_name)
719
+	{
720
+		// register new models
721
+		if (
722
+			! empty(self::$_settings[ $addon_name ]['model_paths'])
723
+			|| ! empty(self::$_settings[ $addon_name ]['class_paths'])
724
+		) {
725
+			EE_Register_Model::register(
726
+				$addon_name,
727
+				[
728
+					'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
729
+					'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
730
+				]
731
+			);
732
+		}
733
+		// register model extensions
734
+		if (
735
+			! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
736
+			|| ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
737
+		) {
738
+			EE_Register_Model_Extensions::register(
739
+				$addon_name,
740
+				[
741
+					'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
742
+					'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
743
+				]
744
+			);
745
+		}
746
+	}
747 747
 
748 748
 
749
-    /**
750
-     * @param string $addon_name
751
-     * @return void
752
-     * @throws EE_Error
753
-     */
754
-    private static function _register_data_migration_scripts(string $addon_name)
755
-    {
756
-        // setup DMS
757
-        if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
758
-            EE_Register_Data_Migration_Scripts::register(
759
-                $addon_name,
760
-                ['dms_paths' => self::$_settings[ $addon_name ]['dms_paths']]
761
-            );
762
-        }
763
-    }
749
+	/**
750
+	 * @param string $addon_name
751
+	 * @return void
752
+	 * @throws EE_Error
753
+	 */
754
+	private static function _register_data_migration_scripts(string $addon_name)
755
+	{
756
+		// setup DMS
757
+		if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
758
+			EE_Register_Data_Migration_Scripts::register(
759
+				$addon_name,
760
+				['dms_paths' => self::$_settings[ $addon_name ]['dms_paths']]
761
+			);
762
+		}
763
+	}
764 764
 
765 765
 
766
-    /**
767
-     * @param string $addon_name
768
-     * @return void
769
-     * @throws EE_Error
770
-     */
771
-    private static function _register_config(string $addon_name)
772
-    {
773
-        // if config_class is present let's register config.
774
-        if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
775
-            EE_Register_Config::register(
776
-                self::$_settings[ $addon_name ]['config_class'],
777
-                [
778
-                    'config_section' => self::$_settings[ $addon_name ]['config_section'],
779
-                    'config_name'    => self::$_settings[ $addon_name ]['config_name'],
780
-                ]
781
-            );
782
-        }
783
-    }
766
+	/**
767
+	 * @param string $addon_name
768
+	 * @return void
769
+	 * @throws EE_Error
770
+	 */
771
+	private static function _register_config(string $addon_name)
772
+	{
773
+		// if config_class is present let's register config.
774
+		if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
775
+			EE_Register_Config::register(
776
+				self::$_settings[ $addon_name ]['config_class'],
777
+				[
778
+					'config_section' => self::$_settings[ $addon_name ]['config_section'],
779
+					'config_name'    => self::$_settings[ $addon_name ]['config_name'],
780
+				]
781
+			);
782
+		}
783
+	}
784 784
 
785 785
 
786
-    /**
787
-     * @param string $addon_name
788
-     * @return void
789
-     * @throws EE_Error
790
-     */
791
-    private static function _register_admin_pages(string $addon_name)
792
-    {
793
-        if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
794
-            EE_Register_Admin_Page::register(
795
-                $addon_name,
796
-                ['page_path' => self::$_settings[ $addon_name ]['admin_path']]
797
-            );
798
-        }
799
-    }
786
+	/**
787
+	 * @param string $addon_name
788
+	 * @return void
789
+	 * @throws EE_Error
790
+	 */
791
+	private static function _register_admin_pages(string $addon_name)
792
+	{
793
+		if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
794
+			EE_Register_Admin_Page::register(
795
+				$addon_name,
796
+				['page_path' => self::$_settings[ $addon_name ]['admin_path']]
797
+			);
798
+		}
799
+	}
800 800
 
801 801
 
802
-    /**
803
-     * @param string $addon_name
804
-     * @return void
805
-     * @throws EE_Error
806
-     */
807
-    private static function _register_modules(string $addon_name)
808
-    {
809
-        if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
810
-            EE_Register_Module::register(
811
-                $addon_name,
812
-                ['module_paths' => self::$_settings[ $addon_name ]['module_paths']]
813
-            );
814
-        }
815
-    }
802
+	/**
803
+	 * @param string $addon_name
804
+	 * @return void
805
+	 * @throws EE_Error
806
+	 */
807
+	private static function _register_modules(string $addon_name)
808
+	{
809
+		if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
810
+			EE_Register_Module::register(
811
+				$addon_name,
812
+				['module_paths' => self::$_settings[ $addon_name ]['module_paths']]
813
+			);
814
+		}
815
+	}
816 816
 
817 817
 
818
-    /**
819
-     * @param string $addon_name
820
-     * @return void
821
-     * @throws EE_Error
822
-     */
823
-    private static function _register_shortcodes(string $addon_name)
824
-    {
825
-        if (
826
-            ! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
827
-            || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
828
-        ) {
829
-            EE_Register_Shortcode::register(
830
-                $addon_name,
831
-                [
832
-                    'shortcode_paths' => self::$_settings[ $addon_name ]['shortcode_paths'] ?? [],
833
-                    'shortcode_fqcns' => self::$_settings[ $addon_name ]['shortcode_fqcns'] ?? [],
834
-                ]
835
-            );
836
-        }
837
-    }
818
+	/**
819
+	 * @param string $addon_name
820
+	 * @return void
821
+	 * @throws EE_Error
822
+	 */
823
+	private static function _register_shortcodes(string $addon_name)
824
+	{
825
+		if (
826
+			! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
827
+			|| ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
828
+		) {
829
+			EE_Register_Shortcode::register(
830
+				$addon_name,
831
+				[
832
+					'shortcode_paths' => self::$_settings[ $addon_name ]['shortcode_paths'] ?? [],
833
+					'shortcode_fqcns' => self::$_settings[ $addon_name ]['shortcode_fqcns'] ?? [],
834
+				]
835
+			);
836
+		}
837
+	}
838 838
 
839 839
 
840
-    /**
841
-     * @param string $addon_name
842
-     * @return void
843
-     * @throws EE_Error
844
-     */
845
-    private static function _register_widgets(string $addon_name)
846
-    {
847
-        if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
848
-            EE_Register_Widget::register(
849
-                $addon_name,
850
-                ['widget_paths' => self::$_settings[ $addon_name ]['widget_paths']]
851
-            );
852
-        }
853
-    }
840
+	/**
841
+	 * @param string $addon_name
842
+	 * @return void
843
+	 * @throws EE_Error
844
+	 */
845
+	private static function _register_widgets(string $addon_name)
846
+	{
847
+		if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
848
+			EE_Register_Widget::register(
849
+				$addon_name,
850
+				['widget_paths' => self::$_settings[ $addon_name ]['widget_paths']]
851
+			);
852
+		}
853
+	}
854 854
 
855 855
 
856
-    /**
857
-     * @param string $addon_name
858
-     * @return void
859
-     * @throws EE_Error
860
-     */
861
-    private static function _register_capabilities(string $addon_name)
862
-    {
863
-        if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
864
-            EE_Register_Capabilities::register(
865
-                $addon_name,
866
-                [
867
-                    'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
868
-                    'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
869
-                ]
870
-            );
871
-        }
872
-    }
856
+	/**
857
+	 * @param string $addon_name
858
+	 * @return void
859
+	 * @throws EE_Error
860
+	 */
861
+	private static function _register_capabilities(string $addon_name)
862
+	{
863
+		if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
864
+			EE_Register_Capabilities::register(
865
+				$addon_name,
866
+				[
867
+					'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
868
+					'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
869
+				]
870
+			);
871
+		}
872
+	}
873 873
 
874 874
 
875
-    /**
876
-     * @param string $addon_name
877
-     * @return void
878
-     */
879
-    private static function _register_message_types(string $addon_name)
880
-    {
881
-        if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
882
-            add_action(
883
-                'EE_Brewing_Regular___messages_caf',
884
-                ['EE_Register_Addon', 'register_message_types']
885
-            );
886
-        }
887
-    }
875
+	/**
876
+	 * @param string $addon_name
877
+	 * @return void
878
+	 */
879
+	private static function _register_message_types(string $addon_name)
880
+	{
881
+		if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
882
+			add_action(
883
+				'EE_Brewing_Regular___messages_caf',
884
+				['EE_Register_Addon', 'register_message_types']
885
+			);
886
+		}
887
+	}
888 888
 
889 889
 
890
-    /**
891
-     * @param string $addon_name
892
-     * @return void
893
-     * @throws EE_Error
894
-     */
895
-    private static function _register_custom_post_types(string $addon_name)
896
-    {
897
-        if (
898
-            ! empty(self::$_settings[ $addon_name ]['custom_post_types'])
899
-            || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
900
-        ) {
901
-            EE_Register_CPT::register(
902
-                $addon_name,
903
-                [
904
-                    'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
905
-                    'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
906
-                    'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
907
-                ]
908
-            );
909
-        }
910
-    }
890
+	/**
891
+	 * @param string $addon_name
892
+	 * @return void
893
+	 * @throws EE_Error
894
+	 */
895
+	private static function _register_custom_post_types(string $addon_name)
896
+	{
897
+		if (
898
+			! empty(self::$_settings[ $addon_name ]['custom_post_types'])
899
+			|| ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
900
+		) {
901
+			EE_Register_CPT::register(
902
+				$addon_name,
903
+				[
904
+					'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
905
+					'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
906
+					'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
907
+				]
908
+			);
909
+		}
910
+	}
911 911
 
912 912
 
913
-    /**
914
-     * @param string $addon_name
915
-     * @return void
916
-     * @throws InvalidArgumentException
917
-     * @throws InvalidInterfaceException
918
-     * @throws InvalidDataTypeException
919
-     * @throws DomainException
920
-     * @throws EE_Error
921
-     */
922
-    private static function _register_payment_methods(string $addon_name)
923
-    {
924
-        if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
925
-            EE_Register_Payment_Method::register(
926
-                $addon_name,
927
-                ['payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths']]
928
-            );
929
-        }
930
-    }
913
+	/**
914
+	 * @param string $addon_name
915
+	 * @return void
916
+	 * @throws InvalidArgumentException
917
+	 * @throws InvalidInterfaceException
918
+	 * @throws InvalidDataTypeException
919
+	 * @throws DomainException
920
+	 * @throws EE_Error
921
+	 */
922
+	private static function _register_payment_methods(string $addon_name)
923
+	{
924
+		if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
925
+			EE_Register_Payment_Method::register(
926
+				$addon_name,
927
+				['payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths']]
928
+			);
929
+		}
930
+	}
931 931
 
932 932
 
933
-    /**
934
-     * @param string $addon_name
935
-     * @return void
936
-     * @throws InvalidArgumentException
937
-     * @throws InvalidInterfaceException
938
-     * @throws InvalidDataTypeException
939
-     * @throws DomainException
940
-     */
941
-    private static function registerPrivacyPolicies(string $addon_name)
942
-    {
943
-        if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) {
944
-            EE_Register_Privacy_Policy::register(
945
-                $addon_name,
946
-                self::$_settings[ $addon_name ]['privacy_policies']
947
-            );
948
-        }
949
-    }
933
+	/**
934
+	 * @param string $addon_name
935
+	 * @return void
936
+	 * @throws InvalidArgumentException
937
+	 * @throws InvalidInterfaceException
938
+	 * @throws InvalidDataTypeException
939
+	 * @throws DomainException
940
+	 */
941
+	private static function registerPrivacyPolicies(string $addon_name)
942
+	{
943
+		if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) {
944
+			EE_Register_Privacy_Policy::register(
945
+				$addon_name,
946
+				self::$_settings[ $addon_name ]['privacy_policies']
947
+			);
948
+		}
949
+	}
950 950
 
951 951
 
952
-    /**
953
-     * @param string $addon_name
954
-     * @return void
955
-     */
956
-    private static function registerPersonalDataExporters(string $addon_name)
957
-    {
958
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) {
959
-            EE_Register_Personal_Data_Eraser::register(
960
-                $addon_name,
961
-                self::$_settings[ $addon_name ]['personal_data_exporters']
962
-            );
963
-        }
964
-    }
952
+	/**
953
+	 * @param string $addon_name
954
+	 * @return void
955
+	 */
956
+	private static function registerPersonalDataExporters(string $addon_name)
957
+	{
958
+		if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) {
959
+			EE_Register_Personal_Data_Eraser::register(
960
+				$addon_name,
961
+				self::$_settings[ $addon_name ]['personal_data_exporters']
962
+			);
963
+		}
964
+	}
965 965
 
966 966
 
967
-    /**
968
-     * @param string $addon_name
969
-     * @return void
970
-     */
971
-    private static function registerPersonalDataErasers(string $addon_name)
972
-    {
973
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) {
974
-            EE_Register_Personal_Data_Eraser::register(
975
-                $addon_name,
976
-                self::$_settings[ $addon_name ]['personal_data_erasers']
977
-            );
978
-        }
979
-    }
967
+	/**
968
+	 * @param string $addon_name
969
+	 * @return void
970
+	 */
971
+	private static function registerPersonalDataErasers(string $addon_name)
972
+	{
973
+		if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) {
974
+			EE_Register_Personal_Data_Eraser::register(
975
+				$addon_name,
976
+				self::$_settings[ $addon_name ]['personal_data_erasers']
977
+			);
978
+		}
979
+	}
980 980
 
981 981
 
982
-    /**
983
-     * Loads and instantiates the EE_Addon class and adds it onto the registry
984
-     *
985
-     * @param string $addon_name
986
-     * @return EE_Addon
987
-     * @throws InvalidArgumentException
988
-     * @throws InvalidInterfaceException
989
-     * @throws InvalidDataTypeException
990
-     */
991
-    private static function _load_and_init_addon_class(string $addon_name): EE_Addon
992
-    {
993
-        $addon = LoaderFactory::getLoader()->getShared(
994
-            self::$_settings[ $addon_name ]['class_name'],
995
-            ['EE_Registry::create(addon)' => true]
996
-        );
997
-        if (! $addon instanceof EE_Addon) {
998
-            throw new DomainException(
999
-                sprintf(
1000
-                    esc_html__(
1001
-                        'Failed to instantiate the %1$s class. PLease check that the class exists.',
1002
-                        'event_espresso'
1003
-                    ),
1004
-                    $addon_name
1005
-                )
1006
-            );
1007
-        }
1008
-        // setter inject dep map if required
1009
-        if ($addon->dependencyMap() === null) {
1010
-            $addon->setDependencyMap(LoaderFactory::getLoader()->getShared('EE_Dependency_Map'));
1011
-        }
1012
-        // setter inject domain if required
1013
-        EE_Register_Addon::injectAddonDomain($addon_name, $addon);
982
+	/**
983
+	 * Loads and instantiates the EE_Addon class and adds it onto the registry
984
+	 *
985
+	 * @param string $addon_name
986
+	 * @return EE_Addon
987
+	 * @throws InvalidArgumentException
988
+	 * @throws InvalidInterfaceException
989
+	 * @throws InvalidDataTypeException
990
+	 */
991
+	private static function _load_and_init_addon_class(string $addon_name): EE_Addon
992
+	{
993
+		$addon = LoaderFactory::getLoader()->getShared(
994
+			self::$_settings[ $addon_name ]['class_name'],
995
+			['EE_Registry::create(addon)' => true]
996
+		);
997
+		if (! $addon instanceof EE_Addon) {
998
+			throw new DomainException(
999
+				sprintf(
1000
+					esc_html__(
1001
+						'Failed to instantiate the %1$s class. PLease check that the class exists.',
1002
+						'event_espresso'
1003
+					),
1004
+					$addon_name
1005
+				)
1006
+			);
1007
+		}
1008
+		// setter inject dep map if required
1009
+		if ($addon->dependencyMap() === null) {
1010
+			$addon->setDependencyMap(LoaderFactory::getLoader()->getShared('EE_Dependency_Map'));
1011
+		}
1012
+		// setter inject domain if required
1013
+		EE_Register_Addon::injectAddonDomain($addon_name, $addon);
1014 1014
 
1015
-        $addon->set_name($addon_name);
1016
-        $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
1017
-        $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
1018
-        $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
1019
-        $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
1020
-        $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
1021
-        $addon->set_version(self::$_settings[ $addon_name ]['version']);
1022
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
1023
-        $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
1024
-        $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
1025
-        $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
1026
-        do_action(
1027
-            'AHEE__EE_Register_Addon___load_and_init_addon_class',
1028
-            $addon,
1029
-            $addon_name,
1030
-            self::$_settings
1031
-        );
1032
-        // unfortunately this can't be hooked in upon construction,
1033
-        // because we don't have the plugin's mainfile path upon construction.
1034
-        register_deactivation_hook($addon->get_main_plugin_file(), [$addon, 'deactivation']);
1035
-        // call any additional admin_callback functions during load_admin_controller hook
1036
-        if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1037
-            add_action(
1038
-                'AHEE__EE_System__load_controllers__load_admin_controllers',
1039
-                [$addon, self::$_settings[ $addon_name ]['admin_callback']]
1040
-            );
1041
-        }
1042
-        return $addon;
1043
-    }
1015
+		$addon->set_name($addon_name);
1016
+		$addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
1017
+		$addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
1018
+		$addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
1019
+		$addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
1020
+		$addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
1021
+		$addon->set_version(self::$_settings[ $addon_name ]['version']);
1022
+		$addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
1023
+		$addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
1024
+		$addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
1025
+		$addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
1026
+		do_action(
1027
+			'AHEE__EE_Register_Addon___load_and_init_addon_class',
1028
+			$addon,
1029
+			$addon_name,
1030
+			self::$_settings
1031
+		);
1032
+		// unfortunately this can't be hooked in upon construction,
1033
+		// because we don't have the plugin's mainfile path upon construction.
1034
+		register_deactivation_hook($addon->get_main_plugin_file(), [$addon, 'deactivation']);
1035
+		// call any additional admin_callback functions during load_admin_controller hook
1036
+		if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1037
+			add_action(
1038
+				'AHEE__EE_System__load_controllers__load_admin_controllers',
1039
+				[$addon, self::$_settings[ $addon_name ]['admin_callback']]
1040
+			);
1041
+		}
1042
+		return $addon;
1043
+	}
1044 1044
 
1045 1045
 
1046
-    /**
1047
-     * @param string   $addon_name
1048
-     * @param EE_Addon $addon
1049
-     * @since   4.10.13.p
1050
-     */
1051
-    private static function injectAddonDomain(string $addon_name, EE_Addon $addon)
1052
-    {
1053
-        if ($addon instanceof RequiresDomainInterface && $addon->domain() === null) {
1054
-            // using supplied Domain object
1055
-            $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
1056
-                ? self::$_settings[ $addon_name ]['domain']
1057
-                : null;
1058
-            // or construct one using Domain FQCN
1059
-            if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
1060
-                $domain = LoaderFactory::getLoader()->getShared(
1061
-                    self::$_settings[ $addon_name ]['domain_fqcn'],
1062
-                    [
1063
-                        new EventEspresso\core\domain\values\FilePath(
1064
-                            self::$_settings[ $addon_name ]['main_file_path']
1065
-                        ),
1066
-                        EventEspresso\core\domain\values\Version::fromString(
1067
-                            self::$_settings[ $addon_name ]['version']
1068
-                        ),
1069
-                    ]
1070
-                );
1071
-            }
1072
-            if ($domain instanceof DomainInterface) {
1073
-                $addon->setDomain($domain);
1074
-            }
1075
-        }
1076
-    }
1046
+	/**
1047
+	 * @param string   $addon_name
1048
+	 * @param EE_Addon $addon
1049
+	 * @since   4.10.13.p
1050
+	 */
1051
+	private static function injectAddonDomain(string $addon_name, EE_Addon $addon)
1052
+	{
1053
+		if ($addon instanceof RequiresDomainInterface && $addon->domain() === null) {
1054
+			// using supplied Domain object
1055
+			$domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
1056
+				? self::$_settings[ $addon_name ]['domain']
1057
+				: null;
1058
+			// or construct one using Domain FQCN
1059
+			if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
1060
+				$domain = LoaderFactory::getLoader()->getShared(
1061
+					self::$_settings[ $addon_name ]['domain_fqcn'],
1062
+					[
1063
+						new EventEspresso\core\domain\values\FilePath(
1064
+							self::$_settings[ $addon_name ]['main_file_path']
1065
+						),
1066
+						EventEspresso\core\domain\values\Version::fromString(
1067
+							self::$_settings[ $addon_name ]['version']
1068
+						),
1069
+					]
1070
+				);
1071
+			}
1072
+			if ($domain instanceof DomainInterface) {
1073
+				$addon->setDomain($domain);
1074
+			}
1075
+		}
1076
+	}
1077 1077
 
1078 1078
 
1079
-    /**
1080
-     * @return void
1081
-     */
1082
-    public static function load_pue_update()
1083
-    {
1084
-        RegisterAddonPUE::loadPueUpdate();
1085
-    }
1079
+	/**
1080
+	 * @return void
1081
+	 */
1082
+	public static function load_pue_update()
1083
+	{
1084
+		RegisterAddonPUE::loadPueUpdate();
1085
+	}
1086 1086
 
1087 1087
 
1088
-    /**
1089
-     * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
1090
-     *
1091
-     * @return void
1092
-     * @throws EE_Error
1093
-     * @since 4.4.0
1094
-     */
1095
-    public static function register_message_types()
1096
-    {
1097
-        foreach (self::$_settings as $settings) {
1098
-            if (! empty($settings['message_types'])) {
1099
-                foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1100
-                    EE_Register_Message_Type::register($message_type, $message_type_settings);
1101
-                }
1102
-            }
1103
-        }
1104
-    }
1088
+	/**
1089
+	 * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
1090
+	 *
1091
+	 * @return void
1092
+	 * @throws EE_Error
1093
+	 * @since 4.4.0
1094
+	 */
1095
+	public static function register_message_types()
1096
+	{
1097
+		foreach (self::$_settings as $settings) {
1098
+			if (! empty($settings['message_types'])) {
1099
+				foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1100
+					EE_Register_Message_Type::register($message_type, $message_type_settings);
1101
+				}
1102
+			}
1103
+		}
1104
+	}
1105 1105
 
1106 1106
 
1107
-    /**
1108
-     * This deregisters an addon that was previously registered with a specific addon_name.
1109
-     *
1110
-     * @param string $addon_name the name for the addon that was previously registered
1111
-     * @throws DomainException
1112
-     * @throws InvalidArgumentException
1113
-     * @throws InvalidDataTypeException
1114
-     * @throws InvalidInterfaceException
1115
-     * @since    4.3.0
1116
-     */
1117
-    public static function deregister($addon_name = '')
1118
-    {
1119
-        if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1120
-            try {
1121
-                do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1122
-                $class_name = self::$_settings[ $addon_name ]['class_name'];
1123
-                if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1124
-                    // setup DMS
1125
-                    EE_Register_Data_Migration_Scripts::deregister($addon_name);
1126
-                }
1127
-                if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1128
-                    // register admin page
1129
-                    EE_Register_Admin_Page::deregister($addon_name);
1130
-                }
1131
-                if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1132
-                    // add to list of modules to be registered
1133
-                    EE_Register_Module::deregister($addon_name);
1134
-                }
1135
-                if (
1136
-                    ! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1137
-                    || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1138
-                ) {
1139
-                    // add to list of shortcodes to be registered
1140
-                    EE_Register_Shortcode::deregister($addon_name);
1141
-                }
1142
-                if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1143
-                    // if config_class present let's register config.
1144
-                    EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1145
-                }
1146
-                if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1147
-                    // add to list of widgets to be registered
1148
-                    EE_Register_Widget::deregister($addon_name);
1149
-                }
1150
-                if (
1151
-                    ! empty(self::$_settings[ $addon_name ]['model_paths'])
1152
-                    || ! empty(self::$_settings[ $addon_name ]['class_paths'])
1153
-                ) {
1154
-                    // add to list of shortcodes to be registered
1155
-                    EE_Register_Model::deregister($addon_name);
1156
-                }
1157
-                if (
1158
-                    ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1159
-                    || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1160
-                ) {
1161
-                    // add to list of shortcodes to be registered
1162
-                    EE_Register_Model_Extensions::deregister($addon_name);
1163
-                }
1164
-                if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1165
-                    foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1166
-                        EE_Register_Message_Type::deregister($message_type);
1167
-                    }
1168
-                }
1169
-                // deregister capabilities for addon
1170
-                if (
1171
-                    ! empty(self::$_settings[ $addon_name ]['capabilities'])
1172
-                    || ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1173
-                ) {
1174
-                    EE_Register_Capabilities::deregister($addon_name);
1175
-                }
1176
-                // deregister custom_post_types for addon
1177
-                if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1178
-                    EE_Register_CPT::deregister($addon_name);
1179
-                }
1180
-                if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1181
-                    EE_Register_Payment_Method::deregister($addon_name);
1182
-                }
1183
-                $addon = EE_Registry::instance()->getAddon($class_name);
1184
-                if ($addon instanceof EE_Addon) {
1185
-                    remove_action(
1186
-                        'deactivate_' . $addon->get_main_plugin_file_basename(),
1187
-                        [$addon, 'deactivation']
1188
-                    );
1189
-                    remove_action(
1190
-                        'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1191
-                        [$addon, 'initialize_db_if_no_migrations_required']
1192
-                    );
1193
-                    // remove `after_registration` call
1194
-                    remove_action(
1195
-                        'AHEE__EE_System__load_espresso_addons__complete',
1196
-                        [$addon, 'after_registration'],
1197
-                        999
1198
-                    );
1199
-                }
1200
-                EE_Registry::instance()->removeAddon($class_name);
1201
-                LoaderFactory::getLoader()->remove($class_name);
1202
-            } catch (OutOfBoundsException $addon_not_yet_registered_exception) {
1203
-                // the add-on was not yet registered in the registry,
1204
-                // so RegistryContainer::__get() throws this exception.
1205
-                // also no need to worry about this or log it,
1206
-                // it's ok to deregister an add-on before its registered in the registry
1207
-            } catch (Exception $e) {
1208
-                new ExceptionLogger($e);
1209
-            }
1210
-            unset(self::$_settings[ $addon_name ]);
1211
-            do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1212
-        }
1213
-    }
1107
+	/**
1108
+	 * This deregisters an addon that was previously registered with a specific addon_name.
1109
+	 *
1110
+	 * @param string $addon_name the name for the addon that was previously registered
1111
+	 * @throws DomainException
1112
+	 * @throws InvalidArgumentException
1113
+	 * @throws InvalidDataTypeException
1114
+	 * @throws InvalidInterfaceException
1115
+	 * @since    4.3.0
1116
+	 */
1117
+	public static function deregister($addon_name = '')
1118
+	{
1119
+		if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1120
+			try {
1121
+				do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1122
+				$class_name = self::$_settings[ $addon_name ]['class_name'];
1123
+				if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1124
+					// setup DMS
1125
+					EE_Register_Data_Migration_Scripts::deregister($addon_name);
1126
+				}
1127
+				if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1128
+					// register admin page
1129
+					EE_Register_Admin_Page::deregister($addon_name);
1130
+				}
1131
+				if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1132
+					// add to list of modules to be registered
1133
+					EE_Register_Module::deregister($addon_name);
1134
+				}
1135
+				if (
1136
+					! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1137
+					|| ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1138
+				) {
1139
+					// add to list of shortcodes to be registered
1140
+					EE_Register_Shortcode::deregister($addon_name);
1141
+				}
1142
+				if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1143
+					// if config_class present let's register config.
1144
+					EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1145
+				}
1146
+				if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1147
+					// add to list of widgets to be registered
1148
+					EE_Register_Widget::deregister($addon_name);
1149
+				}
1150
+				if (
1151
+					! empty(self::$_settings[ $addon_name ]['model_paths'])
1152
+					|| ! empty(self::$_settings[ $addon_name ]['class_paths'])
1153
+				) {
1154
+					// add to list of shortcodes to be registered
1155
+					EE_Register_Model::deregister($addon_name);
1156
+				}
1157
+				if (
1158
+					! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1159
+					|| ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1160
+				) {
1161
+					// add to list of shortcodes to be registered
1162
+					EE_Register_Model_Extensions::deregister($addon_name);
1163
+				}
1164
+				if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1165
+					foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1166
+						EE_Register_Message_Type::deregister($message_type);
1167
+					}
1168
+				}
1169
+				// deregister capabilities for addon
1170
+				if (
1171
+					! empty(self::$_settings[ $addon_name ]['capabilities'])
1172
+					|| ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1173
+				) {
1174
+					EE_Register_Capabilities::deregister($addon_name);
1175
+				}
1176
+				// deregister custom_post_types for addon
1177
+				if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1178
+					EE_Register_CPT::deregister($addon_name);
1179
+				}
1180
+				if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1181
+					EE_Register_Payment_Method::deregister($addon_name);
1182
+				}
1183
+				$addon = EE_Registry::instance()->getAddon($class_name);
1184
+				if ($addon instanceof EE_Addon) {
1185
+					remove_action(
1186
+						'deactivate_' . $addon->get_main_plugin_file_basename(),
1187
+						[$addon, 'deactivation']
1188
+					);
1189
+					remove_action(
1190
+						'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1191
+						[$addon, 'initialize_db_if_no_migrations_required']
1192
+					);
1193
+					// remove `after_registration` call
1194
+					remove_action(
1195
+						'AHEE__EE_System__load_espresso_addons__complete',
1196
+						[$addon, 'after_registration'],
1197
+						999
1198
+					);
1199
+				}
1200
+				EE_Registry::instance()->removeAddon($class_name);
1201
+				LoaderFactory::getLoader()->remove($class_name);
1202
+			} catch (OutOfBoundsException $addon_not_yet_registered_exception) {
1203
+				// the add-on was not yet registered in the registry,
1204
+				// so RegistryContainer::__get() throws this exception.
1205
+				// also no need to worry about this or log it,
1206
+				// it's ok to deregister an add-on before its registered in the registry
1207
+			} catch (Exception $e) {
1208
+				new ExceptionLogger($e);
1209
+			}
1210
+			unset(self::$_settings[ $addon_name ]);
1211
+			do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1212
+		}
1213
+	}
1214 1214
 }
Please login to merge, or discard this patch.