Completed
Branch EDTR/master (4f5190)
by
unknown
34:50 queued 25:32
created
data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_shortcodes.dmsstage.php 1 patch
Indentation   +47 added lines, -48 removed lines patch added patch discarded remove patch
@@ -2,58 +2,57 @@
 block discarded – undo
2 2
 
3 3
 /**
4 4
  * Goes through all the posts and pages, and converts old shortcodes to new ones
5
-
6
-*/
5
+ */
7 6
 
8 7
 class EE_DMS_4_1_0_shortcodes extends EE_Data_Migration_Script_Stage
9 8
 {
10
-    public function __construct()
11
-    {
12
-        global $wpdb;
13
-        $this->_pretty_name = __("Shortcodes", "event_espresso");
14
-        $this->_old_table = $wpdb->posts;
15
-        parent::__construct();
16
-    }
17
-    protected function _migrate_old_row($old_row)
18
-    {
19
-        $new_post_content = $this->_change_event_list_shortcode($old_row['post_content']);
20
-        global $wpdb;
21
-        $wpdb->query($wpdb->prepare("UPDATE ".$this->_old_table." SET post_content=%s WHERE ID=%d", $new_post_content, $old_row['ID']));
22
-    }
9
+	public function __construct()
10
+	{
11
+		global $wpdb;
12
+		$this->_pretty_name = __("Shortcodes", "event_espresso");
13
+		$this->_old_table = $wpdb->posts;
14
+		parent::__construct();
15
+	}
16
+	protected function _migrate_old_row($old_row)
17
+	{
18
+		$new_post_content = $this->_change_event_list_shortcode($old_row['post_content']);
19
+		global $wpdb;
20
+		$wpdb->query($wpdb->prepare("UPDATE ".$this->_old_table." SET post_content=%s WHERE ID=%d", $new_post_content, $old_row['ID']));
21
+	}
23 22
 
24
-    /**
25
-     * replaces [EVENT_LIST... with [ESPRESSO_EVENTS...]
26
-     * @param string $old_content
27
-     */
28
-    private function _change_event_list_shortcode($old_content)
29
-    {
30
-        return str_replace("[EVENT_LIST", "[ESPRESSO_EVENTS", $old_content);
31
-    }
23
+	/**
24
+	 * replaces [EVENT_LIST... with [ESPRESSO_EVENTS...]
25
+	 * @param string $old_content
26
+	 */
27
+	private function _change_event_list_shortcode($old_content)
28
+	{
29
+		return str_replace("[EVENT_LIST", "[ESPRESSO_EVENTS", $old_content);
30
+	}
32 31
 
33
-    public function _migration_step($num_items = 50)
34
-    {
35
-        global $wpdb;
36
-        $start_at_record = $this->count_records_migrated();
37
-        $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table {$this->_sql_to_only_select_non_drafts()} LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
38
-        $items_actually_migrated = 0;
39
-        foreach ($rows as $old_row) {
40
-            $this->_migrate_old_row($old_row);
41
-            $items_actually_migrated++;
42
-        }
43
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
44
-            $this->set_completed();
45
-        }
46
-        return $items_actually_migrated;
47
-    }
48
-    public function _count_records_to_migrate()
49
-    {
50
-        global $wpdb;
51
-        $count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table.$this->_sql_to_only_select_non_drafts());
52
-        return $count;
53
-    }
32
+	public function _migration_step($num_items = 50)
33
+	{
34
+		global $wpdb;
35
+		$start_at_record = $this->count_records_migrated();
36
+		$rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table {$this->_sql_to_only_select_non_drafts()} LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A);
37
+		$items_actually_migrated = 0;
38
+		foreach ($rows as $old_row) {
39
+			$this->_migrate_old_row($old_row);
40
+			$items_actually_migrated++;
41
+		}
42
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
43
+			$this->set_completed();
44
+		}
45
+		return $items_actually_migrated;
46
+	}
47
+	public function _count_records_to_migrate()
48
+	{
49
+		global $wpdb;
50
+		$count = $wpdb->get_var("SELECT COUNT(id) FROM ".$this->_old_table.$this->_sql_to_only_select_non_drafts());
51
+		return $count;
52
+	}
54 53
 
55
-    private function _sql_to_only_select_non_drafts()
56
-    {
57
-        return " WHERE post_type NOT IN ('revision','auto-draft','attachment','nav_menu_item') ";
58
-    }
54
+	private function _sql_to_only_select_non_drafts()
55
+	{
56
+		return " WHERE post_type NOT IN ('revision','auto-draft','attachment','nav_menu_item') ";
57
+	}
59 58
 }
Please login to merge, or discard this patch.
modules/ticket_sales_monitor/EED_Ticket_Sales_Monitor.module.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
     /**
334 334
      * @param  EE_Ticket $ticket
335 335
      * @param  int       $quantity
336
-     * @return bool
336
+     * @return integer
337 337
      * @throws EE_Error
338 338
      */
339 339
     protected function _release_reserved_ticket(EE_Ticket $ticket, $quantity = 1)
@@ -984,6 +984,7 @@  discard block
 block discarded – undo
984 984
      *                       reservations are now invalid. We don't use the list of invalid ticket line items because
985 985
      *                       we don't know which of those have already been taken into account when reducing ticket
986 986
      *                       reservation counts, and which haven't.
987
+     * @param string $source
987 988
      * @return int
988 989
      * @throws UnexpectedEntityException
989 990
      * @throws DomainException
Please login to merge, or discard this patch.
Indentation   +1051 added lines, -1051 removed lines patch added patch discarded remove patch
@@ -20,1056 +20,1056 @@
 block discarded – undo
20 20
 class EED_Ticket_Sales_Monitor extends EED_Module
21 21
 {
22 22
 
23
-    const debug = false;
24
-
25
-    private static $nl = '';
26
-
27
-    /**
28
-     * an array of raw ticket data from EED_Ticket_Selector
29
-     *
30
-     * @var array $ticket_selections
31
-     */
32
-    protected $ticket_selections = array();
33
-
34
-    /**
35
-     * the raw ticket data from EED_Ticket_Selector is organized in rows
36
-     * according to how they are displayed in the actual Ticket_Selector
37
-     * this tracks the current row being processed
38
-     *
39
-     * @var int $current_row
40
-     */
41
-    protected $current_row = 0;
42
-
43
-    /**
44
-     * an array for tracking names of tickets that have sold out
45
-     *
46
-     * @var array $sold_out_tickets
47
-     */
48
-    protected $sold_out_tickets = array();
49
-
50
-    /**
51
-     * an array for tracking names of tickets that have had their quantities reduced
52
-     *
53
-     * @var array $decremented_tickets
54
-     */
55
-    protected $decremented_tickets = array();
56
-
57
-
58
-    /**
59
-     * set_hooks - for hooking into EE Core, other modules, etc
60
-     *
61
-     * @return    void
62
-     */
63
-    public static function set_hooks()
64
-    {
65
-        self::$nl = defined('EE_TESTS_DIR') ? "\n" : '<br />';
66
-        // release tickets for expired carts
67
-        add_action(
68
-            'EED_Ticket_Selector__process_ticket_selections__before',
69
-            array('EED_Ticket_Sales_Monitor', 'release_tickets_for_expired_carts'),
70
-            1
71
-        );
72
-        // check ticket reserves AFTER MER does it's check (hence priority 20)
73
-        add_filter(
74
-            'FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty',
75
-            array('EED_Ticket_Sales_Monitor', 'validate_ticket_sale'),
76
-            20,
77
-            3
78
-        );
79
-        // add notices for sold out tickets
80
-        add_action(
81
-            'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
82
-            array('EED_Ticket_Sales_Monitor', 'post_notices'),
83
-            10
84
-        );
85
-
86
-        // handle tickets deleted from cart
87
-        add_action(
88
-            'FHEE__EED_Multi_Event_Registration__delete_ticket__ticket_removed_from_cart',
89
-            array('EED_Ticket_Sales_Monitor', 'ticket_removed_from_cart'),
90
-            10,
91
-            2
92
-        );
93
-        // handle emptied carts
94
-        add_action(
95
-            'AHEE__EE_Session__reset_cart__before_reset',
96
-            array('EED_Ticket_Sales_Monitor', 'session_cart_reset'),
97
-            10,
98
-            1
99
-        );
100
-        add_action(
101
-            'AHEE__EED_Multi_Event_Registration__empty_event_cart__before_delete_cart',
102
-            array('EED_Ticket_Sales_Monitor', 'session_cart_reset'),
103
-            10,
104
-            1
105
-        );
106
-        // handle cancelled registrations
107
-        add_action(
108
-            'AHEE__EE_Session__reset_checkout__before_reset',
109
-            array('EED_Ticket_Sales_Monitor', 'session_checkout_reset'),
110
-            10,
111
-            1
112
-        );
113
-        // cron tasks
114
-        add_action(
115
-            'AHEE__EE_Cron_Tasks__process_expired_transactions__abandoned_transaction',
116
-            array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'),
117
-            10,
118
-            1
119
-        );
120
-        add_action(
121
-            'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction',
122
-            array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'),
123
-            10,
124
-            1
125
-        );
126
-        add_action(
127
-            'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction',
128
-            array('EED_Ticket_Sales_Monitor', 'process_failed_transactions'),
129
-            10,
130
-            1
131
-        );
132
-    }
133
-
134
-
135
-    /**
136
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
137
-     *
138
-     * @return void
139
-     */
140
-    public static function set_hooks_admin()
141
-    {
142
-        EED_Ticket_Sales_Monitor::set_hooks();
143
-    }
144
-
145
-
146
-    /**
147
-     * @return EED_Ticket_Sales_Monitor|EED_Module
148
-     */
149
-    public static function instance()
150
-    {
151
-        return parent::get_instance(__CLASS__);
152
-    }
153
-
154
-
155
-    /**
156
-     * @param WP_Query $WP_Query
157
-     * @return    void
158
-     */
159
-    public function run($WP_Query)
160
-    {
161
-    }
162
-
163
-
164
-
165
-    /********************************** PRE_TICKET_SALES  **********************************/
166
-
167
-
168
-    /**
169
-     * Retrieves grand totals from the line items that have no TXN ID
170
-     * and timestamps less than the current time minus the session lifespan.
171
-     * These are carts that have been abandoned before the "registrant" even attempted to checkout.
172
-     * We're going to release the tickets for these line items before attempting to add more to the cart.
173
-     *
174
-     * @return void
175
-     * @throws DomainException
176
-     * @throws EE_Error
177
-     * @throws InvalidArgumentException
178
-     * @throws InvalidDataTypeException
179
-     * @throws InvalidInterfaceException
180
-     * @throws UnexpectedEntityException
181
-     */
182
-    public static function release_tickets_for_expired_carts()
183
-    {
184
-        if (self::debug) {
185
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '()';
186
-        }
187
-        do_action('AHEE__EED_Ticket_Sales_Monitor__release_tickets_for_expired_carts__begin');
188
-        $expired_ticket_IDs = array();
189
-        /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
190
-        $session_lifespan = LoaderFactory::getLoader()->getShared(
191
-            'EventEspresso\core\domain\values\session\SessionLifespan'
192
-        );
193
-        $timestamp = $session_lifespan->expiration();
194
-        $expired_ticket_line_items = EEM_Line_Item::instance()->getTicketLineItemsForExpiredCarts($timestamp);
195
-        if (self::debug) {
196
-            echo self::$nl . ' . time(): ' . time();
197
-            echo self::$nl . ' . time() as date: ' . date('Y-m-d H:i a');
198
-            echo self::$nl . ' . session expiration: ' . $session_lifespan->expiration();
199
-            echo self::$nl . ' . session expiration as date: ' . date('Y-m-d H:i a', $session_lifespan->expiration());
200
-            echo self::$nl . ' . timestamp: ' . $timestamp;
201
-            echo self::$nl . ' . $expired_ticket_line_items: ' . count($expired_ticket_line_items);
202
-        }
203
-        if (! empty($expired_ticket_line_items)) {
204
-            foreach ($expired_ticket_line_items as $expired_ticket_line_item) {
205
-                if (! $expired_ticket_line_item instanceof EE_Line_Item) {
206
-                    continue;
207
-                }
208
-                $expired_ticket_IDs[ $expired_ticket_line_item->OBJ_ID() ] = $expired_ticket_line_item->OBJ_ID();
209
-                if (self::debug) {
210
-                    echo self::$nl . ' . $expired_ticket_line_item->OBJ_ID(): ' . $expired_ticket_line_item->OBJ_ID();
211
-                    echo self::$nl . ' . $expired_ticket_line_item->timestamp(): '
212
-                         . date(
213
-                             'Y-m-d h:i a',
214
-                             $expired_ticket_line_item->timestamp(true)
215
-                         );
216
-                }
217
-            }
218
-            if (! empty($expired_ticket_IDs)) {
219
-                EED_Ticket_Sales_Monitor::release_reservations_for_tickets(
220
-                    \EEM_Ticket::instance()->get_tickets_with_IDs($expired_ticket_IDs),
221
-                    array(),
222
-                    __FUNCTION__
223
-                );
224
-                // now  let's get rid of expired line items so that they can't interfere with tracking
225
-                EED_Ticket_Sales_Monitor::clear_expired_line_items_with_no_transaction($timestamp);
226
-            }
227
-        }
228
-        do_action(
229
-            'AHEE__EED_Ticket_Sales_Monitor__release_tickets_for_expired_carts__end',
230
-            $expired_ticket_IDs,
231
-            $expired_ticket_line_items
232
-        );
233
-    }
234
-
235
-
236
-
237
-    /********************************** VALIDATE_TICKET_SALE  **********************************/
238
-
239
-
240
-    /**
241
-     * callback for 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data'
242
-     *
243
-     * @param int       $qty
244
-     * @param EE_Ticket $ticket
245
-     * @return bool
246
-     * @throws UnexpectedEntityException
247
-     * @throws EE_Error
248
-     */
249
-    public static function validate_ticket_sale($qty = 1, EE_Ticket $ticket)
250
-    {
251
-        $qty = absint($qty);
252
-        if ($qty > 0) {
253
-            $qty = EED_Ticket_Sales_Monitor::instance()->_validate_ticket_sale($ticket, $qty);
254
-        }
255
-        if (self::debug) {
256
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '()';
257
-            echo self::$nl . self::$nl . '<b> RETURNED QTY: ' . $qty . '</b>';
258
-        }
259
-        return $qty;
260
-    }
261
-
262
-
263
-    /**
264
-     * checks whether an individual ticket is available for purchase based on datetime, and ticket details
265
-     *
266
-     * @param   EE_Ticket $ticket
267
-     * @param int         $qty
268
-     * @return int
269
-     * @throws UnexpectedEntityException
270
-     * @throws EE_Error
271
-     */
272
-    protected function _validate_ticket_sale(EE_Ticket $ticket, $qty = 1)
273
-    {
274
-        if (self::debug) {
275
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
276
-        }
277
-        if (! $ticket instanceof EE_Ticket) {
278
-            return 0;
279
-        }
280
-        if (self::debug) {
281
-            echo self::$nl . '<b> . ticket->ID: ' . $ticket->ID() . '</b>';
282
-            echo self::$nl . ' . original ticket->reserved: ' . $ticket->reserved();
283
-        }
284
-        $ticket->refresh_from_db();
285
-        // first let's determine the ticket availability based on sales
286
-        $available = $ticket->qty('saleable');
287
-        if (self::debug) {
288
-            echo self::$nl . ' . . . ticket->qty: ' . $ticket->qty();
289
-            echo self::$nl . ' . . . ticket->sold: ' . $ticket->sold();
290
-            echo self::$nl . ' . . . ticket->reserved: ' . $ticket->reserved();
291
-            echo self::$nl . ' . . . ticket->qty(saleable): ' . $ticket->qty('saleable');
292
-            echo self::$nl . ' . . . available: ' . $available;
293
-        }
294
-        if ($available < 1) {
295
-            $this->_ticket_sold_out($ticket);
296
-            return 0;
297
-        }
298
-        if (self::debug) {
299
-            echo self::$nl . ' . . . qty: ' . $qty;
300
-        }
301
-        if ($available < $qty) {
302
-            $qty = $available;
303
-            if (self::debug) {
304
-                echo self::$nl . ' . . . QTY ADJUSTED: ' . $qty;
305
-            }
306
-            $this->_ticket_quantity_decremented($ticket);
307
-        }
308
-        if ($this->_reserve_ticket($ticket, $qty)) {
309
-            return $qty;
310
-        } else {
311
-            return 0;
312
-        }
313
-    }
314
-
315
-
316
-    /**
317
-     * increments ticket reserved based on quantity passed
318
-     *
319
-     * @param    EE_Ticket $ticket
320
-     * @param int          $quantity
321
-     * @return bool indicating success or failure
322
-     * @throws EE_Error
323
-     */
324
-    protected function _reserve_ticket(EE_Ticket $ticket, $quantity = 1)
325
-    {
326
-        if (self::debug) {
327
-            echo self::$nl . self::$nl . ' . . . INCREASE RESERVED: ' . $quantity;
328
-        }
329
-        return $ticket->increaseReserved($quantity, 'TicketSalesMonitor:' . __LINE__);
330
-    }
331
-
332
-
333
-    /**
334
-     * @param  EE_Ticket $ticket
335
-     * @param  int       $quantity
336
-     * @return bool
337
-     * @throws EE_Error
338
-     */
339
-    protected function _release_reserved_ticket(EE_Ticket $ticket, $quantity = 1)
340
-    {
341
-        if (self::debug) {
342
-            echo self::$nl . ' . . . ticket->ID: ' . $ticket->ID();
343
-            echo self::$nl . ' . . . ticket->reserved before: ' . $ticket->reserved();
344
-        }
345
-        $ticket->decreaseReserved($quantity, true, 'TicketSalesMonitor:' . __LINE__);
346
-        if (self::debug) {
347
-            echo self::$nl . ' . . . ticket->reserved after: ' . $ticket->reserved();
348
-        }
349
-        return $ticket->save() ? 1 : 0;
350
-    }
351
-
352
-
353
-    /**
354
-     * removes quantities within the ticket selector based on zero ticket availability
355
-     *
356
-     * @param    EE_Ticket $ticket
357
-     * @return    void
358
-     * @throws UnexpectedEntityException
359
-     * @throws EE_Error
360
-     */
361
-    protected function _ticket_sold_out(EE_Ticket $ticket)
362
-    {
363
-        if (self::debug) {
364
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
365
-            echo self::$nl . ' . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket);
366
-        }
367
-        $this->sold_out_tickets[] = $this->_get_ticket_and_event_name($ticket);
368
-    }
369
-
370
-
371
-    /**
372
-     * adjusts quantities within the ticket selector based on decreased ticket availability
373
-     *
374
-     * @param    EE_Ticket $ticket
375
-     * @return void
376
-     * @throws UnexpectedEntityException
377
-     * @throws EE_Error
378
-     */
379
-    protected function _ticket_quantity_decremented(EE_Ticket $ticket)
380
-    {
381
-        if (self::debug) {
382
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
383
-            echo self::$nl . ' . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket);
384
-        }
385
-        $this->decremented_tickets[] = $this->_get_ticket_and_event_name($ticket);
386
-    }
387
-
388
-
389
-    /**
390
-     * builds string out of ticket and event name
391
-     *
392
-     * @param    EE_Ticket $ticket
393
-     * @return string
394
-     * @throws UnexpectedEntityException
395
-     * @throws EE_Error
396
-     */
397
-    protected function _get_ticket_and_event_name(EE_Ticket $ticket)
398
-    {
399
-        $event = $ticket->get_related_event();
400
-        if ($event instanceof EE_Event) {
401
-            $ticket_name = sprintf(
402
-                _x('%1$s for %2$s', 'ticket name for event name', 'event_espresso'),
403
-                $ticket->name(),
404
-                $event->name()
405
-            );
406
-        } else {
407
-            $ticket_name = $ticket->name();
408
-        }
409
-        return $ticket_name;
410
-    }
411
-
412
-
413
-
414
-    /********************************** EVENT CART  **********************************/
415
-
416
-
417
-    /**
418
-     * releases or reserves ticket(s) based on quantity passed
419
-     *
420
-     * @param  EE_Line_Item $line_item
421
-     * @param  int          $quantity
422
-     * @return void
423
-     * @throws EE_Error
424
-     * @throws InvalidArgumentException
425
-     * @throws InvalidDataTypeException
426
-     * @throws InvalidInterfaceException
427
-     */
428
-    public static function ticket_quantity_updated(EE_Line_Item $line_item, $quantity = 1)
429
-    {
430
-        $ticket = EEM_Ticket::instance()->get_one_by_ID(absint($line_item->OBJ_ID()));
431
-        if ($ticket instanceof EE_Ticket) {
432
-            $ticket->add_extra_meta(
433
-                EE_Ticket::META_KEY_TICKET_RESERVATIONS,
434
-                __LINE__ . ') ' . __METHOD__ . '()'
435
-            );
436
-            if ($quantity > 0) {
437
-                EED_Ticket_Sales_Monitor::instance()->_reserve_ticket($ticket, $quantity);
438
-            } else {
439
-                EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity);
440
-            }
441
-        }
442
-    }
443
-
444
-
445
-    /**
446
-     * releases reserved ticket(s) based on quantity passed
447
-     *
448
-     * @param  EE_Ticket $ticket
449
-     * @param  int       $quantity
450
-     * @return void
451
-     * @throws EE_Error
452
-     */
453
-    public static function ticket_removed_from_cart(EE_Ticket $ticket, $quantity = 1)
454
-    {
455
-        $ticket->add_extra_meta(
456
-            EE_Ticket::META_KEY_TICKET_RESERVATIONS,
457
-            __LINE__ . ') ' . __METHOD__ . '()'
458
-        );
459
-        EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity);
460
-    }
461
-
462
-
463
-
464
-    /********************************** POST_NOTICES  **********************************/
465
-
466
-
467
-    /**
468
-     * @return void
469
-     * @throws EE_Error
470
-     * @throws InvalidArgumentException
471
-     * @throws ReflectionException
472
-     * @throws InvalidDataTypeException
473
-     * @throws InvalidInterfaceException
474
-     */
475
-    public static function post_notices()
476
-    {
477
-        EED_Ticket_Sales_Monitor::instance()->_post_notices();
478
-    }
479
-
480
-
481
-    /**
482
-     * @return void
483
-     * @throws EE_Error
484
-     * @throws InvalidArgumentException
485
-     * @throws ReflectionException
486
-     * @throws InvalidDataTypeException
487
-     * @throws InvalidInterfaceException
488
-     */
489
-    protected function _post_notices()
490
-    {
491
-        if (self::debug) {
492
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
493
-        }
494
-        $refresh_msg = '';
495
-        $none_added_msg = '';
496
-        if (defined('DOING_AJAX') && DOING_AJAX) {
497
-            $refresh_msg = __(
498
-                'Please refresh the page to view updated ticket quantities.',
499
-                'event_espresso'
500
-            );
501
-            $none_added_msg = __('No tickets were added for the event.', 'event_espresso');
502
-        }
503
-        if (! empty($this->sold_out_tickets)) {
504
-            EE_Error::add_attention(
505
-                sprintf(
506
-                    apply_filters(
507
-                        'FHEE__EED_Ticket_Sales_Monitor___post_notices__sold_out_tickets_notice',
508
-                        __(
509
-                            'We\'re sorry...%1$sThe following items have sold out since you first viewed this page, and can no longer be registered for:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%1$s%1$s%3$s%1$s%4$s%1$s',
510
-                            'event_espresso'
511
-                        )
512
-                    ),
513
-                    '<br />',
514
-                    implode('<br />', $this->sold_out_tickets),
515
-                    $none_added_msg,
516
-                    $refresh_msg
517
-                )
518
-            );
519
-            // alter code flow in the Ticket Selector for better UX
520
-            add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', '__return_true');
521
-            add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__success', '__return_false');
522
-            $this->sold_out_tickets = array();
523
-            // and reset the cart
524
-            EED_Ticket_Sales_Monitor::session_cart_reset(EE_Registry::instance()->SSN);
525
-        }
526
-        if (! empty($this->decremented_tickets)) {
527
-            EE_Error::add_attention(
528
-                sprintf(
529
-                    apply_filters(
530
-                        'FHEE__EED_Ticket_Sales_Monitor___ticket_quantity_decremented__notice',
531
-                        __(
532
-                            'We\'re sorry...%1$sDue to sales that have occurred since you first viewed the last page, the following items have had their quantities adjusted to match the current available amount:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%1$s%1$s%3$s%1$s%4$s%1$s',
533
-                            'event_espresso'
534
-                        )
535
-                    ),
536
-                    '<br />',
537
-                    implode('<br />', $this->decremented_tickets),
538
-                    $none_added_msg,
539
-                    $refresh_msg
540
-                )
541
-            );
542
-            $this->decremented_tickets = array();
543
-        }
544
-    }
545
-
546
-
547
-
548
-    /********************************** RELEASE_ALL_RESERVED_TICKETS_FOR_TRANSACTION  **********************************/
549
-
550
-
551
-    /**
552
-     * releases reserved tickets for all registrations of an EE_Transaction
553
-     * by default, will NOT release tickets for finalized transactions
554
-     *
555
-     * @param    EE_Transaction $transaction
556
-     * @return int
557
-     * @throws EE_Error
558
-     * @throws InvalidSessionDataException
559
-     */
560
-    protected function _release_all_reserved_tickets_for_transaction(EE_Transaction $transaction)
561
-    {
562
-        if (self::debug) {
563
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
564
-            echo self::$nl . ' . transaction->ID: ' . $transaction->ID();
565
-            echo self::$nl . ' . TXN status_ID: ' . $transaction->status_ID();
566
-        }
567
-        // check if 'finalize_registration' step has been completed...
568
-        $finalized = $transaction->reg_step_completed('finalize_registration');
569
-        if (self::debug) {
570
-            // DEBUG LOG
571
-            EEH_Debug_Tools::log(
572
-                __CLASS__,
573
-                __FUNCTION__,
574
-                __LINE__,
575
-                array('finalized' => $finalized),
576
-                false,
577
-                'EE_Transaction: ' . $transaction->ID()
578
-            );
579
-        }
580
-        // how many tickets were released
581
-        $count = 0;
582
-        if (self::debug) {
583
-            echo self::$nl . ' . . . TXN finalized: ' . $finalized;
584
-        }
585
-        $release_tickets_with_TXN_status = array(
586
-            EEM_Transaction::failed_status_code,
587
-            EEM_Transaction::abandoned_status_code,
588
-            EEM_Transaction::incomplete_status_code,
589
-        );
590
-        $events = array();
591
-        // if the session is getting cleared BEFORE the TXN has been finalized or the transaction is not completed
592
-        if (! $finalized || in_array($transaction->status_ID(), $release_tickets_with_TXN_status, true)) {
593
-            // cancel any reserved tickets for registrations that were not approved
594
-            $registrations = $transaction->registrations();
595
-            if (self::debug) {
596
-                echo self::$nl . ' . . . # registrations: ' . count($registrations);
597
-                $reg = reset($registrations);
598
-                $ticket = $reg->ticket();
599
-                if ($ticket instanceof EE_Ticket) {
600
-                    $ticket->add_extra_meta(
601
-                        EE_Ticket::META_KEY_TICKET_RESERVATIONS,
602
-                        __LINE__ . ') Release All Tickets TXN:' . $transaction->ID()
603
-                    );
604
-                }
605
-            }
606
-            if (! empty($registrations)) {
607
-                foreach ($registrations as $registration) {
608
-                    if ($registration instanceof EE_Registration
609
-                        && $this->_release_reserved_ticket_for_registration($registration, $transaction)
610
-                    ) {
611
-                        $count++;
612
-                        $events[ $registration->event_ID() ] = $registration->event();
613
-                    }
614
-                }
615
-            }
616
-        }
617
-        if ($events !== array()) {
618
-            foreach ($events as $event) {
619
-                /** @var EE_Event $event */
620
-                $event->perform_sold_out_status_check();
621
-            }
622
-        }
623
-        return $count;
624
-    }
625
-
626
-
627
-    /**
628
-     * releases reserved tickets for an EE_Registration
629
-     * by default, will NOT release tickets for APPROVED registrations
630
-     *
631
-     * @param EE_Registration $registration
632
-     * @param EE_Transaction  $transaction
633
-     * @return int
634
-     * @throws EE_Error
635
-     */
636
-    protected function _release_reserved_ticket_for_registration(
637
-        EE_Registration $registration,
638
-        EE_Transaction $transaction
639
-    ) {
640
-        $STS_ID = $transaction->status_ID();
641
-        if (self::debug) {
642
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
643
-            echo self::$nl . ' . . registration->ID: ' . $registration->ID();
644
-            echo self::$nl . ' . . registration->status_ID: ' . $registration->status_ID();
645
-            echo self::$nl . ' . . transaction->status_ID(): ' . $STS_ID;
646
-        }
647
-        if (// release Tickets for Failed Transactions and Abandoned Transactions
648
-            $STS_ID === EEM_Transaction::failed_status_code
649
-            || $STS_ID === EEM_Transaction::abandoned_status_code
650
-            || (
651
-                // also release Tickets for Incomplete Transactions, but ONLY if the Registrations are NOT Approved
652
-                $STS_ID === EEM_Transaction::incomplete_status_code
653
-                && $registration->status_ID() !== EEM_Registration::status_id_approved
654
-            )
655
-        ) {
656
-            if (self::debug) {
657
-                echo self::$nl . self::$nl . ' . . RELEASE RESERVED TICKET';
658
-                $rsrvd = $registration->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true);
659
-                echo self::$nl . ' . . . registration HAS_RESERVED_TICKET_KEY: ';
660
-                var_dump($rsrvd);
661
-            }
662
-            $registration->release_reserved_ticket(true, 'TicketSalesMonitor:' . __LINE__);
663
-            return 1;
664
-        }
665
-        return 0;
666
-    }
667
-
668
-
669
-
670
-    /********************************** SESSION_CART_RESET  **********************************/
671
-
672
-
673
-    /**
674
-     * callback hooked into 'AHEE__EE_Session__reset_cart__before_reset'
675
-     *
676
-     * @param EE_Session $session
677
-     * @return void
678
-     * @throws EE_Error
679
-     * @throws InvalidArgumentException
680
-     * @throws ReflectionException
681
-     * @throws InvalidDataTypeException
682
-     * @throws InvalidInterfaceException
683
-     */
684
-    public static function session_cart_reset(EE_Session $session)
685
-    {
686
-        // don't release tickets if checkout was already reset
687
-        if (did_action('AHEE__EE_Session__reset_checkout__before_reset')) {
688
-            return;
689
-        }
690
-        if (self::debug) {
691
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
692
-        }
693
-        // first check of the session has a valid Checkout object
694
-        $checkout = $session->checkout();
695
-        if ($checkout instanceof EE_Checkout) {
696
-            // and use that to clear ticket reservations because it will update the associated registration meta data
697
-            EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset($checkout);
698
-            return;
699
-        }
700
-        $cart = $session->cart();
701
-        if ($cart instanceof EE_Cart) {
702
-            if (self::debug) {
703
-                echo self::$nl . self::$nl . ' cart instance of EE_Cart: ';
704
-            }
705
-            EED_Ticket_Sales_Monitor::instance()->_session_cart_reset($cart, $session);
706
-        } else {
707
-            if (self::debug) {
708
-                echo self::$nl . self::$nl . ' invalid EE_Cart: ';
709
-                var_export($cart, true);
710
-            }
711
-        }
712
-    }
713
-
714
-
715
-    /**
716
-     * releases reserved tickets in the EE_Cart
717
-     *
718
-     * @param EE_Cart $cart
719
-     * @return void
720
-     * @throws EE_Error
721
-     * @throws InvalidArgumentException
722
-     * @throws ReflectionException
723
-     * @throws InvalidDataTypeException
724
-     * @throws InvalidInterfaceException
725
-     */
726
-    protected function _session_cart_reset(EE_Cart $cart, EE_Session $session)
727
-    {
728
-        if (self::debug) {
729
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
730
-        }
731
-        $ticket_line_items = $cart->get_tickets();
732
-        if (empty($ticket_line_items)) {
733
-            return;
734
-        }
735
-        if (self::debug) {
736
-            echo '<br /> . ticket_line_item count: ' . count($ticket_line_items);
737
-        }
738
-        foreach ($ticket_line_items as $ticket_line_item) {
739
-            if (self::debug) {
740
-                echo self::$nl . ' . ticket_line_item->ID(): ' . $ticket_line_item->ID();
741
-            }
742
-            if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() === 'Ticket') {
743
-                if (self::debug) {
744
-                    echo self::$nl . ' . . ticket_line_item->OBJ_ID(): ' . $ticket_line_item->OBJ_ID();
745
-                }
746
-                $ticket = EEM_Ticket::instance()->get_one_by_ID($ticket_line_item->OBJ_ID());
747
-                if ($ticket instanceof EE_Ticket) {
748
-                    if (self::debug) {
749
-                        echo self::$nl . ' . . ticket->ID(): ' . $ticket->ID();
750
-                        echo self::$nl . ' . . ticket_line_item->quantity(): ' . $ticket_line_item->quantity();
751
-                    }
752
-                    $ticket->add_extra_meta(
753
-                        EE_Ticket::META_KEY_TICKET_RESERVATIONS,
754
-                        __LINE__ . ') ' . __METHOD__ . '() SID = ' . $session->id()
755
-                    );
756
-                    $this->_release_reserved_ticket($ticket, $ticket_line_item->quantity());
757
-                }
758
-            }
759
-        }
760
-        if (self::debug) {
761
-            echo self::$nl . self::$nl . ' RESET COMPLETED ';
762
-        }
763
-    }
764
-
765
-
766
-
767
-    /********************************** SESSION_CHECKOUT_RESET  **********************************/
768
-
769
-
770
-    /**
771
-     * callback hooked into 'AHEE__EE_Session__reset_checkout__before_reset'
772
-     *
773
-     * @param EE_Session $session
774
-     * @return void
775
-     * @throws EE_Error
776
-     * @throws InvalidSessionDataException
777
-     */
778
-    public static function session_checkout_reset(EE_Session $session)
779
-    {
780
-        // don't release tickets if cart was already reset
781
-        if (did_action('AHEE__EE_Session__reset_cart__before_reset')) {
782
-            return;
783
-        }
784
-        $checkout = $session->checkout();
785
-        if ($checkout instanceof EE_Checkout) {
786
-            EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset($checkout);
787
-        }
788
-    }
789
-
790
-
791
-    /**
792
-     * releases reserved tickets for the EE_Checkout->transaction
793
-     *
794
-     * @param EE_Checkout $checkout
795
-     * @return void
796
-     * @throws EE_Error
797
-     * @throws InvalidSessionDataException
798
-     */
799
-    protected function _session_checkout_reset(EE_Checkout $checkout)
800
-    {
801
-        if (self::debug) {
802
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
803
-        }
804
-        // we want to release the each registration's reserved tickets if the session was cleared, but not if this is a revisit
805
-        if ($checkout->revisit || ! $checkout->transaction instanceof EE_Transaction) {
806
-            return;
807
-        }
808
-        $this->_release_all_reserved_tickets_for_transaction($checkout->transaction);
809
-    }
810
-
811
-
812
-
813
-    /********************************** SESSION_EXPIRED_RESET  **********************************/
814
-
815
-
816
-    /**
817
-     * @param    EE_Session $session
818
-     * @return    void
819
-     */
820
-    public static function session_expired_reset(EE_Session $session)
821
-    {
822
-    }
823
-
824
-
825
-
826
-    /********************************** PROCESS_ABANDONED_TRANSACTIONS  **********************************/
827
-
828
-
829
-    /**
830
-     * releases reserved tickets for all registrations of an ABANDONED EE_Transaction
831
-     * by default, will NOT release tickets for free transactions, or any that have received a payment
832
-     *
833
-     * @param EE_Transaction $transaction
834
-     * @return void
835
-     * @throws EE_Error
836
-     * @throws InvalidSessionDataException
837
-     */
838
-    public static function process_abandoned_transactions(EE_Transaction $transaction)
839
-    {
840
-        // is this TXN free or has any money been paid towards this TXN? If so, then leave it alone
841
-        if ($transaction->is_free() || $transaction->paid() > 0) {
842
-            if (self::debug) {
843
-                // DEBUG LOG
844
-                EEH_Debug_Tools::log(
845
-                    __CLASS__,
846
-                    __FUNCTION__,
847
-                    __LINE__,
848
-                    array($transaction),
849
-                    false,
850
-                    'EE_Transaction: ' . $transaction->ID()
851
-                );
852
-            }
853
-            return;
854
-        }
855
-        // have their been any successful payments made ?
856
-        $payments = $transaction->payments();
857
-        foreach ($payments as $payment) {
858
-            if ($payment instanceof EE_Payment && $payment->status() === EEM_Payment::status_id_approved) {
859
-                if (self::debug) {
860
-                    // DEBUG LOG
861
-                    EEH_Debug_Tools::log(
862
-                        __CLASS__,
863
-                        __FUNCTION__,
864
-                        __LINE__,
865
-                        array($payment),
866
-                        false,
867
-                        'EE_Transaction: ' . $transaction->ID()
868
-                    );
869
-                }
870
-                return;
871
-            }
872
-        }
873
-        // since you haven't even attempted to pay for your ticket...
874
-        EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction);
875
-    }
876
-
877
-
878
-
879
-    /********************************** PROCESS_FAILED_TRANSACTIONS  **********************************/
880
-
881
-
882
-    /**
883
-     * releases reserved tickets for absolutely ALL registrations of a FAILED EE_Transaction
884
-     *
885
-     * @param EE_Transaction $transaction
886
-     * @return void
887
-     * @throws EE_Error
888
-     * @throws InvalidSessionDataException
889
-     */
890
-    public static function process_failed_transactions(EE_Transaction $transaction)
891
-    {
892
-        // since you haven't even attempted to pay for your ticket...
893
-        EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction);
894
-    }
895
-
896
-
897
-
898
-    /********************************** RESET RESERVATION COUNTS  *********************************/
899
-
900
-
901
-    /**
902
-     * Resets the ticket and datetime reserved counts.
903
-     *
904
-     * For all the tickets with reservations, recalculates what their actual reserved counts should be based
905
-     * on the valid transactions.
906
-     *
907
-     * @return int number of tickets whose reservations were released.
908
-     * @throws EE_Error
909
-     * @throws DomainException
910
-     * @throws InvalidDataTypeException
911
-     * @throws InvalidInterfaceException
912
-     * @throws InvalidArgumentException
913
-     * @throws UnexpectedEntityException
914
-     * @throws ReflectionException
915
-     */
916
-    public static function reset_reservation_counts()
917
-    {
918
-        /** @var EE_Line_Item[] $valid_reserved_tickets */
919
-        $valid_reserved_tickets = array();
920
-        /** @var EE_Transaction[] $transactions_in_progress */
921
-        $transactions_in_progress = EEM_Transaction::instance()->get_transactions_in_progress();
922
-        foreach ($transactions_in_progress as $transaction) {
923
-            // if this TXN has been fully completed, then skip it
924
-            if ($transaction->reg_step_completed('finalize_registration')) {
925
-                continue;
926
-            }
927
-            $total_line_item = $transaction->total_line_item();
928
-            // $transaction_in_progress->line
929
-            if (! $total_line_item instanceof EE_Line_Item) {
930
-                throw new DomainException(
931
-                    esc_html__(
932
-                        'Transaction does not have a valid Total Line Item associated with it.',
933
-                        'event_espresso'
934
-                    )
935
-                );
936
-            }
937
-            $valid_reserved_tickets += EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total(
938
-                $total_line_item
939
-            );
940
-        }
941
-        $total_line_items = EEM_Line_Item::instance()->get_total_line_items_for_active_carts();
942
-        foreach ($total_line_items as $total_line_item) {
943
-            $valid_reserved_tickets += EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total(
944
-                $total_line_item
945
-            );
946
-        }
947
-        $tickets_with_reservations = EEM_Ticket::instance()->get_tickets_with_reservations();
948
-        return EED_Ticket_Sales_Monitor::release_reservations_for_tickets(
949
-            $tickets_with_reservations,
950
-            $valid_reserved_tickets,
951
-            __FUNCTION__
952
-        );
953
-    }
954
-
955
-
956
-    /**
957
-     * @param EE_Line_Item $total_line_item
958
-     * @return EE_Line_Item[]
959
-     */
960
-    private static function get_ticket_line_items_for_grand_total(EE_Line_Item $total_line_item)
961
-    {
962
-        /** @var EE_Line_Item[] $valid_reserved_tickets */
963
-        $valid_reserved_tickets = array();
964
-        $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item);
965
-        foreach ($ticket_line_items as $ticket_line_item) {
966
-            if ($ticket_line_item instanceof EE_Line_Item) {
967
-                $valid_reserved_tickets[ $ticket_line_item->ID() ] = $ticket_line_item;
968
-            }
969
-        }
970
-        return $valid_reserved_tickets;
971
-    }
972
-
973
-
974
-    /**
975
-     * Releases ticket and datetime reservations (ie, reduces the number of reserved spots on them).
976
-     *
977
-     * Given the list of tickets which have reserved spots on them, uses the complete list of line items for tickets
978
-     * whose transactions aren't complete and also aren't yet expired (ie, they're incomplete and younger than the
979
-     * session's expiry time) to update the ticket (and their datetimes') reserved counts.
980
-     *
981
-     * @param EE_Ticket[]    $tickets_with_reservations all tickets with TKT_reserved > 0
982
-     * @param EE_Line_Item[] $valid_reserved_ticket_line_items all line items for tickets and incomplete transactions
983
-     *                       whose session has NOT expired. We will use these to determine the number of ticket
984
-     *                       reservations are now invalid. We don't use the list of invalid ticket line items because
985
-     *                       we don't know which of those have already been taken into account when reducing ticket
986
-     *                       reservation counts, and which haven't.
987
-     * @return int
988
-     * @throws UnexpectedEntityException
989
-     * @throws DomainException
990
-     * @throws EE_Error
991
-     */
992
-    protected static function release_reservations_for_tickets(
993
-        array $tickets_with_reservations,
994
-        array $valid_reserved_ticket_line_items = array(),
995
-        $source
996
-    ) {
997
-        $total_tickets_released = 0;
998
-        $sold_out_events = array();
999
-        foreach ($tickets_with_reservations as $ticket_with_reservations) {
1000
-            if (! $ticket_with_reservations instanceof EE_Ticket) {
1001
-                continue;
1002
-            }
1003
-            // The $valid_reserved_ticket_line_items tells us what the reserved count on their tickets (and datetimes)
1004
-            // SHOULD be. Instead of just directly updating the list, we're going to use EE_Ticket::decreaseReserved()
1005
-            // to try to avoid race conditions, so instead of just finding the number to update TO, we're going to find
1006
-            // the number to RELEASE. It's the same end result, just different path.
1007
-            // Begin by assuming we're going to release all the reservations on this ticket.
1008
-            $expired_reservations_count = $ticket_with_reservations->reserved();
1009
-            // Now reduce that number using the list of current valid reservations.
1010
-            foreach ($valid_reserved_ticket_line_items as $valid_reserved_ticket_line_item) {
1011
-                if ($valid_reserved_ticket_line_item instanceof EE_Line_Item
1012
-                    && $valid_reserved_ticket_line_item->OBJ_ID() === $ticket_with_reservations->ID()
1013
-                ) {
1014
-                    $expired_reservations_count -= $valid_reserved_ticket_line_item->quantity();
1015
-                }
1016
-            }
1017
-            // Only bother saving the tickets and datetimes if we're actually going to release some spots.
1018
-            if ($expired_reservations_count > 0) {
1019
-                $ticket_with_reservations->add_extra_meta(
1020
-                    EE_Ticket::META_KEY_TICKET_RESERVATIONS,
1021
-                    __LINE__ . ') ' . $source . '()'
1022
-                );
1023
-                $ticket_with_reservations->decreaseReserved($expired_reservations_count, true, 'TicketSalesMonitor:' . __LINE__);
1024
-                $total_tickets_released += $expired_reservations_count;
1025
-                $event = $ticket_with_reservations->get_related_event();
1026
-                // track sold out events
1027
-                if ($event instanceof EE_Event && $event->is_sold_out()) {
1028
-                    $sold_out_events[] = $event;
1029
-                }
1030
-            }
1031
-        }
1032
-        // Double check whether sold out events should remain sold out after releasing tickets
1033
-        if ($sold_out_events !== array()) {
1034
-            foreach ($sold_out_events as $sold_out_event) {
1035
-                /** @var EE_Event $sold_out_event */
1036
-                $sold_out_event->perform_sold_out_status_check();
1037
-            }
1038
-        }
1039
-        return $total_tickets_released;
1040
-    }
1041
-
1042
-
1043
-
1044
-    /********************************** SHUTDOWN  **********************************/
1045
-
1046
-
1047
-    /**
1048
-     * @param int $timestamp
1049
-     * @return false|int
1050
-     * @throws EE_Error
1051
-     * @throws InvalidArgumentException
1052
-     * @throws InvalidDataTypeException
1053
-     * @throws InvalidInterfaceException
1054
-     */
1055
-    public static function clear_expired_line_items_with_no_transaction($timestamp = 0)
1056
-    {
1057
-        /** @type WPDB $wpdb */
1058
-        global $wpdb;
1059
-        if (! absint($timestamp)) {
1060
-            /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
1061
-            $session_lifespan = LoaderFactory::getLoader()->getShared(
1062
-                'EventEspresso\core\domain\values\session\SessionLifespan'
1063
-            );
1064
-            $timestamp = $session_lifespan->expiration();
1065
-        }
1066
-        return $wpdb->query(
1067
-            $wpdb->prepare(
1068
-                'DELETE FROM ' . EEM_Line_Item::instance()->table() . '
23
+	const debug = false;
24
+
25
+	private static $nl = '';
26
+
27
+	/**
28
+	 * an array of raw ticket data from EED_Ticket_Selector
29
+	 *
30
+	 * @var array $ticket_selections
31
+	 */
32
+	protected $ticket_selections = array();
33
+
34
+	/**
35
+	 * the raw ticket data from EED_Ticket_Selector is organized in rows
36
+	 * according to how they are displayed in the actual Ticket_Selector
37
+	 * this tracks the current row being processed
38
+	 *
39
+	 * @var int $current_row
40
+	 */
41
+	protected $current_row = 0;
42
+
43
+	/**
44
+	 * an array for tracking names of tickets that have sold out
45
+	 *
46
+	 * @var array $sold_out_tickets
47
+	 */
48
+	protected $sold_out_tickets = array();
49
+
50
+	/**
51
+	 * an array for tracking names of tickets that have had their quantities reduced
52
+	 *
53
+	 * @var array $decremented_tickets
54
+	 */
55
+	protected $decremented_tickets = array();
56
+
57
+
58
+	/**
59
+	 * set_hooks - for hooking into EE Core, other modules, etc
60
+	 *
61
+	 * @return    void
62
+	 */
63
+	public static function set_hooks()
64
+	{
65
+		self::$nl = defined('EE_TESTS_DIR') ? "\n" : '<br />';
66
+		// release tickets for expired carts
67
+		add_action(
68
+			'EED_Ticket_Selector__process_ticket_selections__before',
69
+			array('EED_Ticket_Sales_Monitor', 'release_tickets_for_expired_carts'),
70
+			1
71
+		);
72
+		// check ticket reserves AFTER MER does it's check (hence priority 20)
73
+		add_filter(
74
+			'FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty',
75
+			array('EED_Ticket_Sales_Monitor', 'validate_ticket_sale'),
76
+			20,
77
+			3
78
+		);
79
+		// add notices for sold out tickets
80
+		add_action(
81
+			'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
82
+			array('EED_Ticket_Sales_Monitor', 'post_notices'),
83
+			10
84
+		);
85
+
86
+		// handle tickets deleted from cart
87
+		add_action(
88
+			'FHEE__EED_Multi_Event_Registration__delete_ticket__ticket_removed_from_cart',
89
+			array('EED_Ticket_Sales_Monitor', 'ticket_removed_from_cart'),
90
+			10,
91
+			2
92
+		);
93
+		// handle emptied carts
94
+		add_action(
95
+			'AHEE__EE_Session__reset_cart__before_reset',
96
+			array('EED_Ticket_Sales_Monitor', 'session_cart_reset'),
97
+			10,
98
+			1
99
+		);
100
+		add_action(
101
+			'AHEE__EED_Multi_Event_Registration__empty_event_cart__before_delete_cart',
102
+			array('EED_Ticket_Sales_Monitor', 'session_cart_reset'),
103
+			10,
104
+			1
105
+		);
106
+		// handle cancelled registrations
107
+		add_action(
108
+			'AHEE__EE_Session__reset_checkout__before_reset',
109
+			array('EED_Ticket_Sales_Monitor', 'session_checkout_reset'),
110
+			10,
111
+			1
112
+		);
113
+		// cron tasks
114
+		add_action(
115
+			'AHEE__EE_Cron_Tasks__process_expired_transactions__abandoned_transaction',
116
+			array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'),
117
+			10,
118
+			1
119
+		);
120
+		add_action(
121
+			'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction',
122
+			array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'),
123
+			10,
124
+			1
125
+		);
126
+		add_action(
127
+			'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction',
128
+			array('EED_Ticket_Sales_Monitor', 'process_failed_transactions'),
129
+			10,
130
+			1
131
+		);
132
+	}
133
+
134
+
135
+	/**
136
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
137
+	 *
138
+	 * @return void
139
+	 */
140
+	public static function set_hooks_admin()
141
+	{
142
+		EED_Ticket_Sales_Monitor::set_hooks();
143
+	}
144
+
145
+
146
+	/**
147
+	 * @return EED_Ticket_Sales_Monitor|EED_Module
148
+	 */
149
+	public static function instance()
150
+	{
151
+		return parent::get_instance(__CLASS__);
152
+	}
153
+
154
+
155
+	/**
156
+	 * @param WP_Query $WP_Query
157
+	 * @return    void
158
+	 */
159
+	public function run($WP_Query)
160
+	{
161
+	}
162
+
163
+
164
+
165
+	/********************************** PRE_TICKET_SALES  **********************************/
166
+
167
+
168
+	/**
169
+	 * Retrieves grand totals from the line items that have no TXN ID
170
+	 * and timestamps less than the current time minus the session lifespan.
171
+	 * These are carts that have been abandoned before the "registrant" even attempted to checkout.
172
+	 * We're going to release the tickets for these line items before attempting to add more to the cart.
173
+	 *
174
+	 * @return void
175
+	 * @throws DomainException
176
+	 * @throws EE_Error
177
+	 * @throws InvalidArgumentException
178
+	 * @throws InvalidDataTypeException
179
+	 * @throws InvalidInterfaceException
180
+	 * @throws UnexpectedEntityException
181
+	 */
182
+	public static function release_tickets_for_expired_carts()
183
+	{
184
+		if (self::debug) {
185
+			echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '()';
186
+		}
187
+		do_action('AHEE__EED_Ticket_Sales_Monitor__release_tickets_for_expired_carts__begin');
188
+		$expired_ticket_IDs = array();
189
+		/** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
190
+		$session_lifespan = LoaderFactory::getLoader()->getShared(
191
+			'EventEspresso\core\domain\values\session\SessionLifespan'
192
+		);
193
+		$timestamp = $session_lifespan->expiration();
194
+		$expired_ticket_line_items = EEM_Line_Item::instance()->getTicketLineItemsForExpiredCarts($timestamp);
195
+		if (self::debug) {
196
+			echo self::$nl . ' . time(): ' . time();
197
+			echo self::$nl . ' . time() as date: ' . date('Y-m-d H:i a');
198
+			echo self::$nl . ' . session expiration: ' . $session_lifespan->expiration();
199
+			echo self::$nl . ' . session expiration as date: ' . date('Y-m-d H:i a', $session_lifespan->expiration());
200
+			echo self::$nl . ' . timestamp: ' . $timestamp;
201
+			echo self::$nl . ' . $expired_ticket_line_items: ' . count($expired_ticket_line_items);
202
+		}
203
+		if (! empty($expired_ticket_line_items)) {
204
+			foreach ($expired_ticket_line_items as $expired_ticket_line_item) {
205
+				if (! $expired_ticket_line_item instanceof EE_Line_Item) {
206
+					continue;
207
+				}
208
+				$expired_ticket_IDs[ $expired_ticket_line_item->OBJ_ID() ] = $expired_ticket_line_item->OBJ_ID();
209
+				if (self::debug) {
210
+					echo self::$nl . ' . $expired_ticket_line_item->OBJ_ID(): ' . $expired_ticket_line_item->OBJ_ID();
211
+					echo self::$nl . ' . $expired_ticket_line_item->timestamp(): '
212
+						 . date(
213
+							 'Y-m-d h:i a',
214
+							 $expired_ticket_line_item->timestamp(true)
215
+						 );
216
+				}
217
+			}
218
+			if (! empty($expired_ticket_IDs)) {
219
+				EED_Ticket_Sales_Monitor::release_reservations_for_tickets(
220
+					\EEM_Ticket::instance()->get_tickets_with_IDs($expired_ticket_IDs),
221
+					array(),
222
+					__FUNCTION__
223
+				);
224
+				// now  let's get rid of expired line items so that they can't interfere with tracking
225
+				EED_Ticket_Sales_Monitor::clear_expired_line_items_with_no_transaction($timestamp);
226
+			}
227
+		}
228
+		do_action(
229
+			'AHEE__EED_Ticket_Sales_Monitor__release_tickets_for_expired_carts__end',
230
+			$expired_ticket_IDs,
231
+			$expired_ticket_line_items
232
+		);
233
+	}
234
+
235
+
236
+
237
+	/********************************** VALIDATE_TICKET_SALE  **********************************/
238
+
239
+
240
+	/**
241
+	 * callback for 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data'
242
+	 *
243
+	 * @param int       $qty
244
+	 * @param EE_Ticket $ticket
245
+	 * @return bool
246
+	 * @throws UnexpectedEntityException
247
+	 * @throws EE_Error
248
+	 */
249
+	public static function validate_ticket_sale($qty = 1, EE_Ticket $ticket)
250
+	{
251
+		$qty = absint($qty);
252
+		if ($qty > 0) {
253
+			$qty = EED_Ticket_Sales_Monitor::instance()->_validate_ticket_sale($ticket, $qty);
254
+		}
255
+		if (self::debug) {
256
+			echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '()';
257
+			echo self::$nl . self::$nl . '<b> RETURNED QTY: ' . $qty . '</b>';
258
+		}
259
+		return $qty;
260
+	}
261
+
262
+
263
+	/**
264
+	 * checks whether an individual ticket is available for purchase based on datetime, and ticket details
265
+	 *
266
+	 * @param   EE_Ticket $ticket
267
+	 * @param int         $qty
268
+	 * @return int
269
+	 * @throws UnexpectedEntityException
270
+	 * @throws EE_Error
271
+	 */
272
+	protected function _validate_ticket_sale(EE_Ticket $ticket, $qty = 1)
273
+	{
274
+		if (self::debug) {
275
+			echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
276
+		}
277
+		if (! $ticket instanceof EE_Ticket) {
278
+			return 0;
279
+		}
280
+		if (self::debug) {
281
+			echo self::$nl . '<b> . ticket->ID: ' . $ticket->ID() . '</b>';
282
+			echo self::$nl . ' . original ticket->reserved: ' . $ticket->reserved();
283
+		}
284
+		$ticket->refresh_from_db();
285
+		// first let's determine the ticket availability based on sales
286
+		$available = $ticket->qty('saleable');
287
+		if (self::debug) {
288
+			echo self::$nl . ' . . . ticket->qty: ' . $ticket->qty();
289
+			echo self::$nl . ' . . . ticket->sold: ' . $ticket->sold();
290
+			echo self::$nl . ' . . . ticket->reserved: ' . $ticket->reserved();
291
+			echo self::$nl . ' . . . ticket->qty(saleable): ' . $ticket->qty('saleable');
292
+			echo self::$nl . ' . . . available: ' . $available;
293
+		}
294
+		if ($available < 1) {
295
+			$this->_ticket_sold_out($ticket);
296
+			return 0;
297
+		}
298
+		if (self::debug) {
299
+			echo self::$nl . ' . . . qty: ' . $qty;
300
+		}
301
+		if ($available < $qty) {
302
+			$qty = $available;
303
+			if (self::debug) {
304
+				echo self::$nl . ' . . . QTY ADJUSTED: ' . $qty;
305
+			}
306
+			$this->_ticket_quantity_decremented($ticket);
307
+		}
308
+		if ($this->_reserve_ticket($ticket, $qty)) {
309
+			return $qty;
310
+		} else {
311
+			return 0;
312
+		}
313
+	}
314
+
315
+
316
+	/**
317
+	 * increments ticket reserved based on quantity passed
318
+	 *
319
+	 * @param    EE_Ticket $ticket
320
+	 * @param int          $quantity
321
+	 * @return bool indicating success or failure
322
+	 * @throws EE_Error
323
+	 */
324
+	protected function _reserve_ticket(EE_Ticket $ticket, $quantity = 1)
325
+	{
326
+		if (self::debug) {
327
+			echo self::$nl . self::$nl . ' . . . INCREASE RESERVED: ' . $quantity;
328
+		}
329
+		return $ticket->increaseReserved($quantity, 'TicketSalesMonitor:' . __LINE__);
330
+	}
331
+
332
+
333
+	/**
334
+	 * @param  EE_Ticket $ticket
335
+	 * @param  int       $quantity
336
+	 * @return bool
337
+	 * @throws EE_Error
338
+	 */
339
+	protected function _release_reserved_ticket(EE_Ticket $ticket, $quantity = 1)
340
+	{
341
+		if (self::debug) {
342
+			echo self::$nl . ' . . . ticket->ID: ' . $ticket->ID();
343
+			echo self::$nl . ' . . . ticket->reserved before: ' . $ticket->reserved();
344
+		}
345
+		$ticket->decreaseReserved($quantity, true, 'TicketSalesMonitor:' . __LINE__);
346
+		if (self::debug) {
347
+			echo self::$nl . ' . . . ticket->reserved after: ' . $ticket->reserved();
348
+		}
349
+		return $ticket->save() ? 1 : 0;
350
+	}
351
+
352
+
353
+	/**
354
+	 * removes quantities within the ticket selector based on zero ticket availability
355
+	 *
356
+	 * @param    EE_Ticket $ticket
357
+	 * @return    void
358
+	 * @throws UnexpectedEntityException
359
+	 * @throws EE_Error
360
+	 */
361
+	protected function _ticket_sold_out(EE_Ticket $ticket)
362
+	{
363
+		if (self::debug) {
364
+			echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
365
+			echo self::$nl . ' . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket);
366
+		}
367
+		$this->sold_out_tickets[] = $this->_get_ticket_and_event_name($ticket);
368
+	}
369
+
370
+
371
+	/**
372
+	 * adjusts quantities within the ticket selector based on decreased ticket availability
373
+	 *
374
+	 * @param    EE_Ticket $ticket
375
+	 * @return void
376
+	 * @throws UnexpectedEntityException
377
+	 * @throws EE_Error
378
+	 */
379
+	protected function _ticket_quantity_decremented(EE_Ticket $ticket)
380
+	{
381
+		if (self::debug) {
382
+			echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
383
+			echo self::$nl . ' . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket);
384
+		}
385
+		$this->decremented_tickets[] = $this->_get_ticket_and_event_name($ticket);
386
+	}
387
+
388
+
389
+	/**
390
+	 * builds string out of ticket and event name
391
+	 *
392
+	 * @param    EE_Ticket $ticket
393
+	 * @return string
394
+	 * @throws UnexpectedEntityException
395
+	 * @throws EE_Error
396
+	 */
397
+	protected function _get_ticket_and_event_name(EE_Ticket $ticket)
398
+	{
399
+		$event = $ticket->get_related_event();
400
+		if ($event instanceof EE_Event) {
401
+			$ticket_name = sprintf(
402
+				_x('%1$s for %2$s', 'ticket name for event name', 'event_espresso'),
403
+				$ticket->name(),
404
+				$event->name()
405
+			);
406
+		} else {
407
+			$ticket_name = $ticket->name();
408
+		}
409
+		return $ticket_name;
410
+	}
411
+
412
+
413
+
414
+	/********************************** EVENT CART  **********************************/
415
+
416
+
417
+	/**
418
+	 * releases or reserves ticket(s) based on quantity passed
419
+	 *
420
+	 * @param  EE_Line_Item $line_item
421
+	 * @param  int          $quantity
422
+	 * @return void
423
+	 * @throws EE_Error
424
+	 * @throws InvalidArgumentException
425
+	 * @throws InvalidDataTypeException
426
+	 * @throws InvalidInterfaceException
427
+	 */
428
+	public static function ticket_quantity_updated(EE_Line_Item $line_item, $quantity = 1)
429
+	{
430
+		$ticket = EEM_Ticket::instance()->get_one_by_ID(absint($line_item->OBJ_ID()));
431
+		if ($ticket instanceof EE_Ticket) {
432
+			$ticket->add_extra_meta(
433
+				EE_Ticket::META_KEY_TICKET_RESERVATIONS,
434
+				__LINE__ . ') ' . __METHOD__ . '()'
435
+			);
436
+			if ($quantity > 0) {
437
+				EED_Ticket_Sales_Monitor::instance()->_reserve_ticket($ticket, $quantity);
438
+			} else {
439
+				EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity);
440
+			}
441
+		}
442
+	}
443
+
444
+
445
+	/**
446
+	 * releases reserved ticket(s) based on quantity passed
447
+	 *
448
+	 * @param  EE_Ticket $ticket
449
+	 * @param  int       $quantity
450
+	 * @return void
451
+	 * @throws EE_Error
452
+	 */
453
+	public static function ticket_removed_from_cart(EE_Ticket $ticket, $quantity = 1)
454
+	{
455
+		$ticket->add_extra_meta(
456
+			EE_Ticket::META_KEY_TICKET_RESERVATIONS,
457
+			__LINE__ . ') ' . __METHOD__ . '()'
458
+		);
459
+		EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity);
460
+	}
461
+
462
+
463
+
464
+	/********************************** POST_NOTICES  **********************************/
465
+
466
+
467
+	/**
468
+	 * @return void
469
+	 * @throws EE_Error
470
+	 * @throws InvalidArgumentException
471
+	 * @throws ReflectionException
472
+	 * @throws InvalidDataTypeException
473
+	 * @throws InvalidInterfaceException
474
+	 */
475
+	public static function post_notices()
476
+	{
477
+		EED_Ticket_Sales_Monitor::instance()->_post_notices();
478
+	}
479
+
480
+
481
+	/**
482
+	 * @return void
483
+	 * @throws EE_Error
484
+	 * @throws InvalidArgumentException
485
+	 * @throws ReflectionException
486
+	 * @throws InvalidDataTypeException
487
+	 * @throws InvalidInterfaceException
488
+	 */
489
+	protected function _post_notices()
490
+	{
491
+		if (self::debug) {
492
+			echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
493
+		}
494
+		$refresh_msg = '';
495
+		$none_added_msg = '';
496
+		if (defined('DOING_AJAX') && DOING_AJAX) {
497
+			$refresh_msg = __(
498
+				'Please refresh the page to view updated ticket quantities.',
499
+				'event_espresso'
500
+			);
501
+			$none_added_msg = __('No tickets were added for the event.', 'event_espresso');
502
+		}
503
+		if (! empty($this->sold_out_tickets)) {
504
+			EE_Error::add_attention(
505
+				sprintf(
506
+					apply_filters(
507
+						'FHEE__EED_Ticket_Sales_Monitor___post_notices__sold_out_tickets_notice',
508
+						__(
509
+							'We\'re sorry...%1$sThe following items have sold out since you first viewed this page, and can no longer be registered for:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%1$s%1$s%3$s%1$s%4$s%1$s',
510
+							'event_espresso'
511
+						)
512
+					),
513
+					'<br />',
514
+					implode('<br />', $this->sold_out_tickets),
515
+					$none_added_msg,
516
+					$refresh_msg
517
+				)
518
+			);
519
+			// alter code flow in the Ticket Selector for better UX
520
+			add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', '__return_true');
521
+			add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__success', '__return_false');
522
+			$this->sold_out_tickets = array();
523
+			// and reset the cart
524
+			EED_Ticket_Sales_Monitor::session_cart_reset(EE_Registry::instance()->SSN);
525
+		}
526
+		if (! empty($this->decremented_tickets)) {
527
+			EE_Error::add_attention(
528
+				sprintf(
529
+					apply_filters(
530
+						'FHEE__EED_Ticket_Sales_Monitor___ticket_quantity_decremented__notice',
531
+						__(
532
+							'We\'re sorry...%1$sDue to sales that have occurred since you first viewed the last page, the following items have had their quantities adjusted to match the current available amount:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%1$s%1$s%3$s%1$s%4$s%1$s',
533
+							'event_espresso'
534
+						)
535
+					),
536
+					'<br />',
537
+					implode('<br />', $this->decremented_tickets),
538
+					$none_added_msg,
539
+					$refresh_msg
540
+				)
541
+			);
542
+			$this->decremented_tickets = array();
543
+		}
544
+	}
545
+
546
+
547
+
548
+	/********************************** RELEASE_ALL_RESERVED_TICKETS_FOR_TRANSACTION  **********************************/
549
+
550
+
551
+	/**
552
+	 * releases reserved tickets for all registrations of an EE_Transaction
553
+	 * by default, will NOT release tickets for finalized transactions
554
+	 *
555
+	 * @param    EE_Transaction $transaction
556
+	 * @return int
557
+	 * @throws EE_Error
558
+	 * @throws InvalidSessionDataException
559
+	 */
560
+	protected function _release_all_reserved_tickets_for_transaction(EE_Transaction $transaction)
561
+	{
562
+		if (self::debug) {
563
+			echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
564
+			echo self::$nl . ' . transaction->ID: ' . $transaction->ID();
565
+			echo self::$nl . ' . TXN status_ID: ' . $transaction->status_ID();
566
+		}
567
+		// check if 'finalize_registration' step has been completed...
568
+		$finalized = $transaction->reg_step_completed('finalize_registration');
569
+		if (self::debug) {
570
+			// DEBUG LOG
571
+			EEH_Debug_Tools::log(
572
+				__CLASS__,
573
+				__FUNCTION__,
574
+				__LINE__,
575
+				array('finalized' => $finalized),
576
+				false,
577
+				'EE_Transaction: ' . $transaction->ID()
578
+			);
579
+		}
580
+		// how many tickets were released
581
+		$count = 0;
582
+		if (self::debug) {
583
+			echo self::$nl . ' . . . TXN finalized: ' . $finalized;
584
+		}
585
+		$release_tickets_with_TXN_status = array(
586
+			EEM_Transaction::failed_status_code,
587
+			EEM_Transaction::abandoned_status_code,
588
+			EEM_Transaction::incomplete_status_code,
589
+		);
590
+		$events = array();
591
+		// if the session is getting cleared BEFORE the TXN has been finalized or the transaction is not completed
592
+		if (! $finalized || in_array($transaction->status_ID(), $release_tickets_with_TXN_status, true)) {
593
+			// cancel any reserved tickets for registrations that were not approved
594
+			$registrations = $transaction->registrations();
595
+			if (self::debug) {
596
+				echo self::$nl . ' . . . # registrations: ' . count($registrations);
597
+				$reg = reset($registrations);
598
+				$ticket = $reg->ticket();
599
+				if ($ticket instanceof EE_Ticket) {
600
+					$ticket->add_extra_meta(
601
+						EE_Ticket::META_KEY_TICKET_RESERVATIONS,
602
+						__LINE__ . ') Release All Tickets TXN:' . $transaction->ID()
603
+					);
604
+				}
605
+			}
606
+			if (! empty($registrations)) {
607
+				foreach ($registrations as $registration) {
608
+					if ($registration instanceof EE_Registration
609
+						&& $this->_release_reserved_ticket_for_registration($registration, $transaction)
610
+					) {
611
+						$count++;
612
+						$events[ $registration->event_ID() ] = $registration->event();
613
+					}
614
+				}
615
+			}
616
+		}
617
+		if ($events !== array()) {
618
+			foreach ($events as $event) {
619
+				/** @var EE_Event $event */
620
+				$event->perform_sold_out_status_check();
621
+			}
622
+		}
623
+		return $count;
624
+	}
625
+
626
+
627
+	/**
628
+	 * releases reserved tickets for an EE_Registration
629
+	 * by default, will NOT release tickets for APPROVED registrations
630
+	 *
631
+	 * @param EE_Registration $registration
632
+	 * @param EE_Transaction  $transaction
633
+	 * @return int
634
+	 * @throws EE_Error
635
+	 */
636
+	protected function _release_reserved_ticket_for_registration(
637
+		EE_Registration $registration,
638
+		EE_Transaction $transaction
639
+	) {
640
+		$STS_ID = $transaction->status_ID();
641
+		if (self::debug) {
642
+			echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
643
+			echo self::$nl . ' . . registration->ID: ' . $registration->ID();
644
+			echo self::$nl . ' . . registration->status_ID: ' . $registration->status_ID();
645
+			echo self::$nl . ' . . transaction->status_ID(): ' . $STS_ID;
646
+		}
647
+		if (// release Tickets for Failed Transactions and Abandoned Transactions
648
+			$STS_ID === EEM_Transaction::failed_status_code
649
+			|| $STS_ID === EEM_Transaction::abandoned_status_code
650
+			|| (
651
+				// also release Tickets for Incomplete Transactions, but ONLY if the Registrations are NOT Approved
652
+				$STS_ID === EEM_Transaction::incomplete_status_code
653
+				&& $registration->status_ID() !== EEM_Registration::status_id_approved
654
+			)
655
+		) {
656
+			if (self::debug) {
657
+				echo self::$nl . self::$nl . ' . . RELEASE RESERVED TICKET';
658
+				$rsrvd = $registration->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true);
659
+				echo self::$nl . ' . . . registration HAS_RESERVED_TICKET_KEY: ';
660
+				var_dump($rsrvd);
661
+			}
662
+			$registration->release_reserved_ticket(true, 'TicketSalesMonitor:' . __LINE__);
663
+			return 1;
664
+		}
665
+		return 0;
666
+	}
667
+
668
+
669
+
670
+	/********************************** SESSION_CART_RESET  **********************************/
671
+
672
+
673
+	/**
674
+	 * callback hooked into 'AHEE__EE_Session__reset_cart__before_reset'
675
+	 *
676
+	 * @param EE_Session $session
677
+	 * @return void
678
+	 * @throws EE_Error
679
+	 * @throws InvalidArgumentException
680
+	 * @throws ReflectionException
681
+	 * @throws InvalidDataTypeException
682
+	 * @throws InvalidInterfaceException
683
+	 */
684
+	public static function session_cart_reset(EE_Session $session)
685
+	{
686
+		// don't release tickets if checkout was already reset
687
+		if (did_action('AHEE__EE_Session__reset_checkout__before_reset')) {
688
+			return;
689
+		}
690
+		if (self::debug) {
691
+			echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
692
+		}
693
+		// first check of the session has a valid Checkout object
694
+		$checkout = $session->checkout();
695
+		if ($checkout instanceof EE_Checkout) {
696
+			// and use that to clear ticket reservations because it will update the associated registration meta data
697
+			EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset($checkout);
698
+			return;
699
+		}
700
+		$cart = $session->cart();
701
+		if ($cart instanceof EE_Cart) {
702
+			if (self::debug) {
703
+				echo self::$nl . self::$nl . ' cart instance of EE_Cart: ';
704
+			}
705
+			EED_Ticket_Sales_Monitor::instance()->_session_cart_reset($cart, $session);
706
+		} else {
707
+			if (self::debug) {
708
+				echo self::$nl . self::$nl . ' invalid EE_Cart: ';
709
+				var_export($cart, true);
710
+			}
711
+		}
712
+	}
713
+
714
+
715
+	/**
716
+	 * releases reserved tickets in the EE_Cart
717
+	 *
718
+	 * @param EE_Cart $cart
719
+	 * @return void
720
+	 * @throws EE_Error
721
+	 * @throws InvalidArgumentException
722
+	 * @throws ReflectionException
723
+	 * @throws InvalidDataTypeException
724
+	 * @throws InvalidInterfaceException
725
+	 */
726
+	protected function _session_cart_reset(EE_Cart $cart, EE_Session $session)
727
+	{
728
+		if (self::debug) {
729
+			echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
730
+		}
731
+		$ticket_line_items = $cart->get_tickets();
732
+		if (empty($ticket_line_items)) {
733
+			return;
734
+		}
735
+		if (self::debug) {
736
+			echo '<br /> . ticket_line_item count: ' . count($ticket_line_items);
737
+		}
738
+		foreach ($ticket_line_items as $ticket_line_item) {
739
+			if (self::debug) {
740
+				echo self::$nl . ' . ticket_line_item->ID(): ' . $ticket_line_item->ID();
741
+			}
742
+			if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() === 'Ticket') {
743
+				if (self::debug) {
744
+					echo self::$nl . ' . . ticket_line_item->OBJ_ID(): ' . $ticket_line_item->OBJ_ID();
745
+				}
746
+				$ticket = EEM_Ticket::instance()->get_one_by_ID($ticket_line_item->OBJ_ID());
747
+				if ($ticket instanceof EE_Ticket) {
748
+					if (self::debug) {
749
+						echo self::$nl . ' . . ticket->ID(): ' . $ticket->ID();
750
+						echo self::$nl . ' . . ticket_line_item->quantity(): ' . $ticket_line_item->quantity();
751
+					}
752
+					$ticket->add_extra_meta(
753
+						EE_Ticket::META_KEY_TICKET_RESERVATIONS,
754
+						__LINE__ . ') ' . __METHOD__ . '() SID = ' . $session->id()
755
+					);
756
+					$this->_release_reserved_ticket($ticket, $ticket_line_item->quantity());
757
+				}
758
+			}
759
+		}
760
+		if (self::debug) {
761
+			echo self::$nl . self::$nl . ' RESET COMPLETED ';
762
+		}
763
+	}
764
+
765
+
766
+
767
+	/********************************** SESSION_CHECKOUT_RESET  **********************************/
768
+
769
+
770
+	/**
771
+	 * callback hooked into 'AHEE__EE_Session__reset_checkout__before_reset'
772
+	 *
773
+	 * @param EE_Session $session
774
+	 * @return void
775
+	 * @throws EE_Error
776
+	 * @throws InvalidSessionDataException
777
+	 */
778
+	public static function session_checkout_reset(EE_Session $session)
779
+	{
780
+		// don't release tickets if cart was already reset
781
+		if (did_action('AHEE__EE_Session__reset_cart__before_reset')) {
782
+			return;
783
+		}
784
+		$checkout = $session->checkout();
785
+		if ($checkout instanceof EE_Checkout) {
786
+			EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset($checkout);
787
+		}
788
+	}
789
+
790
+
791
+	/**
792
+	 * releases reserved tickets for the EE_Checkout->transaction
793
+	 *
794
+	 * @param EE_Checkout $checkout
795
+	 * @return void
796
+	 * @throws EE_Error
797
+	 * @throws InvalidSessionDataException
798
+	 */
799
+	protected function _session_checkout_reset(EE_Checkout $checkout)
800
+	{
801
+		if (self::debug) {
802
+			echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
803
+		}
804
+		// we want to release the each registration's reserved tickets if the session was cleared, but not if this is a revisit
805
+		if ($checkout->revisit || ! $checkout->transaction instanceof EE_Transaction) {
806
+			return;
807
+		}
808
+		$this->_release_all_reserved_tickets_for_transaction($checkout->transaction);
809
+	}
810
+
811
+
812
+
813
+	/********************************** SESSION_EXPIRED_RESET  **********************************/
814
+
815
+
816
+	/**
817
+	 * @param    EE_Session $session
818
+	 * @return    void
819
+	 */
820
+	public static function session_expired_reset(EE_Session $session)
821
+	{
822
+	}
823
+
824
+
825
+
826
+	/********************************** PROCESS_ABANDONED_TRANSACTIONS  **********************************/
827
+
828
+
829
+	/**
830
+	 * releases reserved tickets for all registrations of an ABANDONED EE_Transaction
831
+	 * by default, will NOT release tickets for free transactions, or any that have received a payment
832
+	 *
833
+	 * @param EE_Transaction $transaction
834
+	 * @return void
835
+	 * @throws EE_Error
836
+	 * @throws InvalidSessionDataException
837
+	 */
838
+	public static function process_abandoned_transactions(EE_Transaction $transaction)
839
+	{
840
+		// is this TXN free or has any money been paid towards this TXN? If so, then leave it alone
841
+		if ($transaction->is_free() || $transaction->paid() > 0) {
842
+			if (self::debug) {
843
+				// DEBUG LOG
844
+				EEH_Debug_Tools::log(
845
+					__CLASS__,
846
+					__FUNCTION__,
847
+					__LINE__,
848
+					array($transaction),
849
+					false,
850
+					'EE_Transaction: ' . $transaction->ID()
851
+				);
852
+			}
853
+			return;
854
+		}
855
+		// have their been any successful payments made ?
856
+		$payments = $transaction->payments();
857
+		foreach ($payments as $payment) {
858
+			if ($payment instanceof EE_Payment && $payment->status() === EEM_Payment::status_id_approved) {
859
+				if (self::debug) {
860
+					// DEBUG LOG
861
+					EEH_Debug_Tools::log(
862
+						__CLASS__,
863
+						__FUNCTION__,
864
+						__LINE__,
865
+						array($payment),
866
+						false,
867
+						'EE_Transaction: ' . $transaction->ID()
868
+					);
869
+				}
870
+				return;
871
+			}
872
+		}
873
+		// since you haven't even attempted to pay for your ticket...
874
+		EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction);
875
+	}
876
+
877
+
878
+
879
+	/********************************** PROCESS_FAILED_TRANSACTIONS  **********************************/
880
+
881
+
882
+	/**
883
+	 * releases reserved tickets for absolutely ALL registrations of a FAILED EE_Transaction
884
+	 *
885
+	 * @param EE_Transaction $transaction
886
+	 * @return void
887
+	 * @throws EE_Error
888
+	 * @throws InvalidSessionDataException
889
+	 */
890
+	public static function process_failed_transactions(EE_Transaction $transaction)
891
+	{
892
+		// since you haven't even attempted to pay for your ticket...
893
+		EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction);
894
+	}
895
+
896
+
897
+
898
+	/********************************** RESET RESERVATION COUNTS  *********************************/
899
+
900
+
901
+	/**
902
+	 * Resets the ticket and datetime reserved counts.
903
+	 *
904
+	 * For all the tickets with reservations, recalculates what their actual reserved counts should be based
905
+	 * on the valid transactions.
906
+	 *
907
+	 * @return int number of tickets whose reservations were released.
908
+	 * @throws EE_Error
909
+	 * @throws DomainException
910
+	 * @throws InvalidDataTypeException
911
+	 * @throws InvalidInterfaceException
912
+	 * @throws InvalidArgumentException
913
+	 * @throws UnexpectedEntityException
914
+	 * @throws ReflectionException
915
+	 */
916
+	public static function reset_reservation_counts()
917
+	{
918
+		/** @var EE_Line_Item[] $valid_reserved_tickets */
919
+		$valid_reserved_tickets = array();
920
+		/** @var EE_Transaction[] $transactions_in_progress */
921
+		$transactions_in_progress = EEM_Transaction::instance()->get_transactions_in_progress();
922
+		foreach ($transactions_in_progress as $transaction) {
923
+			// if this TXN has been fully completed, then skip it
924
+			if ($transaction->reg_step_completed('finalize_registration')) {
925
+				continue;
926
+			}
927
+			$total_line_item = $transaction->total_line_item();
928
+			// $transaction_in_progress->line
929
+			if (! $total_line_item instanceof EE_Line_Item) {
930
+				throw new DomainException(
931
+					esc_html__(
932
+						'Transaction does not have a valid Total Line Item associated with it.',
933
+						'event_espresso'
934
+					)
935
+				);
936
+			}
937
+			$valid_reserved_tickets += EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total(
938
+				$total_line_item
939
+			);
940
+		}
941
+		$total_line_items = EEM_Line_Item::instance()->get_total_line_items_for_active_carts();
942
+		foreach ($total_line_items as $total_line_item) {
943
+			$valid_reserved_tickets += EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total(
944
+				$total_line_item
945
+			);
946
+		}
947
+		$tickets_with_reservations = EEM_Ticket::instance()->get_tickets_with_reservations();
948
+		return EED_Ticket_Sales_Monitor::release_reservations_for_tickets(
949
+			$tickets_with_reservations,
950
+			$valid_reserved_tickets,
951
+			__FUNCTION__
952
+		);
953
+	}
954
+
955
+
956
+	/**
957
+	 * @param EE_Line_Item $total_line_item
958
+	 * @return EE_Line_Item[]
959
+	 */
960
+	private static function get_ticket_line_items_for_grand_total(EE_Line_Item $total_line_item)
961
+	{
962
+		/** @var EE_Line_Item[] $valid_reserved_tickets */
963
+		$valid_reserved_tickets = array();
964
+		$ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item);
965
+		foreach ($ticket_line_items as $ticket_line_item) {
966
+			if ($ticket_line_item instanceof EE_Line_Item) {
967
+				$valid_reserved_tickets[ $ticket_line_item->ID() ] = $ticket_line_item;
968
+			}
969
+		}
970
+		return $valid_reserved_tickets;
971
+	}
972
+
973
+
974
+	/**
975
+	 * Releases ticket and datetime reservations (ie, reduces the number of reserved spots on them).
976
+	 *
977
+	 * Given the list of tickets which have reserved spots on them, uses the complete list of line items for tickets
978
+	 * whose transactions aren't complete and also aren't yet expired (ie, they're incomplete and younger than the
979
+	 * session's expiry time) to update the ticket (and their datetimes') reserved counts.
980
+	 *
981
+	 * @param EE_Ticket[]    $tickets_with_reservations all tickets with TKT_reserved > 0
982
+	 * @param EE_Line_Item[] $valid_reserved_ticket_line_items all line items for tickets and incomplete transactions
983
+	 *                       whose session has NOT expired. We will use these to determine the number of ticket
984
+	 *                       reservations are now invalid. We don't use the list of invalid ticket line items because
985
+	 *                       we don't know which of those have already been taken into account when reducing ticket
986
+	 *                       reservation counts, and which haven't.
987
+	 * @return int
988
+	 * @throws UnexpectedEntityException
989
+	 * @throws DomainException
990
+	 * @throws EE_Error
991
+	 */
992
+	protected static function release_reservations_for_tickets(
993
+		array $tickets_with_reservations,
994
+		array $valid_reserved_ticket_line_items = array(),
995
+		$source
996
+	) {
997
+		$total_tickets_released = 0;
998
+		$sold_out_events = array();
999
+		foreach ($tickets_with_reservations as $ticket_with_reservations) {
1000
+			if (! $ticket_with_reservations instanceof EE_Ticket) {
1001
+				continue;
1002
+			}
1003
+			// The $valid_reserved_ticket_line_items tells us what the reserved count on their tickets (and datetimes)
1004
+			// SHOULD be. Instead of just directly updating the list, we're going to use EE_Ticket::decreaseReserved()
1005
+			// to try to avoid race conditions, so instead of just finding the number to update TO, we're going to find
1006
+			// the number to RELEASE. It's the same end result, just different path.
1007
+			// Begin by assuming we're going to release all the reservations on this ticket.
1008
+			$expired_reservations_count = $ticket_with_reservations->reserved();
1009
+			// Now reduce that number using the list of current valid reservations.
1010
+			foreach ($valid_reserved_ticket_line_items as $valid_reserved_ticket_line_item) {
1011
+				if ($valid_reserved_ticket_line_item instanceof EE_Line_Item
1012
+					&& $valid_reserved_ticket_line_item->OBJ_ID() === $ticket_with_reservations->ID()
1013
+				) {
1014
+					$expired_reservations_count -= $valid_reserved_ticket_line_item->quantity();
1015
+				}
1016
+			}
1017
+			// Only bother saving the tickets and datetimes if we're actually going to release some spots.
1018
+			if ($expired_reservations_count > 0) {
1019
+				$ticket_with_reservations->add_extra_meta(
1020
+					EE_Ticket::META_KEY_TICKET_RESERVATIONS,
1021
+					__LINE__ . ') ' . $source . '()'
1022
+				);
1023
+				$ticket_with_reservations->decreaseReserved($expired_reservations_count, true, 'TicketSalesMonitor:' . __LINE__);
1024
+				$total_tickets_released += $expired_reservations_count;
1025
+				$event = $ticket_with_reservations->get_related_event();
1026
+				// track sold out events
1027
+				if ($event instanceof EE_Event && $event->is_sold_out()) {
1028
+					$sold_out_events[] = $event;
1029
+				}
1030
+			}
1031
+		}
1032
+		// Double check whether sold out events should remain sold out after releasing tickets
1033
+		if ($sold_out_events !== array()) {
1034
+			foreach ($sold_out_events as $sold_out_event) {
1035
+				/** @var EE_Event $sold_out_event */
1036
+				$sold_out_event->perform_sold_out_status_check();
1037
+			}
1038
+		}
1039
+		return $total_tickets_released;
1040
+	}
1041
+
1042
+
1043
+
1044
+	/********************************** SHUTDOWN  **********************************/
1045
+
1046
+
1047
+	/**
1048
+	 * @param int $timestamp
1049
+	 * @return false|int
1050
+	 * @throws EE_Error
1051
+	 * @throws InvalidArgumentException
1052
+	 * @throws InvalidDataTypeException
1053
+	 * @throws InvalidInterfaceException
1054
+	 */
1055
+	public static function clear_expired_line_items_with_no_transaction($timestamp = 0)
1056
+	{
1057
+		/** @type WPDB $wpdb */
1058
+		global $wpdb;
1059
+		if (! absint($timestamp)) {
1060
+			/** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
1061
+			$session_lifespan = LoaderFactory::getLoader()->getShared(
1062
+				'EventEspresso\core\domain\values\session\SessionLifespan'
1063
+			);
1064
+			$timestamp = $session_lifespan->expiration();
1065
+		}
1066
+		return $wpdb->query(
1067
+			$wpdb->prepare(
1068
+				'DELETE FROM ' . EEM_Line_Item::instance()->table() . '
1069 1069
                 WHERE TXN_ID = 0 AND LIN_timestamp <= %s',
1070
-                // use GMT time because that's what LIN_timestamps are in
1071
-                date('Y-m-d H:i:s', $timestamp)
1072
-            )
1073
-        );
1074
-    }
1070
+				// use GMT time because that's what LIN_timestamps are in
1071
+				date('Y-m-d H:i:s', $timestamp)
1072
+			)
1073
+		);
1074
+	}
1075 1075
 }
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
     public static function release_tickets_for_expired_carts()
183 183
     {
184 184
         if (self::debug) {
185
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '()';
185
+            echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'()';
186 186
         }
187 187
         do_action('AHEE__EED_Ticket_Sales_Monitor__release_tickets_for_expired_carts__begin');
188 188
         $expired_ticket_IDs = array();
@@ -193,29 +193,29 @@  discard block
 block discarded – undo
193 193
         $timestamp = $session_lifespan->expiration();
194 194
         $expired_ticket_line_items = EEM_Line_Item::instance()->getTicketLineItemsForExpiredCarts($timestamp);
195 195
         if (self::debug) {
196
-            echo self::$nl . ' . time(): ' . time();
197
-            echo self::$nl . ' . time() as date: ' . date('Y-m-d H:i a');
198
-            echo self::$nl . ' . session expiration: ' . $session_lifespan->expiration();
199
-            echo self::$nl . ' . session expiration as date: ' . date('Y-m-d H:i a', $session_lifespan->expiration());
200
-            echo self::$nl . ' . timestamp: ' . $timestamp;
201
-            echo self::$nl . ' . $expired_ticket_line_items: ' . count($expired_ticket_line_items);
196
+            echo self::$nl.' . time(): '.time();
197
+            echo self::$nl.' . time() as date: '.date('Y-m-d H:i a');
198
+            echo self::$nl.' . session expiration: '.$session_lifespan->expiration();
199
+            echo self::$nl.' . session expiration as date: '.date('Y-m-d H:i a', $session_lifespan->expiration());
200
+            echo self::$nl.' . timestamp: '.$timestamp;
201
+            echo self::$nl.' . $expired_ticket_line_items: '.count($expired_ticket_line_items);
202 202
         }
203
-        if (! empty($expired_ticket_line_items)) {
203
+        if ( ! empty($expired_ticket_line_items)) {
204 204
             foreach ($expired_ticket_line_items as $expired_ticket_line_item) {
205
-                if (! $expired_ticket_line_item instanceof EE_Line_Item) {
205
+                if ( ! $expired_ticket_line_item instanceof EE_Line_Item) {
206 206
                     continue;
207 207
                 }
208
-                $expired_ticket_IDs[ $expired_ticket_line_item->OBJ_ID() ] = $expired_ticket_line_item->OBJ_ID();
208
+                $expired_ticket_IDs[$expired_ticket_line_item->OBJ_ID()] = $expired_ticket_line_item->OBJ_ID();
209 209
                 if (self::debug) {
210
-                    echo self::$nl . ' . $expired_ticket_line_item->OBJ_ID(): ' . $expired_ticket_line_item->OBJ_ID();
211
-                    echo self::$nl . ' . $expired_ticket_line_item->timestamp(): '
210
+                    echo self::$nl.' . $expired_ticket_line_item->OBJ_ID(): '.$expired_ticket_line_item->OBJ_ID();
211
+                    echo self::$nl.' . $expired_ticket_line_item->timestamp(): '
212 212
                          . date(
213 213
                              'Y-m-d h:i a',
214 214
                              $expired_ticket_line_item->timestamp(true)
215 215
                          );
216 216
                 }
217 217
             }
218
-            if (! empty($expired_ticket_IDs)) {
218
+            if ( ! empty($expired_ticket_IDs)) {
219 219
                 EED_Ticket_Sales_Monitor::release_reservations_for_tickets(
220 220
                     \EEM_Ticket::instance()->get_tickets_with_IDs($expired_ticket_IDs),
221 221
                     array(),
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
             $qty = EED_Ticket_Sales_Monitor::instance()->_validate_ticket_sale($ticket, $qty);
254 254
         }
255 255
         if (self::debug) {
256
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '()';
257
-            echo self::$nl . self::$nl . '<b> RETURNED QTY: ' . $qty . '</b>';
256
+            echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'()';
257
+            echo self::$nl.self::$nl.'<b> RETURNED QTY: '.$qty.'</b>';
258 258
         }
259 259
         return $qty;
260 260
     }
@@ -272,36 +272,36 @@  discard block
 block discarded – undo
272 272
     protected function _validate_ticket_sale(EE_Ticket $ticket, $qty = 1)
273 273
     {
274 274
         if (self::debug) {
275
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
275
+            echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() ';
276 276
         }
277
-        if (! $ticket instanceof EE_Ticket) {
277
+        if ( ! $ticket instanceof EE_Ticket) {
278 278
             return 0;
279 279
         }
280 280
         if (self::debug) {
281
-            echo self::$nl . '<b> . ticket->ID: ' . $ticket->ID() . '</b>';
282
-            echo self::$nl . ' . original ticket->reserved: ' . $ticket->reserved();
281
+            echo self::$nl.'<b> . ticket->ID: '.$ticket->ID().'</b>';
282
+            echo self::$nl.' . original ticket->reserved: '.$ticket->reserved();
283 283
         }
284 284
         $ticket->refresh_from_db();
285 285
         // first let's determine the ticket availability based on sales
286 286
         $available = $ticket->qty('saleable');
287 287
         if (self::debug) {
288
-            echo self::$nl . ' . . . ticket->qty: ' . $ticket->qty();
289
-            echo self::$nl . ' . . . ticket->sold: ' . $ticket->sold();
290
-            echo self::$nl . ' . . . ticket->reserved: ' . $ticket->reserved();
291
-            echo self::$nl . ' . . . ticket->qty(saleable): ' . $ticket->qty('saleable');
292
-            echo self::$nl . ' . . . available: ' . $available;
288
+            echo self::$nl.' . . . ticket->qty: '.$ticket->qty();
289
+            echo self::$nl.' . . . ticket->sold: '.$ticket->sold();
290
+            echo self::$nl.' . . . ticket->reserved: '.$ticket->reserved();
291
+            echo self::$nl.' . . . ticket->qty(saleable): '.$ticket->qty('saleable');
292
+            echo self::$nl.' . . . available: '.$available;
293 293
         }
294 294
         if ($available < 1) {
295 295
             $this->_ticket_sold_out($ticket);
296 296
             return 0;
297 297
         }
298 298
         if (self::debug) {
299
-            echo self::$nl . ' . . . qty: ' . $qty;
299
+            echo self::$nl.' . . . qty: '.$qty;
300 300
         }
301 301
         if ($available < $qty) {
302 302
             $qty = $available;
303 303
             if (self::debug) {
304
-                echo self::$nl . ' . . . QTY ADJUSTED: ' . $qty;
304
+                echo self::$nl.' . . . QTY ADJUSTED: '.$qty;
305 305
             }
306 306
             $this->_ticket_quantity_decremented($ticket);
307 307
         }
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
     protected function _reserve_ticket(EE_Ticket $ticket, $quantity = 1)
325 325
     {
326 326
         if (self::debug) {
327
-            echo self::$nl . self::$nl . ' . . . INCREASE RESERVED: ' . $quantity;
327
+            echo self::$nl.self::$nl.' . . . INCREASE RESERVED: '.$quantity;
328 328
         }
329
-        return $ticket->increaseReserved($quantity, 'TicketSalesMonitor:' . __LINE__);
329
+        return $ticket->increaseReserved($quantity, 'TicketSalesMonitor:'.__LINE__);
330 330
     }
331 331
 
332 332
 
@@ -339,12 +339,12 @@  discard block
 block discarded – undo
339 339
     protected function _release_reserved_ticket(EE_Ticket $ticket, $quantity = 1)
340 340
     {
341 341
         if (self::debug) {
342
-            echo self::$nl . ' . . . ticket->ID: ' . $ticket->ID();
343
-            echo self::$nl . ' . . . ticket->reserved before: ' . $ticket->reserved();
342
+            echo self::$nl.' . . . ticket->ID: '.$ticket->ID();
343
+            echo self::$nl.' . . . ticket->reserved before: '.$ticket->reserved();
344 344
         }
345
-        $ticket->decreaseReserved($quantity, true, 'TicketSalesMonitor:' . __LINE__);
345
+        $ticket->decreaseReserved($quantity, true, 'TicketSalesMonitor:'.__LINE__);
346 346
         if (self::debug) {
347
-            echo self::$nl . ' . . . ticket->reserved after: ' . $ticket->reserved();
347
+            echo self::$nl.' . . . ticket->reserved after: '.$ticket->reserved();
348 348
         }
349 349
         return $ticket->save() ? 1 : 0;
350 350
     }
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
     protected function _ticket_sold_out(EE_Ticket $ticket)
362 362
     {
363 363
         if (self::debug) {
364
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
365
-            echo self::$nl . ' . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket);
364
+            echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() ';
365
+            echo self::$nl.' . . ticket->name: '.$this->_get_ticket_and_event_name($ticket);
366 366
         }
367 367
         $this->sold_out_tickets[] = $this->_get_ticket_and_event_name($ticket);
368 368
     }
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
     protected function _ticket_quantity_decremented(EE_Ticket $ticket)
380 380
     {
381 381
         if (self::debug) {
382
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
383
-            echo self::$nl . ' . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket);
382
+            echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() ';
383
+            echo self::$nl.' . . ticket->name: '.$this->_get_ticket_and_event_name($ticket);
384 384
         }
385 385
         $this->decremented_tickets[] = $this->_get_ticket_and_event_name($ticket);
386 386
     }
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
         if ($ticket instanceof EE_Ticket) {
432 432
             $ticket->add_extra_meta(
433 433
                 EE_Ticket::META_KEY_TICKET_RESERVATIONS,
434
-                __LINE__ . ') ' . __METHOD__ . '()'
434
+                __LINE__.') '.__METHOD__.'()'
435 435
             );
436 436
             if ($quantity > 0) {
437 437
                 EED_Ticket_Sales_Monitor::instance()->_reserve_ticket($ticket, $quantity);
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     {
455 455
         $ticket->add_extra_meta(
456 456
             EE_Ticket::META_KEY_TICKET_RESERVATIONS,
457
-            __LINE__ . ') ' . __METHOD__ . '()'
457
+            __LINE__.') '.__METHOD__.'()'
458 458
         );
459 459
         EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity);
460 460
     }
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
     protected function _post_notices()
490 490
     {
491 491
         if (self::debug) {
492
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
492
+            echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() ';
493 493
         }
494 494
         $refresh_msg = '';
495 495
         $none_added_msg = '';
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
             );
501 501
             $none_added_msg = __('No tickets were added for the event.', 'event_espresso');
502 502
         }
503
-        if (! empty($this->sold_out_tickets)) {
503
+        if ( ! empty($this->sold_out_tickets)) {
504 504
             EE_Error::add_attention(
505 505
                 sprintf(
506 506
                     apply_filters(
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
             // and reset the cart
524 524
             EED_Ticket_Sales_Monitor::session_cart_reset(EE_Registry::instance()->SSN);
525 525
         }
526
-        if (! empty($this->decremented_tickets)) {
526
+        if ( ! empty($this->decremented_tickets)) {
527 527
             EE_Error::add_attention(
528 528
                 sprintf(
529 529
                     apply_filters(
@@ -560,9 +560,9 @@  discard block
 block discarded – undo
560 560
     protected function _release_all_reserved_tickets_for_transaction(EE_Transaction $transaction)
561 561
     {
562 562
         if (self::debug) {
563
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
564
-            echo self::$nl . ' . transaction->ID: ' . $transaction->ID();
565
-            echo self::$nl . ' . TXN status_ID: ' . $transaction->status_ID();
563
+            echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() ';
564
+            echo self::$nl.' . transaction->ID: '.$transaction->ID();
565
+            echo self::$nl.' . TXN status_ID: '.$transaction->status_ID();
566 566
         }
567 567
         // check if 'finalize_registration' step has been completed...
568 568
         $finalized = $transaction->reg_step_completed('finalize_registration');
@@ -574,13 +574,13 @@  discard block
 block discarded – undo
574 574
                 __LINE__,
575 575
                 array('finalized' => $finalized),
576 576
                 false,
577
-                'EE_Transaction: ' . $transaction->ID()
577
+                'EE_Transaction: '.$transaction->ID()
578 578
             );
579 579
         }
580 580
         // how many tickets were released
581 581
         $count = 0;
582 582
         if (self::debug) {
583
-            echo self::$nl . ' . . . TXN finalized: ' . $finalized;
583
+            echo self::$nl.' . . . TXN finalized: '.$finalized;
584 584
         }
585 585
         $release_tickets_with_TXN_status = array(
586 586
             EEM_Transaction::failed_status_code,
@@ -589,27 +589,27 @@  discard block
 block discarded – undo
589 589
         );
590 590
         $events = array();
591 591
         // if the session is getting cleared BEFORE the TXN has been finalized or the transaction is not completed
592
-        if (! $finalized || in_array($transaction->status_ID(), $release_tickets_with_TXN_status, true)) {
592
+        if ( ! $finalized || in_array($transaction->status_ID(), $release_tickets_with_TXN_status, true)) {
593 593
             // cancel any reserved tickets for registrations that were not approved
594 594
             $registrations = $transaction->registrations();
595 595
             if (self::debug) {
596
-                echo self::$nl . ' . . . # registrations: ' . count($registrations);
596
+                echo self::$nl.' . . . # registrations: '.count($registrations);
597 597
                 $reg = reset($registrations);
598 598
                 $ticket = $reg->ticket();
599 599
                 if ($ticket instanceof EE_Ticket) {
600 600
                     $ticket->add_extra_meta(
601 601
                         EE_Ticket::META_KEY_TICKET_RESERVATIONS,
602
-                        __LINE__ . ') Release All Tickets TXN:' . $transaction->ID()
602
+                        __LINE__.') Release All Tickets TXN:'.$transaction->ID()
603 603
                     );
604 604
                 }
605 605
             }
606
-            if (! empty($registrations)) {
606
+            if ( ! empty($registrations)) {
607 607
                 foreach ($registrations as $registration) {
608 608
                     if ($registration instanceof EE_Registration
609 609
                         && $this->_release_reserved_ticket_for_registration($registration, $transaction)
610 610
                     ) {
611 611
                         $count++;
612
-                        $events[ $registration->event_ID() ] = $registration->event();
612
+                        $events[$registration->event_ID()] = $registration->event();
613 613
                     }
614 614
                 }
615 615
             }
@@ -639,10 +639,10 @@  discard block
 block discarded – undo
639 639
     ) {
640 640
         $STS_ID = $transaction->status_ID();
641 641
         if (self::debug) {
642
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
643
-            echo self::$nl . ' . . registration->ID: ' . $registration->ID();
644
-            echo self::$nl . ' . . registration->status_ID: ' . $registration->status_ID();
645
-            echo self::$nl . ' . . transaction->status_ID(): ' . $STS_ID;
642
+            echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() ';
643
+            echo self::$nl.' . . registration->ID: '.$registration->ID();
644
+            echo self::$nl.' . . registration->status_ID: '.$registration->status_ID();
645
+            echo self::$nl.' . . transaction->status_ID(): '.$STS_ID;
646 646
         }
647 647
         if (// release Tickets for Failed Transactions and Abandoned Transactions
648 648
             $STS_ID === EEM_Transaction::failed_status_code
@@ -654,12 +654,12 @@  discard block
 block discarded – undo
654 654
             )
655 655
         ) {
656 656
             if (self::debug) {
657
-                echo self::$nl . self::$nl . ' . . RELEASE RESERVED TICKET';
657
+                echo self::$nl.self::$nl.' . . RELEASE RESERVED TICKET';
658 658
                 $rsrvd = $registration->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true);
659
-                echo self::$nl . ' . . . registration HAS_RESERVED_TICKET_KEY: ';
659
+                echo self::$nl.' . . . registration HAS_RESERVED_TICKET_KEY: ';
660 660
                 var_dump($rsrvd);
661 661
             }
662
-            $registration->release_reserved_ticket(true, 'TicketSalesMonitor:' . __LINE__);
662
+            $registration->release_reserved_ticket(true, 'TicketSalesMonitor:'.__LINE__);
663 663
             return 1;
664 664
         }
665 665
         return 0;
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
             return;
689 689
         }
690 690
         if (self::debug) {
691
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
691
+            echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() ';
692 692
         }
693 693
         // first check of the session has a valid Checkout object
694 694
         $checkout = $session->checkout();
@@ -700,12 +700,12 @@  discard block
 block discarded – undo
700 700
         $cart = $session->cart();
701 701
         if ($cart instanceof EE_Cart) {
702 702
             if (self::debug) {
703
-                echo self::$nl . self::$nl . ' cart instance of EE_Cart: ';
703
+                echo self::$nl.self::$nl.' cart instance of EE_Cart: ';
704 704
             }
705 705
             EED_Ticket_Sales_Monitor::instance()->_session_cart_reset($cart, $session);
706 706
         } else {
707 707
             if (self::debug) {
708
-                echo self::$nl . self::$nl . ' invalid EE_Cart: ';
708
+                echo self::$nl.self::$nl.' invalid EE_Cart: ';
709 709
                 var_export($cart, true);
710 710
             }
711 711
         }
@@ -726,39 +726,39 @@  discard block
 block discarded – undo
726 726
     protected function _session_cart_reset(EE_Cart $cart, EE_Session $session)
727 727
     {
728 728
         if (self::debug) {
729
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
729
+            echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() ';
730 730
         }
731 731
         $ticket_line_items = $cart->get_tickets();
732 732
         if (empty($ticket_line_items)) {
733 733
             return;
734 734
         }
735 735
         if (self::debug) {
736
-            echo '<br /> . ticket_line_item count: ' . count($ticket_line_items);
736
+            echo '<br /> . ticket_line_item count: '.count($ticket_line_items);
737 737
         }
738 738
         foreach ($ticket_line_items as $ticket_line_item) {
739 739
             if (self::debug) {
740
-                echo self::$nl . ' . ticket_line_item->ID(): ' . $ticket_line_item->ID();
740
+                echo self::$nl.' . ticket_line_item->ID(): '.$ticket_line_item->ID();
741 741
             }
742 742
             if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() === 'Ticket') {
743 743
                 if (self::debug) {
744
-                    echo self::$nl . ' . . ticket_line_item->OBJ_ID(): ' . $ticket_line_item->OBJ_ID();
744
+                    echo self::$nl.' . . ticket_line_item->OBJ_ID(): '.$ticket_line_item->OBJ_ID();
745 745
                 }
746 746
                 $ticket = EEM_Ticket::instance()->get_one_by_ID($ticket_line_item->OBJ_ID());
747 747
                 if ($ticket instanceof EE_Ticket) {
748 748
                     if (self::debug) {
749
-                        echo self::$nl . ' . . ticket->ID(): ' . $ticket->ID();
750
-                        echo self::$nl . ' . . ticket_line_item->quantity(): ' . $ticket_line_item->quantity();
749
+                        echo self::$nl.' . . ticket->ID(): '.$ticket->ID();
750
+                        echo self::$nl.' . . ticket_line_item->quantity(): '.$ticket_line_item->quantity();
751 751
                     }
752 752
                     $ticket->add_extra_meta(
753 753
                         EE_Ticket::META_KEY_TICKET_RESERVATIONS,
754
-                        __LINE__ . ') ' . __METHOD__ . '() SID = ' . $session->id()
754
+                        __LINE__.') '.__METHOD__.'() SID = '.$session->id()
755 755
                     );
756 756
                     $this->_release_reserved_ticket($ticket, $ticket_line_item->quantity());
757 757
                 }
758 758
             }
759 759
         }
760 760
         if (self::debug) {
761
-            echo self::$nl . self::$nl . ' RESET COMPLETED ';
761
+            echo self::$nl.self::$nl.' RESET COMPLETED ';
762 762
         }
763 763
     }
764 764
 
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
     protected function _session_checkout_reset(EE_Checkout $checkout)
800 800
     {
801 801
         if (self::debug) {
802
-            echo self::$nl . self::$nl . __LINE__ . ') ' . __METHOD__ . '() ';
802
+            echo self::$nl.self::$nl.__LINE__.') '.__METHOD__.'() ';
803 803
         }
804 804
         // we want to release the each registration's reserved tickets if the session was cleared, but not if this is a revisit
805 805
         if ($checkout->revisit || ! $checkout->transaction instanceof EE_Transaction) {
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
                     __LINE__,
848 848
                     array($transaction),
849 849
                     false,
850
-                    'EE_Transaction: ' . $transaction->ID()
850
+                    'EE_Transaction: '.$transaction->ID()
851 851
                 );
852 852
             }
853 853
             return;
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
                         __LINE__,
865 865
                         array($payment),
866 866
                         false,
867
-                        'EE_Transaction: ' . $transaction->ID()
867
+                        'EE_Transaction: '.$transaction->ID()
868 868
                     );
869 869
                 }
870 870
                 return;
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
             }
927 927
             $total_line_item = $transaction->total_line_item();
928 928
             // $transaction_in_progress->line
929
-            if (! $total_line_item instanceof EE_Line_Item) {
929
+            if ( ! $total_line_item instanceof EE_Line_Item) {
930 930
                 throw new DomainException(
931 931
                     esc_html__(
932 932
                         'Transaction does not have a valid Total Line Item associated with it.',
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
         $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item);
965 965
         foreach ($ticket_line_items as $ticket_line_item) {
966 966
             if ($ticket_line_item instanceof EE_Line_Item) {
967
-                $valid_reserved_tickets[ $ticket_line_item->ID() ] = $ticket_line_item;
967
+                $valid_reserved_tickets[$ticket_line_item->ID()] = $ticket_line_item;
968 968
             }
969 969
         }
970 970
         return $valid_reserved_tickets;
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
         $total_tickets_released = 0;
998 998
         $sold_out_events = array();
999 999
         foreach ($tickets_with_reservations as $ticket_with_reservations) {
1000
-            if (! $ticket_with_reservations instanceof EE_Ticket) {
1000
+            if ( ! $ticket_with_reservations instanceof EE_Ticket) {
1001 1001
                 continue;
1002 1002
             }
1003 1003
             // The $valid_reserved_ticket_line_items tells us what the reserved count on their tickets (and datetimes)
@@ -1018,9 +1018,9 @@  discard block
 block discarded – undo
1018 1018
             if ($expired_reservations_count > 0) {
1019 1019
                 $ticket_with_reservations->add_extra_meta(
1020 1020
                     EE_Ticket::META_KEY_TICKET_RESERVATIONS,
1021
-                    __LINE__ . ') ' . $source . '()'
1021
+                    __LINE__.') '.$source.'()'
1022 1022
                 );
1023
-                $ticket_with_reservations->decreaseReserved($expired_reservations_count, true, 'TicketSalesMonitor:' . __LINE__);
1023
+                $ticket_with_reservations->decreaseReserved($expired_reservations_count, true, 'TicketSalesMonitor:'.__LINE__);
1024 1024
                 $total_tickets_released += $expired_reservations_count;
1025 1025
                 $event = $ticket_with_reservations->get_related_event();
1026 1026
                 // track sold out events
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
     {
1057 1057
         /** @type WPDB $wpdb */
1058 1058
         global $wpdb;
1059
-        if (! absint($timestamp)) {
1059
+        if ( ! absint($timestamp)) {
1060 1060
             /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
1061 1061
             $session_lifespan = LoaderFactory::getLoader()->getShared(
1062 1062
                 'EventEspresso\core\domain\values\session\SessionLifespan'
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
         }
1066 1066
         return $wpdb->query(
1067 1067
             $wpdb->prepare(
1068
-                'DELETE FROM ' . EEM_Line_Item::instance()->table() . '
1068
+                'DELETE FROM '.EEM_Line_Item::instance()->table().'
1069 1069
                 WHERE TXN_ID = 0 AND LIN_timestamp <= %s',
1070 1070
                 // use GMT time because that's what LIN_timestamps are in
1071 1071
                 date('Y-m-d H:i:s', $timestamp)
Please login to merge, or discard this patch.
core/EE_Addon.core.php 1 patch
Indentation   +843 added lines, -843 removed lines patch added patch discarded remove patch
@@ -19,797 +19,797 @@  discard block
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * prefix to be added onto an addon's plugin slug to make a wp option name
24
-     * which will be used to store the plugin's activation history
25
-     */
26
-    const ee_addon_version_history_option_prefix = 'ee_version_history_';
27
-
28
-    /**
29
-     * @var $_version
30
-     * @type string
31
-     */
32
-    protected $_version = '';
33
-
34
-    /**
35
-     * @var $_min_core_version
36
-     * @type string
37
-     */
38
-    protected $_min_core_version = '';
39
-
40
-    /**
41
-     * derived from plugin 'main_file_path using plugin_basename()
42
-     *
43
-     * @type string $_plugin_basename
44
-     */
45
-    protected $_plugin_basename = '';
46
-
47
-    /**
48
-     * A non-internationalized name to identify this addon for use in URLs, etc
49
-     *
50
-     * @type string $_plugin_slug
51
-     */
52
-    protected $_plugin_slug = '';
53
-
54
-    /**
55
-     * A non-internationalized name to identify this addon. Eg 'Calendar','MailChimp',etc/
56
-     *
57
-     * @type string _addon_name
58
-     */
59
-    protected $_addon_name = '';
60
-
61
-    /**
62
-     * one of the EE_System::req_type_* constants
63
-     *
64
-     * @type int $_req_type
65
-     */
66
-    protected $_req_type;
67
-
68
-    /**
69
-     * page slug to be used when generating the "Settings" link on the WP plugin page
70
-     *
71
-     * @type string $_plugin_action_slug
72
-     */
73
-    protected $_plugin_action_slug = '';
74
-
75
-    /**
76
-     * if not empty, inserts a new table row after this plugin's row on the WP Plugins page
77
-     * that can be used for adding upgrading/marketing info
78
-     *
79
-     * @type array $_plugins_page_row
80
-     */
81
-    protected $_plugins_page_row = array();
82
-
83
-
84
-    /**
85
-     *    filepath to the main file, which can be used for register_activation_hook, register_deactivation_hook, etc.
86
-     *
87
-     * @type string
88
-     */
89
-    protected $_main_plugin_file;
90
-
91
-    /**
92
-     *    This is the slug used to identify this add-on within the plugin update engine.
93
-     *
94
-     * @type string
95
-     */
96
-    protected $pue_slug;
97
-
98
-
99
-    /**
100
-     * @var EE_Dependency_Map $dependency_map
101
-     */
102
-    private $dependency_map;
103
-
104
-
105
-    /**
106
-     * @var DomainInterface $domain
107
-     */
108
-    private $domain;
109
-
110
-
111
-    /**
112
-     * @param EE_Dependency_Map $dependency_map [optional]
113
-     * @param DomainInterface   $domain         [optional]
114
-     */
115
-    public function __construct(EE_Dependency_Map $dependency_map = null, DomainInterface $domain = null)
116
-    {
117
-        if ($dependency_map instanceof EE_Dependency_Map) {
118
-            $this->setDependencyMap($dependency_map);
119
-        }
120
-        if ($domain instanceof DomainInterface) {
121
-            $this->setDomain($domain);
122
-        }
123
-        add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($this, 'admin_init'));
124
-    }
125
-
126
-
127
-    /**
128
-     * @param EE_Dependency_Map $dependency_map
129
-     */
130
-    public function setDependencyMap($dependency_map)
131
-    {
132
-        $this->dependency_map = $dependency_map;
133
-    }
134
-
135
-
136
-    /**
137
-     * @return EE_Dependency_Map
138
-     */
139
-    public function dependencyMap()
140
-    {
141
-        return $this->dependency_map;
142
-    }
143
-
144
-
145
-    /**
146
-     * @param DomainInterface $domain
147
-     */
148
-    public function setDomain(DomainInterface $domain)
149
-    {
150
-        $this->domain = $domain;
151
-    }
152
-
153
-    /**
154
-     * @return DomainInterface
155
-     */
156
-    public function domain()
157
-    {
158
-        return $this->domain;
159
-    }
160
-
161
-
162
-    /**
163
-     * @param mixed $version
164
-     */
165
-    public function set_version($version = null)
166
-    {
167
-        $this->_version = $version;
168
-    }
169
-
170
-
171
-    /**
172
-     * get__version
173
-     *
174
-     * @return string
175
-     */
176
-    public function version()
177
-    {
178
-        return $this->_version;
179
-    }
180
-
181
-
182
-    /**
183
-     * @param mixed $min_core_version
184
-     */
185
-    public function set_min_core_version($min_core_version = null)
186
-    {
187
-        $this->_min_core_version = $min_core_version;
188
-    }
189
-
190
-
191
-    /**
192
-     * get__min_core_version
193
-     *
194
-     * @return string
195
-     */
196
-    public function min_core_version()
197
-    {
198
-        return $this->_min_core_version;
199
-    }
200
-
201
-
202
-    /**
203
-     * Sets addon_name
204
-     *
205
-     * @param string $addon_name
206
-     * @return boolean
207
-     */
208
-    public function set_name($addon_name)
209
-    {
210
-        return $this->_addon_name = $addon_name;
211
-    }
212
-
213
-
214
-    /**
215
-     * Gets addon_name
216
-     *
217
-     * @return string
218
-     */
219
-    public function name()
220
-    {
221
-        return $this->_addon_name;
222
-    }
223
-
224
-
225
-    /**
226
-     * @return string
227
-     */
228
-    public function plugin_basename()
229
-    {
230
-
231
-        return $this->_plugin_basename;
232
-    }
233
-
234
-
235
-    /**
236
-     * @param string $plugin_basename
237
-     */
238
-    public function set_plugin_basename($plugin_basename)
239
-    {
240
-
241
-        $this->_plugin_basename = $plugin_basename;
242
-    }
243
-
244
-
245
-    /**
246
-     * @return string
247
-     */
248
-    public function plugin_slug()
249
-    {
250
-
251
-        return $this->_plugin_slug;
252
-    }
253
-
254
-
255
-    /**
256
-     * @param string $plugin_slug
257
-     */
258
-    public function set_plugin_slug($plugin_slug)
259
-    {
260
-
261
-        $this->_plugin_slug = $plugin_slug;
262
-    }
263
-
264
-
265
-    /**
266
-     * @return string
267
-     */
268
-    public function plugin_action_slug()
269
-    {
270
-
271
-        return $this->_plugin_action_slug;
272
-    }
273
-
274
-
275
-    /**
276
-     * @param string $plugin_action_slug
277
-     */
278
-    public function set_plugin_action_slug($plugin_action_slug)
279
-    {
280
-
281
-        $this->_plugin_action_slug = $plugin_action_slug;
282
-    }
283
-
284
-
285
-    /**
286
-     * @return array
287
-     */
288
-    public function get_plugins_page_row()
289
-    {
290
-
291
-        return $this->_plugins_page_row;
292
-    }
293
-
294
-
295
-    /**
296
-     * @param array $plugins_page_row
297
-     */
298
-    public function set_plugins_page_row($plugins_page_row = array())
299
-    {
300
-        // sigh.... check for example content that I stupidly merged to master and remove it if found
301
-        if (! is_array($plugins_page_row)
302
-            && strpos($plugins_page_row, '<h3>Promotions Addon Upsell Info</h3>') !== false
303
-        ) {
304
-            $plugins_page_row = array();
305
-        }
306
-        $this->_plugins_page_row = (array) $plugins_page_row;
307
-    }
308
-
309
-
310
-    /**
311
-     * Called when EE core detects this addon has been activated for the first time.
312
-     * If the site isn't in maintenance mode, should setup the addon's database
313
-     *
314
-     * @return void
315
-     */
316
-    public function new_install()
317
-    {
318
-        $classname = get_class($this);
319
-        do_action("AHEE__{$classname}__new_install");
320
-        do_action('AHEE__EE_Addon__new_install', $this);
321
-        EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
322
-        add_action(
323
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
324
-            array($this, 'initialize_db_if_no_migrations_required')
325
-        );
326
-    }
327
-
328
-
329
-    /**
330
-     * Called when EE core detects this addon has been reactivated. When this happens,
331
-     * it's good to just check that your data is still intact
332
-     *
333
-     * @return void
334
-     */
335
-    public function reactivation()
336
-    {
337
-        $classname = get_class($this);
338
-        do_action("AHEE__{$classname}__reactivation");
339
-        do_action('AHEE__EE_Addon__reactivation', $this);
340
-        EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
341
-        add_action(
342
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
343
-            array($this, 'initialize_db_if_no_migrations_required')
344
-        );
345
-    }
346
-
347
-
348
-    /**
349
-     * Called when the registered deactivation hook for this addon fires.
350
-     *
351
-     * @throws EE_Error
352
-     */
353
-    public function deactivation()
354
-    {
355
-        $classname = get_class($this);
356
-        do_action("AHEE__{$classname}__deactivation");
357
-        do_action('AHEE__EE_Addon__deactivation', $this);
358
-        // check if the site no longer needs to be in maintenance mode
359
-        EE_Register_Addon::deregister($this->name());
360
-        EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
361
-    }
362
-
363
-
364
-    /**
365
-     * Takes care of double-checking that we're not in maintenance mode, and then
366
-     * initializing this addon's necessary initial data. This is called by default on new activations
367
-     * and reactivations.
368
-     *
369
-     * @param boolean $verify_schema whether to verify the database's schema for this addon, or just its data.
370
-     *                               This is a resource-intensive job so we prefer to only do it when necessary
371
-     * @return void
372
-     * @throws \EE_Error
373
-     * @throws InvalidInterfaceException
374
-     * @throws InvalidDataTypeException
375
-     * @throws InvalidArgumentException
376
-     */
377
-    public function initialize_db_if_no_migrations_required($verify_schema = true)
378
-    {
379
-        if ($verify_schema === '') {
380
-            // wp core bug imo: if no args are passed to `do_action('some_hook_name')` besides the hook's name
381
-            // (ie, no 2nd or 3rd arguments), instead of calling the registered callbacks with no arguments, it
382
-            // calls them with an argument of an empty string (ie ""), which evaluates to false
383
-            // so we need to treat the empty string as if nothing had been passed, and should instead use the default
384
-            $verify_schema = true;
385
-        }
386
-        if (EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
387
-            if ($verify_schema) {
388
-                $this->initialize_db();
389
-            }
390
-            $this->initialize_default_data();
391
-            // @todo: this will probably need to be adjusted in 4.4 as the array changed formats I believe
392
-            EE_Data_Migration_Manager::instance()->update_current_database_state_to(
393
-                array(
394
-                    'slug'    => $this->name(),
395
-                    'version' => $this->version(),
396
-                )
397
-            );
398
-            /* make sure core's data is a-ok
22
+	/**
23
+	 * prefix to be added onto an addon's plugin slug to make a wp option name
24
+	 * which will be used to store the plugin's activation history
25
+	 */
26
+	const ee_addon_version_history_option_prefix = 'ee_version_history_';
27
+
28
+	/**
29
+	 * @var $_version
30
+	 * @type string
31
+	 */
32
+	protected $_version = '';
33
+
34
+	/**
35
+	 * @var $_min_core_version
36
+	 * @type string
37
+	 */
38
+	protected $_min_core_version = '';
39
+
40
+	/**
41
+	 * derived from plugin 'main_file_path using plugin_basename()
42
+	 *
43
+	 * @type string $_plugin_basename
44
+	 */
45
+	protected $_plugin_basename = '';
46
+
47
+	/**
48
+	 * A non-internationalized name to identify this addon for use in URLs, etc
49
+	 *
50
+	 * @type string $_plugin_slug
51
+	 */
52
+	protected $_plugin_slug = '';
53
+
54
+	/**
55
+	 * A non-internationalized name to identify this addon. Eg 'Calendar','MailChimp',etc/
56
+	 *
57
+	 * @type string _addon_name
58
+	 */
59
+	protected $_addon_name = '';
60
+
61
+	/**
62
+	 * one of the EE_System::req_type_* constants
63
+	 *
64
+	 * @type int $_req_type
65
+	 */
66
+	protected $_req_type;
67
+
68
+	/**
69
+	 * page slug to be used when generating the "Settings" link on the WP plugin page
70
+	 *
71
+	 * @type string $_plugin_action_slug
72
+	 */
73
+	protected $_plugin_action_slug = '';
74
+
75
+	/**
76
+	 * if not empty, inserts a new table row after this plugin's row on the WP Plugins page
77
+	 * that can be used for adding upgrading/marketing info
78
+	 *
79
+	 * @type array $_plugins_page_row
80
+	 */
81
+	protected $_plugins_page_row = array();
82
+
83
+
84
+	/**
85
+	 *    filepath to the main file, which can be used for register_activation_hook, register_deactivation_hook, etc.
86
+	 *
87
+	 * @type string
88
+	 */
89
+	protected $_main_plugin_file;
90
+
91
+	/**
92
+	 *    This is the slug used to identify this add-on within the plugin update engine.
93
+	 *
94
+	 * @type string
95
+	 */
96
+	protected $pue_slug;
97
+
98
+
99
+	/**
100
+	 * @var EE_Dependency_Map $dependency_map
101
+	 */
102
+	private $dependency_map;
103
+
104
+
105
+	/**
106
+	 * @var DomainInterface $domain
107
+	 */
108
+	private $domain;
109
+
110
+
111
+	/**
112
+	 * @param EE_Dependency_Map $dependency_map [optional]
113
+	 * @param DomainInterface   $domain         [optional]
114
+	 */
115
+	public function __construct(EE_Dependency_Map $dependency_map = null, DomainInterface $domain = null)
116
+	{
117
+		if ($dependency_map instanceof EE_Dependency_Map) {
118
+			$this->setDependencyMap($dependency_map);
119
+		}
120
+		if ($domain instanceof DomainInterface) {
121
+			$this->setDomain($domain);
122
+		}
123
+		add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($this, 'admin_init'));
124
+	}
125
+
126
+
127
+	/**
128
+	 * @param EE_Dependency_Map $dependency_map
129
+	 */
130
+	public function setDependencyMap($dependency_map)
131
+	{
132
+		$this->dependency_map = $dependency_map;
133
+	}
134
+
135
+
136
+	/**
137
+	 * @return EE_Dependency_Map
138
+	 */
139
+	public function dependencyMap()
140
+	{
141
+		return $this->dependency_map;
142
+	}
143
+
144
+
145
+	/**
146
+	 * @param DomainInterface $domain
147
+	 */
148
+	public function setDomain(DomainInterface $domain)
149
+	{
150
+		$this->domain = $domain;
151
+	}
152
+
153
+	/**
154
+	 * @return DomainInterface
155
+	 */
156
+	public function domain()
157
+	{
158
+		return $this->domain;
159
+	}
160
+
161
+
162
+	/**
163
+	 * @param mixed $version
164
+	 */
165
+	public function set_version($version = null)
166
+	{
167
+		$this->_version = $version;
168
+	}
169
+
170
+
171
+	/**
172
+	 * get__version
173
+	 *
174
+	 * @return string
175
+	 */
176
+	public function version()
177
+	{
178
+		return $this->_version;
179
+	}
180
+
181
+
182
+	/**
183
+	 * @param mixed $min_core_version
184
+	 */
185
+	public function set_min_core_version($min_core_version = null)
186
+	{
187
+		$this->_min_core_version = $min_core_version;
188
+	}
189
+
190
+
191
+	/**
192
+	 * get__min_core_version
193
+	 *
194
+	 * @return string
195
+	 */
196
+	public function min_core_version()
197
+	{
198
+		return $this->_min_core_version;
199
+	}
200
+
201
+
202
+	/**
203
+	 * Sets addon_name
204
+	 *
205
+	 * @param string $addon_name
206
+	 * @return boolean
207
+	 */
208
+	public function set_name($addon_name)
209
+	{
210
+		return $this->_addon_name = $addon_name;
211
+	}
212
+
213
+
214
+	/**
215
+	 * Gets addon_name
216
+	 *
217
+	 * @return string
218
+	 */
219
+	public function name()
220
+	{
221
+		return $this->_addon_name;
222
+	}
223
+
224
+
225
+	/**
226
+	 * @return string
227
+	 */
228
+	public function plugin_basename()
229
+	{
230
+
231
+		return $this->_plugin_basename;
232
+	}
233
+
234
+
235
+	/**
236
+	 * @param string $plugin_basename
237
+	 */
238
+	public function set_plugin_basename($plugin_basename)
239
+	{
240
+
241
+		$this->_plugin_basename = $plugin_basename;
242
+	}
243
+
244
+
245
+	/**
246
+	 * @return string
247
+	 */
248
+	public function plugin_slug()
249
+	{
250
+
251
+		return $this->_plugin_slug;
252
+	}
253
+
254
+
255
+	/**
256
+	 * @param string $plugin_slug
257
+	 */
258
+	public function set_plugin_slug($plugin_slug)
259
+	{
260
+
261
+		$this->_plugin_slug = $plugin_slug;
262
+	}
263
+
264
+
265
+	/**
266
+	 * @return string
267
+	 */
268
+	public function plugin_action_slug()
269
+	{
270
+
271
+		return $this->_plugin_action_slug;
272
+	}
273
+
274
+
275
+	/**
276
+	 * @param string $plugin_action_slug
277
+	 */
278
+	public function set_plugin_action_slug($plugin_action_slug)
279
+	{
280
+
281
+		$this->_plugin_action_slug = $plugin_action_slug;
282
+	}
283
+
284
+
285
+	/**
286
+	 * @return array
287
+	 */
288
+	public function get_plugins_page_row()
289
+	{
290
+
291
+		return $this->_plugins_page_row;
292
+	}
293
+
294
+
295
+	/**
296
+	 * @param array $plugins_page_row
297
+	 */
298
+	public function set_plugins_page_row($plugins_page_row = array())
299
+	{
300
+		// sigh.... check for example content that I stupidly merged to master and remove it if found
301
+		if (! is_array($plugins_page_row)
302
+			&& strpos($plugins_page_row, '<h3>Promotions Addon Upsell Info</h3>') !== false
303
+		) {
304
+			$plugins_page_row = array();
305
+		}
306
+		$this->_plugins_page_row = (array) $plugins_page_row;
307
+	}
308
+
309
+
310
+	/**
311
+	 * Called when EE core detects this addon has been activated for the first time.
312
+	 * If the site isn't in maintenance mode, should setup the addon's database
313
+	 *
314
+	 * @return void
315
+	 */
316
+	public function new_install()
317
+	{
318
+		$classname = get_class($this);
319
+		do_action("AHEE__{$classname}__new_install");
320
+		do_action('AHEE__EE_Addon__new_install', $this);
321
+		EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
322
+		add_action(
323
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
324
+			array($this, 'initialize_db_if_no_migrations_required')
325
+		);
326
+	}
327
+
328
+
329
+	/**
330
+	 * Called when EE core detects this addon has been reactivated. When this happens,
331
+	 * it's good to just check that your data is still intact
332
+	 *
333
+	 * @return void
334
+	 */
335
+	public function reactivation()
336
+	{
337
+		$classname = get_class($this);
338
+		do_action("AHEE__{$classname}__reactivation");
339
+		do_action('AHEE__EE_Addon__reactivation', $this);
340
+		EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
341
+		add_action(
342
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
343
+			array($this, 'initialize_db_if_no_migrations_required')
344
+		);
345
+	}
346
+
347
+
348
+	/**
349
+	 * Called when the registered deactivation hook for this addon fires.
350
+	 *
351
+	 * @throws EE_Error
352
+	 */
353
+	public function deactivation()
354
+	{
355
+		$classname = get_class($this);
356
+		do_action("AHEE__{$classname}__deactivation");
357
+		do_action('AHEE__EE_Addon__deactivation', $this);
358
+		// check if the site no longer needs to be in maintenance mode
359
+		EE_Register_Addon::deregister($this->name());
360
+		EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
361
+	}
362
+
363
+
364
+	/**
365
+	 * Takes care of double-checking that we're not in maintenance mode, and then
366
+	 * initializing this addon's necessary initial data. This is called by default on new activations
367
+	 * and reactivations.
368
+	 *
369
+	 * @param boolean $verify_schema whether to verify the database's schema for this addon, or just its data.
370
+	 *                               This is a resource-intensive job so we prefer to only do it when necessary
371
+	 * @return void
372
+	 * @throws \EE_Error
373
+	 * @throws InvalidInterfaceException
374
+	 * @throws InvalidDataTypeException
375
+	 * @throws InvalidArgumentException
376
+	 */
377
+	public function initialize_db_if_no_migrations_required($verify_schema = true)
378
+	{
379
+		if ($verify_schema === '') {
380
+			// wp core bug imo: if no args are passed to `do_action('some_hook_name')` besides the hook's name
381
+			// (ie, no 2nd or 3rd arguments), instead of calling the registered callbacks with no arguments, it
382
+			// calls them with an argument of an empty string (ie ""), which evaluates to false
383
+			// so we need to treat the empty string as if nothing had been passed, and should instead use the default
384
+			$verify_schema = true;
385
+		}
386
+		if (EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
387
+			if ($verify_schema) {
388
+				$this->initialize_db();
389
+			}
390
+			$this->initialize_default_data();
391
+			// @todo: this will probably need to be adjusted in 4.4 as the array changed formats I believe
392
+			EE_Data_Migration_Manager::instance()->update_current_database_state_to(
393
+				array(
394
+					'slug'    => $this->name(),
395
+					'version' => $this->version(),
396
+				)
397
+			);
398
+			/* make sure core's data is a-ok
399 399
              * (at the time of writing, we especially want to verify all the caps are present
400 400
              * because payment method type capabilities are added dynamically, and it's
401 401
              * possible this addon added a payment method. But it's also possible
402 402
              * other data needs to be verified)
403 403
              */
404
-            EEH_Activation::initialize_db_content();
405
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
406
-            $rewrite_rules = LoaderFactory::getLoader()->getShared(
407
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
408
-            );
409
-            $rewrite_rules->flushRewriteRules();
410
-            // in case there are lots of addons being activated at once, let's force garbage collection
411
-            // to help avoid memory limit errors
412
-            // EEH_Debug_Tools::instance()->measure_memory( 'db content initialized for ' . get_class( $this), true );
413
-            gc_collect_cycles();
414
-        } else {
415
-            // ask the data migration manager to init this addon's data
416
-            // when migrations are finished because we can't do it now
417
-            EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for($this->name());
418
-        }
419
-    }
420
-
421
-
422
-    /**
423
-     * Used to setup this addon's database tables, but not necessarily any default
424
-     * data in them. The default is to actually use the most up-to-date data migration script
425
-     * for this addon, and just use its schema_changes_before_migration() and schema_changes_after_migration()
426
-     * methods to setup the db.
427
-     */
428
-    public function initialize_db()
429
-    {
430
-        // find the migration script that sets the database to be compatible with the code
431
-        $current_dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms($this->name());
432
-        if ($current_dms_name) {
433
-            $current_data_migration_script = EE_Registry::instance()->load_dms($current_dms_name);
434
-            $current_data_migration_script->set_migrating(false);
435
-            $current_data_migration_script->schema_changes_before_migration();
436
-            $current_data_migration_script->schema_changes_after_migration();
437
-            if ($current_data_migration_script->get_errors()) {
438
-                foreach ($current_data_migration_script->get_errors() as $error) {
439
-                    EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
440
-                }
441
-            }
442
-        }
443
-        // if not DMS was found that should be ok. This addon just doesn't require any database changes
444
-        EE_Data_Migration_Manager::instance()->update_current_database_state_to(
445
-            array(
446
-                'slug'    => $this->name(),
447
-                'version' => $this->version(),
448
-            )
449
-        );
450
-    }
451
-
452
-
453
-    /**
454
-     * If you want to setup default data for the addon, override this method, and call
455
-     * parent::initialize_default_data() from within it. This is normally called
456
-     * from EE_Addon::initialize_db_if_no_migrations_required(), just after EE_Addon::initialize_db()
457
-     * and should verify default data is present (but this is also called
458
-     * on reactivations and just after migrations, so please verify you actually want
459
-     * to ADD default data, because it may already be present).
460
-     * However, please call this parent (currently it just fires a hook which other
461
-     * addons may be depending on)
462
-     */
463
-    public function initialize_default_data()
464
-    {
465
-        /**
466
-         * Called when an addon is ensuring its default data is set (possibly called
467
-         * on a reactivation, so first check for the absence of other data before setting
468
-         * default data)
469
-         *
470
-         * @param EE_Addon $addon the addon that called this
471
-         */
472
-        do_action('AHEE__EE_Addon__initialize_default_data__begin', $this);
473
-        // override to insert default data. It is safe to use the models here
474
-        // because the site should not be in maintenance mode
475
-    }
476
-
477
-
478
-    /**
479
-     * EE Core detected that this addon has been upgraded. We should check if there
480
-     * are any new migration scripts, and if so put the site into maintenance mode until
481
-     * they're ran
482
-     *
483
-     * @return void
484
-     */
485
-    public function upgrade()
486
-    {
487
-        $classname = get_class($this);
488
-        do_action("AHEE__{$classname}__upgrade");
489
-        do_action('AHEE__EE_Addon__upgrade', $this);
490
-        EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
491
-        // also it's possible there is new default data that needs to be added
492
-        add_action(
493
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
494
-            array($this, 'initialize_db_if_no_migrations_required')
495
-        );
496
-    }
497
-
498
-
499
-    /**
500
-     * If Core detects this addon has been downgraded, you may want to invoke some special logic here.
501
-     */
502
-    public function downgrade()
503
-    {
504
-        $classname = get_class($this);
505
-        do_action("AHEE__{$classname}__downgrade");
506
-        do_action('AHEE__EE_Addon__downgrade', $this);
507
-        // it's possible there's old default data that needs to be double-checked
508
-        add_action(
509
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
510
-            array($this, 'initialize_db_if_no_migrations_required')
511
-        );
512
-    }
513
-
514
-
515
-    /**
516
-     * set_db_update_option_name
517
-     * Until we do something better, we'll just check for migration scripts upon
518
-     * plugin activation only. In the future, we'll want to do it on plugin updates too
519
-     *
520
-     * @return bool
521
-     */
522
-    public function set_db_update_option_name()
523
-    {
524
-        EE_Error::doing_it_wrong(
525
-            __FUNCTION__,
526
-            esc_html__(
527
-                'EE_Addon::set_db_update_option_name was renamed to EE_Addon::set_activation_indicator_option',
528
-                'event_espresso'
529
-            ),
530
-            '4.3.0.alpha.016'
531
-        );
532
-        // let's just handle this on the next request, ok? right now we're just not really ready
533
-        return $this->set_activation_indicator_option();
534
-    }
535
-
536
-
537
-    /**
538
-     * Returns the name of the activation indicator option
539
-     * (an option which is set temporarily to indicate that this addon was just activated)
540
-     *
541
-     * @deprecated since version 4.3.0.alpha.016
542
-     * @return string
543
-     */
544
-    public function get_db_update_option_name()
545
-    {
546
-        EE_Error::doing_it_wrong(
547
-            __FUNCTION__,
548
-            esc_html__(
549
-                'EE_Addon::get_db_update_option was renamed to EE_Addon::get_activation_indicator_option_name',
550
-                'event_espresso'
551
-            ),
552
-            '4.3.0.alpha.016'
553
-        );
554
-        return $this->get_activation_indicator_option_name();
555
-    }
556
-
557
-
558
-    /**
559
-     * When the addon is activated, this should be called to set a wordpress option that
560
-     * indicates it was activated. This is especially useful for detecting reactivations.
561
-     *
562
-     * @return bool
563
-     */
564
-    public function set_activation_indicator_option()
565
-    {
566
-        // let's just handle this on the next request, ok? right now we're just not really ready
567
-        return update_option($this->get_activation_indicator_option_name(), true);
568
-    }
569
-
570
-
571
-    /**
572
-     * Gets the name of the wp option which is used to temporarily indicate that this addon was activated
573
-     *
574
-     * @return string
575
-     */
576
-    public function get_activation_indicator_option_name()
577
-    {
578
-        return 'ee_activation_' . $this->name();
579
-    }
580
-
581
-
582
-    /**
583
-     * Used by EE_System to set the request type of this addon. Should not be used by addon developers
584
-     *
585
-     * @param int $req_type
586
-     */
587
-    public function set_req_type($req_type)
588
-    {
589
-        $this->_req_type = $req_type;
590
-    }
591
-
592
-
593
-    /**
594
-     * Returns the request type of this addon (ie, EE_System::req_type_normal, EE_System::req_type_new_activation,
595
-     * EE_System::req_type_reactivation, EE_System::req_type_upgrade, or EE_System::req_type_downgrade). This is set by
596
-     * EE_System when it is checking for new install or upgrades of addons
597
-     */
598
-    public function detect_req_type()
599
-    {
600
-        if (! $this->_req_type) {
601
-            $this->detect_activation_or_upgrade();
602
-        }
603
-        return $this->_req_type;
604
-    }
605
-
606
-
607
-    /**
608
-     * Detects the request type for this addon (whether it was just activated, upgrades, a normal request, etc.)
609
-     * Should only be called once per request
610
-     *
611
-     * @return void
612
-     */
613
-    public function detect_activation_or_upgrade()
614
-    {
615
-        $activation_history_for_addon = $this->get_activation_history();
616
-        $request_type = EE_System::detect_req_type_given_activation_history(
617
-            $activation_history_for_addon,
618
-            $this->get_activation_indicator_option_name(),
619
-            $this->version()
620
-        );
621
-        $this->set_req_type($request_type);
622
-        $classname = get_class($this);
623
-        switch ($request_type) {
624
-            case EE_System::req_type_new_activation:
625
-                do_action("AHEE__{$classname}__detect_activations_or_upgrades__new_activation");
626
-                do_action('AHEE__EE_Addon__detect_activations_or_upgrades__new_activation', $this);
627
-                $this->new_install();
628
-                $this->update_list_of_installed_versions($activation_history_for_addon);
629
-                break;
630
-            case EE_System::req_type_reactivation:
631
-                do_action("AHEE__{$classname}__detect_activations_or_upgrades__reactivation");
632
-                do_action('AHEE__EE_Addon__detect_activations_or_upgrades__reactivation', $this);
633
-                $this->reactivation();
634
-                $this->update_list_of_installed_versions($activation_history_for_addon);
635
-                break;
636
-            case EE_System::req_type_upgrade:
637
-                do_action("AHEE__{$classname}__detect_activations_or_upgrades__upgrade");
638
-                do_action('AHEE__EE_Addon__detect_activations_or_upgrades__upgrade', $this);
639
-                $this->upgrade();
640
-                $this->update_list_of_installed_versions($activation_history_for_addon);
641
-                break;
642
-            case EE_System::req_type_downgrade:
643
-                do_action("AHEE__{$classname}__detect_activations_or_upgrades__downgrade");
644
-                do_action('AHEE__EE_Addon__detect_activations_or_upgrades__downgrade', $this);
645
-                $this->downgrade();
646
-                $this->update_list_of_installed_versions($activation_history_for_addon);
647
-                break;
648
-            case EE_System::req_type_normal:
649
-            default:
650
-                break;
651
-        }
652
-
653
-        do_action("AHEE__{$classname}__detect_if_activation_or_upgrade__complete");
654
-    }
655
-
656
-    /**
657
-     * Updates the version history for this addon
658
-     *
659
-     * @param array  $version_history
660
-     * @param string $current_version_to_add
661
-     * @return boolean success
662
-     */
663
-    public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
664
-    {
665
-        if (! $version_history) {
666
-            $version_history = $this->get_activation_history();
667
-        }
668
-        if ($current_version_to_add === null) {
669
-            $current_version_to_add = $this->version();
670
-        }
671
-        $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
672
-        // resave
673
-        return update_option($this->get_activation_history_option_name(), $version_history);
674
-    }
675
-
676
-    /**
677
-     * Gets the name of the wp option that stores the activation history
678
-     * of this addon
679
-     *
680
-     * @return string
681
-     */
682
-    public function get_activation_history_option_name()
683
-    {
684
-        return self::ee_addon_version_history_option_prefix . $this->name();
685
-    }
686
-
687
-
688
-    /**
689
-     * Gets the wp option which stores the activation history for this addon
690
-     *
691
-     * @return array
692
-     */
693
-    public function get_activation_history()
694
-    {
695
-        return get_option($this->get_activation_history_option_name(), null);
696
-    }
697
-
698
-
699
-    /**
700
-     * @param string $config_section
701
-     */
702
-    public function set_config_section($config_section = '')
703
-    {
704
-        $this->_config_section = ! empty($config_section) ? $config_section : 'addons';
705
-    }
706
-
707
-    /**
708
-     * Sets the filepath to the main plugin file
709
-     *
710
-     * @param string $filepath
711
-     */
712
-    public function set_main_plugin_file($filepath)
713
-    {
714
-        $this->_main_plugin_file = $filepath;
715
-    }
716
-
717
-    /**
718
-     * gets the filepath to teh main file
719
-     *
720
-     * @return string
721
-     */
722
-    public function get_main_plugin_file()
723
-    {
724
-        return $this->_main_plugin_file;
725
-    }
726
-
727
-    /**
728
-     * Gets the filename (no path) of the main file (the main file loaded
729
-     * by WP)
730
-     *
731
-     * @return string
732
-     */
733
-    public function get_main_plugin_file_basename()
734
-    {
735
-        return plugin_basename($this->get_main_plugin_file());
736
-    }
737
-
738
-    /**
739
-     * Gets the folder name which contains the main plugin file
740
-     *
741
-     * @return string
742
-     */
743
-    public function get_main_plugin_file_dirname()
744
-    {
745
-        return dirname($this->get_main_plugin_file());
746
-    }
747
-
748
-
749
-    /**
750
-     * sets hooks used in the admin
751
-     *
752
-     * @return void
753
-     */
754
-    public function admin_init()
755
-    {
756
-        // is admin and not in M-Mode ?
757
-        if (is_admin() && ! EE_Maintenance_Mode::instance()->level()) {
758
-            add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);
759
-            add_filter('after_plugin_row_' . $this->_plugin_basename, array($this, 'after_plugin_row'), 10, 3);
760
-        }
761
-    }
762
-
763
-
764
-    /**
765
-     * plugin_actions
766
-     * Add a settings link to the Plugins page, so people can go straight from the plugin page to the settings page.
767
-     *
768
-     * @param $links
769
-     * @param $file
770
-     * @return array
771
-     */
772
-    public function plugin_action_links($links, $file)
773
-    {
774
-        if ($file === $this->plugin_basename() && $this->plugin_action_slug() !== '') {
775
-            // before other links
776
-            array_unshift(
777
-                $links,
778
-                '<a href="admin.php?page=' . $this->plugin_action_slug() . '">'
779
-                . esc_html__('Settings', 'event_espresso')
780
-                . '</a>'
781
-            );
782
-        }
783
-        return $links;
784
-    }
785
-
786
-
787
-    /**
788
-     * after_plugin_row
789
-     * Add additional content to the plugins page plugin row
790
-     * Inserts another row
791
-     *
792
-     * @param $plugin_file
793
-     * @param $plugin_data
794
-     * @param $status
795
-     * @return void
796
-     */
797
-    public function after_plugin_row($plugin_file, $plugin_data, $status)
798
-    {
799
-        $after_plugin_row = '';
800
-        $plugins_page_row = $this->get_plugins_page_row();
801
-        if (! empty($plugins_page_row) && $plugin_file === $this->plugin_basename()) {
802
-            $class = $status ? 'active' : 'inactive';
803
-            $link_text = isset($plugins_page_row['link_text']) ? $plugins_page_row['link_text'] : '';
804
-            $link_url = isset($plugins_page_row['link_url']) ? $plugins_page_row['link_url'] : '';
805
-            $description = isset($plugins_page_row['description'])
806
-                ? $plugins_page_row['description']
807
-                : '';
808
-            if (! empty($link_text) && ! empty($link_url) && ! empty($description)) {
809
-                $after_plugin_row .= '<tr id="' . sanitize_title($plugin_file) . '-ee-addon" class="' . $class . '">';
810
-                $after_plugin_row .= '<th class="check-column" scope="row"></th>';
811
-                $after_plugin_row .= '<td class="ee-addon-upsell-info-title-td plugin-title column-primary">';
812
-                $after_plugin_row .= '<style>
404
+			EEH_Activation::initialize_db_content();
405
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
406
+			$rewrite_rules = LoaderFactory::getLoader()->getShared(
407
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
408
+			);
409
+			$rewrite_rules->flushRewriteRules();
410
+			// in case there are lots of addons being activated at once, let's force garbage collection
411
+			// to help avoid memory limit errors
412
+			// EEH_Debug_Tools::instance()->measure_memory( 'db content initialized for ' . get_class( $this), true );
413
+			gc_collect_cycles();
414
+		} else {
415
+			// ask the data migration manager to init this addon's data
416
+			// when migrations are finished because we can't do it now
417
+			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for($this->name());
418
+		}
419
+	}
420
+
421
+
422
+	/**
423
+	 * Used to setup this addon's database tables, but not necessarily any default
424
+	 * data in them. The default is to actually use the most up-to-date data migration script
425
+	 * for this addon, and just use its schema_changes_before_migration() and schema_changes_after_migration()
426
+	 * methods to setup the db.
427
+	 */
428
+	public function initialize_db()
429
+	{
430
+		// find the migration script that sets the database to be compatible with the code
431
+		$current_dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms($this->name());
432
+		if ($current_dms_name) {
433
+			$current_data_migration_script = EE_Registry::instance()->load_dms($current_dms_name);
434
+			$current_data_migration_script->set_migrating(false);
435
+			$current_data_migration_script->schema_changes_before_migration();
436
+			$current_data_migration_script->schema_changes_after_migration();
437
+			if ($current_data_migration_script->get_errors()) {
438
+				foreach ($current_data_migration_script->get_errors() as $error) {
439
+					EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
440
+				}
441
+			}
442
+		}
443
+		// if not DMS was found that should be ok. This addon just doesn't require any database changes
444
+		EE_Data_Migration_Manager::instance()->update_current_database_state_to(
445
+			array(
446
+				'slug'    => $this->name(),
447
+				'version' => $this->version(),
448
+			)
449
+		);
450
+	}
451
+
452
+
453
+	/**
454
+	 * If you want to setup default data for the addon, override this method, and call
455
+	 * parent::initialize_default_data() from within it. This is normally called
456
+	 * from EE_Addon::initialize_db_if_no_migrations_required(), just after EE_Addon::initialize_db()
457
+	 * and should verify default data is present (but this is also called
458
+	 * on reactivations and just after migrations, so please verify you actually want
459
+	 * to ADD default data, because it may already be present).
460
+	 * However, please call this parent (currently it just fires a hook which other
461
+	 * addons may be depending on)
462
+	 */
463
+	public function initialize_default_data()
464
+	{
465
+		/**
466
+		 * Called when an addon is ensuring its default data is set (possibly called
467
+		 * on a reactivation, so first check for the absence of other data before setting
468
+		 * default data)
469
+		 *
470
+		 * @param EE_Addon $addon the addon that called this
471
+		 */
472
+		do_action('AHEE__EE_Addon__initialize_default_data__begin', $this);
473
+		// override to insert default data. It is safe to use the models here
474
+		// because the site should not be in maintenance mode
475
+	}
476
+
477
+
478
+	/**
479
+	 * EE Core detected that this addon has been upgraded. We should check if there
480
+	 * are any new migration scripts, and if so put the site into maintenance mode until
481
+	 * they're ran
482
+	 *
483
+	 * @return void
484
+	 */
485
+	public function upgrade()
486
+	{
487
+		$classname = get_class($this);
488
+		do_action("AHEE__{$classname}__upgrade");
489
+		do_action('AHEE__EE_Addon__upgrade', $this);
490
+		EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
491
+		// also it's possible there is new default data that needs to be added
492
+		add_action(
493
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
494
+			array($this, 'initialize_db_if_no_migrations_required')
495
+		);
496
+	}
497
+
498
+
499
+	/**
500
+	 * If Core detects this addon has been downgraded, you may want to invoke some special logic here.
501
+	 */
502
+	public function downgrade()
503
+	{
504
+		$classname = get_class($this);
505
+		do_action("AHEE__{$classname}__downgrade");
506
+		do_action('AHEE__EE_Addon__downgrade', $this);
507
+		// it's possible there's old default data that needs to be double-checked
508
+		add_action(
509
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
510
+			array($this, 'initialize_db_if_no_migrations_required')
511
+		);
512
+	}
513
+
514
+
515
+	/**
516
+	 * set_db_update_option_name
517
+	 * Until we do something better, we'll just check for migration scripts upon
518
+	 * plugin activation only. In the future, we'll want to do it on plugin updates too
519
+	 *
520
+	 * @return bool
521
+	 */
522
+	public function set_db_update_option_name()
523
+	{
524
+		EE_Error::doing_it_wrong(
525
+			__FUNCTION__,
526
+			esc_html__(
527
+				'EE_Addon::set_db_update_option_name was renamed to EE_Addon::set_activation_indicator_option',
528
+				'event_espresso'
529
+			),
530
+			'4.3.0.alpha.016'
531
+		);
532
+		// let's just handle this on the next request, ok? right now we're just not really ready
533
+		return $this->set_activation_indicator_option();
534
+	}
535
+
536
+
537
+	/**
538
+	 * Returns the name of the activation indicator option
539
+	 * (an option which is set temporarily to indicate that this addon was just activated)
540
+	 *
541
+	 * @deprecated since version 4.3.0.alpha.016
542
+	 * @return string
543
+	 */
544
+	public function get_db_update_option_name()
545
+	{
546
+		EE_Error::doing_it_wrong(
547
+			__FUNCTION__,
548
+			esc_html__(
549
+				'EE_Addon::get_db_update_option was renamed to EE_Addon::get_activation_indicator_option_name',
550
+				'event_espresso'
551
+			),
552
+			'4.3.0.alpha.016'
553
+		);
554
+		return $this->get_activation_indicator_option_name();
555
+	}
556
+
557
+
558
+	/**
559
+	 * When the addon is activated, this should be called to set a wordpress option that
560
+	 * indicates it was activated. This is especially useful for detecting reactivations.
561
+	 *
562
+	 * @return bool
563
+	 */
564
+	public function set_activation_indicator_option()
565
+	{
566
+		// let's just handle this on the next request, ok? right now we're just not really ready
567
+		return update_option($this->get_activation_indicator_option_name(), true);
568
+	}
569
+
570
+
571
+	/**
572
+	 * Gets the name of the wp option which is used to temporarily indicate that this addon was activated
573
+	 *
574
+	 * @return string
575
+	 */
576
+	public function get_activation_indicator_option_name()
577
+	{
578
+		return 'ee_activation_' . $this->name();
579
+	}
580
+
581
+
582
+	/**
583
+	 * Used by EE_System to set the request type of this addon. Should not be used by addon developers
584
+	 *
585
+	 * @param int $req_type
586
+	 */
587
+	public function set_req_type($req_type)
588
+	{
589
+		$this->_req_type = $req_type;
590
+	}
591
+
592
+
593
+	/**
594
+	 * Returns the request type of this addon (ie, EE_System::req_type_normal, EE_System::req_type_new_activation,
595
+	 * EE_System::req_type_reactivation, EE_System::req_type_upgrade, or EE_System::req_type_downgrade). This is set by
596
+	 * EE_System when it is checking for new install or upgrades of addons
597
+	 */
598
+	public function detect_req_type()
599
+	{
600
+		if (! $this->_req_type) {
601
+			$this->detect_activation_or_upgrade();
602
+		}
603
+		return $this->_req_type;
604
+	}
605
+
606
+
607
+	/**
608
+	 * Detects the request type for this addon (whether it was just activated, upgrades, a normal request, etc.)
609
+	 * Should only be called once per request
610
+	 *
611
+	 * @return void
612
+	 */
613
+	public function detect_activation_or_upgrade()
614
+	{
615
+		$activation_history_for_addon = $this->get_activation_history();
616
+		$request_type = EE_System::detect_req_type_given_activation_history(
617
+			$activation_history_for_addon,
618
+			$this->get_activation_indicator_option_name(),
619
+			$this->version()
620
+		);
621
+		$this->set_req_type($request_type);
622
+		$classname = get_class($this);
623
+		switch ($request_type) {
624
+			case EE_System::req_type_new_activation:
625
+				do_action("AHEE__{$classname}__detect_activations_or_upgrades__new_activation");
626
+				do_action('AHEE__EE_Addon__detect_activations_or_upgrades__new_activation', $this);
627
+				$this->new_install();
628
+				$this->update_list_of_installed_versions($activation_history_for_addon);
629
+				break;
630
+			case EE_System::req_type_reactivation:
631
+				do_action("AHEE__{$classname}__detect_activations_or_upgrades__reactivation");
632
+				do_action('AHEE__EE_Addon__detect_activations_or_upgrades__reactivation', $this);
633
+				$this->reactivation();
634
+				$this->update_list_of_installed_versions($activation_history_for_addon);
635
+				break;
636
+			case EE_System::req_type_upgrade:
637
+				do_action("AHEE__{$classname}__detect_activations_or_upgrades__upgrade");
638
+				do_action('AHEE__EE_Addon__detect_activations_or_upgrades__upgrade', $this);
639
+				$this->upgrade();
640
+				$this->update_list_of_installed_versions($activation_history_for_addon);
641
+				break;
642
+			case EE_System::req_type_downgrade:
643
+				do_action("AHEE__{$classname}__detect_activations_or_upgrades__downgrade");
644
+				do_action('AHEE__EE_Addon__detect_activations_or_upgrades__downgrade', $this);
645
+				$this->downgrade();
646
+				$this->update_list_of_installed_versions($activation_history_for_addon);
647
+				break;
648
+			case EE_System::req_type_normal:
649
+			default:
650
+				break;
651
+		}
652
+
653
+		do_action("AHEE__{$classname}__detect_if_activation_or_upgrade__complete");
654
+	}
655
+
656
+	/**
657
+	 * Updates the version history for this addon
658
+	 *
659
+	 * @param array  $version_history
660
+	 * @param string $current_version_to_add
661
+	 * @return boolean success
662
+	 */
663
+	public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
664
+	{
665
+		if (! $version_history) {
666
+			$version_history = $this->get_activation_history();
667
+		}
668
+		if ($current_version_to_add === null) {
669
+			$current_version_to_add = $this->version();
670
+		}
671
+		$version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
672
+		// resave
673
+		return update_option($this->get_activation_history_option_name(), $version_history);
674
+	}
675
+
676
+	/**
677
+	 * Gets the name of the wp option that stores the activation history
678
+	 * of this addon
679
+	 *
680
+	 * @return string
681
+	 */
682
+	public function get_activation_history_option_name()
683
+	{
684
+		return self::ee_addon_version_history_option_prefix . $this->name();
685
+	}
686
+
687
+
688
+	/**
689
+	 * Gets the wp option which stores the activation history for this addon
690
+	 *
691
+	 * @return array
692
+	 */
693
+	public function get_activation_history()
694
+	{
695
+		return get_option($this->get_activation_history_option_name(), null);
696
+	}
697
+
698
+
699
+	/**
700
+	 * @param string $config_section
701
+	 */
702
+	public function set_config_section($config_section = '')
703
+	{
704
+		$this->_config_section = ! empty($config_section) ? $config_section : 'addons';
705
+	}
706
+
707
+	/**
708
+	 * Sets the filepath to the main plugin file
709
+	 *
710
+	 * @param string $filepath
711
+	 */
712
+	public function set_main_plugin_file($filepath)
713
+	{
714
+		$this->_main_plugin_file = $filepath;
715
+	}
716
+
717
+	/**
718
+	 * gets the filepath to teh main file
719
+	 *
720
+	 * @return string
721
+	 */
722
+	public function get_main_plugin_file()
723
+	{
724
+		return $this->_main_plugin_file;
725
+	}
726
+
727
+	/**
728
+	 * Gets the filename (no path) of the main file (the main file loaded
729
+	 * by WP)
730
+	 *
731
+	 * @return string
732
+	 */
733
+	public function get_main_plugin_file_basename()
734
+	{
735
+		return plugin_basename($this->get_main_plugin_file());
736
+	}
737
+
738
+	/**
739
+	 * Gets the folder name which contains the main plugin file
740
+	 *
741
+	 * @return string
742
+	 */
743
+	public function get_main_plugin_file_dirname()
744
+	{
745
+		return dirname($this->get_main_plugin_file());
746
+	}
747
+
748
+
749
+	/**
750
+	 * sets hooks used in the admin
751
+	 *
752
+	 * @return void
753
+	 */
754
+	public function admin_init()
755
+	{
756
+		// is admin and not in M-Mode ?
757
+		if (is_admin() && ! EE_Maintenance_Mode::instance()->level()) {
758
+			add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2);
759
+			add_filter('after_plugin_row_' . $this->_plugin_basename, array($this, 'after_plugin_row'), 10, 3);
760
+		}
761
+	}
762
+
763
+
764
+	/**
765
+	 * plugin_actions
766
+	 * Add a settings link to the Plugins page, so people can go straight from the plugin page to the settings page.
767
+	 *
768
+	 * @param $links
769
+	 * @param $file
770
+	 * @return array
771
+	 */
772
+	public function plugin_action_links($links, $file)
773
+	{
774
+		if ($file === $this->plugin_basename() && $this->plugin_action_slug() !== '') {
775
+			// before other links
776
+			array_unshift(
777
+				$links,
778
+				'<a href="admin.php?page=' . $this->plugin_action_slug() . '">'
779
+				. esc_html__('Settings', 'event_espresso')
780
+				. '</a>'
781
+			);
782
+		}
783
+		return $links;
784
+	}
785
+
786
+
787
+	/**
788
+	 * after_plugin_row
789
+	 * Add additional content to the plugins page plugin row
790
+	 * Inserts another row
791
+	 *
792
+	 * @param $plugin_file
793
+	 * @param $plugin_data
794
+	 * @param $status
795
+	 * @return void
796
+	 */
797
+	public function after_plugin_row($plugin_file, $plugin_data, $status)
798
+	{
799
+		$after_plugin_row = '';
800
+		$plugins_page_row = $this->get_plugins_page_row();
801
+		if (! empty($plugins_page_row) && $plugin_file === $this->plugin_basename()) {
802
+			$class = $status ? 'active' : 'inactive';
803
+			$link_text = isset($plugins_page_row['link_text']) ? $plugins_page_row['link_text'] : '';
804
+			$link_url = isset($plugins_page_row['link_url']) ? $plugins_page_row['link_url'] : '';
805
+			$description = isset($plugins_page_row['description'])
806
+				? $plugins_page_row['description']
807
+				: '';
808
+			if (! empty($link_text) && ! empty($link_url) && ! empty($description)) {
809
+				$after_plugin_row .= '<tr id="' . sanitize_title($plugin_file) . '-ee-addon" class="' . $class . '">';
810
+				$after_plugin_row .= '<th class="check-column" scope="row"></th>';
811
+				$after_plugin_row .= '<td class="ee-addon-upsell-info-title-td plugin-title column-primary">';
812
+				$after_plugin_row .= '<style>
813 813
 .ee-button,
814 814
 .ee-button:active,
815 815
 .ee-button:visited {
@@ -846,64 +846,64 @@  discard block
 block discarded – undo
846 846
 }
847 847
 .ee-button:active { top:0; }
848 848
 </style>';
849
-                $after_plugin_row .= '
849
+				$after_plugin_row .= '
850 850
 <p class="ee-addon-upsell-info-dv">
851 851
 	<a class="ee-button" href="' . $link_url . '">'
852
-                                     . $link_text
853
-                                     . ' &nbsp;<span class="dashicons dashicons-arrow-right-alt2" style="margin:0;"></span>'
854
-                                     . '</a>
852
+									 . $link_text
853
+									 . ' &nbsp;<span class="dashicons dashicons-arrow-right-alt2" style="margin:0;"></span>'
854
+									 . '</a>
855 855
 </p>';
856
-                $after_plugin_row .= '</td>';
857
-                $after_plugin_row .= '<td class="ee-addon-upsell-info-desc-td column-description desc">';
858
-                $after_plugin_row .= $description;
859
-                $after_plugin_row .= '</td>';
860
-                $after_plugin_row .= '</tr>';
861
-            } else {
862
-                $after_plugin_row .= $description;
863
-            }
864
-        }
865
-
866
-        echo $after_plugin_row;
867
-    }
868
-
869
-
870
-    /**
871
-     * A safe space for addons to add additional logic like setting hooks that need to be set early in the request.
872
-     * Child classes that have logic like that to run can override this method declaration.  This was not made abstract
873
-     * for back compat reasons.
874
-     *
875
-     * This will fire on the `AHEE__EE_System__load_espresso_addons__complete` hook at priority 999.
876
-     *
877
-     * It is recommended, if client code is `de-registering` an add-on, then do it on the
878
-     * `AHEE__EE_System__load_espresso_addons__complete` hook before priority 999 so as to ensure any code logic in this
879
-     * callback does not get run/set in that request.
880
-     *
881
-     * Also, keep in mind that if a registered add-on happens to be deactivated via
882
-     * EE_System::_deactivate_incompatible_addons() because its incompatible, any code executed in this method
883
-     * (including setting hooks etc) will have executed before the plugin was deactivated.  If you use
884
-     * `after_registration` to set any filter and/or action hooks and want to ensure they are removed on this add-on's
885
-     * deactivation, you can override `EE_Addon::deactivation` and unset your hooks and filters there.  Just remember
886
-     * to call `parent::deactivation`.
887
-     *
888
-     * @since 4.9.26
889
-     */
890
-    public function after_registration()
891
-    {
892
-        // cricket chirp... cricket chirp...
893
-    }
894
-
895
-    /**
896
-     * @return string
897
-     */
898
-    public function getPueSlug()
899
-    {
900
-        return $this->pue_slug;
901
-    }
902
-    /**
903
-     * @param string $pue_slug
904
-     */
905
-    public function setPueSlug($pue_slug)
906
-    {
907
-        $this->pue_slug = $pue_slug;
908
-    }
856
+				$after_plugin_row .= '</td>';
857
+				$after_plugin_row .= '<td class="ee-addon-upsell-info-desc-td column-description desc">';
858
+				$after_plugin_row .= $description;
859
+				$after_plugin_row .= '</td>';
860
+				$after_plugin_row .= '</tr>';
861
+			} else {
862
+				$after_plugin_row .= $description;
863
+			}
864
+		}
865
+
866
+		echo $after_plugin_row;
867
+	}
868
+
869
+
870
+	/**
871
+	 * A safe space for addons to add additional logic like setting hooks that need to be set early in the request.
872
+	 * Child classes that have logic like that to run can override this method declaration.  This was not made abstract
873
+	 * for back compat reasons.
874
+	 *
875
+	 * This will fire on the `AHEE__EE_System__load_espresso_addons__complete` hook at priority 999.
876
+	 *
877
+	 * It is recommended, if client code is `de-registering` an add-on, then do it on the
878
+	 * `AHEE__EE_System__load_espresso_addons__complete` hook before priority 999 so as to ensure any code logic in this
879
+	 * callback does not get run/set in that request.
880
+	 *
881
+	 * Also, keep in mind that if a registered add-on happens to be deactivated via
882
+	 * EE_System::_deactivate_incompatible_addons() because its incompatible, any code executed in this method
883
+	 * (including setting hooks etc) will have executed before the plugin was deactivated.  If you use
884
+	 * `after_registration` to set any filter and/or action hooks and want to ensure they are removed on this add-on's
885
+	 * deactivation, you can override `EE_Addon::deactivation` and unset your hooks and filters there.  Just remember
886
+	 * to call `parent::deactivation`.
887
+	 *
888
+	 * @since 4.9.26
889
+	 */
890
+	public function after_registration()
891
+	{
892
+		// cricket chirp... cricket chirp...
893
+	}
894
+
895
+	/**
896
+	 * @return string
897
+	 */
898
+	public function getPueSlug()
899
+	{
900
+		return $this->pue_slug;
901
+	}
902
+	/**
903
+	 * @param string $pue_slug
904
+	 */
905
+	public function setPueSlug($pue_slug)
906
+	{
907
+		$this->pue_slug = $pue_slug;
908
+	}
909 909
 }
Please login to merge, or discard this patch.
reg_steps/attendee_information/attendee_info_single.template.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -6,16 +6,16 @@  discard block
 block discarded – undo
6 6
 <?php if (!is_admin()) : ?>
7 7
     <p id="spco-attendee_information-pg" class="spco-steps-pg small-text drk-grey-text">
8 8
         <?php echo apply_filters(
9
-            'FHEE__registration_page_attendee_information__attendee_information_pg',
10
-            sprintf(
11
-                esc_html__(
12
-                    'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.',
13
-                    'event_espresso'
14
-                ),
15
-                '<br />',
16
-                '<span class="asterisk">*</span>'
17
-            )
18
-        ); ?>
9
+			'FHEE__registration_page_attendee_information__attendee_information_pg',
10
+			sprintf(
11
+				esc_html__(
12
+					'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.',
13
+					'event_espresso'
14
+				),
15
+				'<br />',
16
+				'<span class="asterisk">*</span>'
17
+			)
18
+		); ?>
19 19
 </p>
20 20
 <?php endif; ?>
21 21
 
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 $prev_ticket = 0;
26 26
 
27 27
 if (count($registrations) > 0) {
28
-    $ticketID = key($template_args['ticket_count']);
29
-    ?>
28
+	$ticketID = key($template_args['ticket_count']);
29
+	?>
30 30
 
31 31
     <div id="spco-attendee-panel-dv-<?php echo $ticketID; ?>"
32 32
         class="spco-attendee-panel-dv spco-attendee-ticket-<?php echo $ticketID; ?>">
@@ -41,54 +41,54 @@  discard block
 block discarded – undo
41 41
                     <th scope="col" width="" class="jst-left"><?php esc_html_e('Name and Description', 'event_espresso'); ?></th>
42 42
                     <th scope="col" width="7.5%" class="jst-rght">
43 43
                         <?php esc_html_e(
44
-                            'Qty',
45
-                            'event_espresso'
46
-                        ); ?></th>
44
+							'Qty',
45
+							'event_espresso'
46
+						); ?></th>
47 47
                     <th scope="col" width="17.5%" class="jst-rght">
48 48
                         <?php esc_html_e(
49
-                            'Price',
50
-                            'event_espresso'
51
-                        ); ?></th>
49
+							'Price',
50
+							'event_espresso'
51
+						); ?></th>
52 52
                     <th scope="col" width="17.5%" class="jst-rght">
53 53
                         <?php esc_html_e(
54
-                            'Total',
55
-                            'event_espresso'
56
-                        ); ?></th>
54
+							'Total',
55
+							'event_espresso'
56
+						); ?></th>
57 57
                 </tr>
58 58
                 </thead>
59 59
                 <tbody>
60 60
                 <?php
61
-                // Store previous values to avoid duplicated rows.
62
-                $prev_ticket = 0;
63
-                // Display all tickets inside.
64
-                foreach ($registrations as $registration) {
65
-                    if ($registration instanceof EE_Registration) {
66
-                        if ($registration->ticket()->ID() !== $prev_ticket) {
67
-                            echo $ticket_line_item[ $registration->ticket()->ID() ];
68
-                        }
61
+				// Store previous values to avoid duplicated rows.
62
+				$prev_ticket = 0;
63
+				// Display all tickets inside.
64
+				foreach ($registrations as $registration) {
65
+					if ($registration instanceof EE_Registration) {
66
+						if ($registration->ticket()->ID() !== $prev_ticket) {
67
+							echo $ticket_line_item[ $registration->ticket()->ID() ];
68
+						}
69 69
 
70
-                        $prev_ticket = $registration->ticket()->ID();
71
-                    }
72
-                }
73
-                ?>
70
+						$prev_ticket = $registration->ticket()->ID();
71
+					}
72
+				}
73
+				?>
74 74
                 </tbody>
75 75
             </table>
76 76
         </div><!-- close spco-ticket-info-dv -->
77 77
 
78 78
         <?php
79
-        // Display the forms below the table.
80
-        foreach ($registrations as $registration) {
81
-            if ($registration instanceof EE_Registration) {
82
-                // Attendee Questions.
83
-                $reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link());
84
-                echo ${$reg_form};
85
-            } // if ( $registration instanceof EE_Registration )
86
-        } // end foreach ( $registrations as $registration )
79
+		// Display the forms below the table.
80
+		foreach ($registrations as $registration) {
81
+			if ($registration instanceof EE_Registration) {
82
+				// Attendee Questions.
83
+				$reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link());
84
+				echo ${$reg_form};
85
+			} // if ( $registration instanceof EE_Registration )
86
+		} // end foreach ( $registrations as $registration )
87 87
 
88
-        ?>
88
+		?>
89 89
     </div><!-- close spco-attendee-panel-dv -->
90 90
     <?php
91
-    echo $default_hidden_inputs;
91
+	echo $default_hidden_inputs;
92 92
 } // end if ( count( $registrations ) > 0 )
93 93
 
94 94
 ?>
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Addon.lib.php 2 patches
Indentation   +1165 added lines, -1165 removed lines patch added patch discarded remove patch
@@ -22,1229 +22,1229 @@
 block discarded – undo
22 22
 class EE_Register_Addon implements EEI_Plugin_API
23 23
 {
24 24
 
25
-    /**
26
-     * possibly truncated version of the EE core version string
27
-     *
28
-     * @var string
29
-     */
30
-    protected static $_core_version = '';
25
+	/**
26
+	 * possibly truncated version of the EE core version string
27
+	 *
28
+	 * @var string
29
+	 */
30
+	protected static $_core_version = '';
31 31
 
32
-    /**
33
-     * Holds values for registered addons
34
-     *
35
-     * @var array
36
-     */
37
-    protected static $_settings = array();
32
+	/**
33
+	 * Holds values for registered addons
34
+	 *
35
+	 * @var array
36
+	 */
37
+	protected static $_settings = array();
38 38
 
39
-    /**
40
-     * @var  array $_incompatible_addons keys are addon SLUGS
41
-     * (first argument passed to EE_Register_Addon::register()), keys are
42
-     * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004).
43
-     * Generally this should be used sparingly, as we don't want to muddle up
44
-     * EE core with knowledge of ALL the addons out there.
45
-     * If you want NO versions of an addon to run with a certain version of core,
46
-     * it's usually best to define the addon's "min_core_version" as part of its call
47
-     * to EE_Register_Addon::register(), rather than using this array with a super high value for its
48
-     * minimum plugin version.
49
-     * @access    protected
50
-     */
51
-    protected static $_incompatible_addons = array(
52
-        'Multi_Event_Registration' => '2.0.11.rc.002',
53
-        'Promotions'               => '1.0.0.rc.084',
54
-    );
39
+	/**
40
+	 * @var  array $_incompatible_addons keys are addon SLUGS
41
+	 * (first argument passed to EE_Register_Addon::register()), keys are
42
+	 * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004).
43
+	 * Generally this should be used sparingly, as we don't want to muddle up
44
+	 * EE core with knowledge of ALL the addons out there.
45
+	 * If you want NO versions of an addon to run with a certain version of core,
46
+	 * it's usually best to define the addon's "min_core_version" as part of its call
47
+	 * to EE_Register_Addon::register(), rather than using this array with a super high value for its
48
+	 * minimum plugin version.
49
+	 * @access    protected
50
+	 */
51
+	protected static $_incompatible_addons = array(
52
+		'Multi_Event_Registration' => '2.0.11.rc.002',
53
+		'Promotions'               => '1.0.0.rc.084',
54
+	);
55 55
 
56 56
 
57
-    /**
58
-     * We should always be comparing core to a version like '4.3.0.rc.000',
59
-     * not just '4.3.0'.
60
-     * So if the addon developer doesn't provide that full version string,
61
-     * fill in the blanks for them
62
-     *
63
-     * @param string $min_core_version
64
-     * @return string always like '4.3.0.rc.000'
65
-     */
66
-    protected static function _effective_version($min_core_version)
67
-    {
68
-        // versions: 4 . 3 . 1 . p . 123
69
-        // offsets:    0 . 1 . 2 . 3 . 4
70
-        $version_parts = explode('.', $min_core_version);
71
-        // check they specified the micro version (after 2nd period)
72
-        if (! isset($version_parts[2])) {
73
-            $version_parts[2] = '0';
74
-        }
75
-        // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
76
-        // soon we can assume that's 'rc', but this current version is 'alpha'
77
-        if (! isset($version_parts[3])) {
78
-            $version_parts[3] = 'dev';
79
-        }
80
-        if (! isset($version_parts[4])) {
81
-            $version_parts[4] = '000';
82
-        }
83
-        return implode('.', $version_parts);
84
-    }
57
+	/**
58
+	 * We should always be comparing core to a version like '4.3.0.rc.000',
59
+	 * not just '4.3.0'.
60
+	 * So if the addon developer doesn't provide that full version string,
61
+	 * fill in the blanks for them
62
+	 *
63
+	 * @param string $min_core_version
64
+	 * @return string always like '4.3.0.rc.000'
65
+	 */
66
+	protected static function _effective_version($min_core_version)
67
+	{
68
+		// versions: 4 . 3 . 1 . p . 123
69
+		// offsets:    0 . 1 . 2 . 3 . 4
70
+		$version_parts = explode('.', $min_core_version);
71
+		// check they specified the micro version (after 2nd period)
72
+		if (! isset($version_parts[2])) {
73
+			$version_parts[2] = '0';
74
+		}
75
+		// if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
76
+		// soon we can assume that's 'rc', but this current version is 'alpha'
77
+		if (! isset($version_parts[3])) {
78
+			$version_parts[3] = 'dev';
79
+		}
80
+		if (! isset($version_parts[4])) {
81
+			$version_parts[4] = '000';
82
+		}
83
+		return implode('.', $version_parts);
84
+	}
85 85
 
86 86
 
87
-    /**
88
-     * Returns whether or not the min core version requirement of the addon is met
89
-     *
90
-     * @param string $min_core_version    the minimum core version required by the addon
91
-     * @param string $actual_core_version the actual core version, optional
92
-     * @return boolean
93
-     */
94
-    public static function _meets_min_core_version_requirement(
95
-        $min_core_version,
96
-        $actual_core_version = EVENT_ESPRESSO_VERSION
97
-    ) {
98
-        return version_compare(
99
-            self::_effective_version($actual_core_version),
100
-            self::_effective_version($min_core_version),
101
-            '>='
102
-        );
103
-    }
87
+	/**
88
+	 * Returns whether or not the min core version requirement of the addon is met
89
+	 *
90
+	 * @param string $min_core_version    the minimum core version required by the addon
91
+	 * @param string $actual_core_version the actual core version, optional
92
+	 * @return boolean
93
+	 */
94
+	public static function _meets_min_core_version_requirement(
95
+		$min_core_version,
96
+		$actual_core_version = EVENT_ESPRESSO_VERSION
97
+	) {
98
+		return version_compare(
99
+			self::_effective_version($actual_core_version),
100
+			self::_effective_version($min_core_version),
101
+			'>='
102
+		);
103
+	}
104 104
 
105 105
 
106
-    /**
107
-     * Method for registering new EE_Addons.
108
-     * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
109
-     * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
110
-     * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
111
-     * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
112
-     * 'activate_plugin', it registers the addon still, but its components are not registered
113
-     * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
114
-     * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
115
-     * (so that we can detect that the addon has activated on the subsequent request)
116
-     *
117
-     * @since    4.3.0
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 string                   $pue_options
168
-     * @type array                    $capabilities                     an array indexed by role name
169
-     *                                                                  (i.e administrator,author ) and the values
170
-     *                                                                  are an array of caps to add to the role.
171
-     *                                                                  'administrator' => array(
172
-     *                                                                  'read_addon',
173
-     *                                                                  'edit_addon',
174
-     *                                                                  etc.
175
-     *                                                                  ).
176
-     * @type EE_Meta_Capability_Map[] $capability_maps                  an array of EE_Meta_Capability_Map object
177
-     *                                                                  for any addons that need to register any
178
-     *                                                                  special meta mapped capabilities.  Should
179
-     *                                                                  be indexed where the key is the
180
-     *                                                                  EE_Meta_Capability_Map class name and the
181
-     *                                                                  values are the arguments sent to the class.
182
-     * @type array                    $model_paths                      array of folders containing DB models
183
-     * @see      EE_Register_Model
184
-     * @type array                    $class_paths                      array of folders containing DB classes
185
-     * @see      EE_Register_Model
186
-     * @type array                    $model_extension_paths            array of folders containing DB model
187
-     *                                                                  extensions
188
-     * @see      EE_Register_Model_Extension
189
-     * @type array                    $class_extension_paths            array of folders containing DB class
190
-     *                                                                  extensions
191
-     * @see      EE_Register_Model_Extension
192
-     * @type array message_types {
193
-     *                                                                  An array of message types with the key as
194
-     *                                                                  the message type name and the values as
195
-     *                                                                  below:
196
-     * @type string                   $mtfilename                       [Required] The filename of the message type
197
-     *                                                                  being registered. This will be the main
198
-     *                                                                  EE_{Message Type Name}_message_type class.
199
-     *                                                                  for example:
200
-     *                                                                  EE_Declined_Registration_message_type.class.php
201
-     * @type array                    $autoloadpaths                    [Required] An array of paths to add to the
202
-     *                                                                  messages autoloader for the new message type.
203
-     * @type array                    $messengers_to_activate_with      An array of messengers that this message
204
-     *                                                                  type should activate with. Each value in
205
-     *                                                                  the
206
-     *                                                                  array
207
-     *                                                                  should match the name property of a
208
-     *                                                                  EE_messenger. Optional.
209
-     * @type array                    $messengers_to_validate_with      An array of messengers that this message
210
-     *                                                                  type should validate with. Each value in
211
-     *                                                                  the
212
-     *                                                                  array
213
-     *                                                                  should match the name property of an
214
-     *                                                                  EE_messenger.
215
-     *                                                                  Optional.
216
-     *                                                                  }
217
-     * @type array                    $custom_post_types
218
-     * @type array                    $custom_taxonomies
219
-     * @type array                    $payment_method_paths             each element is the folder containing the
220
-     *                                                                  EE_PMT_Base child class
221
-     *                                                                  (eg,
222
-     *                                                                  '/wp-content/plugins/my_plugin/Payomatic/'
223
-     *                                                                  which contains the files
224
-     *                                                                  EE_PMT_Payomatic.pm.php)
225
-     * @type array                    $default_terms
226
-     * @type array                    $namespace                        {
227
-     *                                                                  An array with two items for registering the
228
-     *                                                                  addon's namespace. (If, for some reason, you
229
-     *                                                                  require additional namespaces,
230
-     *                                                                  use
231
-     *                                                                  EventEspresso\core\Psr4Autoloader::addNamespace()
232
-     *                                                                  directly)
233
-     * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
234
-     * @type string                   $FQNS                             the namespace prefix
235
-     * @type string                   $DIR                              a base directory for class files in the
236
-     *                                                                  namespace.
237
-     *                                                                  }
238
-     *                                                                  }
239
-     * @type string                   $privacy_policies                 FQNSs (namespaces, each of which contains only
240
-     *                                                                  privacy policy classes) or FQCNs (specific
241
-     *                                                                  classnames of privacy policy classes)
242
-     * @type string                   $personal_data_exporters          FQNSs (namespaces, each of which contains only
243
-     *                                                                  privacy policy classes) or FQCNs (specific
244
-     *                                                                  classnames of privacy policy classes)
245
-     * @type string                   $personal_data_erasers            FQNSs (namespaces, each of which contains only
246
-     *                                                                  privacy policy classes) or FQCNs (specific
247
-     *                                                                  classnames of privacy policy classes)
248
-     * @return void
249
-     * @throws DomainException
250
-     * @throws EE_Error
251
-     * @throws InvalidArgumentException
252
-     * @throws ReflectionException
253
-     * @throws InvalidDataTypeException
254
-     * @throws InvalidInterfaceException
255
-     */
256
-    public static function register($addon_name = '', $setup_args = array())
257
-    {
258
-        // required fields MUST be present, so let's make sure they are.
259
-        EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
260
-        // get class name for addon
261
-        $class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
262
-        // setup $_settings array from incoming values.
263
-        $addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
264
-        // setup PUE
265
-        EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
266
-        // does this addon work with this version of core or WordPress ?
267
-        if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
268
-            return;
269
-        }
270
-        // register namespaces
271
-        EE_Register_Addon::_setup_namespaces($addon_settings);
272
-        // check if this is an activation request
273
-        if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
274
-            // dont bother setting up the rest of the addon atm
275
-            return;
276
-        }
277
-        // we need cars
278
-        EE_Register_Addon::_setup_autoloaders($addon_name);
279
-        // register new models and extensions
280
-        EE_Register_Addon::_register_models_and_extensions($addon_name);
281
-        // setup DMS
282
-        EE_Register_Addon::_register_data_migration_scripts($addon_name);
283
-        // if config_class is present let's register config.
284
-        EE_Register_Addon::_register_config($addon_name);
285
-        // register admin pages
286
-        EE_Register_Addon::_register_admin_pages($addon_name);
287
-        // add to list of modules to be registered
288
-        EE_Register_Addon::_register_modules($addon_name);
289
-        // add to list of shortcodes to be registered
290
-        EE_Register_Addon::_register_shortcodes($addon_name);
291
-        // add to list of widgets to be registered
292
-        EE_Register_Addon::_register_widgets($addon_name);
293
-        // register capability related stuff.
294
-        EE_Register_Addon::_register_capabilities($addon_name);
295
-        // any message type to register?
296
-        EE_Register_Addon::_register_message_types($addon_name);
297
-        // any custom post type/ custom capabilities or default terms to register
298
-        EE_Register_Addon::_register_custom_post_types($addon_name);
299
-        // and any payment methods
300
-        EE_Register_Addon::_register_payment_methods($addon_name);
301
-        // and privacy policy generators
302
-        EE_Register_Addon::registerPrivacyPolicies($addon_name);
303
-        // and privacy policy generators
304
-        EE_Register_Addon::registerPersonalDataExporters($addon_name);
305
-        // and privacy policy generators
306
-        EE_Register_Addon::registerPersonalDataErasers($addon_name);
307
-        // load and instantiate main addon class
308
-        $addon = EE_Register_Addon::_load_and_init_addon_class($addon_name);
309
-        // delay calling after_registration hook on each addon until after all add-ons have been registered.
310
-        add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999);
311
-    }
106
+	/**
107
+	 * Method for registering new EE_Addons.
108
+	 * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
109
+	 * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
110
+	 * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
111
+	 * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
112
+	 * 'activate_plugin', it registers the addon still, but its components are not registered
113
+	 * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
114
+	 * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
115
+	 * (so that we can detect that the addon has activated on the subsequent request)
116
+	 *
117
+	 * @since    4.3.0
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 string                   $pue_options
168
+	 * @type array                    $capabilities                     an array indexed by role name
169
+	 *                                                                  (i.e administrator,author ) and the values
170
+	 *                                                                  are an array of caps to add to the role.
171
+	 *                                                                  'administrator' => array(
172
+	 *                                                                  'read_addon',
173
+	 *                                                                  'edit_addon',
174
+	 *                                                                  etc.
175
+	 *                                                                  ).
176
+	 * @type EE_Meta_Capability_Map[] $capability_maps                  an array of EE_Meta_Capability_Map object
177
+	 *                                                                  for any addons that need to register any
178
+	 *                                                                  special meta mapped capabilities.  Should
179
+	 *                                                                  be indexed where the key is the
180
+	 *                                                                  EE_Meta_Capability_Map class name and the
181
+	 *                                                                  values are the arguments sent to the class.
182
+	 * @type array                    $model_paths                      array of folders containing DB models
183
+	 * @see      EE_Register_Model
184
+	 * @type array                    $class_paths                      array of folders containing DB classes
185
+	 * @see      EE_Register_Model
186
+	 * @type array                    $model_extension_paths            array of folders containing DB model
187
+	 *                                                                  extensions
188
+	 * @see      EE_Register_Model_Extension
189
+	 * @type array                    $class_extension_paths            array of folders containing DB class
190
+	 *                                                                  extensions
191
+	 * @see      EE_Register_Model_Extension
192
+	 * @type array message_types {
193
+	 *                                                                  An array of message types with the key as
194
+	 *                                                                  the message type name and the values as
195
+	 *                                                                  below:
196
+	 * @type string                   $mtfilename                       [Required] The filename of the message type
197
+	 *                                                                  being registered. This will be the main
198
+	 *                                                                  EE_{Message Type Name}_message_type class.
199
+	 *                                                                  for example:
200
+	 *                                                                  EE_Declined_Registration_message_type.class.php
201
+	 * @type array                    $autoloadpaths                    [Required] An array of paths to add to the
202
+	 *                                                                  messages autoloader for the new message type.
203
+	 * @type array                    $messengers_to_activate_with      An array of messengers that this message
204
+	 *                                                                  type should activate with. Each value in
205
+	 *                                                                  the
206
+	 *                                                                  array
207
+	 *                                                                  should match the name property of a
208
+	 *                                                                  EE_messenger. Optional.
209
+	 * @type array                    $messengers_to_validate_with      An array of messengers that this message
210
+	 *                                                                  type should validate with. Each value in
211
+	 *                                                                  the
212
+	 *                                                                  array
213
+	 *                                                                  should match the name property of an
214
+	 *                                                                  EE_messenger.
215
+	 *                                                                  Optional.
216
+	 *                                                                  }
217
+	 * @type array                    $custom_post_types
218
+	 * @type array                    $custom_taxonomies
219
+	 * @type array                    $payment_method_paths             each element is the folder containing the
220
+	 *                                                                  EE_PMT_Base child class
221
+	 *                                                                  (eg,
222
+	 *                                                                  '/wp-content/plugins/my_plugin/Payomatic/'
223
+	 *                                                                  which contains the files
224
+	 *                                                                  EE_PMT_Payomatic.pm.php)
225
+	 * @type array                    $default_terms
226
+	 * @type array                    $namespace                        {
227
+	 *                                                                  An array with two items for registering the
228
+	 *                                                                  addon's namespace. (If, for some reason, you
229
+	 *                                                                  require additional namespaces,
230
+	 *                                                                  use
231
+	 *                                                                  EventEspresso\core\Psr4Autoloader::addNamespace()
232
+	 *                                                                  directly)
233
+	 * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
234
+	 * @type string                   $FQNS                             the namespace prefix
235
+	 * @type string                   $DIR                              a base directory for class files in the
236
+	 *                                                                  namespace.
237
+	 *                                                                  }
238
+	 *                                                                  }
239
+	 * @type string                   $privacy_policies                 FQNSs (namespaces, each of which contains only
240
+	 *                                                                  privacy policy classes) or FQCNs (specific
241
+	 *                                                                  classnames of privacy policy classes)
242
+	 * @type string                   $personal_data_exporters          FQNSs (namespaces, each of which contains only
243
+	 *                                                                  privacy policy classes) or FQCNs (specific
244
+	 *                                                                  classnames of privacy policy classes)
245
+	 * @type string                   $personal_data_erasers            FQNSs (namespaces, each of which contains only
246
+	 *                                                                  privacy policy classes) or FQCNs (specific
247
+	 *                                                                  classnames of privacy policy classes)
248
+	 * @return void
249
+	 * @throws DomainException
250
+	 * @throws EE_Error
251
+	 * @throws InvalidArgumentException
252
+	 * @throws ReflectionException
253
+	 * @throws InvalidDataTypeException
254
+	 * @throws InvalidInterfaceException
255
+	 */
256
+	public static function register($addon_name = '', $setup_args = array())
257
+	{
258
+		// required fields MUST be present, so let's make sure they are.
259
+		EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
260
+		// get class name for addon
261
+		$class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
262
+		// setup $_settings array from incoming values.
263
+		$addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
264
+		// setup PUE
265
+		EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
266
+		// does this addon work with this version of core or WordPress ?
267
+		if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
268
+			return;
269
+		}
270
+		// register namespaces
271
+		EE_Register_Addon::_setup_namespaces($addon_settings);
272
+		// check if this is an activation request
273
+		if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
274
+			// dont bother setting up the rest of the addon atm
275
+			return;
276
+		}
277
+		// we need cars
278
+		EE_Register_Addon::_setup_autoloaders($addon_name);
279
+		// register new models and extensions
280
+		EE_Register_Addon::_register_models_and_extensions($addon_name);
281
+		// setup DMS
282
+		EE_Register_Addon::_register_data_migration_scripts($addon_name);
283
+		// if config_class is present let's register config.
284
+		EE_Register_Addon::_register_config($addon_name);
285
+		// register admin pages
286
+		EE_Register_Addon::_register_admin_pages($addon_name);
287
+		// add to list of modules to be registered
288
+		EE_Register_Addon::_register_modules($addon_name);
289
+		// add to list of shortcodes to be registered
290
+		EE_Register_Addon::_register_shortcodes($addon_name);
291
+		// add to list of widgets to be registered
292
+		EE_Register_Addon::_register_widgets($addon_name);
293
+		// register capability related stuff.
294
+		EE_Register_Addon::_register_capabilities($addon_name);
295
+		// any message type to register?
296
+		EE_Register_Addon::_register_message_types($addon_name);
297
+		// any custom post type/ custom capabilities or default terms to register
298
+		EE_Register_Addon::_register_custom_post_types($addon_name);
299
+		// and any payment methods
300
+		EE_Register_Addon::_register_payment_methods($addon_name);
301
+		// and privacy policy generators
302
+		EE_Register_Addon::registerPrivacyPolicies($addon_name);
303
+		// and privacy policy generators
304
+		EE_Register_Addon::registerPersonalDataExporters($addon_name);
305
+		// and privacy policy generators
306
+		EE_Register_Addon::registerPersonalDataErasers($addon_name);
307
+		// load and instantiate main addon class
308
+		$addon = EE_Register_Addon::_load_and_init_addon_class($addon_name);
309
+		// delay calling after_registration hook on each addon until after all add-ons have been registered.
310
+		add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999);
311
+	}
312 312
 
313 313
 
314
-    /**
315
-     * @param string $addon_name
316
-     * @param array  $setup_args
317
-     * @return void
318
-     * @throws EE_Error
319
-     */
320
-    private static function _verify_parameters($addon_name, array $setup_args)
321
-    {
322
-        // required fields MUST be present, so let's make sure they are.
323
-        if (empty($addon_name) || ! is_array($setup_args)) {
324
-            throw new EE_Error(
325
-                __(
326
-                    '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.',
327
-                    'event_espresso'
328
-                )
329
-            );
330
-        }
331
-        if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
332
-            throw new EE_Error(
333
-                sprintf(
334
-                    __(
335
-                        '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',
336
-                        'event_espresso'
337
-                    ),
338
-                    implode(',', array_keys($setup_args))
339
-                )
340
-            );
341
-        }
342
-        // check that addon has not already been registered with that name
343
-        if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
344
-            throw new EE_Error(
345
-                sprintf(
346
-                    __(
347
-                        'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
348
-                        'event_espresso'
349
-                    ),
350
-                    $addon_name
351
-                )
352
-            );
353
-        }
354
-    }
314
+	/**
315
+	 * @param string $addon_name
316
+	 * @param array  $setup_args
317
+	 * @return void
318
+	 * @throws EE_Error
319
+	 */
320
+	private static function _verify_parameters($addon_name, array $setup_args)
321
+	{
322
+		// required fields MUST be present, so let's make sure they are.
323
+		if (empty($addon_name) || ! is_array($setup_args)) {
324
+			throw new EE_Error(
325
+				__(
326
+					'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.',
327
+					'event_espresso'
328
+				)
329
+			);
330
+		}
331
+		if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
332
+			throw new EE_Error(
333
+				sprintf(
334
+					__(
335
+						'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',
336
+						'event_espresso'
337
+					),
338
+					implode(',', array_keys($setup_args))
339
+				)
340
+			);
341
+		}
342
+		// check that addon has not already been registered with that name
343
+		if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
344
+			throw new EE_Error(
345
+				sprintf(
346
+					__(
347
+						'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
348
+						'event_espresso'
349
+					),
350
+					$addon_name
351
+				)
352
+			);
353
+		}
354
+	}
355 355
 
356 356
 
357
-    /**
358
-     * @param string $addon_name
359
-     * @param array  $setup_args
360
-     * @return string
361
-     */
362
-    private static function _parse_class_name($addon_name, array $setup_args)
363
-    {
364
-        if (empty($setup_args['class_name'])) {
365
-            // generate one by first separating name with spaces
366
-            $class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
367
-            // capitalize, then replace spaces with underscores
368
-            $class_name = str_replace(' ', '_', ucwords($class_name));
369
-        } else {
370
-            $class_name = $setup_args['class_name'];
371
-        }
372
-        // check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
373
-        return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
374
-            ? $class_name
375
-            : 'EE_' . $class_name;
376
-    }
357
+	/**
358
+	 * @param string $addon_name
359
+	 * @param array  $setup_args
360
+	 * @return string
361
+	 */
362
+	private static function _parse_class_name($addon_name, array $setup_args)
363
+	{
364
+		if (empty($setup_args['class_name'])) {
365
+			// generate one by first separating name with spaces
366
+			$class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
367
+			// capitalize, then replace spaces with underscores
368
+			$class_name = str_replace(' ', '_', ucwords($class_name));
369
+		} else {
370
+			$class_name = $setup_args['class_name'];
371
+		}
372
+		// check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
373
+		return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
374
+			? $class_name
375
+			: 'EE_' . $class_name;
376
+	}
377 377
 
378 378
 
379
-    /**
380
-     * @param string $class_name
381
-     * @param array  $setup_args
382
-     * @return array
383
-     */
384
-    private static function _get_addon_settings($class_name, array $setup_args)
385
-    {
386
-        // setup $_settings array from incoming values.
387
-        $addon_settings = array(
388
-            // generated from the addon name, changes something like "calendar" to "EE_Calendar"
389
-            'class_name'            => $class_name,
390
-            // the addon slug for use in URLs, etc
391
-            'plugin_slug'           => isset($setup_args['plugin_slug'])
392
-                ? (string) $setup_args['plugin_slug']
393
-                : '',
394
-            // page slug to be used when generating the "Settings" link on the WP plugin page
395
-            'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
396
-                ? (string) $setup_args['plugin_action_slug']
397
-                : '',
398
-            // the "software" version for the addon
399
-            'version'               => isset($setup_args['version'])
400
-                ? (string) $setup_args['version']
401
-                : '',
402
-            // the minimum version of EE Core that the addon will work with
403
-            'min_core_version'      => isset($setup_args['min_core_version'])
404
-                ? (string) $setup_args['min_core_version']
405
-                : '',
406
-            // the minimum version of WordPress that the addon will work with
407
-            'min_wp_version'        => isset($setup_args['min_wp_version'])
408
-                ? (string) $setup_args['min_wp_version']
409
-                : EE_MIN_WP_VER_REQUIRED,
410
-            // full server path to main file (file loaded directly by WP)
411
-            'main_file_path'        => isset($setup_args['main_file_path'])
412
-                ? (string) $setup_args['main_file_path']
413
-                : '',
414
-            // instance of \EventEspresso\core\domain\DomainInterface
415
-            'domain'                => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface
416
-                ? $setup_args['domain']
417
-                : null,
418
-            // Fully Qualified Class Name for the addon's Domain class
419
-            'domain_fqcn'           => isset($setup_args['domain_fqcn'])
420
-                ? (string) $setup_args['domain_fqcn']
421
-                : '',
422
-            // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
423
-            'admin_path'            => isset($setup_args['admin_path'])
424
-                ? (string) $setup_args['admin_path'] : '',
425
-            // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
426
-            'admin_callback'        => isset($setup_args['admin_callback'])
427
-                ? (string) $setup_args['admin_callback']
428
-                : '',
429
-            // the section name for this addon's configuration settings section (defaults to "addons")
430
-            'config_section'        => isset($setup_args['config_section'])
431
-                ? (string) $setup_args['config_section']
432
-                : 'addons',
433
-            // the class name for this addon's configuration settings object
434
-            'config_class'          => isset($setup_args['config_class'])
435
-                ? (string) $setup_args['config_class'] : '',
436
-            // the name given to the config for this addons' configuration settings object (optional)
437
-            'config_name'           => isset($setup_args['config_name'])
438
-                ? (string) $setup_args['config_name'] : '',
439
-            // an array of "class names" => "full server paths" for any classes that might be invoked by the addon
440
-            'autoloader_paths'      => isset($setup_args['autoloader_paths'])
441
-                ? (array) $setup_args['autoloader_paths']
442
-                : array(),
443
-            // an array of  "full server paths" for any folders containing classes that might be invoked by the addon
444
-            'autoloader_folders'    => isset($setup_args['autoloader_folders'])
445
-                ? (array) $setup_args['autoloader_folders']
446
-                : array(),
447
-            // array of full server paths to any EE_DMS data migration scripts used by the addon.
448
-            // The key should be the EE_Addon class name that this set of data migration scripts belongs to.
449
-            // If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name
450
-            'dms_paths'             => isset($setup_args['dms_paths'])
451
-                ? (array) $setup_args['dms_paths']
452
-                : array(),
453
-            // array of full server paths to any EED_Modules used by the addon
454
-            'module_paths'          => isset($setup_args['module_paths'])
455
-                ? (array) $setup_args['module_paths']
456
-                : array(),
457
-            // array of full server paths to any EES_Shortcodes used by the addon
458
-            'shortcode_paths'       => isset($setup_args['shortcode_paths'])
459
-                ? (array) $setup_args['shortcode_paths']
460
-                : array(),
461
-            'shortcode_fqcns'       => isset($setup_args['shortcode_fqcns'])
462
-                ? (array) $setup_args['shortcode_fqcns']
463
-                : array(),
464
-            // array of full server paths to any WP_Widgets used by the addon
465
-            'widget_paths'          => isset($setup_args['widget_paths'])
466
-                ? (array) $setup_args['widget_paths']
467
-                : array(),
468
-            // array of PUE options used by the addon
469
-            'pue_options'           => isset($setup_args['pue_options'])
470
-                ? (array) $setup_args['pue_options']
471
-                : array(),
472
-            'message_types'         => isset($setup_args['message_types'])
473
-                ? (array) $setup_args['message_types']
474
-                : array(),
475
-            'capabilities'          => isset($setup_args['capabilities'])
476
-                ? (array) $setup_args['capabilities']
477
-                : array(),
478
-            'capability_maps'       => isset($setup_args['capability_maps'])
479
-                ? (array) $setup_args['capability_maps']
480
-                : array(),
481
-            'model_paths'           => isset($setup_args['model_paths'])
482
-                ? (array) $setup_args['model_paths']
483
-                : array(),
484
-            'class_paths'           => isset($setup_args['class_paths'])
485
-                ? (array) $setup_args['class_paths']
486
-                : array(),
487
-            'model_extension_paths' => isset($setup_args['model_extension_paths'])
488
-                ? (array) $setup_args['model_extension_paths']
489
-                : array(),
490
-            'class_extension_paths' => isset($setup_args['class_extension_paths'])
491
-                ? (array) $setup_args['class_extension_paths']
492
-                : array(),
493
-            'custom_post_types'     => isset($setup_args['custom_post_types'])
494
-                ? (array) $setup_args['custom_post_types']
495
-                : array(),
496
-            'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
497
-                ? (array) $setup_args['custom_taxonomies']
498
-                : array(),
499
-            'payment_method_paths'  => isset($setup_args['payment_method_paths'])
500
-                ? (array) $setup_args['payment_method_paths']
501
-                : array(),
502
-            'default_terms'         => isset($setup_args['default_terms'])
503
-                ? (array) $setup_args['default_terms']
504
-                : array(),
505
-            // if not empty, inserts a new table row after this plugin's row on the WP Plugins page
506
-            // that can be used for adding upgrading/marketing info
507
-            'plugins_page_row'      => isset($setup_args['plugins_page_row'])
508
-                ? $setup_args['plugins_page_row']
509
-                : '',
510
-            'namespace'             => isset(
511
-                $setup_args['namespace']['FQNS'],
512
-                $setup_args['namespace']['DIR']
513
-            )
514
-                ? (array) $setup_args['namespace']
515
-                : array(),
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
-    }
379
+	/**
380
+	 * @param string $class_name
381
+	 * @param array  $setup_args
382
+	 * @return array
383
+	 */
384
+	private static function _get_addon_settings($class_name, array $setup_args)
385
+	{
386
+		// setup $_settings array from incoming values.
387
+		$addon_settings = array(
388
+			// generated from the addon name, changes something like "calendar" to "EE_Calendar"
389
+			'class_name'            => $class_name,
390
+			// the addon slug for use in URLs, etc
391
+			'plugin_slug'           => isset($setup_args['plugin_slug'])
392
+				? (string) $setup_args['plugin_slug']
393
+				: '',
394
+			// page slug to be used when generating the "Settings" link on the WP plugin page
395
+			'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
396
+				? (string) $setup_args['plugin_action_slug']
397
+				: '',
398
+			// the "software" version for the addon
399
+			'version'               => isset($setup_args['version'])
400
+				? (string) $setup_args['version']
401
+				: '',
402
+			// the minimum version of EE Core that the addon will work with
403
+			'min_core_version'      => isset($setup_args['min_core_version'])
404
+				? (string) $setup_args['min_core_version']
405
+				: '',
406
+			// the minimum version of WordPress that the addon will work with
407
+			'min_wp_version'        => isset($setup_args['min_wp_version'])
408
+				? (string) $setup_args['min_wp_version']
409
+				: EE_MIN_WP_VER_REQUIRED,
410
+			// full server path to main file (file loaded directly by WP)
411
+			'main_file_path'        => isset($setup_args['main_file_path'])
412
+				? (string) $setup_args['main_file_path']
413
+				: '',
414
+			// instance of \EventEspresso\core\domain\DomainInterface
415
+			'domain'                => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface
416
+				? $setup_args['domain']
417
+				: null,
418
+			// Fully Qualified Class Name for the addon's Domain class
419
+			'domain_fqcn'           => isset($setup_args['domain_fqcn'])
420
+				? (string) $setup_args['domain_fqcn']
421
+				: '',
422
+			// path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
423
+			'admin_path'            => isset($setup_args['admin_path'])
424
+				? (string) $setup_args['admin_path'] : '',
425
+			// a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
426
+			'admin_callback'        => isset($setup_args['admin_callback'])
427
+				? (string) $setup_args['admin_callback']
428
+				: '',
429
+			// the section name for this addon's configuration settings section (defaults to "addons")
430
+			'config_section'        => isset($setup_args['config_section'])
431
+				? (string) $setup_args['config_section']
432
+				: 'addons',
433
+			// the class name for this addon's configuration settings object
434
+			'config_class'          => isset($setup_args['config_class'])
435
+				? (string) $setup_args['config_class'] : '',
436
+			// the name given to the config for this addons' configuration settings object (optional)
437
+			'config_name'           => isset($setup_args['config_name'])
438
+				? (string) $setup_args['config_name'] : '',
439
+			// an array of "class names" => "full server paths" for any classes that might be invoked by the addon
440
+			'autoloader_paths'      => isset($setup_args['autoloader_paths'])
441
+				? (array) $setup_args['autoloader_paths']
442
+				: array(),
443
+			// an array of  "full server paths" for any folders containing classes that might be invoked by the addon
444
+			'autoloader_folders'    => isset($setup_args['autoloader_folders'])
445
+				? (array) $setup_args['autoloader_folders']
446
+				: array(),
447
+			// array of full server paths to any EE_DMS data migration scripts used by the addon.
448
+			// The key should be the EE_Addon class name that this set of data migration scripts belongs to.
449
+			// If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name
450
+			'dms_paths'             => isset($setup_args['dms_paths'])
451
+				? (array) $setup_args['dms_paths']
452
+				: array(),
453
+			// array of full server paths to any EED_Modules used by the addon
454
+			'module_paths'          => isset($setup_args['module_paths'])
455
+				? (array) $setup_args['module_paths']
456
+				: array(),
457
+			// array of full server paths to any EES_Shortcodes used by the addon
458
+			'shortcode_paths'       => isset($setup_args['shortcode_paths'])
459
+				? (array) $setup_args['shortcode_paths']
460
+				: array(),
461
+			'shortcode_fqcns'       => isset($setup_args['shortcode_fqcns'])
462
+				? (array) $setup_args['shortcode_fqcns']
463
+				: array(),
464
+			// array of full server paths to any WP_Widgets used by the addon
465
+			'widget_paths'          => isset($setup_args['widget_paths'])
466
+				? (array) $setup_args['widget_paths']
467
+				: array(),
468
+			// array of PUE options used by the addon
469
+			'pue_options'           => isset($setup_args['pue_options'])
470
+				? (array) $setup_args['pue_options']
471
+				: array(),
472
+			'message_types'         => isset($setup_args['message_types'])
473
+				? (array) $setup_args['message_types']
474
+				: array(),
475
+			'capabilities'          => isset($setup_args['capabilities'])
476
+				? (array) $setup_args['capabilities']
477
+				: array(),
478
+			'capability_maps'       => isset($setup_args['capability_maps'])
479
+				? (array) $setup_args['capability_maps']
480
+				: array(),
481
+			'model_paths'           => isset($setup_args['model_paths'])
482
+				? (array) $setup_args['model_paths']
483
+				: array(),
484
+			'class_paths'           => isset($setup_args['class_paths'])
485
+				? (array) $setup_args['class_paths']
486
+				: array(),
487
+			'model_extension_paths' => isset($setup_args['model_extension_paths'])
488
+				? (array) $setup_args['model_extension_paths']
489
+				: array(),
490
+			'class_extension_paths' => isset($setup_args['class_extension_paths'])
491
+				? (array) $setup_args['class_extension_paths']
492
+				: array(),
493
+			'custom_post_types'     => isset($setup_args['custom_post_types'])
494
+				? (array) $setup_args['custom_post_types']
495
+				: array(),
496
+			'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
497
+				? (array) $setup_args['custom_taxonomies']
498
+				: array(),
499
+			'payment_method_paths'  => isset($setup_args['payment_method_paths'])
500
+				? (array) $setup_args['payment_method_paths']
501
+				: array(),
502
+			'default_terms'         => isset($setup_args['default_terms'])
503
+				? (array) $setup_args['default_terms']
504
+				: array(),
505
+			// if not empty, inserts a new table row after this plugin's row on the WP Plugins page
506
+			// that can be used for adding upgrading/marketing info
507
+			'plugins_page_row'      => isset($setup_args['plugins_page_row'])
508
+				? $setup_args['plugins_page_row']
509
+				: '',
510
+			'namespace'             => isset(
511
+				$setup_args['namespace']['FQNS'],
512
+				$setup_args['namespace']['DIR']
513
+			)
514
+				? (array) $setup_args['namespace']
515
+				: array(),
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 boolean
536
-     */
537
-    private static function _addon_is_compatible($addon_name, array $addon_settings)
538
-    {
539
-        global $wp_version;
540
-        $incompatibility_message = '';
541
-        // check whether this addon version is compatible with EE core
542
-        if (isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
543
-            && ! self::_meets_min_core_version_requirement(
544
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
545
-                $addon_settings['version']
546
-            )
547
-        ) {
548
-            $incompatibility_message = sprintf(
549
-                __(
550
-                    '%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.',
551
-                    'event_espresso'
552
-                ),
553
-                $addon_name,
554
-                '<br />',
555
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
556
-                '<span style="font-weight: bold; color: #D54E21;">',
557
-                '</span><br />'
558
-            );
559
-        } elseif (! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
560
-        ) {
561
-            $incompatibility_message = sprintf(
562
-                __(
563
-                    '%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".',
564
-                    'event_espresso'
565
-                ),
566
-                $addon_name,
567
-                self::_effective_version($addon_settings['min_core_version']),
568
-                self::_effective_version(espresso_version()),
569
-                '<br />',
570
-                '<span style="font-weight: bold; color: #D54E21;">',
571
-                '</span><br />'
572
-            );
573
-        } elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
574
-            $incompatibility_message = sprintf(
575
-                __(
576
-                    '%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.',
577
-                    'event_espresso'
578
-                ),
579
-                $addon_name,
580
-                $addon_settings['min_wp_version'],
581
-                '<br />',
582
-                '<span style="font-weight: bold; color: #D54E21;">',
583
-                '</span><br />'
584
-            );
585
-        }
586
-        if (! empty($incompatibility_message)) {
587
-            // remove 'activate' from the REQUEST
588
-            // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
589
-            unset($_GET['activate'], $_REQUEST['activate']);
590
-            if (current_user_can('activate_plugins')) {
591
-                // show an error message indicating the plugin didn't activate properly
592
-                EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
593
-            }
594
-            // BAIL FROM THE ADDON REGISTRATION PROCESS
595
-            return false;
596
-        }
597
-        // addon IS compatible
598
-        return true;
599
-    }
532
+	/**
533
+	 * @param string $addon_name
534
+	 * @param array  $addon_settings
535
+	 * @return boolean
536
+	 */
537
+	private static function _addon_is_compatible($addon_name, array $addon_settings)
538
+	{
539
+		global $wp_version;
540
+		$incompatibility_message = '';
541
+		// check whether this addon version is compatible with EE core
542
+		if (isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
543
+			&& ! self::_meets_min_core_version_requirement(
544
+				EE_Register_Addon::$_incompatible_addons[ $addon_name ],
545
+				$addon_settings['version']
546
+			)
547
+		) {
548
+			$incompatibility_message = sprintf(
549
+				__(
550
+					'%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.',
551
+					'event_espresso'
552
+				),
553
+				$addon_name,
554
+				'<br />',
555
+				EE_Register_Addon::$_incompatible_addons[ $addon_name ],
556
+				'<span style="font-weight: bold; color: #D54E21;">',
557
+				'</span><br />'
558
+			);
559
+		} elseif (! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
560
+		) {
561
+			$incompatibility_message = sprintf(
562
+				__(
563
+					'%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".',
564
+					'event_espresso'
565
+				),
566
+				$addon_name,
567
+				self::_effective_version($addon_settings['min_core_version']),
568
+				self::_effective_version(espresso_version()),
569
+				'<br />',
570
+				'<span style="font-weight: bold; color: #D54E21;">',
571
+				'</span><br />'
572
+			);
573
+		} elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
574
+			$incompatibility_message = sprintf(
575
+				__(
576
+					'%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.',
577
+					'event_espresso'
578
+				),
579
+				$addon_name,
580
+				$addon_settings['min_wp_version'],
581
+				'<br />',
582
+				'<span style="font-weight: bold; color: #D54E21;">',
583
+				'</span><br />'
584
+			);
585
+		}
586
+		if (! empty($incompatibility_message)) {
587
+			// remove 'activate' from the REQUEST
588
+			// so WP doesn't erroneously tell the user the plugin activated fine when it didn't
589
+			unset($_GET['activate'], $_REQUEST['activate']);
590
+			if (current_user_can('activate_plugins')) {
591
+				// show an error message indicating the plugin didn't activate properly
592
+				EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
593
+			}
594
+			// BAIL FROM THE ADDON REGISTRATION PROCESS
595
+			return false;
596
+		}
597
+		// addon IS compatible
598
+		return true;
599
+	}
600 600
 
601 601
 
602
-    /**
603
-     * if plugin update engine is being used for auto-updates,
604
-     * then let's set that up now before going any further so that ALL addons can be updated
605
-     * (not needed if PUE is not being used)
606
-     *
607
-     * @param string $addon_name
608
-     * @param string $class_name
609
-     * @param array  $setup_args
610
-     * @return void
611
-     */
612
-    private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
613
-    {
614
-        if (! empty($setup_args['pue_options'])) {
615
-            self::$_settings[ $addon_name ]['pue_options'] = array(
616
-                'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
617
-                    ? (string) $setup_args['pue_options']['pue_plugin_slug']
618
-                    : 'espresso_' . strtolower($class_name),
619
-                'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
620
-                    ? (string) $setup_args['pue_options']['plugin_basename']
621
-                    : plugin_basename($setup_args['main_file_path']),
622
-                'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
623
-                    ? (string) $setup_args['pue_options']['checkPeriod']
624
-                    : '24',
625
-                'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
626
-                    ? (string) $setup_args['pue_options']['use_wp_update']
627
-                    : false,
628
-            );
629
-            add_action(
630
-                'AHEE__EE_System__brew_espresso__after_pue_init',
631
-                array('EE_Register_Addon', 'load_pue_update')
632
-            );
633
-        }
634
-    }
602
+	/**
603
+	 * if plugin update engine is being used for auto-updates,
604
+	 * then let's set that up now before going any further so that ALL addons can be updated
605
+	 * (not needed if PUE is not being used)
606
+	 *
607
+	 * @param string $addon_name
608
+	 * @param string $class_name
609
+	 * @param array  $setup_args
610
+	 * @return void
611
+	 */
612
+	private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
613
+	{
614
+		if (! empty($setup_args['pue_options'])) {
615
+			self::$_settings[ $addon_name ]['pue_options'] = array(
616
+				'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
617
+					? (string) $setup_args['pue_options']['pue_plugin_slug']
618
+					: 'espresso_' . strtolower($class_name),
619
+				'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
620
+					? (string) $setup_args['pue_options']['plugin_basename']
621
+					: plugin_basename($setup_args['main_file_path']),
622
+				'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
623
+					? (string) $setup_args['pue_options']['checkPeriod']
624
+					: '24',
625
+				'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
626
+					? (string) $setup_args['pue_options']['use_wp_update']
627
+					: false,
628
+			);
629
+			add_action(
630
+				'AHEE__EE_System__brew_espresso__after_pue_init',
631
+				array('EE_Register_Addon', 'load_pue_update')
632
+			);
633
+		}
634
+	}
635 635
 
636 636
 
637
-    /**
638
-     * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
639
-     *
640
-     * @param array $addon_settings
641
-     * @return void
642
-     */
643
-    private static function _setup_namespaces(array $addon_settings)
644
-    {
645
-        //
646
-        if (isset(
647
-            $addon_settings['namespace']['FQNS'],
648
-            $addon_settings['namespace']['DIR']
649
-        )) {
650
-            EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
651
-                $addon_settings['namespace']['FQNS'],
652
-                $addon_settings['namespace']['DIR']
653
-            );
654
-        }
655
-    }
637
+	/**
638
+	 * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
639
+	 *
640
+	 * @param array $addon_settings
641
+	 * @return void
642
+	 */
643
+	private static function _setup_namespaces(array $addon_settings)
644
+	{
645
+		//
646
+		if (isset(
647
+			$addon_settings['namespace']['FQNS'],
648
+			$addon_settings['namespace']['DIR']
649
+		)) {
650
+			EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
651
+				$addon_settings['namespace']['FQNS'],
652
+				$addon_settings['namespace']['DIR']
653
+			);
654
+		}
655
+	}
656 656
 
657 657
 
658
-    /**
659
-     * @param string $addon_name
660
-     * @param array  $addon_settings
661
-     * @return bool
662
-     * @throws EE_Error
663
-     * @throws InvalidArgumentException
664
-     * @throws ReflectionException
665
-     * @throws InvalidDataTypeException
666
-     * @throws InvalidInterfaceException
667
-     */
668
-    private static function _addon_activation($addon_name, array $addon_settings)
669
-    {
670
-        // this is an activation request
671
-        if (did_action(
672
-            'activate_plugin'
673
-        )) {// to find if THIS is the addon that was activated, just check if we have already registered it or not
674
-            // (as the newly-activated addon wasn't around the first time addons were registered).
675
-            // Note: the presence of pue_options in the addon registration options will initialize the $_settings
676
-            // property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
677
-            if (! isset(self::$_settings[ $addon_name ])
678
-                || (isset(self::$_settings[ $addon_name ])
679
-                    && ! isset(self::$_settings[ $addon_name ]['class_name'])
680
-                )
681
-            ) {
682
-                self::$_settings[ $addon_name ] = $addon_settings;
683
-                $addon = self::_load_and_init_addon_class($addon_name);
684
-                $addon->set_activation_indicator_option();
685
-                // dont bother setting up the rest of the addon.
686
-                // we know it was just activated and the request will end soon
687
-            }
688
-            return true;
689
-        }
690
-        // make sure this was called in the right place!
691
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
692
-            || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
693
-        ) {
694
-            EE_Error::doing_it_wrong(
695
-                __METHOD__,
696
-                sprintf(
697
-                    __(
698
-                        '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.',
699
-                        'event_espresso'
700
-                    ),
701
-                    $addon_name
702
-                ),
703
-                '4.3.0'
704
-            );
705
-        }
706
-        // make sure addon settings are set correctly without overwriting anything existing
707
-        if (isset(self::$_settings[ $addon_name ])) {
708
-            self::$_settings[ $addon_name ] += $addon_settings;
709
-        } else {
710
-            self::$_settings[ $addon_name ] = $addon_settings;
711
-        }
712
-        return false;
713
-    }
658
+	/**
659
+	 * @param string $addon_name
660
+	 * @param array  $addon_settings
661
+	 * @return bool
662
+	 * @throws EE_Error
663
+	 * @throws InvalidArgumentException
664
+	 * @throws ReflectionException
665
+	 * @throws InvalidDataTypeException
666
+	 * @throws InvalidInterfaceException
667
+	 */
668
+	private static function _addon_activation($addon_name, array $addon_settings)
669
+	{
670
+		// this is an activation request
671
+		if (did_action(
672
+			'activate_plugin'
673
+		)) {// to find if THIS is the addon that was activated, just check if we have already registered it or not
674
+			// (as the newly-activated addon wasn't around the first time addons were registered).
675
+			// Note: the presence of pue_options in the addon registration options will initialize the $_settings
676
+			// property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
677
+			if (! isset(self::$_settings[ $addon_name ])
678
+				|| (isset(self::$_settings[ $addon_name ])
679
+					&& ! isset(self::$_settings[ $addon_name ]['class_name'])
680
+				)
681
+			) {
682
+				self::$_settings[ $addon_name ] = $addon_settings;
683
+				$addon = self::_load_and_init_addon_class($addon_name);
684
+				$addon->set_activation_indicator_option();
685
+				// dont bother setting up the rest of the addon.
686
+				// we know it was just activated and the request will end soon
687
+			}
688
+			return true;
689
+		}
690
+		// make sure this was called in the right place!
691
+		if (! did_action('AHEE__EE_System__load_espresso_addons')
692
+			|| did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
693
+		) {
694
+			EE_Error::doing_it_wrong(
695
+				__METHOD__,
696
+				sprintf(
697
+					__(
698
+						'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.',
699
+						'event_espresso'
700
+					),
701
+					$addon_name
702
+				),
703
+				'4.3.0'
704
+			);
705
+		}
706
+		// make sure addon settings are set correctly without overwriting anything existing
707
+		if (isset(self::$_settings[ $addon_name ])) {
708
+			self::$_settings[ $addon_name ] += $addon_settings;
709
+		} else {
710
+			self::$_settings[ $addon_name ] = $addon_settings;
711
+		}
712
+		return false;
713
+	}
714 714
 
715 715
 
716
-    /**
717
-     * @param string $addon_name
718
-     * @return void
719
-     * @throws EE_Error
720
-     */
721
-    private static function _setup_autoloaders($addon_name)
722
-    {
723
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
724
-            // setup autoloader for single file
725
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
726
-        }
727
-        // setup autoloaders for folders
728
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
729
-            foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
730
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
731
-            }
732
-        }
733
-    }
716
+	/**
717
+	 * @param string $addon_name
718
+	 * @return void
719
+	 * @throws EE_Error
720
+	 */
721
+	private static function _setup_autoloaders($addon_name)
722
+	{
723
+		if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
724
+			// setup autoloader for single file
725
+			EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
726
+		}
727
+		// setup autoloaders for folders
728
+		if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
729
+			foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
730
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
731
+			}
732
+		}
733
+	}
734 734
 
735 735
 
736
-    /**
737
-     * register new models and extensions
738
-     *
739
-     * @param string $addon_name
740
-     * @return void
741
-     * @throws EE_Error
742
-     */
743
-    private static function _register_models_and_extensions($addon_name)
744
-    {
745
-        // register new models
746
-        if (! empty(self::$_settings[ $addon_name ]['model_paths'])
747
-            || ! empty(self::$_settings[ $addon_name ]['class_paths'])
748
-        ) {
749
-            EE_Register_Model::register(
750
-                $addon_name,
751
-                array(
752
-                    'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
753
-                    'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
754
-                )
755
-            );
756
-        }
757
-        // register model extensions
758
-        if (! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
759
-            || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
760
-        ) {
761
-            EE_Register_Model_Extensions::register(
762
-                $addon_name,
763
-                array(
764
-                    'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
765
-                    'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
766
-                )
767
-            );
768
-        }
769
-    }
736
+	/**
737
+	 * register new models and extensions
738
+	 *
739
+	 * @param string $addon_name
740
+	 * @return void
741
+	 * @throws EE_Error
742
+	 */
743
+	private static function _register_models_and_extensions($addon_name)
744
+	{
745
+		// register new models
746
+		if (! empty(self::$_settings[ $addon_name ]['model_paths'])
747
+			|| ! empty(self::$_settings[ $addon_name ]['class_paths'])
748
+		) {
749
+			EE_Register_Model::register(
750
+				$addon_name,
751
+				array(
752
+					'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
753
+					'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
754
+				)
755
+			);
756
+		}
757
+		// register model extensions
758
+		if (! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
759
+			|| ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
760
+		) {
761
+			EE_Register_Model_Extensions::register(
762
+				$addon_name,
763
+				array(
764
+					'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
765
+					'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
766
+				)
767
+			);
768
+		}
769
+	}
770 770
 
771 771
 
772
-    /**
773
-     * @param string $addon_name
774
-     * @return void
775
-     * @throws EE_Error
776
-     */
777
-    private static function _register_data_migration_scripts($addon_name)
778
-    {
779
-        // setup DMS
780
-        if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
781
-            EE_Register_Data_Migration_Scripts::register(
782
-                $addon_name,
783
-                array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
784
-            );
785
-        }
786
-    }
772
+	/**
773
+	 * @param string $addon_name
774
+	 * @return void
775
+	 * @throws EE_Error
776
+	 */
777
+	private static function _register_data_migration_scripts($addon_name)
778
+	{
779
+		// setup DMS
780
+		if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
781
+			EE_Register_Data_Migration_Scripts::register(
782
+				$addon_name,
783
+				array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
784
+			);
785
+		}
786
+	}
787 787
 
788 788
 
789
-    /**
790
-     * @param string $addon_name
791
-     * @return void
792
-     * @throws EE_Error
793
-     */
794
-    private static function _register_config($addon_name)
795
-    {
796
-        // if config_class is present let's register config.
797
-        if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
798
-            EE_Register_Config::register(
799
-                self::$_settings[ $addon_name ]['config_class'],
800
-                array(
801
-                    'config_section' => self::$_settings[ $addon_name ]['config_section'],
802
-                    'config_name'    => self::$_settings[ $addon_name ]['config_name'],
803
-                )
804
-            );
805
-        }
806
-    }
789
+	/**
790
+	 * @param string $addon_name
791
+	 * @return void
792
+	 * @throws EE_Error
793
+	 */
794
+	private static function _register_config($addon_name)
795
+	{
796
+		// if config_class is present let's register config.
797
+		if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
798
+			EE_Register_Config::register(
799
+				self::$_settings[ $addon_name ]['config_class'],
800
+				array(
801
+					'config_section' => self::$_settings[ $addon_name ]['config_section'],
802
+					'config_name'    => self::$_settings[ $addon_name ]['config_name'],
803
+				)
804
+			);
805
+		}
806
+	}
807 807
 
808 808
 
809
-    /**
810
-     * @param string $addon_name
811
-     * @return void
812
-     * @throws EE_Error
813
-     */
814
-    private static function _register_admin_pages($addon_name)
815
-    {
816
-        if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
817
-            EE_Register_Admin_Page::register(
818
-                $addon_name,
819
-                array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
820
-            );
821
-        }
822
-    }
809
+	/**
810
+	 * @param string $addon_name
811
+	 * @return void
812
+	 * @throws EE_Error
813
+	 */
814
+	private static function _register_admin_pages($addon_name)
815
+	{
816
+		if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
817
+			EE_Register_Admin_Page::register(
818
+				$addon_name,
819
+				array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
820
+			);
821
+		}
822
+	}
823 823
 
824 824
 
825
-    /**
826
-     * @param string $addon_name
827
-     * @return void
828
-     * @throws EE_Error
829
-     */
830
-    private static function _register_modules($addon_name)
831
-    {
832
-        if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
833
-            EE_Register_Module::register(
834
-                $addon_name,
835
-                array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
836
-            );
837
-        }
838
-    }
825
+	/**
826
+	 * @param string $addon_name
827
+	 * @return void
828
+	 * @throws EE_Error
829
+	 */
830
+	private static function _register_modules($addon_name)
831
+	{
832
+		if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
833
+			EE_Register_Module::register(
834
+				$addon_name,
835
+				array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
836
+			);
837
+		}
838
+	}
839 839
 
840 840
 
841
-    /**
842
-     * @param string $addon_name
843
-     * @return void
844
-     * @throws EE_Error
845
-     */
846
-    private static function _register_shortcodes($addon_name)
847
-    {
848
-        if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
849
-            || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
850
-        ) {
851
-            EE_Register_Shortcode::register(
852
-                $addon_name,
853
-                array(
854
-                    'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
855
-                        ? self::$_settings[ $addon_name ]['shortcode_paths']
856
-                        : array(),
857
-                    'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
858
-                        ? self::$_settings[ $addon_name ]['shortcode_fqcns']
859
-                        : array(),
860
-                )
861
-            );
862
-        }
863
-    }
841
+	/**
842
+	 * @param string $addon_name
843
+	 * @return void
844
+	 * @throws EE_Error
845
+	 */
846
+	private static function _register_shortcodes($addon_name)
847
+	{
848
+		if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
849
+			|| ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
850
+		) {
851
+			EE_Register_Shortcode::register(
852
+				$addon_name,
853
+				array(
854
+					'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
855
+						? self::$_settings[ $addon_name ]['shortcode_paths']
856
+						: array(),
857
+					'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
858
+						? self::$_settings[ $addon_name ]['shortcode_fqcns']
859
+						: array(),
860
+				)
861
+			);
862
+		}
863
+	}
864 864
 
865 865
 
866
-    /**
867
-     * @param string $addon_name
868
-     * @return void
869
-     * @throws EE_Error
870
-     */
871
-    private static function _register_widgets($addon_name)
872
-    {
873
-        if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
874
-            EE_Register_Widget::register(
875
-                $addon_name,
876
-                array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
877
-            );
878
-        }
879
-    }
866
+	/**
867
+	 * @param string $addon_name
868
+	 * @return void
869
+	 * @throws EE_Error
870
+	 */
871
+	private static function _register_widgets($addon_name)
872
+	{
873
+		if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
874
+			EE_Register_Widget::register(
875
+				$addon_name,
876
+				array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
877
+			);
878
+		}
879
+	}
880 880
 
881 881
 
882
-    /**
883
-     * @param string $addon_name
884
-     * @return void
885
-     * @throws EE_Error
886
-     */
887
-    private static function _register_capabilities($addon_name)
888
-    {
889
-        if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
890
-            EE_Register_Capabilities::register(
891
-                $addon_name,
892
-                array(
893
-                    'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
894
-                    'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
895
-                )
896
-            );
897
-        }
898
-    }
882
+	/**
883
+	 * @param string $addon_name
884
+	 * @return void
885
+	 * @throws EE_Error
886
+	 */
887
+	private static function _register_capabilities($addon_name)
888
+	{
889
+		if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
890
+			EE_Register_Capabilities::register(
891
+				$addon_name,
892
+				array(
893
+					'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
894
+					'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
895
+				)
896
+			);
897
+		}
898
+	}
899 899
 
900 900
 
901
-    /**
902
-     * @param string $addon_name
903
-     * @return void
904
-     * @throws EE_Error
905
-     */
906
-    private static function _register_message_types($addon_name)
907
-    {
908
-        if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
909
-            add_action(
910
-                'EE_Brewing_Regular___messages_caf',
911
-                array('EE_Register_Addon', 'register_message_types')
912
-            );
913
-        }
914
-    }
901
+	/**
902
+	 * @param string $addon_name
903
+	 * @return void
904
+	 * @throws EE_Error
905
+	 */
906
+	private static function _register_message_types($addon_name)
907
+	{
908
+		if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
909
+			add_action(
910
+				'EE_Brewing_Regular___messages_caf',
911
+				array('EE_Register_Addon', 'register_message_types')
912
+			);
913
+		}
914
+	}
915 915
 
916 916
 
917
-    /**
918
-     * @param string $addon_name
919
-     * @return void
920
-     * @throws EE_Error
921
-     */
922
-    private static function _register_custom_post_types($addon_name)
923
-    {
924
-        if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])
925
-            || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
926
-        ) {
927
-            EE_Register_CPT::register(
928
-                $addon_name,
929
-                array(
930
-                    'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
931
-                    'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
932
-                    'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
933
-                )
934
-            );
935
-        }
936
-    }
917
+	/**
918
+	 * @param string $addon_name
919
+	 * @return void
920
+	 * @throws EE_Error
921
+	 */
922
+	private static function _register_custom_post_types($addon_name)
923
+	{
924
+		if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])
925
+			|| ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
926
+		) {
927
+			EE_Register_CPT::register(
928
+				$addon_name,
929
+				array(
930
+					'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
931
+					'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
932
+					'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
933
+				)
934
+			);
935
+		}
936
+	}
937 937
 
938 938
 
939
-    /**
940
-     * @param string $addon_name
941
-     * @return void
942
-     * @throws InvalidArgumentException
943
-     * @throws InvalidInterfaceException
944
-     * @throws InvalidDataTypeException
945
-     * @throws DomainException
946
-     * @throws EE_Error
947
-     */
948
-    private static function _register_payment_methods($addon_name)
949
-    {
950
-        if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
951
-            EE_Register_Payment_Method::register(
952
-                $addon_name,
953
-                array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
954
-            );
955
-        }
956
-    }
939
+	/**
940
+	 * @param string $addon_name
941
+	 * @return void
942
+	 * @throws InvalidArgumentException
943
+	 * @throws InvalidInterfaceException
944
+	 * @throws InvalidDataTypeException
945
+	 * @throws DomainException
946
+	 * @throws EE_Error
947
+	 */
948
+	private static function _register_payment_methods($addon_name)
949
+	{
950
+		if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
951
+			EE_Register_Payment_Method::register(
952
+				$addon_name,
953
+				array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
954
+			);
955
+		}
956
+	}
957 957
 
958 958
 
959
-    /**
960
-     * @param string $addon_name
961
-     * @return void
962
-     * @throws InvalidArgumentException
963
-     * @throws InvalidInterfaceException
964
-     * @throws InvalidDataTypeException
965
-     * @throws DomainException
966
-     * @throws EE_Error
967
-     */
968
-    private static function registerPrivacyPolicies($addon_name)
969
-    {
970
-        if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) {
971
-            EE_Register_Privacy_Policy::register(
972
-                $addon_name,
973
-                self::$_settings[ $addon_name ]['privacy_policies']
974
-            );
975
-        }
976
-    }
959
+	/**
960
+	 * @param string $addon_name
961
+	 * @return void
962
+	 * @throws InvalidArgumentException
963
+	 * @throws InvalidInterfaceException
964
+	 * @throws InvalidDataTypeException
965
+	 * @throws DomainException
966
+	 * @throws EE_Error
967
+	 */
968
+	private static function registerPrivacyPolicies($addon_name)
969
+	{
970
+		if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) {
971
+			EE_Register_Privacy_Policy::register(
972
+				$addon_name,
973
+				self::$_settings[ $addon_name ]['privacy_policies']
974
+			);
975
+		}
976
+	}
977 977
 
978 978
 
979
-    /**
980
-     * @param string $addon_name
981
-     * @return void
982
-     */
983
-    private static function registerPersonalDataExporters($addon_name)
984
-    {
985
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) {
986
-            EE_Register_Personal_Data_Eraser::register(
987
-                $addon_name,
988
-                self::$_settings[ $addon_name ]['personal_data_exporters']
989
-            );
990
-        }
991
-    }
979
+	/**
980
+	 * @param string $addon_name
981
+	 * @return void
982
+	 */
983
+	private static function registerPersonalDataExporters($addon_name)
984
+	{
985
+		if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) {
986
+			EE_Register_Personal_Data_Eraser::register(
987
+				$addon_name,
988
+				self::$_settings[ $addon_name ]['personal_data_exporters']
989
+			);
990
+		}
991
+	}
992 992
 
993 993
 
994
-    /**
995
-     * @param string $addon_name
996
-     * @return void
997
-     */
998
-    private static function registerPersonalDataErasers($addon_name)
999
-    {
1000
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) {
1001
-            EE_Register_Personal_Data_Eraser::register(
1002
-                $addon_name,
1003
-                self::$_settings[ $addon_name ]['personal_data_erasers']
1004
-            );
1005
-        }
1006
-    }
994
+	/**
995
+	 * @param string $addon_name
996
+	 * @return void
997
+	 */
998
+	private static function registerPersonalDataErasers($addon_name)
999
+	{
1000
+		if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) {
1001
+			EE_Register_Personal_Data_Eraser::register(
1002
+				$addon_name,
1003
+				self::$_settings[ $addon_name ]['personal_data_erasers']
1004
+			);
1005
+		}
1006
+	}
1007 1007
 
1008 1008
 
1009
-    /**
1010
-     * Loads and instantiates the EE_Addon class and adds it onto the registry
1011
-     *
1012
-     * @param string $addon_name
1013
-     * @return EE_Addon
1014
-     * @throws InvalidArgumentException
1015
-     * @throws InvalidInterfaceException
1016
-     * @throws InvalidDataTypeException
1017
-     * @throws ReflectionException
1018
-     * @throws EE_Error
1019
-     */
1020
-    private static function _load_and_init_addon_class($addon_name)
1021
-    {
1022
-        $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader();
1023
-        $addon = $loader->getShared(
1024
-            self::$_settings[ $addon_name ]['class_name'],
1025
-            array('EE_Registry::create(addon)' => true)
1026
-        );
1027
-        // setter inject dep map if required
1028
-        if ($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null) {
1029
-            $addon->setDependencyMap($loader->getShared('EE_Dependency_Map'));
1030
-        }
1031
-        // setter inject domain if required
1032
-        if ($addon instanceof RequiresDomainInterface
1033
-            && $addon->domain() === null
1034
-        ) {
1035
-            // using supplied Domain object
1036
-            $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
1037
-                ? self::$_settings[ $addon_name ]['domain']
1038
-                : null;
1039
-            // or construct one using Domain FQCN
1040
-            if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
1041
-                $domain = $loader->getShared(
1042
-                    self::$_settings[ $addon_name ]['domain_fqcn'],
1043
-                    array(
1044
-                        new EventEspresso\core\domain\values\FilePath(
1045
-                            self::$_settings[ $addon_name ]['main_file_path']
1046
-                        ),
1047
-                        EventEspresso\core\domain\values\Version::fromString(
1048
-                            self::$_settings[ $addon_name ]['version']
1049
-                        ),
1050
-                    )
1051
-                );
1052
-            }
1053
-            if ($domain instanceof DomainInterface) {
1054
-                $addon->setDomain($domain);
1055
-            }
1056
-        }
1057
-        $addon->set_name($addon_name);
1058
-        $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
1059
-        $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
1060
-        $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
1061
-        $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
1062
-        $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
1063
-        $addon->set_version(self::$_settings[ $addon_name ]['version']);
1064
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
1065
-        $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
1066
-        $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
1067
-        $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
1068
-        // setup the add-on's pue_slug if we have one.
1069
-        if (! empty(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug'])) {
1070
-            $addon->setPueSlug(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug']);
1071
-        }
1072
-        // unfortunately this can't be hooked in upon construction, because we don't have
1073
-        // the plugin mainfile's path upon construction.
1074
-        register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
1075
-        // call any additional admin_callback functions during load_admin_controller hook
1076
-        if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1077
-            add_action(
1078
-                'AHEE__EE_System__load_controllers__load_admin_controllers',
1079
-                array($addon, self::$_settings[ $addon_name ]['admin_callback'])
1080
-            );
1081
-        }
1082
-        return $addon;
1083
-    }
1009
+	/**
1010
+	 * Loads and instantiates the EE_Addon class and adds it onto the registry
1011
+	 *
1012
+	 * @param string $addon_name
1013
+	 * @return EE_Addon
1014
+	 * @throws InvalidArgumentException
1015
+	 * @throws InvalidInterfaceException
1016
+	 * @throws InvalidDataTypeException
1017
+	 * @throws ReflectionException
1018
+	 * @throws EE_Error
1019
+	 */
1020
+	private static function _load_and_init_addon_class($addon_name)
1021
+	{
1022
+		$loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader();
1023
+		$addon = $loader->getShared(
1024
+			self::$_settings[ $addon_name ]['class_name'],
1025
+			array('EE_Registry::create(addon)' => true)
1026
+		);
1027
+		// setter inject dep map if required
1028
+		if ($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null) {
1029
+			$addon->setDependencyMap($loader->getShared('EE_Dependency_Map'));
1030
+		}
1031
+		// setter inject domain if required
1032
+		if ($addon instanceof RequiresDomainInterface
1033
+			&& $addon->domain() === null
1034
+		) {
1035
+			// using supplied Domain object
1036
+			$domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
1037
+				? self::$_settings[ $addon_name ]['domain']
1038
+				: null;
1039
+			// or construct one using Domain FQCN
1040
+			if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
1041
+				$domain = $loader->getShared(
1042
+					self::$_settings[ $addon_name ]['domain_fqcn'],
1043
+					array(
1044
+						new EventEspresso\core\domain\values\FilePath(
1045
+							self::$_settings[ $addon_name ]['main_file_path']
1046
+						),
1047
+						EventEspresso\core\domain\values\Version::fromString(
1048
+							self::$_settings[ $addon_name ]['version']
1049
+						),
1050
+					)
1051
+				);
1052
+			}
1053
+			if ($domain instanceof DomainInterface) {
1054
+				$addon->setDomain($domain);
1055
+			}
1056
+		}
1057
+		$addon->set_name($addon_name);
1058
+		$addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
1059
+		$addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
1060
+		$addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
1061
+		$addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
1062
+		$addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
1063
+		$addon->set_version(self::$_settings[ $addon_name ]['version']);
1064
+		$addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
1065
+		$addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
1066
+		$addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
1067
+		$addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
1068
+		// setup the add-on's pue_slug if we have one.
1069
+		if (! empty(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug'])) {
1070
+			$addon->setPueSlug(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug']);
1071
+		}
1072
+		// unfortunately this can't be hooked in upon construction, because we don't have
1073
+		// the plugin mainfile's path upon construction.
1074
+		register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
1075
+		// call any additional admin_callback functions during load_admin_controller hook
1076
+		if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1077
+			add_action(
1078
+				'AHEE__EE_System__load_controllers__load_admin_controllers',
1079
+				array($addon, self::$_settings[ $addon_name ]['admin_callback'])
1080
+			);
1081
+		}
1082
+		return $addon;
1083
+	}
1084 1084
 
1085 1085
 
1086
-    /**
1087
-     *    load_pue_update - Update notifications
1088
-     *
1089
-     * @return void
1090
-     * @throws InvalidArgumentException
1091
-     * @throws InvalidDataTypeException
1092
-     * @throws InvalidInterfaceException
1093
-     */
1094
-    public static function load_pue_update()
1095
-    {
1096
-        // load PUE client
1097
-        require_once EE_THIRD_PARTY . 'pue/pue-client.php';
1098
-        $license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com';
1099
-        // cycle thru settings
1100
-        foreach (self::$_settings as $settings) {
1101
-            if (! empty($settings['pue_options'])) {
1102
-                // initiate the class and start the plugin update engine!
1103
-                new PluginUpdateEngineChecker(
1104
-                    // host file URL
1105
-                    $license_server,
1106
-                    // plugin slug(s)
1107
-                    array(
1108
-                        'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1109
-                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1110
-                    ),
1111
-                    // options
1112
-                    array(
1113
-                        'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
1114
-                        'lang_domain'       => 'event_espresso',
1115
-                        'checkPeriod'       => $settings['pue_options']['checkPeriod'],
1116
-                        'option_key'        => 'ee_site_license_key',
1117
-                        'options_page_slug' => 'event_espresso',
1118
-                        'plugin_basename'   => $settings['pue_options']['plugin_basename'],
1119
-                        // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
1120
-                        'use_wp_update'     => $settings['pue_options']['use_wp_update'],
1121
-                    )
1122
-                );
1123
-            }
1124
-        }
1125
-    }
1086
+	/**
1087
+	 *    load_pue_update - Update notifications
1088
+	 *
1089
+	 * @return void
1090
+	 * @throws InvalidArgumentException
1091
+	 * @throws InvalidDataTypeException
1092
+	 * @throws InvalidInterfaceException
1093
+	 */
1094
+	public static function load_pue_update()
1095
+	{
1096
+		// load PUE client
1097
+		require_once EE_THIRD_PARTY . 'pue/pue-client.php';
1098
+		$license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com';
1099
+		// cycle thru settings
1100
+		foreach (self::$_settings as $settings) {
1101
+			if (! empty($settings['pue_options'])) {
1102
+				// initiate the class and start the plugin update engine!
1103
+				new PluginUpdateEngineChecker(
1104
+					// host file URL
1105
+					$license_server,
1106
+					// plugin slug(s)
1107
+					array(
1108
+						'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1109
+						'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1110
+					),
1111
+					// options
1112
+					array(
1113
+						'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
1114
+						'lang_domain'       => 'event_espresso',
1115
+						'checkPeriod'       => $settings['pue_options']['checkPeriod'],
1116
+						'option_key'        => 'ee_site_license_key',
1117
+						'options_page_slug' => 'event_espresso',
1118
+						'plugin_basename'   => $settings['pue_options']['plugin_basename'],
1119
+						// if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
1120
+						'use_wp_update'     => $settings['pue_options']['use_wp_update'],
1121
+					)
1122
+				);
1123
+			}
1124
+		}
1125
+	}
1126 1126
 
1127 1127
 
1128
-    /**
1129
-     * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
1130
-     *
1131
-     * @since 4.4.0
1132
-     * @return void
1133
-     * @throws EE_Error
1134
-     */
1135
-    public static function register_message_types()
1136
-    {
1137
-        foreach (self::$_settings as $addon_name => $settings) {
1138
-            if (! empty($settings['message_types'])) {
1139
-                foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1140
-                    EE_Register_Message_Type::register($message_type, $message_type_settings);
1141
-                }
1142
-            }
1143
-        }
1144
-    }
1128
+	/**
1129
+	 * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
1130
+	 *
1131
+	 * @since 4.4.0
1132
+	 * @return void
1133
+	 * @throws EE_Error
1134
+	 */
1135
+	public static function register_message_types()
1136
+	{
1137
+		foreach (self::$_settings as $addon_name => $settings) {
1138
+			if (! empty($settings['message_types'])) {
1139
+				foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1140
+					EE_Register_Message_Type::register($message_type, $message_type_settings);
1141
+				}
1142
+			}
1143
+		}
1144
+	}
1145 1145
 
1146 1146
 
1147
-    /**
1148
-     * This deregisters an addon that was previously registered with a specific addon_name.
1149
-     *
1150
-     * @since    4.3.0
1151
-     * @param string $addon_name the name for the addon that was previously registered
1152
-     * @throws DomainException
1153
-     * @throws EE_Error
1154
-     * @throws InvalidArgumentException
1155
-     * @throws InvalidDataTypeException
1156
-     * @throws InvalidInterfaceException
1157
-     */
1158
-    public static function deregister($addon_name = null)
1159
-    {
1160
-        if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1161
-            try {
1162
-                do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1163
-                $class_name = self::$_settings[ $addon_name ]['class_name'];
1164
-                if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1165
-                    // setup DMS
1166
-                    EE_Register_Data_Migration_Scripts::deregister($addon_name);
1167
-                }
1168
-                if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1169
-                    // register admin page
1170
-                    EE_Register_Admin_Page::deregister($addon_name);
1171
-                }
1172
-                if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1173
-                    // add to list of modules to be registered
1174
-                    EE_Register_Module::deregister($addon_name);
1175
-                }
1176
-                if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1177
-                    || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1178
-                ) {
1179
-                    // add to list of shortcodes to be registered
1180
-                    EE_Register_Shortcode::deregister($addon_name);
1181
-                }
1182
-                if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1183
-                    // if config_class present let's register config.
1184
-                    EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1185
-                }
1186
-                if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1187
-                    // add to list of widgets to be registered
1188
-                    EE_Register_Widget::deregister($addon_name);
1189
-                }
1190
-                if (! empty(self::$_settings[ $addon_name ]['model_paths'])
1191
-                    || ! empty(self::$_settings[ $addon_name ]['class_paths'])
1192
-                ) {
1193
-                    // add to list of shortcodes to be registered
1194
-                    EE_Register_Model::deregister($addon_name);
1195
-                }
1196
-                if (! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1197
-                    || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1198
-                ) {
1199
-                    // add to list of shortcodes to be registered
1200
-                    EE_Register_Model_Extensions::deregister($addon_name);
1201
-                }
1202
-                if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1203
-                    foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1204
-                        EE_Register_Message_Type::deregister($message_type);
1205
-                    }
1206
-                }
1207
-                // deregister capabilities for addon
1208
-                if (! empty(self::$_settings[ $addon_name ]['capabilities'])
1209
-                    || ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1210
-                ) {
1211
-                    EE_Register_Capabilities::deregister($addon_name);
1212
-                }
1213
-                // deregister custom_post_types for addon
1214
-                if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1215
-                    EE_Register_CPT::deregister($addon_name);
1216
-                }
1217
-                if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1218
-                    EE_Register_Payment_Method::deregister($addon_name);
1219
-                }
1220
-                $addon = EE_Registry::instance()->getAddon($class_name);
1221
-                if ($addon instanceof EE_Addon) {
1222
-                    remove_action(
1223
-                        'deactivate_' . $addon->get_main_plugin_file_basename(),
1224
-                        array($addon, 'deactivation')
1225
-                    );
1226
-                    remove_action(
1227
-                        'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1228
-                        array($addon, 'initialize_db_if_no_migrations_required')
1229
-                    );
1230
-                    // remove `after_registration` call
1231
-                    remove_action(
1232
-                        'AHEE__EE_System__load_espresso_addons__complete',
1233
-                        array($addon, 'after_registration'),
1234
-                        999
1235
-                    );
1236
-                }
1237
-                EE_Registry::instance()->removeAddon($class_name);
1238
-            } catch (OutOfBoundsException $addon_not_yet_registered_exception) {
1239
-                // the add-on was not yet registered in the registry,
1240
-                // so RegistryContainer::__get() throws this exception.
1241
-                // also no need to worry about this or log it,
1242
-                // it's ok to deregister an add-on before its registered in the registry
1243
-            } catch (Exception $e) {
1244
-                new ExceptionLogger($e);
1245
-            }
1246
-            unset(self::$_settings[ $addon_name ]);
1247
-            do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1248
-        }
1249
-    }
1147
+	/**
1148
+	 * This deregisters an addon that was previously registered with a specific addon_name.
1149
+	 *
1150
+	 * @since    4.3.0
1151
+	 * @param string $addon_name the name for the addon that was previously registered
1152
+	 * @throws DomainException
1153
+	 * @throws EE_Error
1154
+	 * @throws InvalidArgumentException
1155
+	 * @throws InvalidDataTypeException
1156
+	 * @throws InvalidInterfaceException
1157
+	 */
1158
+	public static function deregister($addon_name = null)
1159
+	{
1160
+		if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1161
+			try {
1162
+				do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1163
+				$class_name = self::$_settings[ $addon_name ]['class_name'];
1164
+				if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1165
+					// setup DMS
1166
+					EE_Register_Data_Migration_Scripts::deregister($addon_name);
1167
+				}
1168
+				if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1169
+					// register admin page
1170
+					EE_Register_Admin_Page::deregister($addon_name);
1171
+				}
1172
+				if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1173
+					// add to list of modules to be registered
1174
+					EE_Register_Module::deregister($addon_name);
1175
+				}
1176
+				if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1177
+					|| ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1178
+				) {
1179
+					// add to list of shortcodes to be registered
1180
+					EE_Register_Shortcode::deregister($addon_name);
1181
+				}
1182
+				if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1183
+					// if config_class present let's register config.
1184
+					EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1185
+				}
1186
+				if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1187
+					// add to list of widgets to be registered
1188
+					EE_Register_Widget::deregister($addon_name);
1189
+				}
1190
+				if (! empty(self::$_settings[ $addon_name ]['model_paths'])
1191
+					|| ! empty(self::$_settings[ $addon_name ]['class_paths'])
1192
+				) {
1193
+					// add to list of shortcodes to be registered
1194
+					EE_Register_Model::deregister($addon_name);
1195
+				}
1196
+				if (! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1197
+					|| ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1198
+				) {
1199
+					// add to list of shortcodes to be registered
1200
+					EE_Register_Model_Extensions::deregister($addon_name);
1201
+				}
1202
+				if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1203
+					foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1204
+						EE_Register_Message_Type::deregister($message_type);
1205
+					}
1206
+				}
1207
+				// deregister capabilities for addon
1208
+				if (! empty(self::$_settings[ $addon_name ]['capabilities'])
1209
+					|| ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1210
+				) {
1211
+					EE_Register_Capabilities::deregister($addon_name);
1212
+				}
1213
+				// deregister custom_post_types for addon
1214
+				if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1215
+					EE_Register_CPT::deregister($addon_name);
1216
+				}
1217
+				if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1218
+					EE_Register_Payment_Method::deregister($addon_name);
1219
+				}
1220
+				$addon = EE_Registry::instance()->getAddon($class_name);
1221
+				if ($addon instanceof EE_Addon) {
1222
+					remove_action(
1223
+						'deactivate_' . $addon->get_main_plugin_file_basename(),
1224
+						array($addon, 'deactivation')
1225
+					);
1226
+					remove_action(
1227
+						'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1228
+						array($addon, 'initialize_db_if_no_migrations_required')
1229
+					);
1230
+					// remove `after_registration` call
1231
+					remove_action(
1232
+						'AHEE__EE_System__load_espresso_addons__complete',
1233
+						array($addon, 'after_registration'),
1234
+						999
1235
+					);
1236
+				}
1237
+				EE_Registry::instance()->removeAddon($class_name);
1238
+			} catch (OutOfBoundsException $addon_not_yet_registered_exception) {
1239
+				// the add-on was not yet registered in the registry,
1240
+				// so RegistryContainer::__get() throws this exception.
1241
+				// also no need to worry about this or log it,
1242
+				// it's ok to deregister an add-on before its registered in the registry
1243
+			} catch (Exception $e) {
1244
+				new ExceptionLogger($e);
1245
+			}
1246
+			unset(self::$_settings[ $addon_name ]);
1247
+			do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1248
+		}
1249
+	}
1250 1250
 }
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
         // offsets:    0 . 1 . 2 . 3 . 4
70 70
         $version_parts = explode('.', $min_core_version);
71 71
         // check they specified the micro version (after 2nd period)
72
-        if (! isset($version_parts[2])) {
72
+        if ( ! isset($version_parts[2])) {
73 73
             $version_parts[2] = '0';
74 74
         }
75 75
         // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
76 76
         // soon we can assume that's 'rc', but this current version is 'alpha'
77
-        if (! isset($version_parts[3])) {
77
+        if ( ! isset($version_parts[3])) {
78 78
             $version_parts[3] = 'dev';
79 79
         }
80
-        if (! isset($version_parts[4])) {
80
+        if ( ! isset($version_parts[4])) {
81 81
             $version_parts[4] = '000';
82 82
         }
83 83
         return implode('.', $version_parts);
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
         // setup PUE
265 265
         EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
266 266
         // does this addon work with this version of core or WordPress ?
267
-        if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
267
+        if ( ! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
268 268
             return;
269 269
         }
270 270
         // register namespaces
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
                 )
329 329
             );
330 330
         }
331
-        if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
331
+        if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
332 332
             throw new EE_Error(
333 333
                 sprintf(
334 334
                     __(
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
             );
341 341
         }
342 342
         // check that addon has not already been registered with that name
343
-        if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
343
+        if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) {
344 344
             throw new EE_Error(
345 345
                 sprintf(
346 346
                     __(
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
         // check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
373 373
         return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
374 374
             ? $class_name
375
-            : 'EE_' . $class_name;
375
+            : 'EE_'.$class_name;
376 376
     }
377 377
 
378 378
 
@@ -539,9 +539,9 @@  discard block
 block discarded – undo
539 539
         global $wp_version;
540 540
         $incompatibility_message = '';
541 541
         // check whether this addon version is compatible with EE core
542
-        if (isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
542
+        if (isset(EE_Register_Addon::$_incompatible_addons[$addon_name])
543 543
             && ! self::_meets_min_core_version_requirement(
544
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
544
+                EE_Register_Addon::$_incompatible_addons[$addon_name],
545 545
                 $addon_settings['version']
546 546
             )
547 547
         ) {
@@ -552,11 +552,11 @@  discard block
 block discarded – undo
552 552
                 ),
553 553
                 $addon_name,
554 554
                 '<br />',
555
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
555
+                EE_Register_Addon::$_incompatible_addons[$addon_name],
556 556
                 '<span style="font-weight: bold; color: #D54E21;">',
557 557
                 '</span><br />'
558 558
             );
559
-        } elseif (! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
559
+        } elseif ( ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
560 560
         ) {
561 561
             $incompatibility_message = sprintf(
562 562
                 __(
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
                 '</span><br />'
584 584
             );
585 585
         }
586
-        if (! empty($incompatibility_message)) {
586
+        if ( ! empty($incompatibility_message)) {
587 587
             // remove 'activate' from the REQUEST
588 588
             // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
589 589
             unset($_GET['activate'], $_REQUEST['activate']);
@@ -611,11 +611,11 @@  discard block
 block discarded – undo
611 611
      */
612 612
     private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
613 613
     {
614
-        if (! empty($setup_args['pue_options'])) {
615
-            self::$_settings[ $addon_name ]['pue_options'] = array(
614
+        if ( ! empty($setup_args['pue_options'])) {
615
+            self::$_settings[$addon_name]['pue_options'] = array(
616 616
                 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
617 617
                     ? (string) $setup_args['pue_options']['pue_plugin_slug']
618
-                    : 'espresso_' . strtolower($class_name),
618
+                    : 'espresso_'.strtolower($class_name),
619 619
                 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
620 620
                     ? (string) $setup_args['pue_options']['plugin_basename']
621 621
                     : plugin_basename($setup_args['main_file_path']),
@@ -674,12 +674,12 @@  discard block
 block discarded – undo
674 674
             // (as the newly-activated addon wasn't around the first time addons were registered).
675 675
             // Note: the presence of pue_options in the addon registration options will initialize the $_settings
676 676
             // property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
677
-            if (! isset(self::$_settings[ $addon_name ])
678
-                || (isset(self::$_settings[ $addon_name ])
679
-                    && ! isset(self::$_settings[ $addon_name ]['class_name'])
677
+            if ( ! isset(self::$_settings[$addon_name])
678
+                || (isset(self::$_settings[$addon_name])
679
+                    && ! isset(self::$_settings[$addon_name]['class_name'])
680 680
                 )
681 681
             ) {
682
-                self::$_settings[ $addon_name ] = $addon_settings;
682
+                self::$_settings[$addon_name] = $addon_settings;
683 683
                 $addon = self::_load_and_init_addon_class($addon_name);
684 684
                 $addon->set_activation_indicator_option();
685 685
                 // dont bother setting up the rest of the addon.
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
             return true;
689 689
         }
690 690
         // make sure this was called in the right place!
691
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
691
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons')
692 692
             || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
693 693
         ) {
694 694
             EE_Error::doing_it_wrong(
@@ -704,10 +704,10 @@  discard block
 block discarded – undo
704 704
             );
705 705
         }
706 706
         // make sure addon settings are set correctly without overwriting anything existing
707
-        if (isset(self::$_settings[ $addon_name ])) {
708
-            self::$_settings[ $addon_name ] += $addon_settings;
707
+        if (isset(self::$_settings[$addon_name])) {
708
+            self::$_settings[$addon_name] += $addon_settings;
709 709
         } else {
710
-            self::$_settings[ $addon_name ] = $addon_settings;
710
+            self::$_settings[$addon_name] = $addon_settings;
711 711
         }
712 712
         return false;
713 713
     }
@@ -720,13 +720,13 @@  discard block
 block discarded – undo
720 720
      */
721 721
     private static function _setup_autoloaders($addon_name)
722 722
     {
723
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
723
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
724 724
             // setup autoloader for single file
725
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
725
+            EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
726 726
         }
727 727
         // setup autoloaders for folders
728
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
729
-            foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
728
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
729
+            foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
730 730
                 EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
731 731
             }
732 732
         }
@@ -743,26 +743,26 @@  discard block
 block discarded – undo
743 743
     private static function _register_models_and_extensions($addon_name)
744 744
     {
745 745
         // register new models
746
-        if (! empty(self::$_settings[ $addon_name ]['model_paths'])
747
-            || ! empty(self::$_settings[ $addon_name ]['class_paths'])
746
+        if ( ! empty(self::$_settings[$addon_name]['model_paths'])
747
+            || ! empty(self::$_settings[$addon_name]['class_paths'])
748 748
         ) {
749 749
             EE_Register_Model::register(
750 750
                 $addon_name,
751 751
                 array(
752
-                    'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
753
-                    'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
752
+                    'model_paths' => self::$_settings[$addon_name]['model_paths'],
753
+                    'class_paths' => self::$_settings[$addon_name]['class_paths'],
754 754
                 )
755 755
             );
756 756
         }
757 757
         // register model extensions
758
-        if (! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
759
-            || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
758
+        if ( ! empty(self::$_settings[$addon_name]['model_extension_paths'])
759
+            || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
760 760
         ) {
761 761
             EE_Register_Model_Extensions::register(
762 762
                 $addon_name,
763 763
                 array(
764
-                    'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
765
-                    'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
764
+                    'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'],
765
+                    'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'],
766 766
                 )
767 767
             );
768 768
         }
@@ -777,10 +777,10 @@  discard block
 block discarded – undo
777 777
     private static function _register_data_migration_scripts($addon_name)
778 778
     {
779 779
         // setup DMS
780
-        if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
780
+        if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
781 781
             EE_Register_Data_Migration_Scripts::register(
782 782
                 $addon_name,
783
-                array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
783
+                array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])
784 784
             );
785 785
         }
786 786
     }
@@ -794,12 +794,12 @@  discard block
 block discarded – undo
794 794
     private static function _register_config($addon_name)
795 795
     {
796 796
         // if config_class is present let's register config.
797
-        if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
797
+        if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
798 798
             EE_Register_Config::register(
799
-                self::$_settings[ $addon_name ]['config_class'],
799
+                self::$_settings[$addon_name]['config_class'],
800 800
                 array(
801
-                    'config_section' => self::$_settings[ $addon_name ]['config_section'],
802
-                    'config_name'    => self::$_settings[ $addon_name ]['config_name'],
801
+                    'config_section' => self::$_settings[$addon_name]['config_section'],
802
+                    'config_name'    => self::$_settings[$addon_name]['config_name'],
803 803
                 )
804 804
             );
805 805
         }
@@ -813,10 +813,10 @@  discard block
 block discarded – undo
813 813
      */
814 814
     private static function _register_admin_pages($addon_name)
815 815
     {
816
-        if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
816
+        if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
817 817
             EE_Register_Admin_Page::register(
818 818
                 $addon_name,
819
-                array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
819
+                array('page_path' => self::$_settings[$addon_name]['admin_path'])
820 820
             );
821 821
         }
822 822
     }
@@ -829,10 +829,10 @@  discard block
 block discarded – undo
829 829
      */
830 830
     private static function _register_modules($addon_name)
831 831
     {
832
-        if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
832
+        if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
833 833
             EE_Register_Module::register(
834 834
                 $addon_name,
835
-                array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
835
+                array('module_paths' => self::$_settings[$addon_name]['module_paths'])
836 836
             );
837 837
         }
838 838
     }
@@ -845,17 +845,17 @@  discard block
 block discarded – undo
845 845
      */
846 846
     private static function _register_shortcodes($addon_name)
847 847
     {
848
-        if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
849
-            || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
848
+        if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])
849
+            || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
850 850
         ) {
851 851
             EE_Register_Shortcode::register(
852 852
                 $addon_name,
853 853
                 array(
854
-                    'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
855
-                        ? self::$_settings[ $addon_name ]['shortcode_paths']
854
+                    'shortcode_paths' => isset(self::$_settings[$addon_name]['shortcode_paths'])
855
+                        ? self::$_settings[$addon_name]['shortcode_paths']
856 856
                         : array(),
857
-                    'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
858
-                        ? self::$_settings[ $addon_name ]['shortcode_fqcns']
857
+                    'shortcode_fqcns' => isset(self::$_settings[$addon_name]['shortcode_fqcns'])
858
+                        ? self::$_settings[$addon_name]['shortcode_fqcns']
859 859
                         : array(),
860 860
                 )
861 861
             );
@@ -870,10 +870,10 @@  discard block
 block discarded – undo
870 870
      */
871 871
     private static function _register_widgets($addon_name)
872 872
     {
873
-        if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
873
+        if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
874 874
             EE_Register_Widget::register(
875 875
                 $addon_name,
876
-                array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
876
+                array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])
877 877
             );
878 878
         }
879 879
     }
@@ -886,12 +886,12 @@  discard block
 block discarded – undo
886 886
      */
887 887
     private static function _register_capabilities($addon_name)
888 888
     {
889
-        if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
889
+        if ( ! empty(self::$_settings[$addon_name]['capabilities'])) {
890 890
             EE_Register_Capabilities::register(
891 891
                 $addon_name,
892 892
                 array(
893
-                    'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
894
-                    'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
893
+                    'capabilities'    => self::$_settings[$addon_name]['capabilities'],
894
+                    'capability_maps' => self::$_settings[$addon_name]['capability_maps'],
895 895
                 )
896 896
             );
897 897
         }
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
      */
906 906
     private static function _register_message_types($addon_name)
907 907
     {
908
-        if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
908
+        if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
909 909
             add_action(
910 910
                 'EE_Brewing_Regular___messages_caf',
911 911
                 array('EE_Register_Addon', 'register_message_types')
@@ -921,15 +921,15 @@  discard block
 block discarded – undo
921 921
      */
922 922
     private static function _register_custom_post_types($addon_name)
923 923
     {
924
-        if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])
925
-            || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
924
+        if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])
925
+            || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])
926 926
         ) {
927 927
             EE_Register_CPT::register(
928 928
                 $addon_name,
929 929
                 array(
930
-                    'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
931
-                    'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
932
-                    'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
930
+                    'cpts'          => self::$_settings[$addon_name]['custom_post_types'],
931
+                    'cts'           => self::$_settings[$addon_name]['custom_taxonomies'],
932
+                    'default_terms' => self::$_settings[$addon_name]['default_terms'],
933 933
                 )
934 934
             );
935 935
         }
@@ -947,10 +947,10 @@  discard block
 block discarded – undo
947 947
      */
948 948
     private static function _register_payment_methods($addon_name)
949 949
     {
950
-        if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
950
+        if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
951 951
             EE_Register_Payment_Method::register(
952 952
                 $addon_name,
953
-                array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
953
+                array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])
954 954
             );
955 955
         }
956 956
     }
@@ -967,10 +967,10 @@  discard block
 block discarded – undo
967 967
      */
968 968
     private static function registerPrivacyPolicies($addon_name)
969 969
     {
970
-        if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) {
970
+        if ( ! empty(self::$_settings[$addon_name]['privacy_policies'])) {
971 971
             EE_Register_Privacy_Policy::register(
972 972
                 $addon_name,
973
-                self::$_settings[ $addon_name ]['privacy_policies']
973
+                self::$_settings[$addon_name]['privacy_policies']
974 974
             );
975 975
         }
976 976
     }
@@ -982,10 +982,10 @@  discard block
 block discarded – undo
982 982
      */
983 983
     private static function registerPersonalDataExporters($addon_name)
984 984
     {
985
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) {
985
+        if ( ! empty(self::$_settings[$addon_name]['personal_data_exporters'])) {
986 986
             EE_Register_Personal_Data_Eraser::register(
987 987
                 $addon_name,
988
-                self::$_settings[ $addon_name ]['personal_data_exporters']
988
+                self::$_settings[$addon_name]['personal_data_exporters']
989 989
             );
990 990
         }
991 991
     }
@@ -997,10 +997,10 @@  discard block
 block discarded – undo
997 997
      */
998 998
     private static function registerPersonalDataErasers($addon_name)
999 999
     {
1000
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) {
1000
+        if ( ! empty(self::$_settings[$addon_name]['personal_data_erasers'])) {
1001 1001
             EE_Register_Personal_Data_Eraser::register(
1002 1002
                 $addon_name,
1003
-                self::$_settings[ $addon_name ]['personal_data_erasers']
1003
+                self::$_settings[$addon_name]['personal_data_erasers']
1004 1004
             );
1005 1005
         }
1006 1006
     }
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
     {
1022 1022
         $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader();
1023 1023
         $addon = $loader->getShared(
1024
-            self::$_settings[ $addon_name ]['class_name'],
1024
+            self::$_settings[$addon_name]['class_name'],
1025 1025
             array('EE_Registry::create(addon)' => true)
1026 1026
         );
1027 1027
         // setter inject dep map if required
@@ -1033,19 +1033,19 @@  discard block
 block discarded – undo
1033 1033
             && $addon->domain() === null
1034 1034
         ) {
1035 1035
             // using supplied Domain object
1036
-            $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
1037
-                ? self::$_settings[ $addon_name ]['domain']
1036
+            $domain = self::$_settings[$addon_name]['domain'] instanceof DomainInterface
1037
+                ? self::$_settings[$addon_name]['domain']
1038 1038
                 : null;
1039 1039
             // or construct one using Domain FQCN
1040
-            if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
1040
+            if ($domain === null && self::$_settings[$addon_name]['domain_fqcn'] !== '') {
1041 1041
                 $domain = $loader->getShared(
1042
-                    self::$_settings[ $addon_name ]['domain_fqcn'],
1042
+                    self::$_settings[$addon_name]['domain_fqcn'],
1043 1043
                     array(
1044 1044
                         new EventEspresso\core\domain\values\FilePath(
1045
-                            self::$_settings[ $addon_name ]['main_file_path']
1045
+                            self::$_settings[$addon_name]['main_file_path']
1046 1046
                         ),
1047 1047
                         EventEspresso\core\domain\values\Version::fromString(
1048
-                            self::$_settings[ $addon_name ]['version']
1048
+                            self::$_settings[$addon_name]['version']
1049 1049
                         ),
1050 1050
                     )
1051 1051
                 );
@@ -1055,28 +1055,28 @@  discard block
 block discarded – undo
1055 1055
             }
1056 1056
         }
1057 1057
         $addon->set_name($addon_name);
1058
-        $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
1059
-        $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
1060
-        $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
1061
-        $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
1062
-        $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
1063
-        $addon->set_version(self::$_settings[ $addon_name ]['version']);
1064
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
1065
-        $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
1066
-        $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
1067
-        $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
1058
+        $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']);
1059
+        $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']);
1060
+        $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']);
1061
+        $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']);
1062
+        $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']);
1063
+        $addon->set_version(self::$_settings[$addon_name]['version']);
1064
+        $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version']));
1065
+        $addon->set_config_section(self::$_settings[$addon_name]['config_section']);
1066
+        $addon->set_config_class(self::$_settings[$addon_name]['config_class']);
1067
+        $addon->set_config_name(self::$_settings[$addon_name]['config_name']);
1068 1068
         // setup the add-on's pue_slug if we have one.
1069
-        if (! empty(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug'])) {
1070
-            $addon->setPueSlug(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug']);
1069
+        if ( ! empty(self::$_settings[$addon_name]['pue_options']['pue_plugin_slug'])) {
1070
+            $addon->setPueSlug(self::$_settings[$addon_name]['pue_options']['pue_plugin_slug']);
1071 1071
         }
1072 1072
         // unfortunately this can't be hooked in upon construction, because we don't have
1073 1073
         // the plugin mainfile's path upon construction.
1074 1074
         register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
1075 1075
         // call any additional admin_callback functions during load_admin_controller hook
1076
-        if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1076
+        if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) {
1077 1077
             add_action(
1078 1078
                 'AHEE__EE_System__load_controllers__load_admin_controllers',
1079
-                array($addon, self::$_settings[ $addon_name ]['admin_callback'])
1079
+                array($addon, self::$_settings[$addon_name]['admin_callback'])
1080 1080
             );
1081 1081
         }
1082 1082
         return $addon;
@@ -1094,11 +1094,11 @@  discard block
 block discarded – undo
1094 1094
     public static function load_pue_update()
1095 1095
     {
1096 1096
         // load PUE client
1097
-        require_once EE_THIRD_PARTY . 'pue/pue-client.php';
1097
+        require_once EE_THIRD_PARTY.'pue/pue-client.php';
1098 1098
         $license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com';
1099 1099
         // cycle thru settings
1100 1100
         foreach (self::$_settings as $settings) {
1101
-            if (! empty($settings['pue_options'])) {
1101
+            if ( ! empty($settings['pue_options'])) {
1102 1102
                 // initiate the class and start the plugin update engine!
1103 1103
                 new PluginUpdateEngineChecker(
1104 1104
                     // host file URL
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
                     // plugin slug(s)
1107 1107
                     array(
1108 1108
                         'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1109
-                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1109
+                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'),
1110 1110
                     ),
1111 1111
                     // options
1112 1112
                     array(
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
     public static function register_message_types()
1136 1136
     {
1137 1137
         foreach (self::$_settings as $addon_name => $settings) {
1138
-            if (! empty($settings['message_types'])) {
1138
+            if ( ! empty($settings['message_types'])) {
1139 1139
                 foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1140 1140
                     EE_Register_Message_Type::register($message_type, $message_type_settings);
1141 1141
                 }
@@ -1157,70 +1157,70 @@  discard block
 block discarded – undo
1157 1157
      */
1158 1158
     public static function deregister($addon_name = null)
1159 1159
     {
1160
-        if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1160
+        if (isset(self::$_settings[$addon_name]['class_name'])) {
1161 1161
             try {
1162 1162
                 do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1163
-                $class_name = self::$_settings[ $addon_name ]['class_name'];
1164
-                if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1163
+                $class_name = self::$_settings[$addon_name]['class_name'];
1164
+                if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
1165 1165
                     // setup DMS
1166 1166
                     EE_Register_Data_Migration_Scripts::deregister($addon_name);
1167 1167
                 }
1168
-                if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1168
+                if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
1169 1169
                     // register admin page
1170 1170
                     EE_Register_Admin_Page::deregister($addon_name);
1171 1171
                 }
1172
-                if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1172
+                if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
1173 1173
                     // add to list of modules to be registered
1174 1174
                     EE_Register_Module::deregister($addon_name);
1175 1175
                 }
1176
-                if (! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1177
-                    || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1176
+                if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])
1177
+                    || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
1178 1178
                 ) {
1179 1179
                     // add to list of shortcodes to be registered
1180 1180
                     EE_Register_Shortcode::deregister($addon_name);
1181 1181
                 }
1182
-                if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1182
+                if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
1183 1183
                     // if config_class present let's register config.
1184
-                    EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1184
+                    EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1185 1185
                 }
1186
-                if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1186
+                if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
1187 1187
                     // add to list of widgets to be registered
1188 1188
                     EE_Register_Widget::deregister($addon_name);
1189 1189
                 }
1190
-                if (! empty(self::$_settings[ $addon_name ]['model_paths'])
1191
-                    || ! empty(self::$_settings[ $addon_name ]['class_paths'])
1190
+                if ( ! empty(self::$_settings[$addon_name]['model_paths'])
1191
+                    || ! empty(self::$_settings[$addon_name]['class_paths'])
1192 1192
                 ) {
1193 1193
                     // add to list of shortcodes to be registered
1194 1194
                     EE_Register_Model::deregister($addon_name);
1195 1195
                 }
1196
-                if (! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1197
-                    || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1196
+                if ( ! empty(self::$_settings[$addon_name]['model_extension_paths'])
1197
+                    || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
1198 1198
                 ) {
1199 1199
                     // add to list of shortcodes to be registered
1200 1200
                     EE_Register_Model_Extensions::deregister($addon_name);
1201 1201
                 }
1202
-                if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1203
-                    foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1202
+                if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
1203
+                    foreach ((array) self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
1204 1204
                         EE_Register_Message_Type::deregister($message_type);
1205 1205
                     }
1206 1206
                 }
1207 1207
                 // deregister capabilities for addon
1208
-                if (! empty(self::$_settings[ $addon_name ]['capabilities'])
1209
-                    || ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1208
+                if ( ! empty(self::$_settings[$addon_name]['capabilities'])
1209
+                    || ! empty(self::$_settings[$addon_name]['capability_maps'])
1210 1210
                 ) {
1211 1211
                     EE_Register_Capabilities::deregister($addon_name);
1212 1212
                 }
1213 1213
                 // deregister custom_post_types for addon
1214
-                if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1214
+                if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1215 1215
                     EE_Register_CPT::deregister($addon_name);
1216 1216
                 }
1217
-                if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1217
+                if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1218 1218
                     EE_Register_Payment_Method::deregister($addon_name);
1219 1219
                 }
1220 1220
                 $addon = EE_Registry::instance()->getAddon($class_name);
1221 1221
                 if ($addon instanceof EE_Addon) {
1222 1222
                     remove_action(
1223
-                        'deactivate_' . $addon->get_main_plugin_file_basename(),
1223
+                        'deactivate_'.$addon->get_main_plugin_file_basename(),
1224 1224
                         array($addon, 'deactivation')
1225 1225
                     );
1226 1226
                     remove_action(
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
             } catch (Exception $e) {
1244 1244
                 new ExceptionLogger($e);
1245 1245
             }
1246
-            unset(self::$_settings[ $addon_name ]);
1246
+            unset(self::$_settings[$addon_name]);
1247 1247
             do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1248 1248
         }
1249 1249
     }
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_10_0.dms.php 1 patch
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
 $stages = glob(EE_CORE . 'data_migration_scripts/4_10_0_stages/*');
16 16
 $class_to_filepath = [];
17 17
 foreach ($stages as $filepath) {
18
-    $matches = [];
19
-    preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
-    $class_to_filepath[ $matches[1] ] = $filepath;
18
+	$matches = [];
19
+	preg_match('~4_10_0_stages/(.*).dmsstage.php~', $filepath, $matches);
20
+	$class_to_filepath[ $matches[1] ] = $filepath;
21 21
 }
22 22
 // give addons a chance to autoload their stages too
23 23
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_10_0__autoloaded_stages', $class_to_filepath);
@@ -35,66 +35,66 @@  discard block
 block discarded – undo
35 35
  */
36 36
 class EE_DMS_Core_4_10_0 extends EE_Data_Migration_Script_Base
37 37
 {
38
-    /**
39
-     *
40
-     * @param TableManager  $table_manager
41
-     * @param TableAnalysis $table_analysis
42
-     */
43
-    public function __construct(
44
-        TableManager $table_manager = null,
45
-        TableAnalysis $table_analysis = null,
46
-        EE_DMS_Core_4_9_0 $dms_4_9
47
-    ) {
48
-        $this->previous_dms = $dms_4_9;
49
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso");
50
-        $this->_priority = 10;
51
-        $this->_migration_stages = array(
52
-            new EE_DMS_4_10_0_Event_Question_Group(),
53
-        );
54
-        parent::__construct($table_manager, $table_analysis);
55
-    }
38
+	/**
39
+	 *
40
+	 * @param TableManager  $table_manager
41
+	 * @param TableAnalysis $table_analysis
42
+	 */
43
+	public function __construct(
44
+		TableManager $table_manager = null,
45
+		TableAnalysis $table_analysis = null,
46
+		EE_DMS_Core_4_9_0 $dms_4_9
47
+	) {
48
+		$this->previous_dms = $dms_4_9;
49
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.10.0", "event_espresso");
50
+		$this->_priority = 10;
51
+		$this->_migration_stages = array(
52
+			new EE_DMS_4_10_0_Event_Question_Group(),
53
+		);
54
+		parent::__construct($table_manager, $table_analysis);
55
+	}
56 56
 
57 57
 
58 58
 
59
-    /**
60
-     * Whether to migrate or not.
61
-     *
62
-     * @param array $version_array
63
-     * @return bool
64
-     */
65
-    public function can_migrate_from_version($version_array)
66
-    {
67
-        $version_string = $version_array['Core'];
68
-        if (version_compare($version_string, '4.10.0.decaf', '<') && version_compare($version_string, '4.9.0.decaf', '>=')) {
69
-            return true;
70
-        } elseif (! $version_string) {
71
-            //          echo "no version string provided: $version_string";
72
-            // no version string provided... this must be pre 4.3
73
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
74
-        }
75
-        return false;
76
-    }
59
+	/**
60
+	 * Whether to migrate or not.
61
+	 *
62
+	 * @param array $version_array
63
+	 * @return bool
64
+	 */
65
+	public function can_migrate_from_version($version_array)
66
+	{
67
+		$version_string = $version_array['Core'];
68
+		if (version_compare($version_string, '4.10.0.decaf', '<') && version_compare($version_string, '4.9.0.decaf', '>=')) {
69
+			return true;
70
+		} elseif (! $version_string) {
71
+			//          echo "no version string provided: $version_string";
72
+			// no version string provided... this must be pre 4.3
73
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
74
+		}
75
+		return false;
76
+	}
77 77
 
78 78
 
79 79
 
80
-    /**
81
-     * @return bool
82
-     */
83
-    public function schema_changes_before_migration()
84
-    {
85
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
86
-        $now_in_mysql = current_time('mysql', true);
87
-        $table_name = 'esp_answer';
88
-        $sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
80
+	/**
81
+	 * @return bool
82
+	 */
83
+	public function schema_changes_before_migration()
84
+	{
85
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
86
+		$now_in_mysql = current_time('mysql', true);
87
+		$table_name = 'esp_answer';
88
+		$sql = " ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
89 89
 					REG_ID int(10) unsigned NOT NULL,
90 90
 					QST_ID int(10) unsigned NOT NULL,
91 91
 					ANS_value text NOT NULL,
92 92
 					PRIMARY KEY  (ANS_ID),
93 93
 					KEY REG_ID (REG_ID),
94 94
 					KEY QST_ID (QST_ID)";
95
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
96
-        $table_name = 'esp_attendee_meta';
97
-        $sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
95
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
96
+		$table_name = 'esp_attendee_meta';
97
+		$sql = "ATTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
98 98
 				ATT_ID bigint(20) unsigned NOT NULL,
99 99
 				ATT_fname varchar(45) NOT NULL,
100 100
 				ATT_lname varchar(45) NOT NULL,
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
 				KEY ATT_email (ATT_email(191)),
112 112
 				KEY ATT_lname (ATT_lname),
113 113
 				KEY ATT_fname (ATT_fname)";
114
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
115
-        $table_name = 'esp_checkin';
116
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
114
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
115
+		$table_name = 'esp_checkin';
116
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
117 117
 				REG_ID int(10) unsigned NOT NULL,
118 118
 				DTT_ID int(10) unsigned NOT NULL,
119 119
 				CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 				PRIMARY KEY  (CHK_ID),
122 122
 				KEY REG_ID (REG_ID),
123 123
 				KEY DTT_ID (DTT_ID)";
124
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
125
-        $table_name = 'esp_country';
126
-        $sql = "CNT_ISO varchar(2) NOT NULL,
124
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
125
+		$table_name = 'esp_country';
126
+		$sql = "CNT_ISO varchar(2) NOT NULL,
127 127
 				CNT_ISO3 varchar(3) NOT NULL,
128 128
 				RGN_ID tinyint(3) unsigned DEFAULT NULL,
129 129
 				CNT_name varchar(45) NOT NULL,
@@ -139,29 +139,29 @@  discard block
 block discarded – undo
139 139
 				CNT_is_EU tinyint(1) DEFAULT '0',
140 140
 				CNT_active tinyint(1) DEFAULT '0',
141 141
 				PRIMARY KEY  (CNT_ISO)";
142
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
143
-        $table_name = 'esp_currency';
144
-        $sql = "CUR_code varchar(6) NOT NULL,
142
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
143
+		$table_name = 'esp_currency';
144
+		$sql = "CUR_code varchar(6) NOT NULL,
145 145
 				CUR_single varchar(45) DEFAULT 'dollar',
146 146
 				CUR_plural varchar(45) DEFAULT 'dollars',
147 147
 				CUR_sign varchar(45) DEFAULT '$',
148 148
 				CUR_dec_plc varchar(1) NOT NULL DEFAULT '2',
149 149
 				CUR_active tinyint(1) DEFAULT '0',
150 150
 				PRIMARY KEY  (CUR_code)";
151
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
152
-        // note: although this table is no longer in use,
153
-        // it hasn't been removed because then queries to the model will have errors.
154
-        // but you should expect this table and its corresponding model to be removed in
155
-        // the next few months
156
-        $table_name = 'esp_currency_payment_method';
157
-        $sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
151
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
152
+		// note: although this table is no longer in use,
153
+		// it hasn't been removed because then queries to the model will have errors.
154
+		// but you should expect this table and its corresponding model to be removed in
155
+		// the next few months
156
+		$table_name = 'esp_currency_payment_method';
157
+		$sql = "CPM_ID int(11) NOT NULL AUTO_INCREMENT,
158 158
 				CUR_code varchar(6) NOT NULL,
159 159
 				PMD_ID int(11) NOT NULL,
160 160
 				PRIMARY KEY  (CPM_ID),
161 161
 				KEY PMD_ID (PMD_ID)";
162
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
163
-        $table_name = 'esp_datetime';
164
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
162
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
163
+		$table_name = 'esp_datetime';
164
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
165 165
 				EVT_ID bigint(20) unsigned NOT NULL,
166 166
 				DTT_name varchar(255) NOT NULL DEFAULT '',
167 167
 				DTT_description text NOT NULL,
@@ -178,25 +178,25 @@  discard block
 block discarded – undo
178 178
 				KEY DTT_EVT_start (DTT_EVT_start),
179 179
 				KEY EVT_ID (EVT_ID),
180 180
 				KEY DTT_is_primary (DTT_is_primary)";
181
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
182
-        $table_name = "esp_datetime_ticket";
183
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
181
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
182
+		$table_name = "esp_datetime_ticket";
183
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
184 184
 				DTT_ID int(10) unsigned NOT NULL,
185 185
 				TKT_ID int(10) unsigned NOT NULL,
186 186
 				PRIMARY KEY  (DTK_ID),
187 187
 				KEY DTT_ID (DTT_ID),
188 188
 				KEY TKT_ID (TKT_ID)";
189
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
190
-        $table_name = 'esp_event_message_template';
191
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
189
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
190
+		$table_name = 'esp_event_message_template';
191
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
192 192
 				EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
193 193
 				GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
194 194
 				PRIMARY KEY  (EMT_ID),
195 195
 				KEY EVT_ID (EVT_ID),
196 196
 				KEY GRP_ID (GRP_ID)";
197
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
198
-        $table_name = 'esp_event_meta';
199
-        $sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
197
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
198
+		$table_name = 'esp_event_meta';
199
+		$sql = "EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
200 200
 				EVT_ID bigint(20) unsigned NOT NULL,
201 201
 				EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
202 202
 				EVT_display_ticket_selector tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 				EVT_donations tinyint(1) NULL,
212 212
 				PRIMARY KEY  (EVTM_ID),
213 213
 				KEY EVT_ID (EVT_ID)";
214
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
215
-        $table_name = 'esp_event_question_group';
216
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
214
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
215
+		$table_name = 'esp_event_question_group';
216
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
217 217
 				EVT_ID bigint(20) unsigned NOT NULL,
218 218
 				QSG_ID int(10) unsigned NOT NULL,
219 219
 				EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
@@ -221,25 +221,25 @@  discard block
 block discarded – undo
221 221
 				PRIMARY KEY  (EQG_ID),
222 222
 				KEY EVT_ID (EVT_ID),
223 223
 				KEY QSG_ID (QSG_ID)";
224
-        $this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
225
-        $table_name = 'esp_event_venue';
226
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
224
+		$this->_table_is_changed_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
225
+		$table_name = 'esp_event_venue';
226
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
227 227
 				EVT_ID bigint(20) unsigned NOT NULL,
228 228
 				VNU_ID bigint(20) unsigned NOT NULL,
229 229
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
230 230
 				PRIMARY KEY  (EVV_ID)";
231
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
232
-        $table_name = 'esp_extra_meta';
233
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
231
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
232
+		$table_name = 'esp_extra_meta';
233
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
234 234
 				OBJ_ID int(11) DEFAULT NULL,
235 235
 				EXM_type varchar(45) DEFAULT NULL,
236 236
 				EXM_key varchar(45) DEFAULT NULL,
237 237
 				EXM_value text,
238 238
 				PRIMARY KEY  (EXM_ID),
239 239
 				KEY EXM_type (EXM_type,OBJ_ID,EXM_key)";
240
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
241
-        $table_name = 'esp_extra_join';
242
-        $sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
240
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
241
+		$table_name = 'esp_extra_join';
242
+		$sql = "EXJ_ID int(11) NOT NULL AUTO_INCREMENT,
243 243
 				EXJ_first_model_id varchar(6) NOT NULL,
244 244
 				EXJ_first_model_name varchar(20) NOT NULL,
245 245
 				EXJ_second_model_id varchar(6) NOT NULL,
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 				PRIMARY KEY  (EXJ_ID),
248 248
 				KEY first_model (EXJ_first_model_name,EXJ_first_model_id),
249 249
 				KEY second_model (EXJ_second_model_name,EXJ_second_model_id)";
250
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
251
-        $table_name = 'esp_line_item';
252
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
250
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
251
+		$table_name = 'esp_line_item';
252
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
253 253
 				LIN_code varchar(245) NOT NULL DEFAULT '',
254 254
 				TXN_ID int(11) DEFAULT NULL,
255 255
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 				KEY txn_type_timestamp (TXN_ID,LIN_type,LIN_timestamp),
271 271
 				KEY txn_obj_id_obj_type (TXN_ID,OBJ_ID,OBJ_type),
272 272
 				KEY obj_id_obj_type (OBJ_ID,OBJ_type)";
273
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
274
-        $table_name = 'esp_log';
275
-        $sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
273
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
274
+		$table_name = 'esp_log';
275
+		$sql = "LOG_ID int(11) NOT NULL AUTO_INCREMENT,
276 276
 				LOG_time datetime DEFAULT NULL,
277 277
 				OBJ_ID varchar(45) DEFAULT NULL,
278 278
 				OBJ_type varchar(45) DEFAULT NULL,
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 				KEY LOG_time (LOG_time),
284 284
 				KEY OBJ (OBJ_type,OBJ_ID),
285 285
 				KEY LOG_type (LOG_type)";
286
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
287
-        $table_name = 'esp_message';
288
-        $sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
286
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
287
+		$table_name = 'esp_message';
288
+		$sql = "MSG_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
289 289
 				GRP_ID int(10) unsigned NULL,
290 290
 				MSG_token varchar(255) NULL,
291 291
 				TXN_ID int(10) unsigned NULL,
@@ -317,18 +317,18 @@  discard block
 block discarded – undo
317 317
 				KEY STS_ID (STS_ID),
318 318
 				KEY MSG_created (MSG_created),
319 319
 				KEY MSG_modified (MSG_modified)";
320
-        $this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
321
-        $table_name = 'esp_message_template';
322
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
320
+		$this->_table_is_new_in_this_version($table_name, $sql, 'ENGINE=InnoDB');
321
+		$table_name = 'esp_message_template';
322
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
323 323
 				GRP_ID int(10) unsigned NOT NULL,
324 324
 				MTP_context varchar(50) NOT NULL,
325 325
 				MTP_template_field varchar(30) NOT NULL,
326 326
 				MTP_content text NOT NULL,
327 327
 				PRIMARY KEY  (MTP_ID),
328 328
 				KEY GRP_ID (GRP_ID)";
329
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
330
-        $table_name = 'esp_message_template_group';
331
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
329
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
330
+		$table_name = 'esp_message_template_group';
331
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
332 332
 				MTP_user_id int(10) NOT NULL DEFAULT '1',
333 333
 				MTP_name varchar(245) NOT NULL DEFAULT '',
334 334
 				MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
 				MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
341 341
 				PRIMARY KEY  (GRP_ID),
342 342
 				KEY MTP_user_id (MTP_user_id)";
343
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
344
-        $table_name = 'esp_payment';
345
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
343
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
344
+		$table_name = 'esp_payment';
345
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
346 346
 				TXN_ID int(10) unsigned DEFAULT NULL,
347 347
 				STS_ID varchar(3) DEFAULT NULL,
348 348
 				PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
 				PRIMARY KEY  (PAY_ID),
360 360
 				KEY PAY_timestamp (PAY_timestamp),
361 361
 				KEY TXN_ID (TXN_ID)";
362
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
363
-        $table_name = 'esp_payment_method';
364
-        $sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
362
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
363
+		$table_name = 'esp_payment_method';
364
+		$sql = "PMD_ID int(11) NOT NULL AUTO_INCREMENT,
365 365
 				PMD_type varchar(124) DEFAULT NULL,
366 366
 				PMD_name varchar(255) DEFAULT NULL,
367 367
 				PMD_desc text,
@@ -377,24 +377,24 @@  discard block
 block discarded – undo
377 377
 				PRIMARY KEY  (PMD_ID),
378 378
 				UNIQUE KEY PMD_slug_UNIQUE (PMD_slug),
379 379
 				KEY PMD_type (PMD_type)";
380
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
381
-        $table_name = "esp_ticket_price";
382
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
380
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
381
+		$table_name = "esp_ticket_price";
382
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
383 383
 				TKT_ID int(10) unsigned NOT NULL,
384 384
 				PRC_ID int(10) unsigned NOT NULL,
385 385
 				PRIMARY KEY  (TKP_ID),
386 386
 				KEY TKT_ID (TKT_ID),
387 387
 				KEY PRC_ID (PRC_ID)";
388
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
389
-        $table_name = "esp_ticket_template";
390
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
388
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
389
+		$table_name = "esp_ticket_template";
390
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
391 391
 				TTM_name varchar(45) NOT NULL,
392 392
 				TTM_description text,
393 393
 				TTM_file varchar(45),
394 394
 				PRIMARY KEY  (TTM_ID)";
395
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
396
-        $table_name = 'esp_question';
397
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
395
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
396
+		$table_name = 'esp_question';
397
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
398 398
 				QST_display_text text NOT NULL,
399 399
 				QST_admin_label varchar(255) NOT NULL,
400 400
 				QST_system varchar(25) DEFAULT NULL,
@@ -408,18 +408,18 @@  discard block
 block discarded – undo
408 408
 				QST_deleted tinyint(2) unsigned NOT NULL DEFAULT 0,
409 409
 				PRIMARY KEY  (QST_ID),
410 410
 				KEY QST_order (QST_order)';
411
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
412
-        $table_name = 'esp_question_group_question';
413
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
411
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
412
+		$table_name = 'esp_question_group_question';
413
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
414 414
 				QSG_ID int(10) unsigned NOT NULL,
415 415
 				QST_ID int(10) unsigned NOT NULL,
416 416
 				QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
417 417
 				PRIMARY KEY  (QGQ_ID),
418 418
 				KEY QST_ID (QST_ID),
419 419
 				KEY QSG_ID_order (QSG_ID,QGQ_order)";
420
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
421
-        $table_name = 'esp_question_option';
422
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
420
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
421
+		$table_name = 'esp_question_option';
422
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
423 423
 				QSO_value varchar(255) NOT NULL,
424 424
 				QSO_desc text NOT NULL,
425 425
 				QST_ID int(10) unsigned NOT NULL,
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
 				PRIMARY KEY  (QSO_ID),
430 430
 				KEY QST_ID (QST_ID),
431 431
 				KEY QSO_order (QSO_order)";
432
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
433
-        $table_name = 'esp_registration';
434
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
432
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
433
+		$table_name = 'esp_registration';
434
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
435 435
 				EVT_ID bigint(20) unsigned NOT NULL,
436 436
 				ATT_ID bigint(20) unsigned NOT NULL,
437 437
 				TXN_ID int(10) unsigned NOT NULL,
@@ -455,18 +455,18 @@  discard block
 block discarded – undo
455 455
 				KEY TKT_ID (TKT_ID),
456 456
 				KEY EVT_ID (EVT_ID),
457 457
 				KEY STS_ID (STS_ID)";
458
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
459
-        $table_name = 'esp_registration_payment';
460
-        $sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
458
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
459
+		$table_name = 'esp_registration_payment';
460
+		$sql = "RPY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
461 461
 					  REG_ID int(10) unsigned NOT NULL,
462 462
 					  PAY_ID int(10) unsigned NULL,
463 463
 					  RPY_amount decimal(12,3) NOT NULL DEFAULT '0.00',
464 464
 					  PRIMARY KEY  (RPY_ID),
465 465
 					  KEY REG_ID (REG_ID),
466 466
 					  KEY PAY_ID (PAY_ID)";
467
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
468
-        $table_name = 'esp_state';
469
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
467
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
468
+		$table_name = 'esp_state';
469
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
470 470
 				CNT_ISO varchar(2) NOT NULL,
471 471
 				STA_abbrev varchar(24) NOT NULL,
472 472
 				STA_name varchar(100) NOT NULL,
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
 				PRIMARY KEY  (STA_ID),
475 475
 				KEY STA_abbrev (STA_abbrev),
476 476
 				KEY CNT_ISO (CNT_ISO)";
477
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
478
-        $table_name = 'esp_status';
479
-        $sql = "STS_ID varchar(3) NOT NULL,
477
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
478
+		$table_name = 'esp_status';
479
+		$sql = "STS_ID varchar(3) NOT NULL,
480 480
 				STS_code varchar(45) NOT NULL,
481 481
 				STS_type varchar(45) NOT NULL,
482 482
 				STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -484,9 +484,9 @@  discard block
 block discarded – undo
484 484
 				STS_open tinyint(1) NOT NULL DEFAULT 1,
485 485
 				UNIQUE KEY STS_ID_UNIQUE (STS_ID),
486 486
 				KEY STS_type (STS_type)";
487
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
488
-        $table_name = 'esp_transaction';
489
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
487
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
488
+		$table_name = 'esp_transaction';
489
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
490 490
 				TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
491 491
 				TXN_total decimal(12,3) DEFAULT '0.00',
492 492
 				TXN_paid decimal(12,3) NOT NULL DEFAULT '0.00',
@@ -498,9 +498,9 @@  discard block
 block discarded – undo
498 498
 				PRIMARY KEY  (TXN_ID),
499 499
 				KEY TXN_timestamp (TXN_timestamp),
500 500
 				KEY STS_ID (STS_ID)";
501
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
502
-        $table_name = 'esp_venue_meta';
503
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
501
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
502
+		$table_name = 'esp_venue_meta';
503
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
504 504
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
505 505
 			VNU_address varchar(255) DEFAULT NULL,
506 506
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -519,10 +519,10 @@  discard block
 block discarded – undo
519 519
 			KEY VNU_ID (VNU_ID),
520 520
 			KEY STA_ID (STA_ID),
521 521
 			KEY CNT_ISO (CNT_ISO)";
522
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
523
-        // modified tables
524
-        $table_name = "esp_price";
525
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
522
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
523
+		// modified tables
524
+		$table_name = "esp_price";
525
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
526 526
 				PRT_ID tinyint(3) unsigned NOT NULL,
527 527
 				PRC_amount decimal(12,3) NOT NULL DEFAULT '0.00',
528 528
 				PRC_name varchar(245) NOT NULL,
@@ -535,9 +535,9 @@  discard block
 block discarded – undo
535 535
 				PRC_parent int(10) unsigned DEFAULT 0,
536 536
 				PRIMARY KEY  (PRC_ID),
537 537
 				KEY PRT_ID (PRT_ID)";
538
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
539
-        $table_name = "esp_price_type";
540
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
538
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
539
+		$table_name = "esp_price_type";
540
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
541 541
 				PRT_name varchar(45) NOT NULL,
542 542
 				PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
543 543
 				PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -546,9 +546,9 @@  discard block
 block discarded – undo
546 546
 				PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
547 547
 				UNIQUE KEY PRT_name_UNIQUE (PRT_name),
548 548
 				PRIMARY KEY  (PRT_ID)";
549
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
550
-        $table_name = "esp_ticket";
551
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
549
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB ');
550
+		$table_name = "esp_ticket";
551
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
552 552
 				TTM_ID int(10) unsigned NOT NULL,
553 553
 				TKT_name varchar(245) NOT NULL DEFAULT '',
554 554
 				TKT_description text NOT NULL,
@@ -571,9 +571,9 @@  discard block
 block discarded – undo
571 571
 				TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
572 572
 				PRIMARY KEY  (TKT_ID),
573 573
 				KEY TKT_start_date (TKT_start_date)";
574
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
575
-        $table_name = 'esp_question_group';
576
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
574
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
575
+		$table_name = 'esp_question_group';
576
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
577 577
 				QSG_name varchar(255) NOT NULL,
578 578
 				QSG_identifier varchar(100) NOT NULL,
579 579
 				QSG_desc text NULL,
@@ -586,70 +586,70 @@  discard block
 block discarded – undo
586 586
 				PRIMARY KEY  (QSG_ID),
587 587
 				UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier),
588 588
 				KEY QSG_order (QSG_order)';
589
-        $this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
590
-        $this->insert_default_data();
591
-        return true;
592
-    }
589
+		$this->_table_has_not_changed_since_previous($table_name, $sql, 'ENGINE=InnoDB');
590
+		$this->insert_default_data();
591
+		return true;
592
+	}
593 593
 
594
-    /**
595
-     * Inserts default data on new installs
596
-     * @since 4.10.0.p
597
-     * @throws EE_Error
598
-     * @throws InvalidArgumentException
599
-     * @throws ReflectionException
600
-     * @throws InvalidDataTypeException
601
-     * @throws InvalidInterfaceException
602
-     */
603
-    public function insert_default_data()
604
-    {
605
-        $this->previous_dms->insert_default_data();
606
-        $this->removeMijirehPM();
607
-    }
594
+	/**
595
+	 * Inserts default data on new installs
596
+	 * @since 4.10.0.p
597
+	 * @throws EE_Error
598
+	 * @throws InvalidArgumentException
599
+	 * @throws ReflectionException
600
+	 * @throws InvalidDataTypeException
601
+	 * @throws InvalidInterfaceException
602
+	 */
603
+	public function insert_default_data()
604
+	{
605
+		$this->previous_dms->insert_default_data();
606
+		$this->removeMijirehPM();
607
+	}
608 608
 
609 609
 
610 610
 
611
-    /**
612
-     * @return boolean
613
-     */
614
-    public function schema_changes_after_migration()
615
-    {
616
-        return true;
617
-    }
611
+	/**
612
+	 * @return boolean
613
+	 */
614
+	public function schema_changes_after_migration()
615
+	{
616
+		return true;
617
+	}
618 618
 
619 619
 
620 620
 
621
-    public function migration_page_hooks()
622
-    {
623
-    }
621
+	public function migration_page_hooks()
622
+	{
623
+	}
624 624
 
625
-    /**
626
-     * Mijireh was removed in 4.10.3.p, but let's avoid having an error message because its files were removed, and don't
627
-     * show old payments made with it as being by "Unknown". The fix is to make it an "Admin_Only" payment method
628
-     * (like Invoice or Check) but don't allow it to be used in the admin either... so it's usable nowhere from now on,
629
-     * but it still exists so there's no problems.
630
-     * @since 4.10.3.p
631
-     */
632
-    protected function removeMijirehPM()
633
-    {
634
-        global $wpdb;
635
-        $wpdb->update(
636
-            $wpdb->prefix . 'esp_payment_method',
637
-            [
638
-                'PMD_type' => 'Admin_Only',
639
-                'PMD_scope' => serialize(array())
640
-            ],
641
-            [
642
-                'PMD_type' => 'Mijireh'
643
-            ],
644
-            [
645
-                // update formats
646
-                '%s', // PMD_type
647
-                '%s', // PMD_scope
648
-            ],
649
-            [
650
-                // where formats
651
-                '%s'
652
-            ]
653
-        );
654
-    }
625
+	/**
626
+	 * Mijireh was removed in 4.10.3.p, but let's avoid having an error message because its files were removed, and don't
627
+	 * show old payments made with it as being by "Unknown". The fix is to make it an "Admin_Only" payment method
628
+	 * (like Invoice or Check) but don't allow it to be used in the admin either... so it's usable nowhere from now on,
629
+	 * but it still exists so there's no problems.
630
+	 * @since 4.10.3.p
631
+	 */
632
+	protected function removeMijirehPM()
633
+	{
634
+		global $wpdb;
635
+		$wpdb->update(
636
+			$wpdb->prefix . 'esp_payment_method',
637
+			[
638
+				'PMD_type' => 'Admin_Only',
639
+				'PMD_scope' => serialize(array())
640
+			],
641
+			[
642
+				'PMD_type' => 'Mijireh'
643
+			],
644
+			[
645
+				// update formats
646
+				'%s', // PMD_type
647
+				'%s', // PMD_scope
648
+			],
649
+			[
650
+				// where formats
651
+				'%s'
652
+			]
653
+		);
654
+	}
655 655
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.4.rc.006');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.4.rc.006');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.