Completed
Branch BUG/11268/release-reserved-cou... (6d4092)
by
unknown
26:45 queued 13:23
created
admin_pages/maintenance/templates/migration_options_from_ee4.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
     </div>
69 69
     <p><?php esc_html_e('Don\'t want to keep your old Event Espresso data? Alternatively, you can delete it all and start fresh.',
70 70
                 'event_espresso'); ?> <a
71
-                href="<?php echo $data_reset_page;?>"><?php esc_html_e('Visit the Maintenance Page and Reset Your Event Espresso Data',
71
+                href="<?php echo $data_reset_page; ?>"><?php esc_html_e('Visit the Maintenance Page and Reset Your Event Espresso Data',
72 72
                     'event_espresso'); ?></a></p>
73 73
     <?php do_action('AHEE__ee_migration_page__after_migration_options_table'); ?>
74 74
 </div>
75 75
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
             <tr>
26 26
                 <td>
27 27
                     <?php
28
-                    echo apply_filters(
29
-                            'FHEE__ee_migration_page__option_1_main',
30
-                            esc_html__('Before updating your database, you should first create a database backup',
31
-                                    "event_espresso"),
32
-                            $current_db_state,
33
-                            $next_db_state
34
-                    );
35
-                    ?>
28
+					echo apply_filters(
29
+							'FHEE__ee_migration_page__option_1_main',
30
+							esc_html__('Before updating your database, you should first create a database backup',
31
+									"event_espresso"),
32
+							$current_db_state,
33
+							$next_db_state
34
+					);
35
+					?>
36 36
                     <a id="display-migration-details"
37 37
                        class="display-the-hidden lt-grey-text smaller-text hide-if-no-js"
38 38
                        rel="migration-details"><?php esc_html_e('How Do I Make a Database Backup?', "event_espresso"); ?>
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
                 <td>
42 42
                     <a id="db-backed-up"
43 43
                        class="toggle-migration-monitor button-primary"><?php echo apply_filters('FHEE__ee_migration_page__option_1_button_text',
44
-                                sprintf(esc_html__("My Database Is Backed Up, Continue", "event_espresso"), $current_db_state,
45
-                                        $next_db_state), $current_db_state, $next_db_state); ?></a>
44
+								sprintf(esc_html__("My Database Is Backed Up, Continue", "event_espresso"), $current_db_state,
45
+										$next_db_state), $current_db_state, $next_db_state); ?></a>
46 46
                 </td>
47 47
             </tr>
48 48
             <tr>
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
                     <div id="migration-details-dv" style="display: none; padding: 1em;">
51 51
                         <p>
52 52
                             <?php
53
-                            printf(
54
-                                    esc_html__('%1$sClick Here to Learn How To Backup your Database Yourself%2$s. Or have one of our dedicated support technicians help you by %3$spurchasing a Priority Support Token.%2$s',
55
-                                            "event_espresso"),
56
-                                    '<a target="_blank" href="http://eventespresso.com/wiki/how-to-back-up-your-site/">',
57
-                                    "</a>",
58
-                                    "<a target=\"_blank\" href='http://eventespresso.com/product/priority-support-tokens/'>"
59
-                            );
60
-                            ?>
53
+							printf(
54
+									esc_html__('%1$sClick Here to Learn How To Backup your Database Yourself%2$s. Or have one of our dedicated support technicians help you by %3$spurchasing a Priority Support Token.%2$s',
55
+											"event_espresso"),
56
+									'<a target="_blank" href="http://eventespresso.com/wiki/how-to-back-up-your-site/">',
57
+									"</a>",
58
+									"<a target=\"_blank\" href='http://eventespresso.com/product/priority-support-tokens/'>"
59
+							);
60
+							?>
61 61
                         </p>
62 62
                         <?php do_action('AHEE__ee_migration_page__option_1_extra_details'); ?>
63 63
                     </div>
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
         </table>
68 68
     </div>
69 69
     <p><?php esc_html_e('Don\'t want to keep your old Event Espresso data? Alternatively, you can delete it all and start fresh.',
70
-                'event_espresso'); ?> <a
70
+				'event_espresso'); ?> <a
71 71
                 href="<?php echo $data_reset_page;?>"><?php esc_html_e('Visit the Maintenance Page and Reset Your Event Espresso Data',
72
-                    'event_espresso'); ?></a></p>
72
+					'event_espresso'); ?></a></p>
73 73
     <?php do_action('AHEE__ee_migration_page__after_migration_options_table'); ?>
74 74
 </div>
75 75
\ No newline at end of file
Please login to merge, or discard this patch.
core/EE_Cart.core.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
      * @access  public
261 261
      * @param EE_Ticket $ticket
262 262
      * @param int       $qty
263
-     * @return TRUE on success, FALSE on fail
263
+     * @return boolean on success, FALSE on fail
264 264
      * @throws \EE_Error
265 265
      */
266 266
     public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1)
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
      * @save   cart to session
386 386
      * @access public
387 387
      * @param bool $apply_taxes
388
-     * @return TRUE on success, FALSE on fail
388
+     * @return boolean on success, FALSE on fail
389 389
      * @throws \EE_Error
390 390
      */
391 391
     public function save_cart($apply_taxes = true)
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 
420 420
 
421 421
     /**
422
-     * @return array
422
+     * @return string[]
423 423
      */
424 424
     public function __sleep()
425 425
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -203,7 +203,7 @@
 block discarded – undo
203 203
      */
204 204
     public function get_tickets()
205 205
     {
206
-        if ($this->_grand_total === null ) {
206
+        if ($this->_grand_total === null) {
207 207
             return array();
208 208
         }
209 209
         return EEH_Line_Item::get_ticket_line_items($this->_grand_total);
Please login to merge, or discard this patch.
Indentation   +416 added lines, -416 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\interfaces\ResettableInterface;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
8 8
 
@@ -23,421 +23,421 @@  discard block
 block discarded – undo
23 23
 class EE_Cart implements ResettableInterface
24 24
 {
25 25
 
26
-    /**
27
-     * instance of the EE_Cart object
28
-     *
29
-     * @access    private
30
-     * @var EE_Cart $_instance
31
-     */
32
-    private static $_instance;
33
-
34
-    /**
35
-     * instance of the EE_Session object
36
-     *
37
-     * @access    protected
38
-     * @var EE_Session $_session
39
-     */
40
-    protected $_session;
41
-
42
-    /**
43
-     * The total Line item which comprises all the children line-item subtotals,
44
-     * which in turn each have their line items.
45
-     * Typically, the line item structure will look like:
46
-     * grand total
47
-     * -tickets-sub-total
48
-     * --ticket1
49
-     * --ticket2
50
-     * --...
51
-     * -taxes-sub-total
52
-     * --tax1
53
-     * --tax2
54
-     *
55
-     * @var EE_Line_Item
56
-     */
57
-    private $_grand_total;
58
-
59
-
60
-
61
-    /**
62
-     * @singleton method used to instantiate class object
63
-     * @access    public
64
-     * @param EE_Line_Item $grand_total
65
-     * @param EE_Session   $session
66
-     * @return \EE_Cart
67
-     * @throws \EE_Error
68
-     */
69
-    public static function instance(EE_Line_Item $grand_total = null, EE_Session $session = null)
70
-    {
71
-        if ( ! empty($grand_total)) {
72
-            self::$_instance = new self($grand_total, $session);
73
-        }
74
-        // or maybe retrieve an existing one ?
75
-        if ( ! self::$_instance instanceof EE_Cart) {
76
-            // try getting the cart out of the session
77
-            $saved_cart = $session instanceof EE_Session ? $session->cart() : null;
78
-            self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total, $session);
79
-            unset($saved_cart);
80
-        }
81
-        // verify that cart is ok and grand total line item exists
82
-        if ( ! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) {
83
-            self::$_instance = new self($grand_total, $session);
84
-        }
85
-        self::$_instance->get_grand_total();
86
-        // once everything is all said and done, save the cart to the EE_Session
87
-        add_action('shutdown', array(self::$_instance, 'save_cart'), 90);
88
-        return self::$_instance;
89
-    }
90
-
91
-
92
-
93
-    /**
94
-     * private constructor to prevent direct creation
95
-     *
96
-     * @Constructor
97
-     * @access private
98
-     * @param EE_Line_Item $grand_total
99
-     * @param EE_Session   $session
100
-     */
101
-    private function __construct(EE_Line_Item $grand_total = null, EE_Session $session = null)
102
-    {
103
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
104
-        $this->set_session($session);
105
-        if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) {
106
-            $this->set_grand_total_line_item($grand_total);
107
-        }
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * Resets the cart completely (whereas empty_cart
114
-     *
115
-     * @param EE_Line_Item $grand_total
116
-     * @param EE_Session   $session
117
-     * @return EE_Cart
118
-     * @throws \EE_Error
119
-     */
120
-    public static function reset(EE_Line_Item $grand_total = null, EE_Session $session = null)
121
-    {
122
-        remove_action('shutdown', array(self::$_instance, 'save_cart'), 90);
123
-        if ($session instanceof EE_Session) {
124
-            $session->reset_cart();
125
-        }
126
-        self::$_instance = null;
127
-        return self::instance($grand_total, $session);
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     * @return \EE_Session
134
-     */
135
-    public function session()
136
-    {
137
-        if ( ! $this->_session instanceof EE_Session) {
138
-            $this->set_session();
139
-        }
140
-        return $this->_session;
141
-    }
142
-
143
-
144
-
145
-    /**
146
-     * @param EE_Session $session
147
-     */
148
-    public function set_session(EE_Session $session = null)
149
-    {
150
-        $this->_session = $session instanceof EE_Session ? $session : EE_Registry::instance()->load_core('Session');
151
-    }
152
-
153
-
154
-
155
-    /**
156
-     * Sets the cart to match the line item. Especially handy for loading an old cart where you
157
-     *  know the grand total line item on it
158
-     *
159
-     * @param EE_Line_Item $line_item
160
-     */
161
-    public function set_grand_total_line_item(EE_Line_Item $line_item)
162
-    {
163
-        $this->_grand_total = $line_item;
164
-    }
165
-
166
-
167
-
168
-    /**
169
-     * get_cart_from_reg_url_link
170
-     *
171
-     * @access public
172
-     * @param EE_Transaction $transaction
173
-     * @param EE_Session     $session
174
-     * @return \EE_Cart
175
-     * @throws \EE_Error
176
-     */
177
-    public static function get_cart_from_txn(EE_Transaction $transaction, EE_Session $session = null)
178
-    {
179
-        $grand_total = $transaction->total_line_item();
180
-        $grand_total->get_items();
181
-        $grand_total->tax_descendants();
182
-        return EE_Cart::instance($grand_total, $session);
183
-    }
184
-
185
-
186
-
187
-    /**
188
-     * Creates the total line item, and ensures it has its 'tickets' and 'taxes' sub-items
189
-     *
190
-     * @return EE_Line_Item
191
-     * @throws \EE_Error
192
-     */
193
-    private function _create_grand_total()
194
-    {
195
-        $this->_grand_total = EEH_Line_Item::create_total_line_item();
196
-        return $this->_grand_total;
197
-    }
198
-
199
-
200
-
201
-    /**
202
-     * Gets all the line items of object type Ticket
203
-     *
204
-     * @access public
205
-     * @return \EE_Line_Item[]
206
-     */
207
-    public function get_tickets()
208
-    {
209
-        if ($this->_grand_total === null ) {
210
-            return array();
211
-        }
212
-        return EEH_Line_Item::get_ticket_line_items($this->_grand_total);
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     * returns the total quantity of tickets in the cart
219
-     *
220
-     * @access public
221
-     * @return int
222
-     * @throws \EE_Error
223
-     */
224
-    public function all_ticket_quantity_count()
225
-    {
226
-        $tickets = $this->get_tickets();
227
-        if (empty($tickets)) {
228
-            return 0;
229
-        }
230
-        $count = 0;
231
-        foreach ($tickets as $ticket) {
232
-            $count += $ticket->get('LIN_quantity');
233
-        }
234
-        return $count;
235
-    }
236
-
237
-
238
-
239
-    /**
240
-     * Gets all the tax line items
241
-     *
242
-     * @return \EE_Line_Item[]
243
-     * @throws \EE_Error
244
-     */
245
-    public function get_taxes()
246
-    {
247
-        return EEH_Line_Item::get_taxes_subtotal($this->_grand_total)->children();
248
-    }
249
-
250
-
251
-
252
-    /**
253
-     * Gets the total line item (which is a parent of all other line items) on this cart
254
-     *
255
-     * @return EE_Line_Item
256
-     * @throws \EE_Error
257
-     */
258
-    public function get_grand_total()
259
-    {
260
-        return $this->_grand_total instanceof EE_Line_Item ? $this->_grand_total : $this->_create_grand_total();
261
-    }
262
-
263
-
264
-
265
-    /**
266
-     * @process items for adding to cart
267
-     * @access  public
268
-     * @param EE_Ticket $ticket
269
-     * @param int       $qty
270
-     * @return TRUE on success, FALSE on fail
271
-     * @throws \EE_Error
272
-     */
273
-    public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1)
274
-    {
275
-        EEH_Line_Item::add_ticket_purchase($this->get_grand_total(), $ticket, $qty);
276
-        return $this->save_cart() ? true : false;
277
-    }
278
-
279
-
280
-
281
-    /**
282
-     * get_cart_total_before_tax
283
-     *
284
-     * @access public
285
-     * @return float
286
-     * @throws \EE_Error
287
-     */
288
-    public function get_cart_total_before_tax()
289
-    {
290
-        return $this->get_grand_total()->recalculate_pre_tax_total();
291
-    }
292
-
293
-
294
-
295
-    /**
296
-     * gets the total amount of tax paid for items in this cart
297
-     *
298
-     * @access public
299
-     * @return float
300
-     * @throws \EE_Error
301
-     */
302
-    public function get_applied_taxes()
303
-    {
304
-        return EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
305
-    }
306
-
307
-
308
-
309
-    /**
310
-     * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers
311
-     *
312
-     * @access public
313
-     * @return float
314
-     * @throws \EE_Error
315
-     */
316
-    public function get_cart_grand_total()
317
-    {
318
-        EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
319
-        return $this->get_grand_total()->total();
320
-    }
321
-
322
-
323
-
324
-    /**
325
-     * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers
326
-     *
327
-     * @access public
328
-     * @return float
329
-     * @throws \EE_Error
330
-     */
331
-    public function recalculate_all_cart_totals()
332
-    {
333
-        $pre_tax_total = $this->get_cart_total_before_tax();
334
-        $taxes_total = EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
335
-        $this->_grand_total->set_total($pre_tax_total + $taxes_total);
336
-        $this->_grand_total->save_this_and_descendants_to_txn();
337
-        return $this->get_grand_total()->total();
338
-    }
339
-
340
-
341
-
342
-    /**
343
-     * deletes an item from the cart
344
-     *
345
-     * @access public
346
-     * @param array|bool|string $line_item_codes
347
-     * @return int on success, FALSE on fail
348
-     * @throws \EE_Error
349
-     */
350
-    public function delete_items($line_item_codes = false)
351
-    {
352
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
353
-        return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes);
354
-    }
355
-
356
-
357
-
358
-    /**
359
-     * @remove ALL items from cart and zero ALL totals
360
-     * @access public
361
-     * @return bool
362
-     * @throws \EE_Error
363
-     */
364
-    public function empty_cart()
365
-    {
366
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
367
-        $this->_grand_total = $this->_create_grand_total();
368
-        return $this->save_cart(true);
369
-    }
370
-
371
-
372
-
373
-    /**
374
-     * @remove ALL items from cart and delete total as well
375
-     * @access public
376
-     * @return bool
377
-     * @throws \EE_Error
378
-     */
379
-    public function delete_cart()
380
-    {
381
-        if ($this->_grand_total instanceof EE_Line_Item) {
382
-            $deleted = EEH_Line_Item::delete_all_child_items($this->_grand_total);
383
-            if ($deleted) {
384
-                $deleted += $this->_grand_total->delete();
385
-                $this->_grand_total = null;
386
-                return true;
387
-            }
388
-        }
389
-        return false;
390
-    }
391
-
392
-
393
-
394
-    /**
395
-     * @save   cart to session
396
-     * @access public
397
-     * @param bool $apply_taxes
398
-     * @return TRUE on success, FALSE on fail
399
-     * @throws \EE_Error
400
-     */
401
-    public function save_cart($apply_taxes = true)
402
-    {
403
-        if ($apply_taxes && $this->_grand_total instanceof EE_Line_Item) {
404
-            EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
405
-            //make sure we don't cache the transaction because it can get stale
406
-            if ($this->_grand_total->get_one_from_cache('Transaction') instanceof EE_Transaction
407
-                && $this->_grand_total->get_one_from_cache('Transaction')->ID()
408
-            ) {
409
-                $this->_grand_total->clear_cache('Transaction', null, true);
410
-            }
411
-        }
412
-        if ($this->session() instanceof EE_Session) {
413
-            return $this->session()->set_cart($this);
414
-        } else {
415
-            return false;
416
-        }
417
-    }
418
-
419
-
420
-
421
-    public function __wakeup()
422
-    {
423
-        if ( ! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) {
424
-            // $this->_grand_total is actually just an ID, so use it to get the object from the db
425
-            $this->_grand_total = EEM_Line_Item::instance()->get_one_by_ID($this->_grand_total);
426
-        }
427
-    }
428
-
429
-
430
-
431
-    /**
432
-     * @return array
433
-     */
434
-    public function __sleep()
435
-    {
436
-        if ($this->_grand_total instanceof EE_Line_Item && $this->_grand_total->ID()) {
437
-            $this->_grand_total = $this->_grand_total->ID();
438
-        }
439
-        return array('_grand_total');
440
-    }
26
+	/**
27
+	 * instance of the EE_Cart object
28
+	 *
29
+	 * @access    private
30
+	 * @var EE_Cart $_instance
31
+	 */
32
+	private static $_instance;
33
+
34
+	/**
35
+	 * instance of the EE_Session object
36
+	 *
37
+	 * @access    protected
38
+	 * @var EE_Session $_session
39
+	 */
40
+	protected $_session;
41
+
42
+	/**
43
+	 * The total Line item which comprises all the children line-item subtotals,
44
+	 * which in turn each have their line items.
45
+	 * Typically, the line item structure will look like:
46
+	 * grand total
47
+	 * -tickets-sub-total
48
+	 * --ticket1
49
+	 * --ticket2
50
+	 * --...
51
+	 * -taxes-sub-total
52
+	 * --tax1
53
+	 * --tax2
54
+	 *
55
+	 * @var EE_Line_Item
56
+	 */
57
+	private $_grand_total;
58
+
59
+
60
+
61
+	/**
62
+	 * @singleton method used to instantiate class object
63
+	 * @access    public
64
+	 * @param EE_Line_Item $grand_total
65
+	 * @param EE_Session   $session
66
+	 * @return \EE_Cart
67
+	 * @throws \EE_Error
68
+	 */
69
+	public static function instance(EE_Line_Item $grand_total = null, EE_Session $session = null)
70
+	{
71
+		if ( ! empty($grand_total)) {
72
+			self::$_instance = new self($grand_total, $session);
73
+		}
74
+		// or maybe retrieve an existing one ?
75
+		if ( ! self::$_instance instanceof EE_Cart) {
76
+			// try getting the cart out of the session
77
+			$saved_cart = $session instanceof EE_Session ? $session->cart() : null;
78
+			self::$_instance = $saved_cart instanceof EE_Cart ? $saved_cart : new self($grand_total, $session);
79
+			unset($saved_cart);
80
+		}
81
+		// verify that cart is ok and grand total line item exists
82
+		if ( ! self::$_instance instanceof EE_Cart || ! self::$_instance->_grand_total instanceof EE_Line_Item) {
83
+			self::$_instance = new self($grand_total, $session);
84
+		}
85
+		self::$_instance->get_grand_total();
86
+		// once everything is all said and done, save the cart to the EE_Session
87
+		add_action('shutdown', array(self::$_instance, 'save_cart'), 90);
88
+		return self::$_instance;
89
+	}
90
+
91
+
92
+
93
+	/**
94
+	 * private constructor to prevent direct creation
95
+	 *
96
+	 * @Constructor
97
+	 * @access private
98
+	 * @param EE_Line_Item $grand_total
99
+	 * @param EE_Session   $session
100
+	 */
101
+	private function __construct(EE_Line_Item $grand_total = null, EE_Session $session = null)
102
+	{
103
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
104
+		$this->set_session($session);
105
+		if ($grand_total instanceof EE_Line_Item && $grand_total->is_total()) {
106
+			$this->set_grand_total_line_item($grand_total);
107
+		}
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * Resets the cart completely (whereas empty_cart
114
+	 *
115
+	 * @param EE_Line_Item $grand_total
116
+	 * @param EE_Session   $session
117
+	 * @return EE_Cart
118
+	 * @throws \EE_Error
119
+	 */
120
+	public static function reset(EE_Line_Item $grand_total = null, EE_Session $session = null)
121
+	{
122
+		remove_action('shutdown', array(self::$_instance, 'save_cart'), 90);
123
+		if ($session instanceof EE_Session) {
124
+			$session->reset_cart();
125
+		}
126
+		self::$_instance = null;
127
+		return self::instance($grand_total, $session);
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 * @return \EE_Session
134
+	 */
135
+	public function session()
136
+	{
137
+		if ( ! $this->_session instanceof EE_Session) {
138
+			$this->set_session();
139
+		}
140
+		return $this->_session;
141
+	}
142
+
143
+
144
+
145
+	/**
146
+	 * @param EE_Session $session
147
+	 */
148
+	public function set_session(EE_Session $session = null)
149
+	{
150
+		$this->_session = $session instanceof EE_Session ? $session : EE_Registry::instance()->load_core('Session');
151
+	}
152
+
153
+
154
+
155
+	/**
156
+	 * Sets the cart to match the line item. Especially handy for loading an old cart where you
157
+	 *  know the grand total line item on it
158
+	 *
159
+	 * @param EE_Line_Item $line_item
160
+	 */
161
+	public function set_grand_total_line_item(EE_Line_Item $line_item)
162
+	{
163
+		$this->_grand_total = $line_item;
164
+	}
165
+
166
+
167
+
168
+	/**
169
+	 * get_cart_from_reg_url_link
170
+	 *
171
+	 * @access public
172
+	 * @param EE_Transaction $transaction
173
+	 * @param EE_Session     $session
174
+	 * @return \EE_Cart
175
+	 * @throws \EE_Error
176
+	 */
177
+	public static function get_cart_from_txn(EE_Transaction $transaction, EE_Session $session = null)
178
+	{
179
+		$grand_total = $transaction->total_line_item();
180
+		$grand_total->get_items();
181
+		$grand_total->tax_descendants();
182
+		return EE_Cart::instance($grand_total, $session);
183
+	}
184
+
185
+
186
+
187
+	/**
188
+	 * Creates the total line item, and ensures it has its 'tickets' and 'taxes' sub-items
189
+	 *
190
+	 * @return EE_Line_Item
191
+	 * @throws \EE_Error
192
+	 */
193
+	private function _create_grand_total()
194
+	{
195
+		$this->_grand_total = EEH_Line_Item::create_total_line_item();
196
+		return $this->_grand_total;
197
+	}
198
+
199
+
200
+
201
+	/**
202
+	 * Gets all the line items of object type Ticket
203
+	 *
204
+	 * @access public
205
+	 * @return \EE_Line_Item[]
206
+	 */
207
+	public function get_tickets()
208
+	{
209
+		if ($this->_grand_total === null ) {
210
+			return array();
211
+		}
212
+		return EEH_Line_Item::get_ticket_line_items($this->_grand_total);
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 * returns the total quantity of tickets in the cart
219
+	 *
220
+	 * @access public
221
+	 * @return int
222
+	 * @throws \EE_Error
223
+	 */
224
+	public function all_ticket_quantity_count()
225
+	{
226
+		$tickets = $this->get_tickets();
227
+		if (empty($tickets)) {
228
+			return 0;
229
+		}
230
+		$count = 0;
231
+		foreach ($tickets as $ticket) {
232
+			$count += $ticket->get('LIN_quantity');
233
+		}
234
+		return $count;
235
+	}
236
+
237
+
238
+
239
+	/**
240
+	 * Gets all the tax line items
241
+	 *
242
+	 * @return \EE_Line_Item[]
243
+	 * @throws \EE_Error
244
+	 */
245
+	public function get_taxes()
246
+	{
247
+		return EEH_Line_Item::get_taxes_subtotal($this->_grand_total)->children();
248
+	}
249
+
250
+
251
+
252
+	/**
253
+	 * Gets the total line item (which is a parent of all other line items) on this cart
254
+	 *
255
+	 * @return EE_Line_Item
256
+	 * @throws \EE_Error
257
+	 */
258
+	public function get_grand_total()
259
+	{
260
+		return $this->_grand_total instanceof EE_Line_Item ? $this->_grand_total : $this->_create_grand_total();
261
+	}
262
+
263
+
264
+
265
+	/**
266
+	 * @process items for adding to cart
267
+	 * @access  public
268
+	 * @param EE_Ticket $ticket
269
+	 * @param int       $qty
270
+	 * @return TRUE on success, FALSE on fail
271
+	 * @throws \EE_Error
272
+	 */
273
+	public function add_ticket_to_cart(EE_Ticket $ticket, $qty = 1)
274
+	{
275
+		EEH_Line_Item::add_ticket_purchase($this->get_grand_total(), $ticket, $qty);
276
+		return $this->save_cart() ? true : false;
277
+	}
278
+
279
+
280
+
281
+	/**
282
+	 * get_cart_total_before_tax
283
+	 *
284
+	 * @access public
285
+	 * @return float
286
+	 * @throws \EE_Error
287
+	 */
288
+	public function get_cart_total_before_tax()
289
+	{
290
+		return $this->get_grand_total()->recalculate_pre_tax_total();
291
+	}
292
+
293
+
294
+
295
+	/**
296
+	 * gets the total amount of tax paid for items in this cart
297
+	 *
298
+	 * @access public
299
+	 * @return float
300
+	 * @throws \EE_Error
301
+	 */
302
+	public function get_applied_taxes()
303
+	{
304
+		return EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
305
+	}
306
+
307
+
308
+
309
+	/**
310
+	 * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers
311
+	 *
312
+	 * @access public
313
+	 * @return float
314
+	 * @throws \EE_Error
315
+	 */
316
+	public function get_cart_grand_total()
317
+	{
318
+		EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
319
+		return $this->get_grand_total()->total();
320
+	}
321
+
322
+
323
+
324
+	/**
325
+	 * Gets the total amount to be paid for the items in the cart, including taxes and other modifiers
326
+	 *
327
+	 * @access public
328
+	 * @return float
329
+	 * @throws \EE_Error
330
+	 */
331
+	public function recalculate_all_cart_totals()
332
+	{
333
+		$pre_tax_total = $this->get_cart_total_before_tax();
334
+		$taxes_total = EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
335
+		$this->_grand_total->set_total($pre_tax_total + $taxes_total);
336
+		$this->_grand_total->save_this_and_descendants_to_txn();
337
+		return $this->get_grand_total()->total();
338
+	}
339
+
340
+
341
+
342
+	/**
343
+	 * deletes an item from the cart
344
+	 *
345
+	 * @access public
346
+	 * @param array|bool|string $line_item_codes
347
+	 * @return int on success, FALSE on fail
348
+	 * @throws \EE_Error
349
+	 */
350
+	public function delete_items($line_item_codes = false)
351
+	{
352
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
353
+		return EEH_Line_Item::delete_items($this->get_grand_total(), $line_item_codes);
354
+	}
355
+
356
+
357
+
358
+	/**
359
+	 * @remove ALL items from cart and zero ALL totals
360
+	 * @access public
361
+	 * @return bool
362
+	 * @throws \EE_Error
363
+	 */
364
+	public function empty_cart()
365
+	{
366
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
367
+		$this->_grand_total = $this->_create_grand_total();
368
+		return $this->save_cart(true);
369
+	}
370
+
371
+
372
+
373
+	/**
374
+	 * @remove ALL items from cart and delete total as well
375
+	 * @access public
376
+	 * @return bool
377
+	 * @throws \EE_Error
378
+	 */
379
+	public function delete_cart()
380
+	{
381
+		if ($this->_grand_total instanceof EE_Line_Item) {
382
+			$deleted = EEH_Line_Item::delete_all_child_items($this->_grand_total);
383
+			if ($deleted) {
384
+				$deleted += $this->_grand_total->delete();
385
+				$this->_grand_total = null;
386
+				return true;
387
+			}
388
+		}
389
+		return false;
390
+	}
391
+
392
+
393
+
394
+	/**
395
+	 * @save   cart to session
396
+	 * @access public
397
+	 * @param bool $apply_taxes
398
+	 * @return TRUE on success, FALSE on fail
399
+	 * @throws \EE_Error
400
+	 */
401
+	public function save_cart($apply_taxes = true)
402
+	{
403
+		if ($apply_taxes && $this->_grand_total instanceof EE_Line_Item) {
404
+			EEH_Line_Item::ensure_taxes_applied($this->_grand_total);
405
+			//make sure we don't cache the transaction because it can get stale
406
+			if ($this->_grand_total->get_one_from_cache('Transaction') instanceof EE_Transaction
407
+				&& $this->_grand_total->get_one_from_cache('Transaction')->ID()
408
+			) {
409
+				$this->_grand_total->clear_cache('Transaction', null, true);
410
+			}
411
+		}
412
+		if ($this->session() instanceof EE_Session) {
413
+			return $this->session()->set_cart($this);
414
+		} else {
415
+			return false;
416
+		}
417
+	}
418
+
419
+
420
+
421
+	public function __wakeup()
422
+	{
423
+		if ( ! $this->_grand_total instanceof EE_Line_Item && absint($this->_grand_total) !== 0) {
424
+			// $this->_grand_total is actually just an ID, so use it to get the object from the db
425
+			$this->_grand_total = EEM_Line_Item::instance()->get_one_by_ID($this->_grand_total);
426
+		}
427
+	}
428
+
429
+
430
+
431
+	/**
432
+	 * @return array
433
+	 */
434
+	public function __sleep()
435
+	{
436
+		if ($this->_grand_total instanceof EE_Line_Item && $this->_grand_total->ID()) {
437
+			$this->_grand_total = $this->_grand_total->ID();
438
+		}
439
+		return array('_grand_total');
440
+	}
441 441
 
442 442
 
443 443
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Activation.helper.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
      *
614 614
      * @since  4.6.0
615 615
      * @global WPDB $wpdb
616
-     * @return mixed null|int WP_user ID or NULL
616
+     * @return integer|null null|int WP_user ID or NULL
617 617
      */
618 618
     public static function get_default_creator_id()
619 619
     {
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
      * @static
775 775
      * @deprecated instead use TableManager::dropTable()
776 776
      * @param string $table_name
777
-     * @return bool | int
777
+     * @return integer | int
778 778
      */
779 779
     public static function delete_unused_db_table($table_name)
780 780
     {
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
      * @deprecated instead use TableManager::dropIndex()
792 792
      * @param string $table_name
793 793
      * @param string $index_name
794
-     * @return bool | int
794
+     * @return integer | int
795 795
      */
796 796
     public static function drop_index($table_name, $index_name)
797 797
     {
Please login to merge, or discard this patch.
Indentation   +1650 added lines, -1650 removed lines patch added patch discarded remove patch
@@ -18,243 +18,243 @@  discard block
 block discarded – undo
18 18
 class EEH_Activation implements ResettableInterface
19 19
 {
20 20
 
21
-    /**
22
-     * constant used to indicate a cron task is no longer in use
23
-     */
24
-    const cron_task_no_longer_in_use = 'no_longer_in_use';
25
-
26
-    /**
27
-     * option name that will indicate whether or not we still
28
-     * need to create EE's folders in the uploads directory
29
-     * (because if EE was installed without file system access,
30
-     * we need to request credentials before we can create them)
31
-     */
32
-    const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete';
33
-
34
-    /**
35
-     * WP_User->ID
36
-     *
37
-     * @var int
38
-     */
39
-    private static $_default_creator_id;
40
-
41
-    /**
42
-     * indicates whether or not we've already verified core's default data during this request,
43
-     * because after migrations are done, any addons activated while in maintenance mode
44
-     * will want to setup their own default data, and they might hook into core's default data
45
-     * and trigger core to setup its default data. In which case they might all ask for core to init its default data.
46
-     * This prevents doing that for EVERY single addon.
47
-     *
48
-     * @var boolean
49
-     */
50
-    protected static $_initialized_db_content_already_in_this_request = false;
51
-
52
-    /**
53
-     * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
54
-     */
55
-    private static $table_analysis;
56
-
57
-    /**
58
-     * @var \EventEspresso\core\services\database\TableManager $table_manager
59
-     */
60
-    private static $table_manager;
61
-
62
-
63
-    /**
64
-     * @return \EventEspresso\core\services\database\TableAnalysis
65
-     */
66
-    public static function getTableAnalysis()
67
-    {
68
-        if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
69
-            self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
70
-        }
71
-        return self::$table_analysis;
72
-    }
73
-
74
-
75
-    /**
76
-     * @return \EventEspresso\core\services\database\TableManager
77
-     */
78
-    public static function getTableManager()
79
-    {
80
-        if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
81
-            self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
82
-        }
83
-        return self::$table_manager;
84
-    }
85
-
86
-
87
-    /**
88
-     *    _ensure_table_name_has_prefix
89
-     *
90
-     * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix()
91
-     * @access     public
92
-     * @static
93
-     * @param $table_name
94
-     * @return string
95
-     */
96
-    public static function ensure_table_name_has_prefix($table_name)
97
-    {
98
-        return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name);
99
-    }
100
-
101
-
102
-    /**
103
-     *    system_initialization
104
-     *    ensures the EE configuration settings are loaded with at least default options set
105
-     *    and that all critical EE pages have been generated with the appropriate shortcodes in place
106
-     *
107
-     * @access public
108
-     * @static
109
-     * @return void
110
-     */
111
-    public static function system_initialization()
112
-    {
113
-        EEH_Activation::reset_and_update_config();
114
-        //which is fired BEFORE activation of plugin anyways
115
-        EEH_Activation::verify_default_pages_exist();
116
-    }
117
-
118
-
119
-    /**
120
-     * Sets the database schema and creates folders. This should
121
-     * be called on plugin activation and reactivation
122
-     *
123
-     * @return boolean success, whether the database and folders are setup properly
124
-     * @throws \EE_Error
125
-     */
126
-    public static function initialize_db_and_folders()
127
-    {
128
-        $good_filesystem = EEH_Activation::create_upload_directories();
129
-        $good_db         = EEH_Activation::create_database_tables();
130
-        return $good_filesystem && $good_db;
131
-    }
132
-
133
-
134
-    /**
135
-     * assuming we have an up-to-date database schema, this will populate it
136
-     * with default and initial data. This should be called
137
-     * upon activation of a new plugin, reactivation, and at the end
138
-     * of running migration scripts
139
-     *
140
-     * @throws \EE_Error
141
-     */
142
-    public static function initialize_db_content()
143
-    {
144
-        //let's avoid doing all this logic repeatedly, especially when addons are requesting it
145
-        if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
146
-            return;
147
-        }
148
-        EEH_Activation::$_initialized_db_content_already_in_this_request = true;
149
-
150
-        EEH_Activation::initialize_system_questions();
151
-        EEH_Activation::insert_default_status_codes();
152
-        EEH_Activation::generate_default_message_templates();
153
-        EEH_Activation::create_no_ticket_prices_array();
154
-
155
-        EEH_Activation::validate_messages_system();
156
-        EEH_Activation::insert_default_payment_methods();
157
-        //in case we've
158
-        EEH_Activation::remove_cron_tasks();
159
-        EEH_Activation::create_cron_tasks();
160
-        // remove all TXN locks since that is being done via extra meta now
161
-        delete_option('ee_locked_transactions');
162
-        //also, check for CAF default db content
163
-        do_action('AHEE__EEH_Activation__initialize_db_content');
164
-        //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
165
-        //which users really won't care about on initial activation
166
-        EE_Error::overwrite_success();
167
-    }
168
-
169
-
170
-    /**
171
-     * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"),
172
-     * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event
173
-     * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use
174
-     * (null)
175
-     *
176
-     * @param string $which_to_include can be 'current' (ones that are currently in use),
177
-     *                                 'old' (only returns ones that should no longer be used),or 'all',
178
-     * @return array
179
-     * @throws \EE_Error
180
-     */
181
-    public static function get_cron_tasks($which_to_include)
182
-    {
183
-        $cron_tasks = apply_filters(
184
-            'FHEE__EEH_Activation__get_cron_tasks',
185
-            array(
186
-                'AHEE__EE_Cron_Tasks__clean_up_junk_transactions'      => 'hourly',
21
+	/**
22
+	 * constant used to indicate a cron task is no longer in use
23
+	 */
24
+	const cron_task_no_longer_in_use = 'no_longer_in_use';
25
+
26
+	/**
27
+	 * option name that will indicate whether or not we still
28
+	 * need to create EE's folders in the uploads directory
29
+	 * (because if EE was installed without file system access,
30
+	 * we need to request credentials before we can create them)
31
+	 */
32
+	const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete';
33
+
34
+	/**
35
+	 * WP_User->ID
36
+	 *
37
+	 * @var int
38
+	 */
39
+	private static $_default_creator_id;
40
+
41
+	/**
42
+	 * indicates whether or not we've already verified core's default data during this request,
43
+	 * because after migrations are done, any addons activated while in maintenance mode
44
+	 * will want to setup their own default data, and they might hook into core's default data
45
+	 * and trigger core to setup its default data. In which case they might all ask for core to init its default data.
46
+	 * This prevents doing that for EVERY single addon.
47
+	 *
48
+	 * @var boolean
49
+	 */
50
+	protected static $_initialized_db_content_already_in_this_request = false;
51
+
52
+	/**
53
+	 * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
54
+	 */
55
+	private static $table_analysis;
56
+
57
+	/**
58
+	 * @var \EventEspresso\core\services\database\TableManager $table_manager
59
+	 */
60
+	private static $table_manager;
61
+
62
+
63
+	/**
64
+	 * @return \EventEspresso\core\services\database\TableAnalysis
65
+	 */
66
+	public static function getTableAnalysis()
67
+	{
68
+		if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
69
+			self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
70
+		}
71
+		return self::$table_analysis;
72
+	}
73
+
74
+
75
+	/**
76
+	 * @return \EventEspresso\core\services\database\TableManager
77
+	 */
78
+	public static function getTableManager()
79
+	{
80
+		if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
81
+			self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
82
+		}
83
+		return self::$table_manager;
84
+	}
85
+
86
+
87
+	/**
88
+	 *    _ensure_table_name_has_prefix
89
+	 *
90
+	 * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix()
91
+	 * @access     public
92
+	 * @static
93
+	 * @param $table_name
94
+	 * @return string
95
+	 */
96
+	public static function ensure_table_name_has_prefix($table_name)
97
+	{
98
+		return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name);
99
+	}
100
+
101
+
102
+	/**
103
+	 *    system_initialization
104
+	 *    ensures the EE configuration settings are loaded with at least default options set
105
+	 *    and that all critical EE pages have been generated with the appropriate shortcodes in place
106
+	 *
107
+	 * @access public
108
+	 * @static
109
+	 * @return void
110
+	 */
111
+	public static function system_initialization()
112
+	{
113
+		EEH_Activation::reset_and_update_config();
114
+		//which is fired BEFORE activation of plugin anyways
115
+		EEH_Activation::verify_default_pages_exist();
116
+	}
117
+
118
+
119
+	/**
120
+	 * Sets the database schema and creates folders. This should
121
+	 * be called on plugin activation and reactivation
122
+	 *
123
+	 * @return boolean success, whether the database and folders are setup properly
124
+	 * @throws \EE_Error
125
+	 */
126
+	public static function initialize_db_and_folders()
127
+	{
128
+		$good_filesystem = EEH_Activation::create_upload_directories();
129
+		$good_db         = EEH_Activation::create_database_tables();
130
+		return $good_filesystem && $good_db;
131
+	}
132
+
133
+
134
+	/**
135
+	 * assuming we have an up-to-date database schema, this will populate it
136
+	 * with default and initial data. This should be called
137
+	 * upon activation of a new plugin, reactivation, and at the end
138
+	 * of running migration scripts
139
+	 *
140
+	 * @throws \EE_Error
141
+	 */
142
+	public static function initialize_db_content()
143
+	{
144
+		//let's avoid doing all this logic repeatedly, especially when addons are requesting it
145
+		if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
146
+			return;
147
+		}
148
+		EEH_Activation::$_initialized_db_content_already_in_this_request = true;
149
+
150
+		EEH_Activation::initialize_system_questions();
151
+		EEH_Activation::insert_default_status_codes();
152
+		EEH_Activation::generate_default_message_templates();
153
+		EEH_Activation::create_no_ticket_prices_array();
154
+
155
+		EEH_Activation::validate_messages_system();
156
+		EEH_Activation::insert_default_payment_methods();
157
+		//in case we've
158
+		EEH_Activation::remove_cron_tasks();
159
+		EEH_Activation::create_cron_tasks();
160
+		// remove all TXN locks since that is being done via extra meta now
161
+		delete_option('ee_locked_transactions');
162
+		//also, check for CAF default db content
163
+		do_action('AHEE__EEH_Activation__initialize_db_content');
164
+		//also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
165
+		//which users really won't care about on initial activation
166
+		EE_Error::overwrite_success();
167
+	}
168
+
169
+
170
+	/**
171
+	 * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"),
172
+	 * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event
173
+	 * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use
174
+	 * (null)
175
+	 *
176
+	 * @param string $which_to_include can be 'current' (ones that are currently in use),
177
+	 *                                 'old' (only returns ones that should no longer be used),or 'all',
178
+	 * @return array
179
+	 * @throws \EE_Error
180
+	 */
181
+	public static function get_cron_tasks($which_to_include)
182
+	{
183
+		$cron_tasks = apply_filters(
184
+			'FHEE__EEH_Activation__get_cron_tasks',
185
+			array(
186
+				'AHEE__EE_Cron_Tasks__clean_up_junk_transactions'      => 'hourly',
187 187
 //				'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions' => EEH_Activation::cron_task_no_longer_in_use, actually this is still in use
188
-                'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use,
189
-                //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
190
-                'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs'       => 'daily',
191
-            )
192
-        );
193
-        if ($which_to_include === 'old') {
194
-            $cron_tasks = array_filter(
195
-                $cron_tasks,
196
-                function ($value) {
197
-                    return $value === EEH_Activation::cron_task_no_longer_in_use;
198
-                }
199
-            );
200
-        } elseif ($which_to_include === 'current') {
201
-            $cron_tasks = array_filter($cron_tasks);
202
-        } elseif (WP_DEBUG && $which_to_include !== 'all') {
203
-            throw new EE_Error(
204
-                sprintf(
205
-                    __(
206
-                        'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".',
207
-                        'event_espresso'
208
-                    ),
209
-                    $which_to_include
210
-                )
211
-            );
212
-        }
213
-        return $cron_tasks;
214
-    }
215
-
216
-
217
-    /**
218
-     * Ensure cron tasks are setup (the removal of crons should be done by remove_crons())
219
-     *
220
-     * @throws \EE_Error
221
-     */
222
-    public static function create_cron_tasks()
223
-    {
224
-
225
-        foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
226
-            if (! wp_next_scheduled($hook_name)) {
227
-                /**
228
-                 * This allows client code to define the initial start timestamp for this schedule.
229
-                 */
230
-                if (is_array($frequency)
231
-                    && count($frequency) === 2
232
-                    && isset($frequency[0], $frequency[1])
233
-                ) {
234
-                    $start_timestamp = $frequency[0];
235
-                    $frequency = $frequency[1];
236
-                } else {
237
-                    $start_timestamp = time();
238
-                }
239
-                wp_schedule_event($start_timestamp, $frequency, $hook_name);
240
-            }
241
-        }
242
-
243
-    }
244
-
245
-
246
-    /**
247
-     * Remove the currently-existing and now-removed cron tasks.
248
-     *
249
-     * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
250
-     * @throws \EE_Error
251
-     */
252
-    public static function remove_cron_tasks($remove_all = true)
253
-    {
254
-        $cron_tasks_to_remove = $remove_all ? 'all' : 'old';
255
-        $crons                = _get_cron_array();
256
-        $crons                = is_array($crons) ? $crons : array();
257
-        /* reminder of what $crons look like:
188
+				'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use,
189
+				//there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
190
+				'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs'       => 'daily',
191
+			)
192
+		);
193
+		if ($which_to_include === 'old') {
194
+			$cron_tasks = array_filter(
195
+				$cron_tasks,
196
+				function ($value) {
197
+					return $value === EEH_Activation::cron_task_no_longer_in_use;
198
+				}
199
+			);
200
+		} elseif ($which_to_include === 'current') {
201
+			$cron_tasks = array_filter($cron_tasks);
202
+		} elseif (WP_DEBUG && $which_to_include !== 'all') {
203
+			throw new EE_Error(
204
+				sprintf(
205
+					__(
206
+						'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".',
207
+						'event_espresso'
208
+					),
209
+					$which_to_include
210
+				)
211
+			);
212
+		}
213
+		return $cron_tasks;
214
+	}
215
+
216
+
217
+	/**
218
+	 * Ensure cron tasks are setup (the removal of crons should be done by remove_crons())
219
+	 *
220
+	 * @throws \EE_Error
221
+	 */
222
+	public static function create_cron_tasks()
223
+	{
224
+
225
+		foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
226
+			if (! wp_next_scheduled($hook_name)) {
227
+				/**
228
+				 * This allows client code to define the initial start timestamp for this schedule.
229
+				 */
230
+				if (is_array($frequency)
231
+					&& count($frequency) === 2
232
+					&& isset($frequency[0], $frequency[1])
233
+				) {
234
+					$start_timestamp = $frequency[0];
235
+					$frequency = $frequency[1];
236
+				} else {
237
+					$start_timestamp = time();
238
+				}
239
+				wp_schedule_event($start_timestamp, $frequency, $hook_name);
240
+			}
241
+		}
242
+
243
+	}
244
+
245
+
246
+	/**
247
+	 * Remove the currently-existing and now-removed cron tasks.
248
+	 *
249
+	 * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
250
+	 * @throws \EE_Error
251
+	 */
252
+	public static function remove_cron_tasks($remove_all = true)
253
+	{
254
+		$cron_tasks_to_remove = $remove_all ? 'all' : 'old';
255
+		$crons                = _get_cron_array();
256
+		$crons                = is_array($crons) ? $crons : array();
257
+		/* reminder of what $crons look like:
258 258
          * Top-level keys are timestamps, and their values are arrays.
259 259
          * The 2nd level arrays have keys with each of the cron task hook names to run at that time
260 260
          * and their values are arrays.
@@ -271,911 +271,911 @@  discard block
 block discarded – undo
271 271
          *					...
272 272
          *      ...
273 273
          */
274
-        $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
275
-        foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
276
-            if (is_array($hooks_to_fire_at_time)) {
277
-                foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
278
-                    if (isset($ee_cron_tasks_to_remove[$hook_name])
279
-                        && is_array($ee_cron_tasks_to_remove[$hook_name])
280
-                    ) {
281
-                        unset($crons[$timestamp][$hook_name]);
282
-                    }
283
-                }
284
-                //also take care of any empty cron timestamps.
285
-                if (empty($hooks_to_fire_at_time)) {
286
-                    unset($crons[$timestamp]);
287
-                }
288
-            }
289
-        }
290
-        _set_cron_array($crons);
291
-    }
292
-
293
-
294
-    /**
295
-     *    CPT_initialization
296
-     *    registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist
297
-     *
298
-     * @access public
299
-     * @static
300
-     * @return void
301
-     */
302
-    public static function CPT_initialization()
303
-    {
304
-        // register Custom Post Types
305
-        EE_Registry::instance()->load_core('Register_CPTs');
306
-        flush_rewrite_rules();
307
-    }
308
-
309
-
310
-
311
-    /**
312
-     *    reset_and_update_config
313
-     * The following code was moved over from EE_Config so that it will no longer run on every request.
314
-     * If there is old calendar config data saved, then it will get converted on activation.
315
-     * This was basically a DMS before we had DMS's, and will get removed after a few more versions.
316
-     *
317
-     * @access public
318
-     * @static
319
-     * @return void
320
-     */
321
-    public static function reset_and_update_config()
322
-    {
323
-        do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
324
-        add_filter(
325
-            'FHEE__EE_Config___load_core_config__config_settings',
326
-            array('EEH_Activation', 'migrate_old_config_data'),
327
-            10,
328
-            3
329
-        );
330
-        //EE_Config::reset();
331
-        if (! EE_Config::logging_enabled()) {
332
-            delete_option(EE_Config::LOG_NAME);
333
-        }
334
-    }
335
-
336
-
337
-    /**
338
-     *    load_calendar_config
339
-     *
340
-     * @access    public
341
-     * @return    void
342
-     */
343
-    public static function load_calendar_config()
344
-    {
345
-        // grab array of all plugin folders and loop thru it
346
-        $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
347
-        if (empty($plugins)) {
348
-            return;
349
-        }
350
-        foreach ($plugins as $plugin_path) {
351
-            // grab plugin folder name from path
352
-            $plugin = basename($plugin_path);
353
-            // drill down to Espresso plugins
354
-            // then to calendar related plugins
355
-            if (
356
-                strpos($plugin, 'espresso') !== false
357
-                || strpos($plugin, 'Espresso') !== false
358
-                || strpos($plugin, 'ee4') !== false
359
-                || strpos($plugin, 'EE4') !== false
360
-                || strpos($plugin, 'calendar') !== false
361
-            ) {
362
-                // this is what we are looking for
363
-                $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
364
-                // does it exist in this folder ?
365
-                if (is_readable($calendar_config)) {
366
-                    // YEAH! let's load it
367
-                    require_once($calendar_config);
368
-                }
369
-            }
370
-        }
371
-    }
372
-
373
-
374
-
375
-    /**
376
-     *    _migrate_old_config_data
377
-     *
378
-     * @access    public
379
-     * @param array|stdClass $settings
380
-     * @param string         $config
381
-     * @param \EE_Config     $EE_Config
382
-     * @return \stdClass
383
-     */
384
-    public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config)
385
-    {
386
-        $convert_from_array = array('addons');
387
-        // in case old settings were saved as an array
388
-        if (is_array($settings) && in_array($config, $convert_from_array)) {
389
-            // convert existing settings to an object
390
-            $config_array = $settings;
391
-            $settings = new stdClass();
392
-            foreach ($config_array as $key => $value) {
393
-                if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
394
-                    $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
395
-                } else {
396
-                    $settings->{$key} = $value;
397
-                }
398
-            }
399
-            add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
400
-        }
401
-        return $settings;
402
-    }
403
-
404
-
405
-    /**
406
-     * deactivate_event_espresso
407
-     *
408
-     * @access public
409
-     * @static
410
-     * @return void
411
-     */
412
-    public static function deactivate_event_espresso()
413
-    {
414
-        // check permissions
415
-        if (current_user_can('activate_plugins')) {
416
-            deactivate_plugins(EE_PLUGIN_BASENAME, true);
417
-        }
418
-    }
419
-
420
-
421
-
422
-    /**
423
-     * verify_default_pages_exist
424
-     *
425
-     * @access public
426
-     * @static
427
-     * @return void
428
-     * @throws InvalidDataTypeException
429
-     */
430
-    public static function verify_default_pages_exist()
431
-    {
432
-        $critical_page_problem = false;
433
-        $critical_pages = array(
434
-            array(
435
-                'id'   => 'reg_page_id',
436
-                'name' => __('Registration Checkout', 'event_espresso'),
437
-                'post' => null,
438
-                'code' => 'ESPRESSO_CHECKOUT',
439
-            ),
440
-            array(
441
-                'id'   => 'txn_page_id',
442
-                'name' => __('Transactions', 'event_espresso'),
443
-                'post' => null,
444
-                'code' => 'ESPRESSO_TXN_PAGE',
445
-            ),
446
-            array(
447
-                'id'   => 'thank_you_page_id',
448
-                'name' => __('Thank You', 'event_espresso'),
449
-                'post' => null,
450
-                'code' => 'ESPRESSO_THANK_YOU',
451
-            ),
452
-            array(
453
-                'id'   => 'cancel_page_id',
454
-                'name' => __('Registration Cancelled', 'event_espresso'),
455
-                'post' => null,
456
-                'code' => 'ESPRESSO_CANCELLED',
457
-            ),
458
-        );
459
-        $EE_Core_Config = EE_Registry::instance()->CFG->core;
460
-        foreach ($critical_pages as $critical_page) {
461
-            // is critical page ID set in config ?
462
-            if ($EE_Core_Config->{$critical_page['id']} !== false) {
463
-                // attempt to find post by ID
464
-                $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']});
465
-            }
466
-            // no dice?
467
-            if ($critical_page['post'] === null) {
468
-                // attempt to find post by title
469
-                $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
470
-                // still nothing?
471
-                if ($critical_page['post'] === null) {
472
-                    $critical_page = EEH_Activation::create_critical_page($critical_page);
473
-                    // REALLY? Still nothing ??!?!?
474
-                    if ($critical_page['post'] === null) {
475
-                        $msg = __(
476
-                            'The Event Espresso critical page configuration settings could not be updated.',
477
-                            'event_espresso'
478
-                        );
479
-                        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
480
-                        break;
481
-                    }
482
-                }
483
-            }
484
-            // check that Post ID matches critical page ID in config
485
-            if (
486
-                isset($critical_page['post']->ID)
487
-                && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
488
-            ) {
489
-                //update Config with post ID
490
-                $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
491
-                if (! EE_Config::instance()->update_espresso_config(false, false)) {
492
-                    $msg = __(
493
-                        'The Event Espresso critical page configuration settings could not be updated.',
494
-                        'event_espresso'
495
-                    );
496
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
497
-                }
498
-            }
499
-            $critical_page_problem =
500
-                ! isset($critical_page['post']->post_status)
501
-                || $critical_page['post']->post_status !== 'publish'
502
-                || strpos($critical_page['post']->post_content, $critical_page['code']) === false
503
-                    ? true
504
-                    : $critical_page_problem;
505
-        }
506
-        if ($critical_page_problem) {
507
-            new PersistentAdminNotice(
508
-                'critical_page_problem',
509
-                sprintf(
510
-                    esc_html__(
511
-                        'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
512
-                        'event_espresso'
513
-                    ),
514
-                    '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">'
515
-                    . __('Event Espresso Critical Pages Settings', 'event_espresso')
516
-                    . '</a>'
517
-                )
518
-            );
519
-        }
520
-        if (EE_Error::has_notices()) {
521
-            EE_Error::get_notices(false, true, true);
522
-        }
523
-    }
524
-
525
-
526
-
527
-    /**
528
-     * Returns the first post which uses the specified shortcode
529
-     *
530
-     * @param string $ee_shortcode usually one of the critical pages shortcodes, eg
531
-     *                             ESPRESSO_THANK_YOU. So we will search fora post with the content
532
-     *                             "[ESPRESSO_THANK_YOU"
533
-     *                             (we don't search for the closing shortcode bracket because they might have added
534
-     *                             parameter to the shortcode
535
-     * @return WP_Post or NULl
536
-     */
537
-    public static function get_page_by_ee_shortcode($ee_shortcode)
538
-    {
539
-        global $wpdb;
540
-        $shortcode_and_opening_bracket = '[' . $ee_shortcode;
541
-        $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
542
-        if ($post_id) {
543
-            return get_post($post_id);
544
-        } else {
545
-            return null;
546
-        }
547
-    }
548
-
549
-
550
-    /**
551
-     *    This function generates a post for critical espresso pages
552
-     *
553
-     * @access public
554
-     * @static
555
-     * @param array $critical_page
556
-     * @return array
557
-     */
558
-    public static function create_critical_page($critical_page)
559
-    {
560
-
561
-        $post_args = array(
562
-            'post_title'     => $critical_page['name'],
563
-            'post_status'    => 'publish',
564
-            'post_type'      => 'page',
565
-            'comment_status' => 'closed',
566
-            'post_content'   => '[' . $critical_page['code'] . ']',
567
-        );
568
-
569
-        $post_id = wp_insert_post($post_args);
570
-        if (! $post_id) {
571
-            $msg = sprintf(
572
-                __('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
573
-                $critical_page['name']
574
-            );
575
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
576
-            return $critical_page;
577
-        }
578
-        // get newly created post's details
579
-        if (! $critical_page['post'] = get_post($post_id)) {
580
-            $msg = sprintf(
581
-                __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
582
-                $critical_page['name']
583
-            );
584
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
585
-        }
586
-
587
-        return $critical_page;
588
-
589
-    }
590
-
591
-
592
-
593
-
594
-    /**
595
-     * Tries to find the oldest admin for this site.  If there are no admins for this site then return NULL.
596
-     * The role being used to check is filterable.
597
-     *
598
-     * @since  4.6.0
599
-     * @global WPDB $wpdb
600
-     * @return mixed null|int WP_user ID or NULL
601
-     */
602
-    public static function get_default_creator_id()
603
-    {
604
-        global $wpdb;
605
-        if ( ! empty(self::$_default_creator_id)) {
606
-            return self::$_default_creator_id;
607
-        }/**/
608
-        $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
609
-        //let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
610
-        $pre_filtered_id = apply_filters(
611
-            'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id',
612
-            false,
613
-            $role_to_check
614
-        );
615
-        if ($pre_filtered_id !== false) {
616
-            return (int)$pre_filtered_id;
617
-        }
618
-        $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
619
-        $query = $wpdb->prepare(
620
-            "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
621
-            '%' . $role_to_check . '%'
622
-        );
623
-        $user_id = $wpdb->get_var($query);
624
-        $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
625
-        if ($user_id && (int)$user_id) {
626
-            self::$_default_creator_id = (int)$user_id;
627
-            return self::$_default_creator_id;
628
-        } else {
629
-            return null;
630
-        }
631
-    }
632
-
633
-
634
-
635
-    /**
636
-     * used by EE and EE addons during plugin activation to create tables.
637
-     * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable,
638
-     * but includes extra logic regarding activations.
639
-     *
640
-     * @access public
641
-     * @static
642
-     * @param string  $table_name              without the $wpdb->prefix
643
-     * @param string  $sql                     SQL for creating the table (contents between brackets in an SQL create
644
-     *                                         table query)
645
-     * @param string  $engine                  like 'ENGINE=MyISAM' or 'ENGINE=InnoDB'
646
-     * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty
647
-     *                                         and new once this function is done (ie, you really do want to CREATE a
648
-     *                                         table, and expect it to be empty once you're done) leave as FALSE when
649
-     *                                         you just want to verify the table exists and matches this definition
650
-     *                                         (and if it HAS data in it you want to leave it be)
651
-     * @return void
652
-     * @throws EE_Error if there are database errors
653
-     */
654
-    public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false)
655
-    {
656
-        if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) {
657
-            return;
658
-        }
659
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
660
-        if ( ! function_exists('dbDelta')) {
661
-            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
662
-        }
663
-        $tableAnalysis = \EEH_Activation::getTableAnalysis();
664
-        $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
665
-        // do we need to first delete an existing version of this table ?
666
-        if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) {
667
-            // ok, delete the table... but ONLY if it's empty
668
-            $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
669
-            // table is NOT empty, are you SURE you want to delete this table ???
670
-            if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
671
-                \EEH_Activation::getTableManager()->dropTable($wp_table_name);
672
-            } else if ( ! $deleted_safely) {
673
-                // so we should be more cautious rather than just dropping tables so easily
674
-                error_log(
675
-                    sprintf(
676
-                        __(
677
-                            'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.',
678
-                            'event_espresso'
679
-                        ),
680
-                        $wp_table_name,
681
-                        '<br/>',
682
-                        'espresso_db_update'
683
-                    )
684
-                );
685
-            }
686
-        }
687
-        $engine = str_replace('ENGINE=', '', $engine);
688
-        \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine);
689
-    }
690
-
691
-
692
-
693
-    /**
694
-     *    add_column_if_it_doesn't_exist
695
-     *    Checks if this column already exists on the specified table. Handy for addons which want to add a column
696
-     *
697
-     * @access     public
698
-     * @static
699
-     * @deprecated instead use TableManager::addColumn()
700
-     * @param string $table_name  (without "wp_", eg "esp_attendee"
701
-     * @param string $column_name
702
-     * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be
703
-     *                            'VARCHAR(10)'
704
-     * @return bool|int
705
-     */
706
-    public static function add_column_if_it_doesnt_exist(
707
-        $table_name,
708
-        $column_name,
709
-        $column_info = 'INT UNSIGNED NOT NULL'
710
-    ) {
711
-        return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info);
712
-    }
713
-
714
-
715
-    /**
716
-     * get_fields_on_table
717
-     * Gets all the fields on the database table.
718
-     *
719
-     * @access     public
720
-     * @deprecated instead use TableManager::getTableColumns()
721
-     * @static
722
-     * @param string $table_name , without prefixed $wpdb->prefix
723
-     * @return array of database column names
724
-     */
725
-    public static function get_fields_on_table($table_name = null)
726
-    {
727
-        return \EEH_Activation::getTableManager()->getTableColumns($table_name);
728
-    }
729
-
730
-
731
-    /**
732
-     * db_table_is_empty
733
-     *
734
-     * @access     public\
735
-     * @deprecated instead use TableAnalysis::tableIsEmpty()
736
-     * @static
737
-     * @param string $table_name
738
-     * @return bool
739
-     */
740
-    public static function db_table_is_empty($table_name)
741
-    {
742
-        return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name);
743
-    }
744
-
745
-
746
-    /**
747
-     * delete_db_table_if_empty
748
-     *
749
-     * @access public
750
-     * @static
751
-     * @param string $table_name
752
-     * @return bool | int
753
-     */
754
-    public static function delete_db_table_if_empty($table_name)
755
-    {
756
-        if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) {
757
-            return \EEH_Activation::getTableManager()->dropTable($table_name);
758
-        }
759
-        return false;
760
-    }
761
-
762
-
763
-    /**
764
-     * delete_unused_db_table
765
-     *
766
-     * @access     public
767
-     * @static
768
-     * @deprecated instead use TableManager::dropTable()
769
-     * @param string $table_name
770
-     * @return bool | int
771
-     */
772
-    public static function delete_unused_db_table($table_name)
773
-    {
774
-        return \EEH_Activation::getTableManager()->dropTable($table_name);
775
-    }
776
-
777
-
778
-    /**
779
-     * drop_index
780
-     *
781
-     * @access     public
782
-     * @static
783
-     * @deprecated instead use TableManager::dropIndex()
784
-     * @param string $table_name
785
-     * @param string $index_name
786
-     * @return bool | int
787
-     */
788
-    public static function drop_index($table_name, $index_name)
789
-    {
790
-        return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name);
791
-    }
792
-
793
-
794
-
795
-    /**
796
-     * create_database_tables
797
-     *
798
-     * @access public
799
-     * @static
800
-     * @throws EE_Error
801
-     * @return boolean success (whether database is setup properly or not)
802
-     */
803
-    public static function create_database_tables()
804
-    {
805
-        EE_Registry::instance()->load_core('Data_Migration_Manager');
806
-        //find the migration script that sets the database to be compatible with the code
807
-        $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
808
-        if ($dms_name) {
809
-            $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
810
-            $current_data_migration_script->set_migrating(false);
811
-            $current_data_migration_script->schema_changes_before_migration();
812
-            $current_data_migration_script->schema_changes_after_migration();
813
-            if ($current_data_migration_script->get_errors()) {
814
-                if (WP_DEBUG) {
815
-                    foreach ($current_data_migration_script->get_errors() as $error) {
816
-                        EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
817
-                    }
818
-                } else {
819
-                    EE_Error::add_error(
820
-                        __(
821
-                            'There were errors creating the Event Espresso database tables and Event Espresso has been 
274
+		$ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
275
+		foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
276
+			if (is_array($hooks_to_fire_at_time)) {
277
+				foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
278
+					if (isset($ee_cron_tasks_to_remove[$hook_name])
279
+						&& is_array($ee_cron_tasks_to_remove[$hook_name])
280
+					) {
281
+						unset($crons[$timestamp][$hook_name]);
282
+					}
283
+				}
284
+				//also take care of any empty cron timestamps.
285
+				if (empty($hooks_to_fire_at_time)) {
286
+					unset($crons[$timestamp]);
287
+				}
288
+			}
289
+		}
290
+		_set_cron_array($crons);
291
+	}
292
+
293
+
294
+	/**
295
+	 *    CPT_initialization
296
+	 *    registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist
297
+	 *
298
+	 * @access public
299
+	 * @static
300
+	 * @return void
301
+	 */
302
+	public static function CPT_initialization()
303
+	{
304
+		// register Custom Post Types
305
+		EE_Registry::instance()->load_core('Register_CPTs');
306
+		flush_rewrite_rules();
307
+	}
308
+
309
+
310
+
311
+	/**
312
+	 *    reset_and_update_config
313
+	 * The following code was moved over from EE_Config so that it will no longer run on every request.
314
+	 * If there is old calendar config data saved, then it will get converted on activation.
315
+	 * This was basically a DMS before we had DMS's, and will get removed after a few more versions.
316
+	 *
317
+	 * @access public
318
+	 * @static
319
+	 * @return void
320
+	 */
321
+	public static function reset_and_update_config()
322
+	{
323
+		do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
324
+		add_filter(
325
+			'FHEE__EE_Config___load_core_config__config_settings',
326
+			array('EEH_Activation', 'migrate_old_config_data'),
327
+			10,
328
+			3
329
+		);
330
+		//EE_Config::reset();
331
+		if (! EE_Config::logging_enabled()) {
332
+			delete_option(EE_Config::LOG_NAME);
333
+		}
334
+	}
335
+
336
+
337
+	/**
338
+	 *    load_calendar_config
339
+	 *
340
+	 * @access    public
341
+	 * @return    void
342
+	 */
343
+	public static function load_calendar_config()
344
+	{
345
+		// grab array of all plugin folders and loop thru it
346
+		$plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
347
+		if (empty($plugins)) {
348
+			return;
349
+		}
350
+		foreach ($plugins as $plugin_path) {
351
+			// grab plugin folder name from path
352
+			$plugin = basename($plugin_path);
353
+			// drill down to Espresso plugins
354
+			// then to calendar related plugins
355
+			if (
356
+				strpos($plugin, 'espresso') !== false
357
+				|| strpos($plugin, 'Espresso') !== false
358
+				|| strpos($plugin, 'ee4') !== false
359
+				|| strpos($plugin, 'EE4') !== false
360
+				|| strpos($plugin, 'calendar') !== false
361
+			) {
362
+				// this is what we are looking for
363
+				$calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
364
+				// does it exist in this folder ?
365
+				if (is_readable($calendar_config)) {
366
+					// YEAH! let's load it
367
+					require_once($calendar_config);
368
+				}
369
+			}
370
+		}
371
+	}
372
+
373
+
374
+
375
+	/**
376
+	 *    _migrate_old_config_data
377
+	 *
378
+	 * @access    public
379
+	 * @param array|stdClass $settings
380
+	 * @param string         $config
381
+	 * @param \EE_Config     $EE_Config
382
+	 * @return \stdClass
383
+	 */
384
+	public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config)
385
+	{
386
+		$convert_from_array = array('addons');
387
+		// in case old settings were saved as an array
388
+		if (is_array($settings) && in_array($config, $convert_from_array)) {
389
+			// convert existing settings to an object
390
+			$config_array = $settings;
391
+			$settings = new stdClass();
392
+			foreach ($config_array as $key => $value) {
393
+				if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
394
+					$EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
395
+				} else {
396
+					$settings->{$key} = $value;
397
+				}
398
+			}
399
+			add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
400
+		}
401
+		return $settings;
402
+	}
403
+
404
+
405
+	/**
406
+	 * deactivate_event_espresso
407
+	 *
408
+	 * @access public
409
+	 * @static
410
+	 * @return void
411
+	 */
412
+	public static function deactivate_event_espresso()
413
+	{
414
+		// check permissions
415
+		if (current_user_can('activate_plugins')) {
416
+			deactivate_plugins(EE_PLUGIN_BASENAME, true);
417
+		}
418
+	}
419
+
420
+
421
+
422
+	/**
423
+	 * verify_default_pages_exist
424
+	 *
425
+	 * @access public
426
+	 * @static
427
+	 * @return void
428
+	 * @throws InvalidDataTypeException
429
+	 */
430
+	public static function verify_default_pages_exist()
431
+	{
432
+		$critical_page_problem = false;
433
+		$critical_pages = array(
434
+			array(
435
+				'id'   => 'reg_page_id',
436
+				'name' => __('Registration Checkout', 'event_espresso'),
437
+				'post' => null,
438
+				'code' => 'ESPRESSO_CHECKOUT',
439
+			),
440
+			array(
441
+				'id'   => 'txn_page_id',
442
+				'name' => __('Transactions', 'event_espresso'),
443
+				'post' => null,
444
+				'code' => 'ESPRESSO_TXN_PAGE',
445
+			),
446
+			array(
447
+				'id'   => 'thank_you_page_id',
448
+				'name' => __('Thank You', 'event_espresso'),
449
+				'post' => null,
450
+				'code' => 'ESPRESSO_THANK_YOU',
451
+			),
452
+			array(
453
+				'id'   => 'cancel_page_id',
454
+				'name' => __('Registration Cancelled', 'event_espresso'),
455
+				'post' => null,
456
+				'code' => 'ESPRESSO_CANCELLED',
457
+			),
458
+		);
459
+		$EE_Core_Config = EE_Registry::instance()->CFG->core;
460
+		foreach ($critical_pages as $critical_page) {
461
+			// is critical page ID set in config ?
462
+			if ($EE_Core_Config->{$critical_page['id']} !== false) {
463
+				// attempt to find post by ID
464
+				$critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']});
465
+			}
466
+			// no dice?
467
+			if ($critical_page['post'] === null) {
468
+				// attempt to find post by title
469
+				$critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
470
+				// still nothing?
471
+				if ($critical_page['post'] === null) {
472
+					$critical_page = EEH_Activation::create_critical_page($critical_page);
473
+					// REALLY? Still nothing ??!?!?
474
+					if ($critical_page['post'] === null) {
475
+						$msg = __(
476
+							'The Event Espresso critical page configuration settings could not be updated.',
477
+							'event_espresso'
478
+						);
479
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
480
+						break;
481
+					}
482
+				}
483
+			}
484
+			// check that Post ID matches critical page ID in config
485
+			if (
486
+				isset($critical_page['post']->ID)
487
+				&& $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
488
+			) {
489
+				//update Config with post ID
490
+				$EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
491
+				if (! EE_Config::instance()->update_espresso_config(false, false)) {
492
+					$msg = __(
493
+						'The Event Espresso critical page configuration settings could not be updated.',
494
+						'event_espresso'
495
+					);
496
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
497
+				}
498
+			}
499
+			$critical_page_problem =
500
+				! isset($critical_page['post']->post_status)
501
+				|| $critical_page['post']->post_status !== 'publish'
502
+				|| strpos($critical_page['post']->post_content, $critical_page['code']) === false
503
+					? true
504
+					: $critical_page_problem;
505
+		}
506
+		if ($critical_page_problem) {
507
+			new PersistentAdminNotice(
508
+				'critical_page_problem',
509
+				sprintf(
510
+					esc_html__(
511
+						'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
512
+						'event_espresso'
513
+					),
514
+					'<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">'
515
+					. __('Event Espresso Critical Pages Settings', 'event_espresso')
516
+					. '</a>'
517
+				)
518
+			);
519
+		}
520
+		if (EE_Error::has_notices()) {
521
+			EE_Error::get_notices(false, true, true);
522
+		}
523
+	}
524
+
525
+
526
+
527
+	/**
528
+	 * Returns the first post which uses the specified shortcode
529
+	 *
530
+	 * @param string $ee_shortcode usually one of the critical pages shortcodes, eg
531
+	 *                             ESPRESSO_THANK_YOU. So we will search fora post with the content
532
+	 *                             "[ESPRESSO_THANK_YOU"
533
+	 *                             (we don't search for the closing shortcode bracket because they might have added
534
+	 *                             parameter to the shortcode
535
+	 * @return WP_Post or NULl
536
+	 */
537
+	public static function get_page_by_ee_shortcode($ee_shortcode)
538
+	{
539
+		global $wpdb;
540
+		$shortcode_and_opening_bracket = '[' . $ee_shortcode;
541
+		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
542
+		if ($post_id) {
543
+			return get_post($post_id);
544
+		} else {
545
+			return null;
546
+		}
547
+	}
548
+
549
+
550
+	/**
551
+	 *    This function generates a post for critical espresso pages
552
+	 *
553
+	 * @access public
554
+	 * @static
555
+	 * @param array $critical_page
556
+	 * @return array
557
+	 */
558
+	public static function create_critical_page($critical_page)
559
+	{
560
+
561
+		$post_args = array(
562
+			'post_title'     => $critical_page['name'],
563
+			'post_status'    => 'publish',
564
+			'post_type'      => 'page',
565
+			'comment_status' => 'closed',
566
+			'post_content'   => '[' . $critical_page['code'] . ']',
567
+		);
568
+
569
+		$post_id = wp_insert_post($post_args);
570
+		if (! $post_id) {
571
+			$msg = sprintf(
572
+				__('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
573
+				$critical_page['name']
574
+			);
575
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
576
+			return $critical_page;
577
+		}
578
+		// get newly created post's details
579
+		if (! $critical_page['post'] = get_post($post_id)) {
580
+			$msg = sprintf(
581
+				__('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
582
+				$critical_page['name']
583
+			);
584
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
585
+		}
586
+
587
+		return $critical_page;
588
+
589
+	}
590
+
591
+
592
+
593
+
594
+	/**
595
+	 * Tries to find the oldest admin for this site.  If there are no admins for this site then return NULL.
596
+	 * The role being used to check is filterable.
597
+	 *
598
+	 * @since  4.6.0
599
+	 * @global WPDB $wpdb
600
+	 * @return mixed null|int WP_user ID or NULL
601
+	 */
602
+	public static function get_default_creator_id()
603
+	{
604
+		global $wpdb;
605
+		if ( ! empty(self::$_default_creator_id)) {
606
+			return self::$_default_creator_id;
607
+		}/**/
608
+		$role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
609
+		//let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
610
+		$pre_filtered_id = apply_filters(
611
+			'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id',
612
+			false,
613
+			$role_to_check
614
+		);
615
+		if ($pre_filtered_id !== false) {
616
+			return (int)$pre_filtered_id;
617
+		}
618
+		$capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
619
+		$query = $wpdb->prepare(
620
+			"SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
621
+			'%' . $role_to_check . '%'
622
+		);
623
+		$user_id = $wpdb->get_var($query);
624
+		$user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
625
+		if ($user_id && (int)$user_id) {
626
+			self::$_default_creator_id = (int)$user_id;
627
+			return self::$_default_creator_id;
628
+		} else {
629
+			return null;
630
+		}
631
+	}
632
+
633
+
634
+
635
+	/**
636
+	 * used by EE and EE addons during plugin activation to create tables.
637
+	 * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable,
638
+	 * but includes extra logic regarding activations.
639
+	 *
640
+	 * @access public
641
+	 * @static
642
+	 * @param string  $table_name              without the $wpdb->prefix
643
+	 * @param string  $sql                     SQL for creating the table (contents between brackets in an SQL create
644
+	 *                                         table query)
645
+	 * @param string  $engine                  like 'ENGINE=MyISAM' or 'ENGINE=InnoDB'
646
+	 * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty
647
+	 *                                         and new once this function is done (ie, you really do want to CREATE a
648
+	 *                                         table, and expect it to be empty once you're done) leave as FALSE when
649
+	 *                                         you just want to verify the table exists and matches this definition
650
+	 *                                         (and if it HAS data in it you want to leave it be)
651
+	 * @return void
652
+	 * @throws EE_Error if there are database errors
653
+	 */
654
+	public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false)
655
+	{
656
+		if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) {
657
+			return;
658
+		}
659
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
660
+		if ( ! function_exists('dbDelta')) {
661
+			require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
662
+		}
663
+		$tableAnalysis = \EEH_Activation::getTableAnalysis();
664
+		$wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
665
+		// do we need to first delete an existing version of this table ?
666
+		if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) {
667
+			// ok, delete the table... but ONLY if it's empty
668
+			$deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
669
+			// table is NOT empty, are you SURE you want to delete this table ???
670
+			if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
671
+				\EEH_Activation::getTableManager()->dropTable($wp_table_name);
672
+			} else if ( ! $deleted_safely) {
673
+				// so we should be more cautious rather than just dropping tables so easily
674
+				error_log(
675
+					sprintf(
676
+						__(
677
+							'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.',
678
+							'event_espresso'
679
+						),
680
+						$wp_table_name,
681
+						'<br/>',
682
+						'espresso_db_update'
683
+					)
684
+				);
685
+			}
686
+		}
687
+		$engine = str_replace('ENGINE=', '', $engine);
688
+		\EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine);
689
+	}
690
+
691
+
692
+
693
+	/**
694
+	 *    add_column_if_it_doesn't_exist
695
+	 *    Checks if this column already exists on the specified table. Handy for addons which want to add a column
696
+	 *
697
+	 * @access     public
698
+	 * @static
699
+	 * @deprecated instead use TableManager::addColumn()
700
+	 * @param string $table_name  (without "wp_", eg "esp_attendee"
701
+	 * @param string $column_name
702
+	 * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be
703
+	 *                            'VARCHAR(10)'
704
+	 * @return bool|int
705
+	 */
706
+	public static function add_column_if_it_doesnt_exist(
707
+		$table_name,
708
+		$column_name,
709
+		$column_info = 'INT UNSIGNED NOT NULL'
710
+	) {
711
+		return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info);
712
+	}
713
+
714
+
715
+	/**
716
+	 * get_fields_on_table
717
+	 * Gets all the fields on the database table.
718
+	 *
719
+	 * @access     public
720
+	 * @deprecated instead use TableManager::getTableColumns()
721
+	 * @static
722
+	 * @param string $table_name , without prefixed $wpdb->prefix
723
+	 * @return array of database column names
724
+	 */
725
+	public static function get_fields_on_table($table_name = null)
726
+	{
727
+		return \EEH_Activation::getTableManager()->getTableColumns($table_name);
728
+	}
729
+
730
+
731
+	/**
732
+	 * db_table_is_empty
733
+	 *
734
+	 * @access     public\
735
+	 * @deprecated instead use TableAnalysis::tableIsEmpty()
736
+	 * @static
737
+	 * @param string $table_name
738
+	 * @return bool
739
+	 */
740
+	public static function db_table_is_empty($table_name)
741
+	{
742
+		return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name);
743
+	}
744
+
745
+
746
+	/**
747
+	 * delete_db_table_if_empty
748
+	 *
749
+	 * @access public
750
+	 * @static
751
+	 * @param string $table_name
752
+	 * @return bool | int
753
+	 */
754
+	public static function delete_db_table_if_empty($table_name)
755
+	{
756
+		if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) {
757
+			return \EEH_Activation::getTableManager()->dropTable($table_name);
758
+		}
759
+		return false;
760
+	}
761
+
762
+
763
+	/**
764
+	 * delete_unused_db_table
765
+	 *
766
+	 * @access     public
767
+	 * @static
768
+	 * @deprecated instead use TableManager::dropTable()
769
+	 * @param string $table_name
770
+	 * @return bool | int
771
+	 */
772
+	public static function delete_unused_db_table($table_name)
773
+	{
774
+		return \EEH_Activation::getTableManager()->dropTable($table_name);
775
+	}
776
+
777
+
778
+	/**
779
+	 * drop_index
780
+	 *
781
+	 * @access     public
782
+	 * @static
783
+	 * @deprecated instead use TableManager::dropIndex()
784
+	 * @param string $table_name
785
+	 * @param string $index_name
786
+	 * @return bool | int
787
+	 */
788
+	public static function drop_index($table_name, $index_name)
789
+	{
790
+		return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name);
791
+	}
792
+
793
+
794
+
795
+	/**
796
+	 * create_database_tables
797
+	 *
798
+	 * @access public
799
+	 * @static
800
+	 * @throws EE_Error
801
+	 * @return boolean success (whether database is setup properly or not)
802
+	 */
803
+	public static function create_database_tables()
804
+	{
805
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
806
+		//find the migration script that sets the database to be compatible with the code
807
+		$dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
808
+		if ($dms_name) {
809
+			$current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
810
+			$current_data_migration_script->set_migrating(false);
811
+			$current_data_migration_script->schema_changes_before_migration();
812
+			$current_data_migration_script->schema_changes_after_migration();
813
+			if ($current_data_migration_script->get_errors()) {
814
+				if (WP_DEBUG) {
815
+					foreach ($current_data_migration_script->get_errors() as $error) {
816
+						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
817
+					}
818
+				} else {
819
+					EE_Error::add_error(
820
+						__(
821
+							'There were errors creating the Event Espresso database tables and Event Espresso has been 
822 822
                             deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.',
823
-                            'event_espresso'
824
-                        )
825
-                    );
826
-                }
827
-                return false;
828
-            }
829
-            EE_Data_Migration_Manager::instance()->update_current_database_state_to();
830
-        } else {
831
-            EE_Error::add_error(
832
-                __(
833
-                    'Could not determine most up-to-date data migration script from which to pull database schema
823
+							'event_espresso'
824
+						)
825
+					);
826
+				}
827
+				return false;
828
+			}
829
+			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
830
+		} else {
831
+			EE_Error::add_error(
832
+				__(
833
+					'Could not determine most up-to-date data migration script from which to pull database schema
834 834
                      structure. So database is probably not setup properly',
835
-                    'event_espresso'
836
-                ),
837
-                __FILE__,
838
-                __FUNCTION__,
839
-                __LINE__
840
-            );
841
-            return false;
842
-        }
843
-        return true;
844
-    }
845
-
846
-
847
-
848
-    /**
849
-     * initialize_system_questions
850
-     *
851
-     * @access public
852
-     * @static
853
-     * @return void
854
-     */
855
-    public static function initialize_system_questions()
856
-    {
857
-        // QUESTION GROUPS
858
-        global $wpdb;
859
-        $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group');
860
-        $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
861
-        // what we have
862
-        $question_groups = $wpdb->get_col($SQL);
863
-        // check the response
864
-        $question_groups = is_array($question_groups) ? $question_groups : array();
865
-        // what we should have
866
-        $QSG_systems = array(1, 2);
867
-        // loop thru what we should have and compare to what we have
868
-        foreach ($QSG_systems as $QSG_system) {
869
-            // reset values array
870
-            $QSG_values = array();
871
-            // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
872
-            if (! in_array("$QSG_system", $question_groups)) {
873
-                // add it
874
-                switch ($QSG_system) {
875
-                    case 1:
876
-                        $QSG_values = array(
877
-                            'QSG_name'            => __('Personal Information', 'event_espresso'),
878
-                            'QSG_identifier'      => 'personal-information-' . time(),
879
-                            'QSG_desc'            => '',
880
-                            'QSG_order'           => 1,
881
-                            'QSG_show_group_name' => 1,
882
-                            'QSG_show_group_desc' => 1,
883
-                            'QSG_system'          => EEM_Question_Group::system_personal,
884
-                            'QSG_deleted'         => 0,
885
-                        );
886
-                        break;
887
-                    case 2:
888
-                        $QSG_values = array(
889
-                            'QSG_name'            => __('Address Information', 'event_espresso'),
890
-                            'QSG_identifier'      => 'address-information-' . time(),
891
-                            'QSG_desc'            => '',
892
-                            'QSG_order'           => 2,
893
-                            'QSG_show_group_name' => 1,
894
-                            'QSG_show_group_desc' => 1,
895
-                            'QSG_system'          => EEM_Question_Group::system_address,
896
-                            'QSG_deleted'         => 0,
897
-                        );
898
-                        break;
899
-                }
900
-                // make sure we have some values before inserting them
901
-                if (! empty($QSG_values)) {
902
-                    // insert system question
903
-                    $wpdb->insert(
904
-                        $table_name,
905
-                        $QSG_values,
906
-                        array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
907
-                    );
908
-                    $QSG_IDs[$QSG_system] = $wpdb->insert_id;
909
-                }
910
-            }
911
-        }
912
-        // QUESTIONS
913
-        global $wpdb;
914
-        $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question');
915
-        $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
916
-        // what we have
917
-        $questions = $wpdb->get_col($SQL);
918
-        // what we should have
919
-        $QST_systems = array(
920
-            'fname',
921
-            'lname',
922
-            'email',
923
-            'address',
924
-            'address2',
925
-            'city',
926
-            'country',
927
-            'state',
928
-            'zip',
929
-            'phone',
930
-        );
931
-        $order_for_group_1 = 1;
932
-        $order_for_group_2 = 1;
933
-        // loop thru what we should have and compare to what we have
934
-        foreach ($QST_systems as $QST_system) {
935
-            // reset values array
936
-            $QST_values = array();
937
-            // if we don't have what we should have
938
-            if (! in_array($QST_system, $questions)) {
939
-                // add it
940
-                switch ($QST_system) {
941
-                    case 'fname':
942
-                        $QST_values = array(
943
-                            'QST_display_text'  => __('First Name', 'event_espresso'),
944
-                            'QST_admin_label'   => __('First Name - System Question', 'event_espresso'),
945
-                            'QST_system'        => 'fname',
946
-                            'QST_type'          => 'TEXT',
947
-                            'QST_required'      => 1,
948
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
949
-                            'QST_order'         => 1,
950
-                            'QST_admin_only'    => 0,
951
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
952
-                            'QST_wp_user'       => self::get_default_creator_id(),
953
-                            'QST_deleted'       => 0,
954
-                        );
955
-                        break;
956
-                    case 'lname':
957
-                        $QST_values = array(
958
-                            'QST_display_text'  => __('Last Name', 'event_espresso'),
959
-                            'QST_admin_label'   => __('Last Name - System Question', 'event_espresso'),
960
-                            'QST_system'        => 'lname',
961
-                            'QST_type'          => 'TEXT',
962
-                            'QST_required'      => 1,
963
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
964
-                            'QST_order'         => 2,
965
-                            'QST_admin_only'    => 0,
966
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
967
-                            'QST_wp_user'       => self::get_default_creator_id(),
968
-                            'QST_deleted'       => 0,
969
-                        );
970
-                        break;
971
-                    case 'email':
972
-                        $QST_values = array(
973
-                            'QST_display_text'  => __('Email Address', 'event_espresso'),
974
-                            'QST_admin_label'   => __('Email Address - System Question', 'event_espresso'),
975
-                            'QST_system'        => 'email',
976
-                            'QST_type'          => 'EMAIL',
977
-                            'QST_required'      => 1,
978
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
979
-                            'QST_order'         => 3,
980
-                            'QST_admin_only'    => 0,
981
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
982
-                            'QST_wp_user'       => self::get_default_creator_id(),
983
-                            'QST_deleted'       => 0,
984
-                        );
985
-                        break;
986
-                    case 'address':
987
-                        $QST_values = array(
988
-                            'QST_display_text'  => __('Address', 'event_espresso'),
989
-                            'QST_admin_label'   => __('Address - System Question', 'event_espresso'),
990
-                            'QST_system'        => 'address',
991
-                            'QST_type'          => 'TEXT',
992
-                            'QST_required'      => 0,
993
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
994
-                            'QST_order'         => 4,
995
-                            'QST_admin_only'    => 0,
996
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
997
-                            'QST_wp_user'       => self::get_default_creator_id(),
998
-                            'QST_deleted'       => 0,
999
-                        );
1000
-                        break;
1001
-                    case 'address2':
1002
-                        $QST_values = array(
1003
-                            'QST_display_text'  => __('Address2', 'event_espresso'),
1004
-                            'QST_admin_label'   => __('Address2 - System Question', 'event_espresso'),
1005
-                            'QST_system'        => 'address2',
1006
-                            'QST_type'          => 'TEXT',
1007
-                            'QST_required'      => 0,
1008
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1009
-                            'QST_order'         => 5,
1010
-                            'QST_admin_only'    => 0,
1011
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1012
-                            'QST_wp_user'       => self::get_default_creator_id(),
1013
-                            'QST_deleted'       => 0,
1014
-                        );
1015
-                        break;
1016
-                    case 'city':
1017
-                        $QST_values = array(
1018
-                            'QST_display_text'  => __('City', 'event_espresso'),
1019
-                            'QST_admin_label'   => __('City - System Question', 'event_espresso'),
1020
-                            'QST_system'        => 'city',
1021
-                            'QST_type'          => 'TEXT',
1022
-                            'QST_required'      => 0,
1023
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1024
-                            'QST_order'         => 6,
1025
-                            'QST_admin_only'    => 0,
1026
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1027
-                            'QST_wp_user'       => self::get_default_creator_id(),
1028
-                            'QST_deleted'       => 0,
1029
-                        );
1030
-                        break;
1031
-                    case 'country':
1032
-                        $QST_values = array(
1033
-                            'QST_display_text'  => __('Country', 'event_espresso'),
1034
-                            'QST_admin_label'   => __('Country - System Question', 'event_espresso'),
1035
-                            'QST_system'        => 'country',
1036
-                            'QST_type'          => 'COUNTRY',
1037
-                            'QST_required'      => 0,
1038
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1039
-                            'QST_order'         => 7,
1040
-                            'QST_admin_only'    => 0,
1041
-                            'QST_wp_user'       => self::get_default_creator_id(),
1042
-                            'QST_deleted'       => 0,
1043
-                        );
1044
-                        break;
1045
-                    case 'state':
1046
-                        $QST_values = array(
1047
-                            'QST_display_text'  => __('State/Province', 'event_espresso'),
1048
-                            'QST_admin_label'   => __('State/Province - System Question', 'event_espresso'),
1049
-                            'QST_system'        => 'state',
1050
-                            'QST_type'          => 'STATE',
1051
-                            'QST_required'      => 0,
1052
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1053
-                            'QST_order'         => 8,
1054
-                            'QST_admin_only'    => 0,
1055
-                            'QST_wp_user'       => self::get_default_creator_id(),
1056
-                            'QST_deleted'       => 0,
1057
-                        );
1058
-                        break;
1059
-                    case 'zip':
1060
-                        $QST_values = array(
1061
-                            'QST_display_text'  => __('Zip/Postal Code', 'event_espresso'),
1062
-                            'QST_admin_label'   => __('Zip/Postal Code - System Question', 'event_espresso'),
1063
-                            'QST_system'        => 'zip',
1064
-                            'QST_type'          => 'TEXT',
1065
-                            'QST_required'      => 0,
1066
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1067
-                            'QST_order'         => 9,
1068
-                            'QST_admin_only'    => 0,
1069
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1070
-                            'QST_wp_user'       => self::get_default_creator_id(),
1071
-                            'QST_deleted'       => 0,
1072
-                        );
1073
-                        break;
1074
-                    case 'phone':
1075
-                        $QST_values = array(
1076
-                            'QST_display_text'  => __('Phone Number', 'event_espresso'),
1077
-                            'QST_admin_label'   => __('Phone Number - System Question', 'event_espresso'),
1078
-                            'QST_system'        => 'phone',
1079
-                            'QST_type'          => 'TEXT',
1080
-                            'QST_required'      => 0,
1081
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1082
-                            'QST_order'         => 10,
1083
-                            'QST_admin_only'    => 0,
1084
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1085
-                            'QST_wp_user'       => self::get_default_creator_id(),
1086
-                            'QST_deleted'       => 0,
1087
-                        );
1088
-                        break;
1089
-                }
1090
-                if (! empty($QST_values)) {
1091
-                    // insert system question
1092
-                    $wpdb->insert(
1093
-                        $table_name,
1094
-                        $QST_values,
1095
-                        array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1096
-                    );
1097
-                    $QST_ID = $wpdb->insert_id;
1098
-                    // QUESTION GROUP QUESTIONS
1099
-                    if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1100
-                        $system_question_we_want = EEM_Question_Group::system_personal;
1101
-                    } else {
1102
-                        $system_question_we_want = EEM_Question_Group::system_address;
1103
-                    }
1104
-                    if (isset($QSG_IDs[$system_question_we_want])) {
1105
-                        $QSG_ID = $QSG_IDs[$system_question_we_want];
1106
-                    } else {
1107
-                        $id_col = EEM_Question_Group::instance()
1108
-                                                    ->get_col(array(array('QSG_system' => $system_question_we_want)));
1109
-                        if (is_array($id_col)) {
1110
-                            $QSG_ID = reset($id_col);
1111
-                        } else {
1112
-                            //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1113
-                            EE_Log::instance()->log(
1114
-                                __FILE__,
1115
-                                __FUNCTION__,
1116
-                                sprintf(
1117
-                                    __(
1118
-                                        'Could not associate question %1$s to a question group because no system question
835
+					'event_espresso'
836
+				),
837
+				__FILE__,
838
+				__FUNCTION__,
839
+				__LINE__
840
+			);
841
+			return false;
842
+		}
843
+		return true;
844
+	}
845
+
846
+
847
+
848
+	/**
849
+	 * initialize_system_questions
850
+	 *
851
+	 * @access public
852
+	 * @static
853
+	 * @return void
854
+	 */
855
+	public static function initialize_system_questions()
856
+	{
857
+		// QUESTION GROUPS
858
+		global $wpdb;
859
+		$table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group');
860
+		$SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
861
+		// what we have
862
+		$question_groups = $wpdb->get_col($SQL);
863
+		// check the response
864
+		$question_groups = is_array($question_groups) ? $question_groups : array();
865
+		// what we should have
866
+		$QSG_systems = array(1, 2);
867
+		// loop thru what we should have and compare to what we have
868
+		foreach ($QSG_systems as $QSG_system) {
869
+			// reset values array
870
+			$QSG_values = array();
871
+			// if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
872
+			if (! in_array("$QSG_system", $question_groups)) {
873
+				// add it
874
+				switch ($QSG_system) {
875
+					case 1:
876
+						$QSG_values = array(
877
+							'QSG_name'            => __('Personal Information', 'event_espresso'),
878
+							'QSG_identifier'      => 'personal-information-' . time(),
879
+							'QSG_desc'            => '',
880
+							'QSG_order'           => 1,
881
+							'QSG_show_group_name' => 1,
882
+							'QSG_show_group_desc' => 1,
883
+							'QSG_system'          => EEM_Question_Group::system_personal,
884
+							'QSG_deleted'         => 0,
885
+						);
886
+						break;
887
+					case 2:
888
+						$QSG_values = array(
889
+							'QSG_name'            => __('Address Information', 'event_espresso'),
890
+							'QSG_identifier'      => 'address-information-' . time(),
891
+							'QSG_desc'            => '',
892
+							'QSG_order'           => 2,
893
+							'QSG_show_group_name' => 1,
894
+							'QSG_show_group_desc' => 1,
895
+							'QSG_system'          => EEM_Question_Group::system_address,
896
+							'QSG_deleted'         => 0,
897
+						);
898
+						break;
899
+				}
900
+				// make sure we have some values before inserting them
901
+				if (! empty($QSG_values)) {
902
+					// insert system question
903
+					$wpdb->insert(
904
+						$table_name,
905
+						$QSG_values,
906
+						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
907
+					);
908
+					$QSG_IDs[$QSG_system] = $wpdb->insert_id;
909
+				}
910
+			}
911
+		}
912
+		// QUESTIONS
913
+		global $wpdb;
914
+		$table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question');
915
+		$SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
916
+		// what we have
917
+		$questions = $wpdb->get_col($SQL);
918
+		// what we should have
919
+		$QST_systems = array(
920
+			'fname',
921
+			'lname',
922
+			'email',
923
+			'address',
924
+			'address2',
925
+			'city',
926
+			'country',
927
+			'state',
928
+			'zip',
929
+			'phone',
930
+		);
931
+		$order_for_group_1 = 1;
932
+		$order_for_group_2 = 1;
933
+		// loop thru what we should have and compare to what we have
934
+		foreach ($QST_systems as $QST_system) {
935
+			// reset values array
936
+			$QST_values = array();
937
+			// if we don't have what we should have
938
+			if (! in_array($QST_system, $questions)) {
939
+				// add it
940
+				switch ($QST_system) {
941
+					case 'fname':
942
+						$QST_values = array(
943
+							'QST_display_text'  => __('First Name', 'event_espresso'),
944
+							'QST_admin_label'   => __('First Name - System Question', 'event_espresso'),
945
+							'QST_system'        => 'fname',
946
+							'QST_type'          => 'TEXT',
947
+							'QST_required'      => 1,
948
+							'QST_required_text' => __('This field is required', 'event_espresso'),
949
+							'QST_order'         => 1,
950
+							'QST_admin_only'    => 0,
951
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
952
+							'QST_wp_user'       => self::get_default_creator_id(),
953
+							'QST_deleted'       => 0,
954
+						);
955
+						break;
956
+					case 'lname':
957
+						$QST_values = array(
958
+							'QST_display_text'  => __('Last Name', 'event_espresso'),
959
+							'QST_admin_label'   => __('Last Name - System Question', 'event_espresso'),
960
+							'QST_system'        => 'lname',
961
+							'QST_type'          => 'TEXT',
962
+							'QST_required'      => 1,
963
+							'QST_required_text' => __('This field is required', 'event_espresso'),
964
+							'QST_order'         => 2,
965
+							'QST_admin_only'    => 0,
966
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
967
+							'QST_wp_user'       => self::get_default_creator_id(),
968
+							'QST_deleted'       => 0,
969
+						);
970
+						break;
971
+					case 'email':
972
+						$QST_values = array(
973
+							'QST_display_text'  => __('Email Address', 'event_espresso'),
974
+							'QST_admin_label'   => __('Email Address - System Question', 'event_espresso'),
975
+							'QST_system'        => 'email',
976
+							'QST_type'          => 'EMAIL',
977
+							'QST_required'      => 1,
978
+							'QST_required_text' => __('This field is required', 'event_espresso'),
979
+							'QST_order'         => 3,
980
+							'QST_admin_only'    => 0,
981
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
982
+							'QST_wp_user'       => self::get_default_creator_id(),
983
+							'QST_deleted'       => 0,
984
+						);
985
+						break;
986
+					case 'address':
987
+						$QST_values = array(
988
+							'QST_display_text'  => __('Address', 'event_espresso'),
989
+							'QST_admin_label'   => __('Address - System Question', 'event_espresso'),
990
+							'QST_system'        => 'address',
991
+							'QST_type'          => 'TEXT',
992
+							'QST_required'      => 0,
993
+							'QST_required_text' => __('This field is required', 'event_espresso'),
994
+							'QST_order'         => 4,
995
+							'QST_admin_only'    => 0,
996
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
997
+							'QST_wp_user'       => self::get_default_creator_id(),
998
+							'QST_deleted'       => 0,
999
+						);
1000
+						break;
1001
+					case 'address2':
1002
+						$QST_values = array(
1003
+							'QST_display_text'  => __('Address2', 'event_espresso'),
1004
+							'QST_admin_label'   => __('Address2 - System Question', 'event_espresso'),
1005
+							'QST_system'        => 'address2',
1006
+							'QST_type'          => 'TEXT',
1007
+							'QST_required'      => 0,
1008
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1009
+							'QST_order'         => 5,
1010
+							'QST_admin_only'    => 0,
1011
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1012
+							'QST_wp_user'       => self::get_default_creator_id(),
1013
+							'QST_deleted'       => 0,
1014
+						);
1015
+						break;
1016
+					case 'city':
1017
+						$QST_values = array(
1018
+							'QST_display_text'  => __('City', 'event_espresso'),
1019
+							'QST_admin_label'   => __('City - System Question', 'event_espresso'),
1020
+							'QST_system'        => 'city',
1021
+							'QST_type'          => 'TEXT',
1022
+							'QST_required'      => 0,
1023
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1024
+							'QST_order'         => 6,
1025
+							'QST_admin_only'    => 0,
1026
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1027
+							'QST_wp_user'       => self::get_default_creator_id(),
1028
+							'QST_deleted'       => 0,
1029
+						);
1030
+						break;
1031
+					case 'country':
1032
+						$QST_values = array(
1033
+							'QST_display_text'  => __('Country', 'event_espresso'),
1034
+							'QST_admin_label'   => __('Country - System Question', 'event_espresso'),
1035
+							'QST_system'        => 'country',
1036
+							'QST_type'          => 'COUNTRY',
1037
+							'QST_required'      => 0,
1038
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1039
+							'QST_order'         => 7,
1040
+							'QST_admin_only'    => 0,
1041
+							'QST_wp_user'       => self::get_default_creator_id(),
1042
+							'QST_deleted'       => 0,
1043
+						);
1044
+						break;
1045
+					case 'state':
1046
+						$QST_values = array(
1047
+							'QST_display_text'  => __('State/Province', 'event_espresso'),
1048
+							'QST_admin_label'   => __('State/Province - System Question', 'event_espresso'),
1049
+							'QST_system'        => 'state',
1050
+							'QST_type'          => 'STATE',
1051
+							'QST_required'      => 0,
1052
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1053
+							'QST_order'         => 8,
1054
+							'QST_admin_only'    => 0,
1055
+							'QST_wp_user'       => self::get_default_creator_id(),
1056
+							'QST_deleted'       => 0,
1057
+						);
1058
+						break;
1059
+					case 'zip':
1060
+						$QST_values = array(
1061
+							'QST_display_text'  => __('Zip/Postal Code', 'event_espresso'),
1062
+							'QST_admin_label'   => __('Zip/Postal Code - System Question', 'event_espresso'),
1063
+							'QST_system'        => 'zip',
1064
+							'QST_type'          => 'TEXT',
1065
+							'QST_required'      => 0,
1066
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1067
+							'QST_order'         => 9,
1068
+							'QST_admin_only'    => 0,
1069
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1070
+							'QST_wp_user'       => self::get_default_creator_id(),
1071
+							'QST_deleted'       => 0,
1072
+						);
1073
+						break;
1074
+					case 'phone':
1075
+						$QST_values = array(
1076
+							'QST_display_text'  => __('Phone Number', 'event_espresso'),
1077
+							'QST_admin_label'   => __('Phone Number - System Question', 'event_espresso'),
1078
+							'QST_system'        => 'phone',
1079
+							'QST_type'          => 'TEXT',
1080
+							'QST_required'      => 0,
1081
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1082
+							'QST_order'         => 10,
1083
+							'QST_admin_only'    => 0,
1084
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1085
+							'QST_wp_user'       => self::get_default_creator_id(),
1086
+							'QST_deleted'       => 0,
1087
+						);
1088
+						break;
1089
+				}
1090
+				if (! empty($QST_values)) {
1091
+					// insert system question
1092
+					$wpdb->insert(
1093
+						$table_name,
1094
+						$QST_values,
1095
+						array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1096
+					);
1097
+					$QST_ID = $wpdb->insert_id;
1098
+					// QUESTION GROUP QUESTIONS
1099
+					if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1100
+						$system_question_we_want = EEM_Question_Group::system_personal;
1101
+					} else {
1102
+						$system_question_we_want = EEM_Question_Group::system_address;
1103
+					}
1104
+					if (isset($QSG_IDs[$system_question_we_want])) {
1105
+						$QSG_ID = $QSG_IDs[$system_question_we_want];
1106
+					} else {
1107
+						$id_col = EEM_Question_Group::instance()
1108
+													->get_col(array(array('QSG_system' => $system_question_we_want)));
1109
+						if (is_array($id_col)) {
1110
+							$QSG_ID = reset($id_col);
1111
+						} else {
1112
+							//ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1113
+							EE_Log::instance()->log(
1114
+								__FILE__,
1115
+								__FUNCTION__,
1116
+								sprintf(
1117
+									__(
1118
+										'Could not associate question %1$s to a question group because no system question
1119 1119
                                          group existed',
1120
-                                        'event_espresso'
1121
-                                    ),
1122
-                                    $QST_ID),
1123
-                                'error');
1124
-                            continue;
1125
-                        }
1126
-                    }
1127
-                    // add system questions to groups
1128
-                    $wpdb->insert(
1129
-                        \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'),
1130
-                        array(
1131
-                            'QSG_ID'    => $QSG_ID,
1132
-                            'QST_ID'    => $QST_ID,
1133
-                            'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++,
1134
-                        ),
1135
-                        array('%d', '%d', '%d')
1136
-                    );
1137
-                }
1138
-            }
1139
-        }
1140
-    }
1141
-
1142
-
1143
-    /**
1144
-     * Makes sure the default payment method (Invoice) is active.
1145
-     * This used to be done automatically as part of constructing the old gateways config
1146
-     *
1147
-     * @throws \EE_Error
1148
-     */
1149
-    public static function insert_default_payment_methods()
1150
-    {
1151
-        if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1152
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
1153
-            EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1154
-        } else {
1155
-            EEM_Payment_Method::instance()->verify_button_urls();
1156
-        }
1157
-    }
1158
-
1159
-    /**
1160
-     * insert_default_status_codes
1161
-     *
1162
-     * @access public
1163
-     * @static
1164
-     * @return void
1165
-     */
1166
-    public static function insert_default_status_codes()
1167
-    {
1168
-
1169
-        global $wpdb;
1170
-
1171
-        if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) {
1172
-
1173
-            $table_name = EEM_Status::instance()->table();
1174
-
1175
-            $SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );";
1176
-            $wpdb->query($SQL);
1177
-
1178
-            $SQL = "INSERT INTO $table_name
1120
+										'event_espresso'
1121
+									),
1122
+									$QST_ID),
1123
+								'error');
1124
+							continue;
1125
+						}
1126
+					}
1127
+					// add system questions to groups
1128
+					$wpdb->insert(
1129
+						\EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'),
1130
+						array(
1131
+							'QSG_ID'    => $QSG_ID,
1132
+							'QST_ID'    => $QST_ID,
1133
+							'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++,
1134
+						),
1135
+						array('%d', '%d', '%d')
1136
+					);
1137
+				}
1138
+			}
1139
+		}
1140
+	}
1141
+
1142
+
1143
+	/**
1144
+	 * Makes sure the default payment method (Invoice) is active.
1145
+	 * This used to be done automatically as part of constructing the old gateways config
1146
+	 *
1147
+	 * @throws \EE_Error
1148
+	 */
1149
+	public static function insert_default_payment_methods()
1150
+	{
1151
+		if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1152
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
1153
+			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1154
+		} else {
1155
+			EEM_Payment_Method::instance()->verify_button_urls();
1156
+		}
1157
+	}
1158
+
1159
+	/**
1160
+	 * insert_default_status_codes
1161
+	 *
1162
+	 * @access public
1163
+	 * @static
1164
+	 * @return void
1165
+	 */
1166
+	public static function insert_default_status_codes()
1167
+	{
1168
+
1169
+		global $wpdb;
1170
+
1171
+		if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) {
1172
+
1173
+			$table_name = EEM_Status::instance()->table();
1174
+
1175
+			$SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );";
1176
+			$wpdb->query($SQL);
1177
+
1178
+			$SQL = "INSERT INTO $table_name
1179 1179
 					(STS_ID, STS_code, STS_type, STS_can_edit, STS_desc, STS_open) VALUES
1180 1180
 					('ACT', 'ACTIVE', 'event', 0, NULL, 1),
1181 1181
 					('NAC', 'NOT_ACTIVE', 'event', 0, NULL, 0),
@@ -1215,521 +1215,521 @@  discard block
 block discarded – undo
1215 1215
 					('MID', 'IDLE', 'message', 0, NULL, 1),
1216 1216
 					('MRS', 'RESEND', 'message', 0, NULL, 1),
1217 1217
 					('MIC', 'INCOMPLETE', 'message', 0, NULL, 0);";
1218
-            $wpdb->query($SQL);
1219
-
1220
-        }
1221
-
1222
-    }
1223
-
1224
-
1225
-    /**
1226
-     * create_upload_directories
1227
-     * Creates folders in the uploads directory to facilitate addons and templates
1228
-     *
1229
-     * @access public
1230
-     * @static
1231
-     * @return boolean success of verifying upload directories exist
1232
-     */
1233
-    public static function create_upload_directories()
1234
-    {
1235
-        // Create the required folders
1236
-        $folders = array(
1237
-            EVENT_ESPRESSO_TEMPLATE_DIR,
1238
-            EVENT_ESPRESSO_GATEWAY_DIR,
1239
-            EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1240
-            EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1241
-            EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1242
-        );
1243
-        foreach ($folders as $folder) {
1244
-            try {
1245
-                EEH_File::ensure_folder_exists_and_is_writable($folder);
1246
-                @ chmod($folder, 0755);
1247
-            } catch (EE_Error $e) {
1248
-                EE_Error::add_error(
1249
-                    sprintf(
1250
-                        __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1251
-                        $folder,
1252
-                        '<br />' . $e->getMessage()
1253
-                    ),
1254
-                    __FILE__, __FUNCTION__, __LINE__
1255
-                );
1256
-                //indicate we'll need to fix this later
1257
-                update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1258
-                return false;
1259
-            }
1260
-        }
1261
-        //just add the .htaccess file to the logs directory to begin with. Even if logging
1262
-        //is disabled, there might be activation errors recorded in there
1263
-        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1264
-        //remember EE's folders are all good
1265
-        delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1266
-        return true;
1267
-    }
1268
-
1269
-    /**
1270
-     * Whether the upload directories need to be fixed or not.
1271
-     * If EE is installed but filesystem access isn't initially available,
1272
-     * we need to get the user's filesystem credentials and THEN create them,
1273
-     * so there might be period of time when EE is installed but its
1274
-     * upload directories aren't available. This indicates such a state
1275
-     *
1276
-     * @return boolean
1277
-     */
1278
-    public static function upload_directories_incomplete()
1279
-    {
1280
-        return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1281
-    }
1282
-
1283
-
1284
-    /**
1285
-     * generate_default_message_templates
1286
-     *
1287
-     * @static
1288
-     * @throws EE_Error
1289
-     * @return bool     true means new templates were created.
1290
-     *                  false means no templates were created.
1291
-     *                  This is NOT an error flag. To check for errors you will want
1292
-     *                  to use either EE_Error or a try catch for an EE_Error exception.
1293
-     */
1294
-    public static function generate_default_message_templates()
1295
-    {
1296
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
1297
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1298
-        /*
1218
+			$wpdb->query($SQL);
1219
+
1220
+		}
1221
+
1222
+	}
1223
+
1224
+
1225
+	/**
1226
+	 * create_upload_directories
1227
+	 * Creates folders in the uploads directory to facilitate addons and templates
1228
+	 *
1229
+	 * @access public
1230
+	 * @static
1231
+	 * @return boolean success of verifying upload directories exist
1232
+	 */
1233
+	public static function create_upload_directories()
1234
+	{
1235
+		// Create the required folders
1236
+		$folders = array(
1237
+			EVENT_ESPRESSO_TEMPLATE_DIR,
1238
+			EVENT_ESPRESSO_GATEWAY_DIR,
1239
+			EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1240
+			EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1241
+			EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1242
+		);
1243
+		foreach ($folders as $folder) {
1244
+			try {
1245
+				EEH_File::ensure_folder_exists_and_is_writable($folder);
1246
+				@ chmod($folder, 0755);
1247
+			} catch (EE_Error $e) {
1248
+				EE_Error::add_error(
1249
+					sprintf(
1250
+						__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1251
+						$folder,
1252
+						'<br />' . $e->getMessage()
1253
+					),
1254
+					__FILE__, __FUNCTION__, __LINE__
1255
+				);
1256
+				//indicate we'll need to fix this later
1257
+				update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1258
+				return false;
1259
+			}
1260
+		}
1261
+		//just add the .htaccess file to the logs directory to begin with. Even if logging
1262
+		//is disabled, there might be activation errors recorded in there
1263
+		EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1264
+		//remember EE's folders are all good
1265
+		delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1266
+		return true;
1267
+	}
1268
+
1269
+	/**
1270
+	 * Whether the upload directories need to be fixed or not.
1271
+	 * If EE is installed but filesystem access isn't initially available,
1272
+	 * we need to get the user's filesystem credentials and THEN create them,
1273
+	 * so there might be period of time when EE is installed but its
1274
+	 * upload directories aren't available. This indicates such a state
1275
+	 *
1276
+	 * @return boolean
1277
+	 */
1278
+	public static function upload_directories_incomplete()
1279
+	{
1280
+		return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1281
+	}
1282
+
1283
+
1284
+	/**
1285
+	 * generate_default_message_templates
1286
+	 *
1287
+	 * @static
1288
+	 * @throws EE_Error
1289
+	 * @return bool     true means new templates were created.
1290
+	 *                  false means no templates were created.
1291
+	 *                  This is NOT an error flag. To check for errors you will want
1292
+	 *                  to use either EE_Error or a try catch for an EE_Error exception.
1293
+	 */
1294
+	public static function generate_default_message_templates()
1295
+	{
1296
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
1297
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1298
+		/*
1299 1299
          * This first method is taking care of ensuring any default messengers
1300 1300
          * that should be made active and have templates generated are done.
1301 1301
          */
1302
-        $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates(
1303
-            $message_resource_manager
1304
-        );
1305
-        /**
1306
-         * This method is verifying there are no NEW default message types
1307
-         * for ACTIVE messengers that need activated (and corresponding templates setup).
1308
-         */
1309
-        $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates(
1310
-            $message_resource_manager
1311
-        );
1312
-        //after all is done, let's persist these changes to the db.
1313
-        $message_resource_manager->update_has_activated_messengers_option();
1314
-        $message_resource_manager->update_active_messengers_option();
1315
-        // will return true if either of these are true.  Otherwise will return false.
1316
-        return $new_templates_created_for_message_type || $new_templates_created_for_messenger;
1317
-    }
1318
-
1319
-
1320
-
1321
-    /**
1322
-     * @param \EE_Message_Resource_Manager $message_resource_manager
1323
-     * @return array|bool
1324
-     * @throws \EE_Error
1325
-     */
1326
-    protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates(
1327
-        EE_Message_Resource_Manager $message_resource_manager
1328
-    ) {
1329
-        /** @type EE_messenger[] $active_messengers */
1330
-        $active_messengers = $message_resource_manager->active_messengers();
1331
-        $installed_message_types = $message_resource_manager->installed_message_types();
1332
-        $templates_created = false;
1333
-        foreach ($active_messengers as $active_messenger) {
1334
-            $default_message_type_names_for_messenger = $active_messenger->get_default_message_types();
1335
-            $default_message_type_names_to_activate = array();
1336
-            // looping through each default message type reported by the messenger
1337
-            // and setup the actual message types to activate.
1338
-            foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) {
1339
-                // if already active or has already been activated before we skip
1340
-                // (otherwise we might reactivate something user's intentionally deactivated.)
1341
-                // we also skip if the message type is not installed.
1342
-                if (
1343
-                    $message_resource_manager->has_message_type_been_activated_for_messenger(
1344
-                        $default_message_type_name_for_messenger,
1345
-                        $active_messenger->name
1346
-                    )
1347
-                    || $message_resource_manager->is_message_type_active_for_messenger(
1348
-                        $active_messenger->name,
1349
-                        $default_message_type_name_for_messenger
1350
-                    )
1351
-                    || ! isset($installed_message_types[$default_message_type_name_for_messenger])
1352
-                ) {
1353
-                    continue;
1354
-                }
1355
-                $default_message_type_names_to_activate[] = $default_message_type_name_for_messenger;
1356
-            }
1357
-            //let's activate!
1358
-            $message_resource_manager->ensure_message_types_are_active(
1359
-                $default_message_type_names_to_activate,
1360
-                $active_messenger->name,
1361
-                false
1362
-            );
1363
-            //activate the templates for these message types
1364
-            if ( ! empty($default_message_type_names_to_activate)) {
1365
-                $templates_created = EEH_MSG_Template::generate_new_templates(
1366
-                    $active_messenger->name,
1367
-                    $default_message_type_names_for_messenger,
1368
-                    '',
1369
-                    true
1370
-                );
1371
-            }
1372
-        }
1373
-        return $templates_created;
1374
-    }
1375
-
1376
-
1377
-
1378
-    /**
1379
-     * This will activate and generate default messengers and default message types for those messengers.
1380
-     *
1381
-     * @param EE_message_Resource_Manager $message_resource_manager
1382
-     * @return array|bool  True means there were default messengers and message type templates generated.
1383
-     *                     False means that there were no templates generated
1384
-     *                     (which could simply mean there are no default message types for a messenger).
1385
-     * @throws EE_Error
1386
-     */
1387
-    protected static function _activate_and_generate_default_messengers_and_message_templates(
1388
-        EE_Message_Resource_Manager $message_resource_manager
1389
-    ) {
1390
-        /** @type EE_messenger[] $messengers_to_generate */
1391
-        $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager);
1392
-        $installed_message_types = $message_resource_manager->installed_message_types();
1393
-        $templates_generated = false;
1394
-        foreach ($messengers_to_generate as $messenger_to_generate) {
1395
-            $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types();
1396
-            //verify the default message types match an installed message type.
1397
-            foreach ($default_message_type_names_for_messenger as $key => $name) {
1398
-                if (
1399
-                    ! isset($installed_message_types[$name])
1400
-                    || $message_resource_manager->has_message_type_been_activated_for_messenger(
1401
-                        $name,
1402
-                        $messenger_to_generate->name
1403
-                    )
1404
-                ) {
1405
-                    unset($default_message_type_names_for_messenger[$key]);
1406
-                }
1407
-            }
1408
-            // in previous iterations, the active_messengers option in the db
1409
-            // needed updated before calling create templates. however with the changes this may not be necessary.
1410
-            // This comment is left here just in case we discover that we _do_ need to update before
1411
-            // passing off to create templates (after the refactor is done).
1412
-            // @todo remove this comment when determined not necessary.
1413
-            $message_resource_manager->activate_messenger(
1414
-                $messenger_to_generate->name,
1415
-                $default_message_type_names_for_messenger,
1416
-                false
1417
-            );
1418
-            //create any templates needing created (or will reactivate templates already generated as necessary).
1419
-            if ( ! empty($default_message_type_names_for_messenger)) {
1420
-                $templates_generated = EEH_MSG_Template::generate_new_templates(
1421
-                    $messenger_to_generate->name,
1422
-                    $default_message_type_names_for_messenger,
1423
-                    '',
1424
-                    true
1425
-                );
1426
-            }
1427
-        }
1428
-        return $templates_generated;
1429
-    }
1430
-
1431
-
1432
-    /**
1433
-     * This returns the default messengers to generate templates for on activation of EE.
1434
-     * It considers:
1435
-     * - whether a messenger is already active in the db.
1436
-     * - whether a messenger has been made active at any time in the past.
1437
-     *
1438
-     * @static
1439
-     * @param  EE_Message_Resource_Manager $message_resource_manager
1440
-     * @return EE_messenger[]
1441
-     */
1442
-    protected static function _get_default_messengers_to_generate_on_activation(
1443
-        EE_Message_Resource_Manager $message_resource_manager
1444
-    ) {
1445
-        $active_messengers    = $message_resource_manager->active_messengers();
1446
-        $installed_messengers = $message_resource_manager->installed_messengers();
1447
-        $has_activated        = $message_resource_manager->get_has_activated_messengers_option();
1448
-
1449
-        $messengers_to_generate = array();
1450
-        foreach ($installed_messengers as $installed_messenger) {
1451
-            //if installed messenger is a messenger that should be activated on install
1452
-            //and is not already active
1453
-            //and has never been activated
1454
-            if (
1455
-                ! $installed_messenger->activate_on_install
1456
-                || isset($active_messengers[$installed_messenger->name])
1457
-                || isset($has_activated[$installed_messenger->name])
1458
-            ) {
1459
-                continue;
1460
-            }
1461
-            $messengers_to_generate[$installed_messenger->name] = $installed_messenger;
1462
-        }
1463
-        return $messengers_to_generate;
1464
-    }
1465
-
1466
-
1467
-    /**
1468
-     * This simply validates active message types to ensure they actually match installed
1469
-     * message types.  If there's a mismatch then we deactivate the message type and ensure all related db
1470
-     * rows are set inactive.
1471
-     * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever
1472
-     * EE_Messenger_Resource_Manager is constructed.  Message Types are a bit more resource heavy for validation so they
1473
-     * are still handled in here.
1474
-     *
1475
-     * @since 4.3.1
1476
-     * @return void
1477
-     */
1478
-    public static function validate_messages_system()
1479
-    {
1480
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
1481
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1482
-        $message_resource_manager->validate_active_message_types_are_installed();
1483
-        do_action('AHEE__EEH_Activation__validate_messages_system');
1484
-    }
1485
-
1486
-
1487
-    /**
1488
-     * create_no_ticket_prices_array
1489
-     *
1490
-     * @access public
1491
-     * @static
1492
-     * @return void
1493
-     */
1494
-    public static function create_no_ticket_prices_array()
1495
-    {
1496
-        // this creates an array for tracking events that have no active ticket prices created
1497
-        // this allows us to warn admins of the situation so that it can be corrected
1498
-        $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1499
-        if (! $espresso_no_ticket_prices) {
1500
-            add_option('ee_no_ticket_prices', array(), '', false);
1501
-        }
1502
-    }
1503
-
1504
-
1505
-    /**
1506
-     * plugin_deactivation
1507
-     *
1508
-     * @access public
1509
-     * @static
1510
-     * @return void
1511
-     */
1512
-    public static function plugin_deactivation()
1513
-    {
1514
-    }
1515
-
1516
-
1517
-    /**
1518
-     * Finds all our EE4 custom post types, and deletes them and their associated data
1519
-     * (like post meta or term relations)
1520
-     *
1521
-     * @global wpdb $wpdb
1522
-     * @throws \EE_Error
1523
-     */
1524
-    public static function delete_all_espresso_cpt_data()
1525
-    {
1526
-        global $wpdb;
1527
-        //get all the CPT post_types
1528
-        $ee_post_types = array();
1529
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1530
-            if (method_exists($model_name, 'instance')) {
1531
-                $model_obj = call_user_func(array($model_name, 'instance'));
1532
-                if ($model_obj instanceof EEM_CPT_Base) {
1533
-                    $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1534
-                }
1535
-            }
1536
-        }
1537
-        //get all our CPTs
1538
-        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1539
-        $cpt_ids = $wpdb->get_col($query);
1540
-        //delete each post meta and term relations too
1541
-        foreach ($cpt_ids as $post_id) {
1542
-            wp_delete_post($post_id, true);
1543
-        }
1544
-    }
1545
-
1546
-    /**
1547
-     * Deletes all EE custom tables
1548
-     *
1549
-     * @return array
1550
-     */
1551
-    public static function drop_espresso_tables()
1552
-    {
1553
-        $tables = array();
1554
-        // load registry
1555
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1556
-            if (method_exists($model_name, 'instance')) {
1557
-                $model_obj = call_user_func(array($model_name, 'instance'));
1558
-                if ($model_obj instanceof EEM_Base) {
1559
-                    foreach ($model_obj->get_tables() as $table) {
1560
-                        if (strpos($table->get_table_name(), 'esp_')
1561
-                            &&
1562
-                            (
1563
-                                is_main_site()//main site? nuke them all
1564
-                                || ! $table->is_global()//not main site,but not global either. nuke it
1565
-                            )
1566
-                        ) {
1567
-                            $tables[$table->get_table_name()] = $table->get_table_name();
1568
-                        }
1569
-                    }
1570
-                }
1571
-            }
1572
-        }
1573
-
1574
-        //there are some tables whose models were removed.
1575
-        //they should be removed when removing all EE core's data
1576
-        $tables_without_models = array(
1577
-            'esp_promotion',
1578
-            'esp_promotion_applied',
1579
-            'esp_promotion_object',
1580
-            'esp_promotion_rule',
1581
-            'esp_rule',
1582
-        );
1583
-        foreach ($tables_without_models as $table) {
1584
-            $tables[$table] = $table;
1585
-        }
1586
-        return \EEH_Activation::getTableManager()->dropTables($tables);
1587
-    }
1588
-
1589
-
1590
-
1591
-    /**
1592
-     * Drops all the tables mentioned in a single MYSQL query. Double-checks
1593
-     * each table name provided has a wpdb prefix attached, and that it exists.
1594
-     * Returns the list actually deleted
1595
-     *
1596
-     * @deprecated in 4.9.13. Instead use TableManager::dropTables()
1597
-     * @global WPDB $wpdb
1598
-     * @param array $table_names
1599
-     * @return array of table names which we deleted
1600
-     */
1601
-    public static function drop_tables($table_names)
1602
-    {
1603
-        return \EEH_Activation::getTableManager()->dropTables($table_names);
1604
-    }
1605
-
1606
-
1607
-
1608
-    /**
1609
-     * plugin_uninstall
1610
-     *
1611
-     * @access public
1612
-     * @static
1613
-     * @param bool $remove_all
1614
-     * @return void
1615
-     */
1616
-    public static function delete_all_espresso_tables_and_data($remove_all = true)
1617
-    {
1618
-        global $wpdb;
1619
-        self::drop_espresso_tables();
1620
-        $wp_options_to_delete = array(
1621
-            'ee_no_ticket_prices'                => true,
1622
-            'ee_active_messengers'               => true,
1623
-            'ee_has_activated_messenger'         => true,
1624
-            'ee_flush_rewrite_rules'             => true,
1625
-            'ee_config'                          => false,
1626
-            'ee_data_migration_current_db_state' => true,
1627
-            'ee_data_migration_mapping_'         => false,
1628
-            'ee_data_migration_script_'          => false,
1629
-            'ee_data_migrations'                 => true,
1630
-            'ee_dms_map'                         => false,
1631
-            'ee_notices'                         => true,
1632
-            'lang_file_check_'                   => false,
1633
-            'ee_maintenance_mode'                => true,
1634
-            'ee_ueip_optin'                      => true,
1635
-            'ee_ueip_has_notified'               => true,
1636
-            'ee_plugin_activation_errors'        => true,
1637
-            'ee_id_mapping_from'                 => false,
1638
-            'espresso_persistent_admin_notices'  => true,
1639
-            'ee_encryption_key'                  => true,
1640
-            'pue_force_upgrade_'                 => false,
1641
-            'pue_json_error_'                    => false,
1642
-            'pue_install_key_'                   => false,
1643
-            'pue_verification_error_'            => false,
1644
-            'pu_dismissed_upgrade_'              => false,
1645
-            'external_updates-'                  => false,
1646
-            'ee_extra_data'                      => true,
1647
-            'ee_ssn_'                            => false,
1648
-            'ee_rss_'                            => false,
1649
-            'ee_rte_n_tx_'                       => false,
1650
-            'ee_pers_admin_notices'              => true,
1651
-            'ee_job_parameters_'                 => false,
1652
-            'ee_upload_directories_incomplete'   => true,
1653
-            'ee_verified_db_collations'          => true,
1654
-        );
1655
-        if (is_main_site()) {
1656
-            $wp_options_to_delete['ee_network_config'] = true;
1657
-        }
1658
-        $undeleted_options = array();
1659
-        foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1660
-            if ($no_wildcard) {
1661
-                if ( ! delete_option($option_name)) {
1662
-                    $undeleted_options[] = $option_name;
1663
-                }
1664
-            } else {
1665
-                $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1666
-                foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1667
-                    if ( ! delete_option($option_name_from_wildcard)) {
1668
-                        $undeleted_options[] = $option_name_from_wildcard;
1669
-                    }
1670
-                }
1671
-            }
1672
-        }
1673
-        //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1674
-        remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1675
-        if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1676
-            $db_update_sans_ee4 = array();
1677
-            foreach ($espresso_db_update as $version => $times_activated) {
1678
-                if ((string)$version[0] === '3') {//if its NON EE4
1679
-                    $db_update_sans_ee4[$version] = $times_activated;
1680
-                }
1681
-            }
1682
-            update_option('espresso_db_update', $db_update_sans_ee4);
1683
-        }
1684
-        $errors = '';
1685
-        if ( ! empty($undeleted_options)) {
1686
-            $errors .= sprintf(
1687
-                __('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1688
-                '<br/>',
1689
-                implode(',<br/>', $undeleted_options)
1690
-            );
1691
-        }
1692
-        if ( ! empty($errors)) {
1693
-            EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1694
-        }
1695
-    }
1696
-
1697
-    /**
1698
-     * Gets the mysql error code from the last used query by wpdb
1699
-     *
1700
-     * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
1701
-     */
1702
-    public static function last_wpdb_error_code()
1703
-    {
1704
-        global $wpdb;
1705
-        if ($wpdb->use_mysqli) {
1706
-            return mysqli_errno($wpdb->dbh);
1707
-        } else {
1708
-            return mysql_errno($wpdb->dbh);
1709
-        }
1710
-    }
1711
-
1712
-    /**
1713
-     * Checks that the database table exists. Also works on temporary tables (for unit tests mostly).
1714
-     *
1715
-     * @global wpdb  $wpdb
1716
-     * @deprecated instead use TableAnalysis::tableExists()
1717
-     * @param string $table_name with or without $wpdb->prefix
1718
-     * @return boolean
1719
-     */
1720
-    public static function table_exists($table_name)
1721
-    {
1722
-        return \EEH_Activation::getTableAnalysis()->tableExists($table_name);
1723
-    }
1724
-
1725
-    /**
1726
-     * Resets the cache on EEH_Activation
1727
-     */
1728
-    public static function reset()
1729
-    {
1730
-        self::$_default_creator_id                             = null;
1731
-        self::$_initialized_db_content_already_in_this_request = false;
1732
-    }
1302
+		$new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates(
1303
+			$message_resource_manager
1304
+		);
1305
+		/**
1306
+		 * This method is verifying there are no NEW default message types
1307
+		 * for ACTIVE messengers that need activated (and corresponding templates setup).
1308
+		 */
1309
+		$new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates(
1310
+			$message_resource_manager
1311
+		);
1312
+		//after all is done, let's persist these changes to the db.
1313
+		$message_resource_manager->update_has_activated_messengers_option();
1314
+		$message_resource_manager->update_active_messengers_option();
1315
+		// will return true if either of these are true.  Otherwise will return false.
1316
+		return $new_templates_created_for_message_type || $new_templates_created_for_messenger;
1317
+	}
1318
+
1319
+
1320
+
1321
+	/**
1322
+	 * @param \EE_Message_Resource_Manager $message_resource_manager
1323
+	 * @return array|bool
1324
+	 * @throws \EE_Error
1325
+	 */
1326
+	protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates(
1327
+		EE_Message_Resource_Manager $message_resource_manager
1328
+	) {
1329
+		/** @type EE_messenger[] $active_messengers */
1330
+		$active_messengers = $message_resource_manager->active_messengers();
1331
+		$installed_message_types = $message_resource_manager->installed_message_types();
1332
+		$templates_created = false;
1333
+		foreach ($active_messengers as $active_messenger) {
1334
+			$default_message_type_names_for_messenger = $active_messenger->get_default_message_types();
1335
+			$default_message_type_names_to_activate = array();
1336
+			// looping through each default message type reported by the messenger
1337
+			// and setup the actual message types to activate.
1338
+			foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) {
1339
+				// if already active or has already been activated before we skip
1340
+				// (otherwise we might reactivate something user's intentionally deactivated.)
1341
+				// we also skip if the message type is not installed.
1342
+				if (
1343
+					$message_resource_manager->has_message_type_been_activated_for_messenger(
1344
+						$default_message_type_name_for_messenger,
1345
+						$active_messenger->name
1346
+					)
1347
+					|| $message_resource_manager->is_message_type_active_for_messenger(
1348
+						$active_messenger->name,
1349
+						$default_message_type_name_for_messenger
1350
+					)
1351
+					|| ! isset($installed_message_types[$default_message_type_name_for_messenger])
1352
+				) {
1353
+					continue;
1354
+				}
1355
+				$default_message_type_names_to_activate[] = $default_message_type_name_for_messenger;
1356
+			}
1357
+			//let's activate!
1358
+			$message_resource_manager->ensure_message_types_are_active(
1359
+				$default_message_type_names_to_activate,
1360
+				$active_messenger->name,
1361
+				false
1362
+			);
1363
+			//activate the templates for these message types
1364
+			if ( ! empty($default_message_type_names_to_activate)) {
1365
+				$templates_created = EEH_MSG_Template::generate_new_templates(
1366
+					$active_messenger->name,
1367
+					$default_message_type_names_for_messenger,
1368
+					'',
1369
+					true
1370
+				);
1371
+			}
1372
+		}
1373
+		return $templates_created;
1374
+	}
1375
+
1376
+
1377
+
1378
+	/**
1379
+	 * This will activate and generate default messengers and default message types for those messengers.
1380
+	 *
1381
+	 * @param EE_message_Resource_Manager $message_resource_manager
1382
+	 * @return array|bool  True means there were default messengers and message type templates generated.
1383
+	 *                     False means that there were no templates generated
1384
+	 *                     (which could simply mean there are no default message types for a messenger).
1385
+	 * @throws EE_Error
1386
+	 */
1387
+	protected static function _activate_and_generate_default_messengers_and_message_templates(
1388
+		EE_Message_Resource_Manager $message_resource_manager
1389
+	) {
1390
+		/** @type EE_messenger[] $messengers_to_generate */
1391
+		$messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager);
1392
+		$installed_message_types = $message_resource_manager->installed_message_types();
1393
+		$templates_generated = false;
1394
+		foreach ($messengers_to_generate as $messenger_to_generate) {
1395
+			$default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types();
1396
+			//verify the default message types match an installed message type.
1397
+			foreach ($default_message_type_names_for_messenger as $key => $name) {
1398
+				if (
1399
+					! isset($installed_message_types[$name])
1400
+					|| $message_resource_manager->has_message_type_been_activated_for_messenger(
1401
+						$name,
1402
+						$messenger_to_generate->name
1403
+					)
1404
+				) {
1405
+					unset($default_message_type_names_for_messenger[$key]);
1406
+				}
1407
+			}
1408
+			// in previous iterations, the active_messengers option in the db
1409
+			// needed updated before calling create templates. however with the changes this may not be necessary.
1410
+			// This comment is left here just in case we discover that we _do_ need to update before
1411
+			// passing off to create templates (after the refactor is done).
1412
+			// @todo remove this comment when determined not necessary.
1413
+			$message_resource_manager->activate_messenger(
1414
+				$messenger_to_generate->name,
1415
+				$default_message_type_names_for_messenger,
1416
+				false
1417
+			);
1418
+			//create any templates needing created (or will reactivate templates already generated as necessary).
1419
+			if ( ! empty($default_message_type_names_for_messenger)) {
1420
+				$templates_generated = EEH_MSG_Template::generate_new_templates(
1421
+					$messenger_to_generate->name,
1422
+					$default_message_type_names_for_messenger,
1423
+					'',
1424
+					true
1425
+				);
1426
+			}
1427
+		}
1428
+		return $templates_generated;
1429
+	}
1430
+
1431
+
1432
+	/**
1433
+	 * This returns the default messengers to generate templates for on activation of EE.
1434
+	 * It considers:
1435
+	 * - whether a messenger is already active in the db.
1436
+	 * - whether a messenger has been made active at any time in the past.
1437
+	 *
1438
+	 * @static
1439
+	 * @param  EE_Message_Resource_Manager $message_resource_manager
1440
+	 * @return EE_messenger[]
1441
+	 */
1442
+	protected static function _get_default_messengers_to_generate_on_activation(
1443
+		EE_Message_Resource_Manager $message_resource_manager
1444
+	) {
1445
+		$active_messengers    = $message_resource_manager->active_messengers();
1446
+		$installed_messengers = $message_resource_manager->installed_messengers();
1447
+		$has_activated        = $message_resource_manager->get_has_activated_messengers_option();
1448
+
1449
+		$messengers_to_generate = array();
1450
+		foreach ($installed_messengers as $installed_messenger) {
1451
+			//if installed messenger is a messenger that should be activated on install
1452
+			//and is not already active
1453
+			//and has never been activated
1454
+			if (
1455
+				! $installed_messenger->activate_on_install
1456
+				|| isset($active_messengers[$installed_messenger->name])
1457
+				|| isset($has_activated[$installed_messenger->name])
1458
+			) {
1459
+				continue;
1460
+			}
1461
+			$messengers_to_generate[$installed_messenger->name] = $installed_messenger;
1462
+		}
1463
+		return $messengers_to_generate;
1464
+	}
1465
+
1466
+
1467
+	/**
1468
+	 * This simply validates active message types to ensure they actually match installed
1469
+	 * message types.  If there's a mismatch then we deactivate the message type and ensure all related db
1470
+	 * rows are set inactive.
1471
+	 * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever
1472
+	 * EE_Messenger_Resource_Manager is constructed.  Message Types are a bit more resource heavy for validation so they
1473
+	 * are still handled in here.
1474
+	 *
1475
+	 * @since 4.3.1
1476
+	 * @return void
1477
+	 */
1478
+	public static function validate_messages_system()
1479
+	{
1480
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
1481
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1482
+		$message_resource_manager->validate_active_message_types_are_installed();
1483
+		do_action('AHEE__EEH_Activation__validate_messages_system');
1484
+	}
1485
+
1486
+
1487
+	/**
1488
+	 * create_no_ticket_prices_array
1489
+	 *
1490
+	 * @access public
1491
+	 * @static
1492
+	 * @return void
1493
+	 */
1494
+	public static function create_no_ticket_prices_array()
1495
+	{
1496
+		// this creates an array for tracking events that have no active ticket prices created
1497
+		// this allows us to warn admins of the situation so that it can be corrected
1498
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1499
+		if (! $espresso_no_ticket_prices) {
1500
+			add_option('ee_no_ticket_prices', array(), '', false);
1501
+		}
1502
+	}
1503
+
1504
+
1505
+	/**
1506
+	 * plugin_deactivation
1507
+	 *
1508
+	 * @access public
1509
+	 * @static
1510
+	 * @return void
1511
+	 */
1512
+	public static function plugin_deactivation()
1513
+	{
1514
+	}
1515
+
1516
+
1517
+	/**
1518
+	 * Finds all our EE4 custom post types, and deletes them and their associated data
1519
+	 * (like post meta or term relations)
1520
+	 *
1521
+	 * @global wpdb $wpdb
1522
+	 * @throws \EE_Error
1523
+	 */
1524
+	public static function delete_all_espresso_cpt_data()
1525
+	{
1526
+		global $wpdb;
1527
+		//get all the CPT post_types
1528
+		$ee_post_types = array();
1529
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1530
+			if (method_exists($model_name, 'instance')) {
1531
+				$model_obj = call_user_func(array($model_name, 'instance'));
1532
+				if ($model_obj instanceof EEM_CPT_Base) {
1533
+					$ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1534
+				}
1535
+			}
1536
+		}
1537
+		//get all our CPTs
1538
+		$query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1539
+		$cpt_ids = $wpdb->get_col($query);
1540
+		//delete each post meta and term relations too
1541
+		foreach ($cpt_ids as $post_id) {
1542
+			wp_delete_post($post_id, true);
1543
+		}
1544
+	}
1545
+
1546
+	/**
1547
+	 * Deletes all EE custom tables
1548
+	 *
1549
+	 * @return array
1550
+	 */
1551
+	public static function drop_espresso_tables()
1552
+	{
1553
+		$tables = array();
1554
+		// load registry
1555
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1556
+			if (method_exists($model_name, 'instance')) {
1557
+				$model_obj = call_user_func(array($model_name, 'instance'));
1558
+				if ($model_obj instanceof EEM_Base) {
1559
+					foreach ($model_obj->get_tables() as $table) {
1560
+						if (strpos($table->get_table_name(), 'esp_')
1561
+							&&
1562
+							(
1563
+								is_main_site()//main site? nuke them all
1564
+								|| ! $table->is_global()//not main site,but not global either. nuke it
1565
+							)
1566
+						) {
1567
+							$tables[$table->get_table_name()] = $table->get_table_name();
1568
+						}
1569
+					}
1570
+				}
1571
+			}
1572
+		}
1573
+
1574
+		//there are some tables whose models were removed.
1575
+		//they should be removed when removing all EE core's data
1576
+		$tables_without_models = array(
1577
+			'esp_promotion',
1578
+			'esp_promotion_applied',
1579
+			'esp_promotion_object',
1580
+			'esp_promotion_rule',
1581
+			'esp_rule',
1582
+		);
1583
+		foreach ($tables_without_models as $table) {
1584
+			$tables[$table] = $table;
1585
+		}
1586
+		return \EEH_Activation::getTableManager()->dropTables($tables);
1587
+	}
1588
+
1589
+
1590
+
1591
+	/**
1592
+	 * Drops all the tables mentioned in a single MYSQL query. Double-checks
1593
+	 * each table name provided has a wpdb prefix attached, and that it exists.
1594
+	 * Returns the list actually deleted
1595
+	 *
1596
+	 * @deprecated in 4.9.13. Instead use TableManager::dropTables()
1597
+	 * @global WPDB $wpdb
1598
+	 * @param array $table_names
1599
+	 * @return array of table names which we deleted
1600
+	 */
1601
+	public static function drop_tables($table_names)
1602
+	{
1603
+		return \EEH_Activation::getTableManager()->dropTables($table_names);
1604
+	}
1605
+
1606
+
1607
+
1608
+	/**
1609
+	 * plugin_uninstall
1610
+	 *
1611
+	 * @access public
1612
+	 * @static
1613
+	 * @param bool $remove_all
1614
+	 * @return void
1615
+	 */
1616
+	public static function delete_all_espresso_tables_and_data($remove_all = true)
1617
+	{
1618
+		global $wpdb;
1619
+		self::drop_espresso_tables();
1620
+		$wp_options_to_delete = array(
1621
+			'ee_no_ticket_prices'                => true,
1622
+			'ee_active_messengers'               => true,
1623
+			'ee_has_activated_messenger'         => true,
1624
+			'ee_flush_rewrite_rules'             => true,
1625
+			'ee_config'                          => false,
1626
+			'ee_data_migration_current_db_state' => true,
1627
+			'ee_data_migration_mapping_'         => false,
1628
+			'ee_data_migration_script_'          => false,
1629
+			'ee_data_migrations'                 => true,
1630
+			'ee_dms_map'                         => false,
1631
+			'ee_notices'                         => true,
1632
+			'lang_file_check_'                   => false,
1633
+			'ee_maintenance_mode'                => true,
1634
+			'ee_ueip_optin'                      => true,
1635
+			'ee_ueip_has_notified'               => true,
1636
+			'ee_plugin_activation_errors'        => true,
1637
+			'ee_id_mapping_from'                 => false,
1638
+			'espresso_persistent_admin_notices'  => true,
1639
+			'ee_encryption_key'                  => true,
1640
+			'pue_force_upgrade_'                 => false,
1641
+			'pue_json_error_'                    => false,
1642
+			'pue_install_key_'                   => false,
1643
+			'pue_verification_error_'            => false,
1644
+			'pu_dismissed_upgrade_'              => false,
1645
+			'external_updates-'                  => false,
1646
+			'ee_extra_data'                      => true,
1647
+			'ee_ssn_'                            => false,
1648
+			'ee_rss_'                            => false,
1649
+			'ee_rte_n_tx_'                       => false,
1650
+			'ee_pers_admin_notices'              => true,
1651
+			'ee_job_parameters_'                 => false,
1652
+			'ee_upload_directories_incomplete'   => true,
1653
+			'ee_verified_db_collations'          => true,
1654
+		);
1655
+		if (is_main_site()) {
1656
+			$wp_options_to_delete['ee_network_config'] = true;
1657
+		}
1658
+		$undeleted_options = array();
1659
+		foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1660
+			if ($no_wildcard) {
1661
+				if ( ! delete_option($option_name)) {
1662
+					$undeleted_options[] = $option_name;
1663
+				}
1664
+			} else {
1665
+				$option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1666
+				foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1667
+					if ( ! delete_option($option_name_from_wildcard)) {
1668
+						$undeleted_options[] = $option_name_from_wildcard;
1669
+					}
1670
+				}
1671
+			}
1672
+		}
1673
+		//also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1674
+		remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1675
+		if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1676
+			$db_update_sans_ee4 = array();
1677
+			foreach ($espresso_db_update as $version => $times_activated) {
1678
+				if ((string)$version[0] === '3') {//if its NON EE4
1679
+					$db_update_sans_ee4[$version] = $times_activated;
1680
+				}
1681
+			}
1682
+			update_option('espresso_db_update', $db_update_sans_ee4);
1683
+		}
1684
+		$errors = '';
1685
+		if ( ! empty($undeleted_options)) {
1686
+			$errors .= sprintf(
1687
+				__('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1688
+				'<br/>',
1689
+				implode(',<br/>', $undeleted_options)
1690
+			);
1691
+		}
1692
+		if ( ! empty($errors)) {
1693
+			EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1694
+		}
1695
+	}
1696
+
1697
+	/**
1698
+	 * Gets the mysql error code from the last used query by wpdb
1699
+	 *
1700
+	 * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
1701
+	 */
1702
+	public static function last_wpdb_error_code()
1703
+	{
1704
+		global $wpdb;
1705
+		if ($wpdb->use_mysqli) {
1706
+			return mysqli_errno($wpdb->dbh);
1707
+		} else {
1708
+			return mysql_errno($wpdb->dbh);
1709
+		}
1710
+	}
1711
+
1712
+	/**
1713
+	 * Checks that the database table exists. Also works on temporary tables (for unit tests mostly).
1714
+	 *
1715
+	 * @global wpdb  $wpdb
1716
+	 * @deprecated instead use TableAnalysis::tableExists()
1717
+	 * @param string $table_name with or without $wpdb->prefix
1718
+	 * @return boolean
1719
+	 */
1720
+	public static function table_exists($table_name)
1721
+	{
1722
+		return \EEH_Activation::getTableAnalysis()->tableExists($table_name);
1723
+	}
1724
+
1725
+	/**
1726
+	 * Resets the cache on EEH_Activation
1727
+	 */
1728
+	public static function reset()
1729
+	{
1730
+		self::$_default_creator_id                             = null;
1731
+		self::$_initialized_db_content_already_in_this_request = false;
1732
+	}
1733 1733
 }
1734 1734
 // End of file EEH_Activation.helper.php
1735 1735
 // Location: /helpers/EEH_Activation.core.php
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public static function getTableAnalysis()
67 67
     {
68
-        if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
68
+        if ( ! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
69 69
             self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
70 70
         }
71 71
         return self::$table_analysis;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      */
78 78
     public static function getTableManager()
79 79
     {
80
-        if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
80
+        if ( ! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
81 81
             self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
82 82
         }
83 83
         return self::$table_manager;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         if ($which_to_include === 'old') {
194 194
             $cron_tasks = array_filter(
195 195
                 $cron_tasks,
196
-                function ($value) {
196
+                function($value) {
197 197
                     return $value === EEH_Activation::cron_task_no_longer_in_use;
198 198
                 }
199 199
             );
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
     {
224 224
 
225 225
         foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
226
-            if (! wp_next_scheduled($hook_name)) {
226
+            if ( ! wp_next_scheduled($hook_name)) {
227 227
                 /**
228 228
                  * This allows client code to define the initial start timestamp for this schedule.
229 229
                  */
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
             3
329 329
         );
330 330
         //EE_Config::reset();
331
-        if (! EE_Config::logging_enabled()) {
331
+        if ( ! EE_Config::logging_enabled()) {
332 332
             delete_option(EE_Config::LOG_NAME);
333 333
         }
334 334
     }
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
     public static function load_calendar_config()
344 344
     {
345 345
         // grab array of all plugin folders and loop thru it
346
-        $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
346
+        $plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR);
347 347
         if (empty($plugins)) {
348 348
             return;
349 349
         }
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
                 || strpos($plugin, 'calendar') !== false
361 361
             ) {
362 362
                 // this is what we are looking for
363
-                $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
363
+                $calendar_config = $plugin_path.DS.'EE_Calendar_Config.php';
364 364
                 // does it exist in this folder ?
365 365
                 if (is_readable($calendar_config)) {
366 366
                     // YEAH! let's load it
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
             ) {
489 489
                 //update Config with post ID
490 490
                 $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
491
-                if (! EE_Config::instance()->update_espresso_config(false, false)) {
491
+                if ( ! EE_Config::instance()->update_espresso_config(false, false)) {
492 492
                     $msg = __(
493 493
                         'The Event Espresso critical page configuration settings could not be updated.',
494 494
                         'event_espresso'
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
                         'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
512 512
                         'event_espresso'
513 513
                     ),
514
-                    '<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">'
514
+                    '<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'
515 515
                     . __('Event Espresso Critical Pages Settings', 'event_espresso')
516 516
                     . '</a>'
517 517
                 )
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
     public static function get_page_by_ee_shortcode($ee_shortcode)
538 538
     {
539 539
         global $wpdb;
540
-        $shortcode_and_opening_bracket = '[' . $ee_shortcode;
540
+        $shortcode_and_opening_bracket = '['.$ee_shortcode;
541 541
         $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
542 542
         if ($post_id) {
543 543
             return get_post($post_id);
@@ -563,11 +563,11 @@  discard block
 block discarded – undo
563 563
             'post_status'    => 'publish',
564 564
             'post_type'      => 'page',
565 565
             'comment_status' => 'closed',
566
-            'post_content'   => '[' . $critical_page['code'] . ']',
566
+            'post_content'   => '['.$critical_page['code'].']',
567 567
         );
568 568
 
569 569
         $post_id = wp_insert_post($post_args);
570
-        if (! $post_id) {
570
+        if ( ! $post_id) {
571 571
             $msg = sprintf(
572 572
                 __('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
573 573
                 $critical_page['name']
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
             return $critical_page;
577 577
         }
578 578
         // get newly created post's details
579
-        if (! $critical_page['post'] = get_post($post_id)) {
579
+        if ( ! $critical_page['post'] = get_post($post_id)) {
580 580
             $msg = sprintf(
581 581
                 __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
582 582
                 $critical_page['name']
@@ -613,17 +613,17 @@  discard block
 block discarded – undo
613 613
             $role_to_check
614 614
         );
615 615
         if ($pre_filtered_id !== false) {
616
-            return (int)$pre_filtered_id;
616
+            return (int) $pre_filtered_id;
617 617
         }
618 618
         $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
619 619
         $query = $wpdb->prepare(
620 620
             "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
621
-            '%' . $role_to_check . '%'
621
+            '%'.$role_to_check.'%'
622 622
         );
623 623
         $user_id = $wpdb->get_var($query);
624 624
         $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
625
-        if ($user_id && (int)$user_id) {
626
-            self::$_default_creator_id = (int)$user_id;
625
+        if ($user_id && (int) $user_id) {
626
+            self::$_default_creator_id = (int) $user_id;
627 627
             return self::$_default_creator_id;
628 628
         } else {
629 629
             return null;
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
         }
659 659
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
660 660
         if ( ! function_exists('dbDelta')) {
661
-            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
661
+            require_once(ABSPATH.'wp-admin/includes/upgrade.php');
662 662
         }
663 663
         $tableAnalysis = \EEH_Activation::getTableAnalysis();
664 664
         $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
@@ -869,13 +869,13 @@  discard block
 block discarded – undo
869 869
             // reset values array
870 870
             $QSG_values = array();
871 871
             // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
872
-            if (! in_array("$QSG_system", $question_groups)) {
872
+            if ( ! in_array("$QSG_system", $question_groups)) {
873 873
                 // add it
874 874
                 switch ($QSG_system) {
875 875
                     case 1:
876 876
                         $QSG_values = array(
877 877
                             'QSG_name'            => __('Personal Information', 'event_espresso'),
878
-                            'QSG_identifier'      => 'personal-information-' . time(),
878
+                            'QSG_identifier'      => 'personal-information-'.time(),
879 879
                             'QSG_desc'            => '',
880 880
                             'QSG_order'           => 1,
881 881
                             'QSG_show_group_name' => 1,
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
                     case 2:
888 888
                         $QSG_values = array(
889 889
                             'QSG_name'            => __('Address Information', 'event_espresso'),
890
-                            'QSG_identifier'      => 'address-information-' . time(),
890
+                            'QSG_identifier'      => 'address-information-'.time(),
891 891
                             'QSG_desc'            => '',
892 892
                             'QSG_order'           => 2,
893 893
                             'QSG_show_group_name' => 1,
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
                         break;
899 899
                 }
900 900
                 // make sure we have some values before inserting them
901
-                if (! empty($QSG_values)) {
901
+                if ( ! empty($QSG_values)) {
902 902
                     // insert system question
903 903
                     $wpdb->insert(
904 904
                         $table_name,
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
             // reset values array
936 936
             $QST_values = array();
937 937
             // if we don't have what we should have
938
-            if (! in_array($QST_system, $questions)) {
938
+            if ( ! in_array($QST_system, $questions)) {
939 939
                 // add it
940 940
                 switch ($QST_system) {
941 941
                     case 'fname':
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
                         );
1088 1088
                         break;
1089 1089
                 }
1090
-                if (! empty($QST_values)) {
1090
+                if ( ! empty($QST_values)) {
1091 1091
                     // insert system question
1092 1092
                     $wpdb->insert(
1093 1093
                         $table_name,
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
      */
1149 1149
     public static function insert_default_payment_methods()
1150 1150
     {
1151
-        if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1151
+        if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1152 1152
             EE_Registry::instance()->load_lib('Payment_Method_Manager');
1153 1153
             EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1154 1154
         } else {
@@ -1236,9 +1236,9 @@  discard block
 block discarded – undo
1236 1236
         $folders = array(
1237 1237
             EVENT_ESPRESSO_TEMPLATE_DIR,
1238 1238
             EVENT_ESPRESSO_GATEWAY_DIR,
1239
-            EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1240
-            EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1241
-            EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1239
+            EVENT_ESPRESSO_UPLOAD_DIR.'logs/',
1240
+            EVENT_ESPRESSO_UPLOAD_DIR.'css/',
1241
+            EVENT_ESPRESSO_UPLOAD_DIR.'tickets/',
1242 1242
         );
1243 1243
         foreach ($folders as $folder) {
1244 1244
             try {
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
                     sprintf(
1250 1250
                         __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1251 1251
                         $folder,
1252
-                        '<br />' . $e->getMessage()
1252
+                        '<br />'.$e->getMessage()
1253 1253
                     ),
1254 1254
                     __FILE__, __FUNCTION__, __LINE__
1255 1255
                 );
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
         }
1261 1261
         //just add the .htaccess file to the logs directory to begin with. Even if logging
1262 1262
         //is disabled, there might be activation errors recorded in there
1263
-        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1263
+        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/');
1264 1264
         //remember EE's folders are all good
1265 1265
         delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1266 1266
         return true;
@@ -1496,7 +1496,7 @@  discard block
 block discarded – undo
1496 1496
         // this creates an array for tracking events that have no active ticket prices created
1497 1497
         // this allows us to warn admins of the situation so that it can be corrected
1498 1498
         $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1499
-        if (! $espresso_no_ticket_prices) {
1499
+        if ( ! $espresso_no_ticket_prices) {
1500 1500
             add_option('ee_no_ticket_prices', array(), '', false);
1501 1501
         }
1502 1502
     }
@@ -1535,7 +1535,7 @@  discard block
 block discarded – undo
1535 1535
             }
1536 1536
         }
1537 1537
         //get all our CPTs
1538
-        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1538
+        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")";
1539 1539
         $cpt_ids = $wpdb->get_col($query);
1540 1540
         //delete each post meta and term relations too
1541 1541
         foreach ($cpt_ids as $post_id) {
@@ -1675,7 +1675,7 @@  discard block
 block discarded – undo
1675 1675
         if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1676 1676
             $db_update_sans_ee4 = array();
1677 1677
             foreach ($espresso_db_update as $version => $times_activated) {
1678
-                if ((string)$version[0] === '3') {//if its NON EE4
1678
+                if ((string) $version[0] === '3') {//if its NON EE4
1679 1679
                     $db_update_sans_ee4[$version] = $times_activated;
1680 1680
                 }
1681 1681
             }
Please login to merge, or discard this patch.
caffeinated/brewing_regular.php 2 patches
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
  * define and use the hook in a specific caffeinated/whatever class or file.
11 11
  */
12 12
 // defined some new constants related to caffeinated folder
13
-define('EE_CAF_URL', EE_PLUGIN_DIR_URL . 'caffeinated/');
14
-define('EE_CAF_CORE', EE_CAFF_PATH . 'core' . DS);
15
-define('EE_CAF_LIBRARIES', EE_CAF_CORE . 'libraries' . DS);
16
-define('EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH . 'payment_methods' . DS);
13
+define('EE_CAF_URL', EE_PLUGIN_DIR_URL.'caffeinated/');
14
+define('EE_CAF_CORE', EE_CAFF_PATH.'core'.DS);
15
+define('EE_CAF_LIBRARIES', EE_CAF_CORE.'libraries'.DS);
16
+define('EE_CAF_PAYMENT_METHODS', EE_CAFF_PATH.'payment_methods'.DS);
17 17
 
18 18
 
19 19
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function caf_helper_paths($paths)
78 78
     {
79
-        $paths[] = EE_CAF_CORE . 'helpers' . DS;
79
+        $paths[] = EE_CAF_CORE.'helpers'.DS;
80 80
         return $paths;
81 81
     }
82 82
 
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
         global $wpdb;
99 99
         //use same method of getting creator id as the version introducing the change
100 100
         $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
101
-        $price_type_table = $wpdb->prefix . "esp_price_type";
102
-        $price_table = $wpdb->prefix . "esp_price";
101
+        $price_type_table = $wpdb->prefix."esp_price_type";
102
+        $price_table = $wpdb->prefix."esp_price";
103 103
         if ($this->_get_table_analysis()->tableExists($price_type_table)) {
104
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';//include trashed price types
104
+            $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table.' WHERE PBT_ID=4'; //include trashed price types
105 105
             $tax_price_type_count = $wpdb->get_var($SQL);
106 106
             if ($tax_price_type_count <= 1) {
107 107
                 $wpdb->insert(
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
                         'PRT_wp_user'    => $default_creator_id,
116 116
                     ),
117 117
                     array(
118
-                        '%s',//PRT_name
119
-                        '%d',//PBT_id
120
-                        '%d',//PRT_is_percent
121
-                        '%d',//PRT_order
122
-                        '%d',//PRT_deleted
118
+                        '%s', //PRT_name
119
+                        '%d', //PBT_id
120
+                        '%d', //PRT_is_percent
121
+                        '%d', //PRT_order
122
+                        '%d', //PRT_deleted
123 123
                         '%d', //PRT_wp_user
124 124
                     )
125 125
                 );
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
                         'PRT_wp_user'    => $default_creator_id,
136 136
                     ),
137 137
                     array(
138
-                        '%s',//PRT_name
139
-                        '%d',//PBT_id
140
-                        '%d',//PRT_is_percent
141
-                        '%d',//PRT_order
142
-                        '%d',//PRT_deleted
138
+                        '%s', //PRT_name
139
+                        '%d', //PBT_id
140
+                        '%d', //PRT_is_percent
141
+                        '%d', //PRT_order
142
+                        '%d', //PRT_deleted
143 143
                         '%d' //PRT_wp_user
144 144
                     )
145 145
                 );
@@ -159,15 +159,15 @@  discard block
 block discarded – undo
159 159
                             'PRC_wp_user'    => $default_creator_id,
160 160
                         ),
161 161
                         array(
162
-                            '%d',//PRT_id
163
-                            '%f',//PRC_amount
164
-                            '%s',//PRC_name
165
-                            '%s',//PRC_desc
166
-                            '%d',//PRC_is_default
167
-                            '%d',//PRC_overrides
168
-                            '%d',//PRC_deleted
169
-                            '%d',//PRC_order
170
-                            '%d',//PRC_parent
162
+                            '%d', //PRT_id
163
+                            '%f', //PRC_amount
164
+                            '%s', //PRC_name
165
+                            '%s', //PRC_desc
166
+                            '%d', //PRC_is_default
167
+                            '%d', //PRC_overrides
168
+                            '%d', //PRC_deleted
169
+                            '%d', //PRC_order
170
+                            '%d', //PRC_parent
171 171
                             '%d' //PRC_wp_user
172 172
                         )
173 173
                     );
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
      */
188 188
     public function caffeinated_modules_to_register($modules_to_register = array())
189 189
     {
190
-        if (is_readable(EE_CAFF_PATH . 'modules')) {
191
-            $caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules' . DS . '*', GLOB_ONLYDIR);
190
+        if (is_readable(EE_CAFF_PATH.'modules')) {
191
+            $caffeinated_modules_to_register = glob(EE_CAFF_PATH.'modules'.DS.'*', GLOB_ONLYDIR);
192 192
             if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
193 193
                 $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
194 194
             }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      */
269 269
     public function caf_payment_methods($payment_method_paths)
270 270
     {
271
-        $caf_payment_methods_paths = glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
271
+        $caf_payment_methods_paths = glob(EE_CAF_PAYMENT_METHODS.'*', GLOB_ONLYDIR);
272 272
         $payment_method_paths = array_merge($payment_method_paths, $caf_payment_methods_paths);
273 273
         return $payment_method_paths;
274 274
     }
Please login to merge, or discard this patch.
Indentation   +269 added lines, -269 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\services\database\TableAnalysis;
5 5
 
6 6
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
-    exit('No direct script access allowed');
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 /**
10 10
  * the purpose of this file is to simply contain any action/filter hook callbacks etc for specific aspects of EE
@@ -29,277 +29,277 @@  discard block
 block discarded – undo
29 29
 class EE_Brewing_Regular extends EE_BASE implements InterminableInterface
30 30
 {
31 31
 
32
-    /**
33
-     * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
34
-     */
35
-    protected $_table_analysis;
36
-
37
-
38
-
39
-    /**
40
-     * EE_Brewing_Regular constructor.
41
-     */
42
-    public function __construct(TableAnalysis $table_analysis)
43
-    {
44
-        $this->_table_analysis = $table_analysis;
45
-        if (defined('EE_CAFF_PATH')) {
46
-            // activation
47
-            add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content'));
48
-            // load caff init
49
-            add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init'));
50
-            // remove the "powered by" credit link from receipts and invoices
51
-            add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false');
52
-            // add caffeinated modules
53
-            add_filter(
54
-                'FHEE__EE_Config__register_modules__modules_to_register',
55
-                array($this, 'caffeinated_modules_to_register')
56
-            );
57
-            // load caff scripts
58
-            add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10);
59
-            add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10);
60
-            add_filter(
61
-                'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
62
-                array($this, 'caf_payment_methods')
63
-            );
64
-            // caffeinated constructed
65
-            do_action('AHEE__EE_Brewing_Regular__construct__complete');
66
-            //seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer
67
-            add_filter('FHEE__ee_show_affiliate_links', '__return_false');
68
-        }
69
-    }
70
-
71
-
72
-
73
-    /**
74
-     * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths
75
-     *
76
-     * @param array $paths original helper paths array
77
-     * @return array             new array of paths
78
-     */
79
-    public function caf_helper_paths($paths)
80
-    {
81
-        $paths[] = EE_CAF_CORE . 'helpers' . DS;
82
-        return $paths;
83
-    }
84
-
85
-
86
-
87
-    /**
88
-     * Upon brand-new activation, if this is a new activation of CAF, we want to add
89
-     * some global prices that will show off EE4's capabilities. However, if they're upgrading
90
-     * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices.
91
-     * This action should only be called when EE 4.x.0.P is initially activated.
92
-     * Right now the only CAF content are these global prices. If there's more in the future, then
93
-     * we should probably create a caf file to contain it all instead just a function like this.
94
-     * Right now, we ASSUME the only price types in the system are default ones
95
-     *
96
-     * @global wpdb $wpdb
97
-     */
98
-    public function initialize_caf_db_content()
99
-    {
100
-        global $wpdb;
101
-        //use same method of getting creator id as the version introducing the change
102
-        $default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
103
-        $price_type_table = $wpdb->prefix . "esp_price_type";
104
-        $price_table = $wpdb->prefix . "esp_price";
105
-        if ($this->_get_table_analysis()->tableExists($price_type_table)) {
106
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';//include trashed price types
107
-            $tax_price_type_count = $wpdb->get_var($SQL);
108
-            if ($tax_price_type_count <= 1) {
109
-                $wpdb->insert(
110
-                    $price_type_table,
111
-                    array(
112
-                        'PRT_name'       => __("Regional Tax", "event_espresso"),
113
-                        'PBT_ID'         => 4,
114
-                        'PRT_is_percent' => true,
115
-                        'PRT_order'      => 60,
116
-                        'PRT_deleted'    => false,
117
-                        'PRT_wp_user'    => $default_creator_id,
118
-                    ),
119
-                    array(
120
-                        '%s',//PRT_name
121
-                        '%d',//PBT_id
122
-                        '%d',//PRT_is_percent
123
-                        '%d',//PRT_order
124
-                        '%d',//PRT_deleted
125
-                        '%d', //PRT_wp_user
126
-                    )
127
-                );
128
-                //federal tax
129
-                $result = $wpdb->insert(
130
-                    $price_type_table,
131
-                    array(
132
-                        'PRT_name'       => __("Federal Tax", "event_espresso"),
133
-                        'PBT_ID'         => 4,
134
-                        'PRT_is_percent' => true,
135
-                        'PRT_order'      => 70,
136
-                        'PRT_deleted'    => false,
137
-                        'PRT_wp_user'    => $default_creator_id,
138
-                    ),
139
-                    array(
140
-                        '%s',//PRT_name
141
-                        '%d',//PBT_id
142
-                        '%d',//PRT_is_percent
143
-                        '%d',//PRT_order
144
-                        '%d',//PRT_deleted
145
-                        '%d' //PRT_wp_user
146
-                    )
147
-                );
148
-                if ($result) {
149
-                    $wpdb->insert(
150
-                        $price_table,
151
-                        array(
152
-                            'PRT_ID'         => $wpdb->insert_id,
153
-                            'PRC_amount'     => 15.00,
154
-                            'PRC_name'       => __("Sales Tax", "event_espresso"),
155
-                            'PRC_desc'       => '',
156
-                            'PRC_is_default' => true,
157
-                            'PRC_overrides'  => null,
158
-                            'PRC_deleted'    => false,
159
-                            'PRC_order'      => 50,
160
-                            'PRC_parent'     => null,
161
-                            'PRC_wp_user'    => $default_creator_id,
162
-                        ),
163
-                        array(
164
-                            '%d',//PRT_id
165
-                            '%f',//PRC_amount
166
-                            '%s',//PRC_name
167
-                            '%s',//PRC_desc
168
-                            '%d',//PRC_is_default
169
-                            '%d',//PRC_overrides
170
-                            '%d',//PRC_deleted
171
-                            '%d',//PRC_order
172
-                            '%d',//PRC_parent
173
-                            '%d' //PRC_wp_user
174
-                        )
175
-                    );
176
-                }
177
-            }
178
-        }
179
-    }
180
-
181
-
182
-
183
-    /**
184
-     *    caffeinated_modules_to_register
185
-     *
186
-     * @access public
187
-     * @param array $modules_to_register
188
-     * @return array
189
-     */
190
-    public function caffeinated_modules_to_register($modules_to_register = array())
191
-    {
192
-        if (is_readable(EE_CAFF_PATH . 'modules')) {
193
-            $caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules' . DS . '*', GLOB_ONLYDIR);
194
-            if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
195
-                $modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
196
-            }
197
-        }
198
-        return $modules_to_register;
199
-    }
200
-
201
-
202
-
203
-    public function caffeinated_init()
204
-    {
205
-        // EE_Register_CPTs hooks
206
-        add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array($this, 'filter_taxonomies'), 10);
207
-        add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array($this, 'filter_cpts'), 10);
208
-        add_filter('FHEE__EE_Admin__get_extra_nav_menu_pages_items', array($this, 'nav_metabox_items'), 10);
209
-        EE_Registry::instance()->load_file(EE_CAFF_PATH, 'EE_Caf_Messages', 'class', array(), false);
210
-        // caffeinated_init__complete hook
211
-        do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete');
212
-    }
213
-
214
-
215
-
216
-    public function enqueue_caffeinated_scripts()
217
-    {
218
-        // sound of crickets...
219
-    }
220
-
221
-
222
-
223
-    /**
224
-     * callbacks below here
225
-     *
226
-     * @param array $taxonomy_array
227
-     * @return array
228
-     */
229
-    public function filter_taxonomies(array $taxonomy_array)
230
-    {
231
-        $taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true;
232
-        return $taxonomy_array;
233
-    }
234
-
235
-
236
-
237
-    /**
238
-     * @param array $cpt_array
239
-     * @return mixed
240
-     */
241
-    public function filter_cpts(array $cpt_array)
242
-    {
243
-        $cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true;
244
-        return $cpt_array;
245
-    }
246
-
247
-
248
-
249
-    /**
250
-     * @param array $menuitems
251
-     * @return array
252
-     */
253
-    public function nav_metabox_items(array $menuitems)
254
-    {
255
-        $menuitems[] = array(
256
-            'title'       => __('Venue List', 'event_espresso'),
257
-            'url'         => get_post_type_archive_link('espresso_venues'),
258
-            'description' => __('Archive page for all venues.', 'event_espresso'),
259
-        );
260
-        return $menuitems;
261
-    }
262
-
263
-
264
-
265
-    /**
266
-     * Adds the payment methods in {event-espresso-core}/caffeinated/payment_methods
267
-     *
268
-     * @param array $payment_method_paths
269
-     * @return array values are folder paths to payment method folders
270
-     */
271
-    public function caf_payment_methods($payment_method_paths)
272
-    {
273
-        $caf_payment_methods_paths = glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
274
-        $payment_method_paths = array_merge($payment_method_paths, $caf_payment_methods_paths);
275
-        return $payment_method_paths;
276
-    }
277
-
278
-
279
-
280
-    /**
281
-     * Gets the injected table analyzer, or throws an exception
282
-     *
283
-     * @return TableAnalysis
284
-     * @throws \EE_Error
285
-     */
286
-    protected function _get_table_analysis()
287
-    {
288
-        if ($this->_table_analysis instanceof TableAnalysis) {
289
-            return $this->_table_analysis;
290
-        } else {
291
-            throw new \EE_Error(
292
-                sprintf(
293
-                    __('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
294
-                    get_class($this)
295
-                )
296
-            );
297
-        }
298
-    }
32
+	/**
33
+	 * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
34
+	 */
35
+	protected $_table_analysis;
36
+
37
+
38
+
39
+	/**
40
+	 * EE_Brewing_Regular constructor.
41
+	 */
42
+	public function __construct(TableAnalysis $table_analysis)
43
+	{
44
+		$this->_table_analysis = $table_analysis;
45
+		if (defined('EE_CAFF_PATH')) {
46
+			// activation
47
+			add_action('AHEE__EEH_Activation__initialize_db_content', array($this, 'initialize_caf_db_content'));
48
+			// load caff init
49
+			add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'caffeinated_init'));
50
+			// remove the "powered by" credit link from receipts and invoices
51
+			add_filter('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', '__return_false');
52
+			// add caffeinated modules
53
+			add_filter(
54
+				'FHEE__EE_Config__register_modules__modules_to_register',
55
+				array($this, 'caffeinated_modules_to_register')
56
+			);
57
+			// load caff scripts
58
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_caffeinated_scripts'), 10);
59
+			add_filter('FHEE__EE_Registry__load_helper__helper_paths', array($this, 'caf_helper_paths'), 10);
60
+			add_filter(
61
+				'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
62
+				array($this, 'caf_payment_methods')
63
+			);
64
+			// caffeinated constructed
65
+			do_action('AHEE__EE_Brewing_Regular__construct__complete');
66
+			//seeing how this is caf, which isn't put on WordPress.org, we can have affiliate links without a disclaimer
67
+			add_filter('FHEE__ee_show_affiliate_links', '__return_false');
68
+		}
69
+	}
70
+
71
+
72
+
73
+	/**
74
+	 * callback for the FHEE__EE_Registry__load_helper__helper_paths filter to add the caffeinated paths
75
+	 *
76
+	 * @param array $paths original helper paths array
77
+	 * @return array             new array of paths
78
+	 */
79
+	public function caf_helper_paths($paths)
80
+	{
81
+		$paths[] = EE_CAF_CORE . 'helpers' . DS;
82
+		return $paths;
83
+	}
84
+
85
+
86
+
87
+	/**
88
+	 * Upon brand-new activation, if this is a new activation of CAF, we want to add
89
+	 * some global prices that will show off EE4's capabilities. However, if they're upgrading
90
+	 * from 3.1, or simply EE4.x decaf, we assume they don't want us to suddenly introduce these extra prices.
91
+	 * This action should only be called when EE 4.x.0.P is initially activated.
92
+	 * Right now the only CAF content are these global prices. If there's more in the future, then
93
+	 * we should probably create a caf file to contain it all instead just a function like this.
94
+	 * Right now, we ASSUME the only price types in the system are default ones
95
+	 *
96
+	 * @global wpdb $wpdb
97
+	 */
98
+	public function initialize_caf_db_content()
99
+	{
100
+		global $wpdb;
101
+		//use same method of getting creator id as the version introducing the change
102
+		$default_creator_id = apply_filters('FHEE__EE_DMS_Core_4_5_0__get_default_creator_id', get_current_user_id());
103
+		$price_type_table = $wpdb->prefix . "esp_price_type";
104
+		$price_table = $wpdb->prefix . "esp_price";
105
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
106
+			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table . ' WHERE PBT_ID=4';//include trashed price types
107
+			$tax_price_type_count = $wpdb->get_var($SQL);
108
+			if ($tax_price_type_count <= 1) {
109
+				$wpdb->insert(
110
+					$price_type_table,
111
+					array(
112
+						'PRT_name'       => __("Regional Tax", "event_espresso"),
113
+						'PBT_ID'         => 4,
114
+						'PRT_is_percent' => true,
115
+						'PRT_order'      => 60,
116
+						'PRT_deleted'    => false,
117
+						'PRT_wp_user'    => $default_creator_id,
118
+					),
119
+					array(
120
+						'%s',//PRT_name
121
+						'%d',//PBT_id
122
+						'%d',//PRT_is_percent
123
+						'%d',//PRT_order
124
+						'%d',//PRT_deleted
125
+						'%d', //PRT_wp_user
126
+					)
127
+				);
128
+				//federal tax
129
+				$result = $wpdb->insert(
130
+					$price_type_table,
131
+					array(
132
+						'PRT_name'       => __("Federal Tax", "event_espresso"),
133
+						'PBT_ID'         => 4,
134
+						'PRT_is_percent' => true,
135
+						'PRT_order'      => 70,
136
+						'PRT_deleted'    => false,
137
+						'PRT_wp_user'    => $default_creator_id,
138
+					),
139
+					array(
140
+						'%s',//PRT_name
141
+						'%d',//PBT_id
142
+						'%d',//PRT_is_percent
143
+						'%d',//PRT_order
144
+						'%d',//PRT_deleted
145
+						'%d' //PRT_wp_user
146
+					)
147
+				);
148
+				if ($result) {
149
+					$wpdb->insert(
150
+						$price_table,
151
+						array(
152
+							'PRT_ID'         => $wpdb->insert_id,
153
+							'PRC_amount'     => 15.00,
154
+							'PRC_name'       => __("Sales Tax", "event_espresso"),
155
+							'PRC_desc'       => '',
156
+							'PRC_is_default' => true,
157
+							'PRC_overrides'  => null,
158
+							'PRC_deleted'    => false,
159
+							'PRC_order'      => 50,
160
+							'PRC_parent'     => null,
161
+							'PRC_wp_user'    => $default_creator_id,
162
+						),
163
+						array(
164
+							'%d',//PRT_id
165
+							'%f',//PRC_amount
166
+							'%s',//PRC_name
167
+							'%s',//PRC_desc
168
+							'%d',//PRC_is_default
169
+							'%d',//PRC_overrides
170
+							'%d',//PRC_deleted
171
+							'%d',//PRC_order
172
+							'%d',//PRC_parent
173
+							'%d' //PRC_wp_user
174
+						)
175
+					);
176
+				}
177
+			}
178
+		}
179
+	}
180
+
181
+
182
+
183
+	/**
184
+	 *    caffeinated_modules_to_register
185
+	 *
186
+	 * @access public
187
+	 * @param array $modules_to_register
188
+	 * @return array
189
+	 */
190
+	public function caffeinated_modules_to_register($modules_to_register = array())
191
+	{
192
+		if (is_readable(EE_CAFF_PATH . 'modules')) {
193
+			$caffeinated_modules_to_register = glob(EE_CAFF_PATH . 'modules' . DS . '*', GLOB_ONLYDIR);
194
+			if (is_array($caffeinated_modules_to_register) && ! empty($caffeinated_modules_to_register)) {
195
+				$modules_to_register = array_merge($modules_to_register, $caffeinated_modules_to_register);
196
+			}
197
+		}
198
+		return $modules_to_register;
199
+	}
200
+
201
+
202
+
203
+	public function caffeinated_init()
204
+	{
205
+		// EE_Register_CPTs hooks
206
+		add_filter('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array($this, 'filter_taxonomies'), 10);
207
+		add_filter('FHEE__EE_Register_CPTs__get_CPTs__cpts', array($this, 'filter_cpts'), 10);
208
+		add_filter('FHEE__EE_Admin__get_extra_nav_menu_pages_items', array($this, 'nav_metabox_items'), 10);
209
+		EE_Registry::instance()->load_file(EE_CAFF_PATH, 'EE_Caf_Messages', 'class', array(), false);
210
+		// caffeinated_init__complete hook
211
+		do_action('AHEE__EE_Brewing_Regular__caffeinated_init__complete');
212
+	}
213
+
214
+
215
+
216
+	public function enqueue_caffeinated_scripts()
217
+	{
218
+		// sound of crickets...
219
+	}
220
+
221
+
222
+
223
+	/**
224
+	 * callbacks below here
225
+	 *
226
+	 * @param array $taxonomy_array
227
+	 * @return array
228
+	 */
229
+	public function filter_taxonomies(array $taxonomy_array)
230
+	{
231
+		$taxonomy_array['espresso_venue_categories']['args']['show_in_nav_menus'] = true;
232
+		return $taxonomy_array;
233
+	}
234
+
235
+
236
+
237
+	/**
238
+	 * @param array $cpt_array
239
+	 * @return mixed
240
+	 */
241
+	public function filter_cpts(array $cpt_array)
242
+	{
243
+		$cpt_array['espresso_venues']['args']['show_in_nav_menus'] = true;
244
+		return $cpt_array;
245
+	}
246
+
247
+
248
+
249
+	/**
250
+	 * @param array $menuitems
251
+	 * @return array
252
+	 */
253
+	public function nav_metabox_items(array $menuitems)
254
+	{
255
+		$menuitems[] = array(
256
+			'title'       => __('Venue List', 'event_espresso'),
257
+			'url'         => get_post_type_archive_link('espresso_venues'),
258
+			'description' => __('Archive page for all venues.', 'event_espresso'),
259
+		);
260
+		return $menuitems;
261
+	}
262
+
263
+
264
+
265
+	/**
266
+	 * Adds the payment methods in {event-espresso-core}/caffeinated/payment_methods
267
+	 *
268
+	 * @param array $payment_method_paths
269
+	 * @return array values are folder paths to payment method folders
270
+	 */
271
+	public function caf_payment_methods($payment_method_paths)
272
+	{
273
+		$caf_payment_methods_paths = glob(EE_CAF_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
274
+		$payment_method_paths = array_merge($payment_method_paths, $caf_payment_methods_paths);
275
+		return $payment_method_paths;
276
+	}
277
+
278
+
279
+
280
+	/**
281
+	 * Gets the injected table analyzer, or throws an exception
282
+	 *
283
+	 * @return TableAnalysis
284
+	 * @throws \EE_Error
285
+	 */
286
+	protected function _get_table_analysis()
287
+	{
288
+		if ($this->_table_analysis instanceof TableAnalysis) {
289
+			return $this->_table_analysis;
290
+		} else {
291
+			throw new \EE_Error(
292
+				sprintf(
293
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
294
+					get_class($this)
295
+				)
296
+			);
297
+		}
298
+	}
299 299
 }
300 300
 
301 301
 
302 302
 
303 303
 $brewing = new EE_Brewing_Regular(
304
-    EE_Registry::instance()->create('TableAnalysis', array(), true)
304
+	EE_Registry::instance()->create('TableAnalysis', array(), true)
305 305
 );
306 306
\ No newline at end of file
Please login to merge, or discard this patch.
admin_pages/messages/templates/ee_msg_messages_help_tab.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,3 +1,3 @@
 block discarded – undo
1 1
 <h2><?php esc_html_e('What is the Event Espresso Messages System?', 'event_espresso'); ?></h2>
2
-<p><?php printf( esc_html__('The Event Espresso Messages system is a powerful framework that Event Espresso uses to prepare %1$smessages%2$s for different types of use (message types) and delivered by different %1$smessengers%2$s.', 'event_espresso'), '<strong>', '</strong>' ); ?></p>
2
+<p><?php printf(esc_html__('The Event Espresso Messages system is a powerful framework that Event Espresso uses to prepare %1$smessages%2$s for different types of use (message types) and delivered by different %1$smessengers%2$s.', 'event_espresso'), '<strong>', '</strong>'); ?></p>
3 3
 <p><?php esc_html_e('We\'ve intentionally created this framework so that we have as much flexibility as possible for future ideas that we think of (or customers think of) for the kinds of messages that get sent out related to your events.', 'event_espresso'); ?></p>
4 4
\ No newline at end of file
Please login to merge, or discard this patch.
messages/defaults/default/email_payment_cancelled_content.template.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,35 +31,35 @@  discard block
 block discarded – undo
31 31
 						<tbody>
32 32
 							<tr>
33 33
 								<td>
34
-									<h2><?php printf( esc_html__( 'Hello, %s:', 'event_espresso' ), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]' ); ?></h2>
35
-									<p class="lead"><?php printf( esc_html__( 'Your payment was %1$sCANCELLED%2$s for the following transaction and ticket purchases:', 'event_espresso' ), '<strong>', '</strong>'); ?></p>
36
-									<h3><?php esc_html_e( 'Payment Details:', 'event_espresso' ); ?></h3>
34
+									<h2><?php printf(esc_html__('Hello, %s:', 'event_espresso'), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]'); ?></h2>
35
+									<p class="lead"><?php printf(esc_html__('Your payment was %1$sCANCELLED%2$s for the following transaction and ticket purchases:', 'event_espresso'), '<strong>', '</strong>'); ?></p>
36
+									<h3><?php esc_html_e('Payment Details:', 'event_espresso'); ?></h3>
37 37
 									<ul>
38 38
 										<li>
39
-											<strong><?php esc_html_e( 'Payment Status:', 'event_espresso' ); ?></strong> [PAYMENT_STATUS]
39
+											<strong><?php esc_html_e('Payment Status:', 'event_espresso'); ?></strong> [PAYMENT_STATUS]
40 40
 										</li>
41 41
 										<li>
42
-											<strong><?php esc_html_e( 'Transaction ID:', 'event_espresso' ); ?></strong> [TXN_ID]
42
+											<strong><?php esc_html_e('Transaction ID:', 'event_espresso'); ?></strong> [TXN_ID]
43 43
 										</li>
44 44
 										<li>
45
-											<strong><?php esc_html_e( 'Total Cost:', 'event_espresso' ); ?></strong> [TOTAL_COST]
45
+											<strong><?php esc_html_e('Total Cost:', 'event_espresso'); ?></strong> [TOTAL_COST]
46 46
 										</li>
47 47
 										<li>
48
-											<strong><?php esc_html_e( 'Payment Method:', 'event_espresso' ); ?></strong> [PAYMENT_GATEWAY]
48
+											<strong><?php esc_html_e('Payment Method:', 'event_espresso'); ?></strong> [PAYMENT_GATEWAY]
49 49
 										</li>
50 50
 										<li>
51
-											<strong><?php esc_html_e( 'Payment Amount:', 'event_espresso' ); ?></strong> [AMOUNT_PAID]
51
+											<strong><?php esc_html_e('Payment Amount:', 'event_espresso'); ?></strong> [AMOUNT_PAID]
52 52
 										</li>
53 53
 										<li>
54
-											<strong><?php esc_html_e( 'Amount Due:', 'event_espresso' ); ?></strong> [TOTAL_OWING]
54
+											<strong><?php esc_html_e('Amount Due:', 'event_espresso'); ?></strong> [TOTAL_OWING]
55 55
 										</li>
56 56
 									</ul>
57 57
 									<p class="callout">
58
-										<?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?>
58
+										<?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?>
59 59
 									</p>
60 60
 									[EVENT_LIST]
61 61
 									<p class="callout">
62
-										<?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?>
62
+										<?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?>
63 63
 									</p>
64 64
 								</td>
65 65
 							</tr>
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
 									<tbody>
85 85
 										<tr>
86 86
 											<td>
87
-												<h3><?php esc_html_e( 'Connect with Us:', 'event_espresso' ); ?></h3>
88
-												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e( 'Facebook', 'event_espresso' ); ?></a>
89
-												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e( 'Twitter', 'event_espresso' ); ?></a>
90
-												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e( 'Google+', 'event_espresso' ); ?></a>
87
+												<h3><?php esc_html_e('Connect with Us:', 'event_espresso'); ?></h3>
88
+												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e('Facebook', 'event_espresso'); ?></a>
89
+												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e('Twitter', 'event_espresso'); ?></a>
90
+												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e('Google+', 'event_espresso'); ?></a>
91 91
 											</td>
92 92
 										</tr>
93 93
 									</tbody>
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 									<tbody>
98 98
 										<tr>
99 99
 											<td>
100
-												<h3><?php esc_html_e( 'Contact Info:', 'event_espresso' ); ?></h3>
101
-												<?php esc_html_e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong>
102
-												<?php esc_html_e( 'Email:', 'event_espresso' ); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong>
100
+												<h3><?php esc_html_e('Contact Info:', 'event_espresso'); ?></h3>
101
+												<?php esc_html_e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong>
102
+												<?php esc_html_e('Email:', 'event_espresso'); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong>
103 103
 											</td>
104 104
 										</tr>
105 105
 									</tbody>
Please login to merge, or discard this patch.
messages/defaults/default/email_payment_declined_content.template.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,35 +31,35 @@  discard block
 block discarded – undo
31 31
 						<tbody>
32 32
 							<tr>
33 33
 								<td>
34
-									<h2><?php printf( esc_html__( 'Hello, %s:', 'event_espresso' ), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]' ); ?></h2>
35
-									<p class="lead"><?php printf( esc_html__( 'Your payment was %1$sDECLINED%2$s for the following transaction and ticket purchases:', 'event_espresso' ), '<strong>', '</strong>') ?></p>
36
-									<h3><?php esc_html_e( 'Payment Details:', 'event_espresso' ); ?></h3>
34
+									<h2><?php printf(esc_html__('Hello, %s:', 'event_espresso'), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]'); ?></h2>
35
+									<p class="lead"><?php printf(esc_html__('Your payment was %1$sDECLINED%2$s for the following transaction and ticket purchases:', 'event_espresso'), '<strong>', '</strong>') ?></p>
36
+									<h3><?php esc_html_e('Payment Details:', 'event_espresso'); ?></h3>
37 37
 									<ul>
38 38
 										<li>
39
-											<strong><?php esc_html_e( 'Payment Status:', 'event_espresso' ); ?></strong> [PAYMENT_STATUS]
39
+											<strong><?php esc_html_e('Payment Status:', 'event_espresso'); ?></strong> [PAYMENT_STATUS]
40 40
 										</li>
41 41
 										<li>
42
-											<strong><?php esc_html_e( 'Transaction ID:', 'event_espresso' ); ?></strong> [TXN_ID]
42
+											<strong><?php esc_html_e('Transaction ID:', 'event_espresso'); ?></strong> [TXN_ID]
43 43
 										</li>
44 44
 										<li>
45
-											<strong><?php esc_html_e( 'Total Cost:', 'event_espresso' ); ?></strong> [TOTAL_COST]
45
+											<strong><?php esc_html_e('Total Cost:', 'event_espresso'); ?></strong> [TOTAL_COST]
46 46
 										</li>
47 47
 										<li>
48
-											<strong><?php esc_html_e( 'Payment Method:', 'event_espresso' ); ?></strong> [PAYMENT_GATEWAY]
48
+											<strong><?php esc_html_e('Payment Method:', 'event_espresso'); ?></strong> [PAYMENT_GATEWAY]
49 49
 										</li>
50 50
 										<li>
51
-											<strong><?php esc_html_e( 'Payment Amount:', 'event_espresso' ); ?></strong> [AMOUNT_PAID]
51
+											<strong><?php esc_html_e('Payment Amount:', 'event_espresso'); ?></strong> [AMOUNT_PAID]
52 52
 										</li>
53 53
 										<li>
54
-											<strong><?php esc_html_e( 'Amount Due:', 'event_espresso' ); ?></strong> [TOTAL_OWING]
54
+											<strong><?php esc_html_e('Amount Due:', 'event_espresso'); ?></strong> [TOTAL_OWING]
55 55
 										</li>
56 56
 									</ul>
57 57
 									<p class="callout">
58
-										<?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?>
58
+										<?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?>
59 59
 									</p>
60 60
 									[EVENT_LIST]
61 61
 									<p class="callout">
62
-										<?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?>
62
+										<?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?>
63 63
 									</p>
64 64
 								</td>
65 65
 							</tr>
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
 									<tbody>
85 85
 										<tr>
86 86
 											<td>
87
-												<h3><?php esc_html_e( 'Connect with Us:', 'event_espresso' ); ?></h3>
88
-												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e( 'Facebook', 'event_espresso' ); ?></a>
89
-												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e( 'Twitter', 'event_espresso' ); ?></a>
90
-												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e( 'Google+', 'event_espresso' ); ?></a>
87
+												<h3><?php esc_html_e('Connect with Us:', 'event_espresso'); ?></h3>
88
+												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e('Facebook', 'event_espresso'); ?></a>
89
+												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e('Twitter', 'event_espresso'); ?></a>
90
+												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e('Google+', 'event_espresso'); ?></a>
91 91
 											</td>
92 92
 										</tr>
93 93
 									</tbody>
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 									<tbody>
98 98
 										<tr>
99 99
 											<td>
100
-												<h3><?php esc_html_e( 'Contact Info:', 'event_espresso' ); ?></h3>
101
-												<?php esc_html_e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong>
102
-												<?php esc_html_e( 'Email:', 'event_espresso' ); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong>
100
+												<h3><?php esc_html_e('Contact Info:', 'event_espresso'); ?></h3>
101
+												<?php esc_html_e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong>
102
+												<?php esc_html_e('Email:', 'event_espresso'); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong>
103 103
 											</td>
104 104
 										</tr>
105 105
 									</tbody>
Please login to merge, or discard this patch.
core/EE_Data_Migration_Manager.core.php 4 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 use EventEspresso\core\interfaces\ResettableInterface;
3
-
4 3
 use EventEspresso\core\services\database\TableManager;
5 4
 use EventEspresso\core\services\database\TableAnalysis;
6 5
 
Please login to merge, or discard this patch.
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
 	protected $_table_analysis;
128 128
 
129 129
 	/**
130
-     * 	@var EE_Data_Migration_Manager $_instance
130
+	 * 	@var EE_Data_Migration_Manager $_instance
131 131
 	 * 	@access 	private
132
-     */
132
+	 */
133 133
 	private static $_instance = NULL;
134 134
 
135 135
 
@@ -720,18 +720,18 @@  discard block
 block discarded – undo
720 720
 
721 721
 
722 722
 
723
-    /**
724
-     * Gets all the data migration scripts available in the core folder and folders
725
-     * in addons. Has the side effect of adding them for autoloading
726
-     *
727
-     * @return array keys are expected classnames, values are their filepaths
728
-     * @throws \EE_Error
729
-     */
723
+	/**
724
+	 * Gets all the data migration scripts available in the core folder and folders
725
+	 * in addons. Has the side effect of adding them for autoloading
726
+	 *
727
+	 * @return array keys are expected classnames, values are their filepaths
728
+	 * @throws \EE_Error
729
+	 */
730 730
 	public function get_all_data_migration_scripts_available(){
731 731
 		if( ! $this->_data_migration_class_to_filepath_map){
732 732
 			$this->_data_migration_class_to_filepath_map = array();
733 733
 			foreach($this->get_data_migration_script_folders() as $folder_path){
734
-                $folder_path = EEH_File::end_with_directory_separator($folder_path);
734
+				$folder_path = EEH_File::end_with_directory_separator($folder_path);
735 735
 				$files = glob( $folder_path. '*.dms.php' );
736 736
 
737 737
 				if ( empty( $files ) ) {
@@ -748,15 +748,15 @@  discard block
 block discarded – undo
748 748
 					if( $slug !== 'Core' ){
749 749
 						if( ! EE_Registry::instance()->get_addon_by_name( $slug ) ) {
750 750
 							EE_Error::doing_it_wrong(
751
-							    __FUNCTION__,
752
-                                sprintf(
753
-                                    __( 'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso' ),
754
-                                    $classname,
755
-                                    $slug,
756
-                                    implode(', ', array_keys( EE_Registry::instance()->get_addons_by_name() ) )
757
-                                ),
758
-                                '4.3.0.alpha.019'
759
-                            );
751
+								__FUNCTION__,
752
+								sprintf(
753
+									__( 'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso' ),
754
+									$classname,
755
+									$slug,
756
+									implode(', ', array_keys( EE_Registry::instance()->get_addons_by_name() ) )
757
+								),
758
+								'4.3.0.alpha.019'
759
+							);
760 760
 						}
761 761
 					}
762 762
 					$this->_data_migration_class_to_filepath_map[$classname] = $file;
@@ -939,12 +939,12 @@  discard block
 block discarded – undo
939 939
 	}
940 940
 
941 941
 /**
942
-	 * Resets the borked data migration scripts so they're no longer borked
943
-	 * so we can again attempt to migrate
944
-	 *
945
-	 * @return bool
946
-	 * @throws \EE_Error
947
-	 */
942
+ * Resets the borked data migration scripts so they're no longer borked
943
+ * so we can again attempt to migrate
944
+ *
945
+ * @return bool
946
+ * @throws \EE_Error
947
+ */
948 948
 	public function reattempt(){
949 949
 		//find if the last-ran script was borked
950 950
 		//set it as being non-borked (we shouldn't ever get DMSs that we don't recognize)
Please login to merge, or discard this patch.
Braces   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			//it's 4.2-style.eg Core.4.1.0
209 209
 			$plugin_slug = $parts[0];//eg Core
210 210
 			$version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0
211
-		}else{
211
+		} else{
212 212
 			//it's 4.1-style: eg 4.1.0
213 213
 			$plugin_slug = 'Core';
214 214
 			$version_string = $plugin_slug_and_version_string;//eg 4.1.0
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 			if($class instanceof EE_Data_Migration_Script_Base){
232 232
 				$class->instantiate_from_array_of_properties($data_migration_data);
233 233
 				return $class;
234
-			}else{
234
+			} else{
235 235
 				//huh, so its an object but not a data migration script?? that shouldn't happen
236 236
 				//just leave it as an array (which will probably just get ignored)
237 237
 				throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class']));
238 238
 			}
239
-		}else{
239
+		} else{
240 240
 			//so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists
241 241
 			throw new EE_Error(sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name));
242 242
 		}
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 						//sometimes we also like to know which was the last incomplete script (or if there are any at all)
267 267
 						$this->_last_ran_incomplete_script = $class;
268 268
 					}
269
-				}catch(EE_Error $e){
269
+				} catch(EE_Error $e){
270 270
 					//ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs
271 271
 					$data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']);
272 272
 				}
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 				//so we want the data migrations to happen. SO, we're going to say the DB is at that state
368 368
 //				echo "4.1.0 is greater than $previous_version_installed! update the option";
369 369
 				$db_state = array('Core'=>$previous_version_installed);
370
-			}else{
370
+			} else{
371 371
 //					echo "4.1.0 is SMALLER than $previous_version_installed";
372 372
 					$db_state = array('Core'=>EVENT_ESPRESSO_VERSION);
373 373
 			}
@@ -435,10 +435,10 @@  discard block
 block discarded – undo
435 435
 						$migrates_to_version = $script->migrates_to_version();
436 436
 						$next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ];
437 437
 						unset($script_class_and_filepaths_available[$classname]);
438
-					}else{
438
+					} else{
439 439
 						//it must have a status that indicates it has finished, so we don't want to try and run it again
440 440
 					}
441
-				}else{
441
+				} else{
442 442
 					//it exists but it's not  a proper data migration script
443 443
 					//maybe the script got renamed? or was simply removed from EE?
444 444
 					//either way, its certainly not runnable!
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 		}
479 479
 		if($include_completed_scripts){
480 480
 			return $this->_last_ran_script;
481
-		}else{
481
+		} else{
482 482
 			return $this->_last_ran_incomplete_script;
483 483
 		}
484 484
 	}
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 				$this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script;
540 540
 			}
541 541
 			$current_script_name = get_class($currently_executing_script);
542
-		}catch(Exception $e){
542
+		} catch(Exception $e){
543 543
 			//an exception occurred while trying to get migration scripts
544 544
 
545 545
 			$message =  sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() );
@@ -604,14 +604,14 @@  discard block
 block discarded – undo
604 604
 					);
605 605
 					break;
606 606
 			}
607
-		}catch(Exception $e){
607
+		} catch(Exception $e){
608 608
 			//ok so some exception was thrown which killed the data migration script
609 609
 			//double-check we have a real script
610 610
 			if($currently_executing_script instanceof EE_Data_Migration_Script_Base){
611 611
 				$script_name = $currently_executing_script->pretty_name();
612 612
 				$currently_executing_script->set_broken();
613 613
 				$currently_executing_script->add_error($e->getMessage());
614
-			}else{
614
+			} else{
615 615
 				$script_name = __("Error getting Migration Script", "event_espresso");
616 616
 			}
617 617
 			$response_array = array(
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 		ob_start();
655 655
 		try{
656 656
 			$response = $this->migration_step();
657
-		}catch(Exception $e){
657
+		} catch(Exception $e){
658 658
 			$response = array(
659 659
 				'records_to_migrate'=>0,
660 660
 				'records_migrated'=>0,
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 		$current_database_state = get_option(self::current_database_state);
704 704
 		if( ! isset( $current_database_state[ $slug ] ) ) {
705 705
 			return true;
706
-		}else{
706
+		} else{
707 707
 			//just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes
708 708
 			$version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3);
709 709
 			$version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 );
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 			//ok then just add this error to its list of errors
804 804
 			$last_ran_migration_script_properties['_errors'][] = $error_message;
805 805
 			$last_ran_migration_script_properties['_status'] = self::status_fatal_error;
806
-		}else{
806
+		} else{
807 807
 			//so we don't even know which script was last running
808 808
 			//use the data migration error stub, which is designed specifically for this type of thing
809 809
 			$general_migration_error = new EE_DMS_Unknown_1_0_0();
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 					if( $old_option_value != $script_array_for_saving){
840 840
 						$successful_updates = update_option($option_name,$script_array_for_saving);
841 841
 					}
842
-				}else{//we don't know what this array-thing is. So just save it as-is
842
+				} else{//we don't know what this array-thing is. So just save it as-is
843 843
 	//				$array_of_migrations[$version_string] = $array_or_migration_obj;
844 844
 					if($old_option_value != $array_or_migration_obj){
845 845
 						$successful_updates = update_option($option_name,$array_or_migration_obj);
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
 				}
907 907
 				//if it wasn't for core, we must keep searching for one that is!
908 908
 				continue;
909
-			}else{
909
+			} else{
910 910
 				$champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname);
911 911
 				$contender_migrates_to = $this->script_migrates_to_version($classname);
912 912
 				if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 		$migrations_ran = $this->get_data_migrations_ran();
934 934
 		if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){
935 935
 			return $migrations_ran[ $plugin_slug ][ $version ];
936
-		}else{
936
+		} else{
937 937
 			return NULL;
938 938
 		}
939 939
 	}
@@ -955,9 +955,9 @@  discard block
 block discarded – undo
955 955
 		if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){
956 956
 			//if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it)
957 957
 			$last_ran_script->set_completed();
958
-		}elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) {
958
+		} elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) {
959 959
 			$last_ran_script->reattempt();
960
-		}else{
960
+		} else{
961 961
 			throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script, true ) ) );
962 962
 		}
963 963
 		return $this->_save_migrations_ran();
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 			if( ! $most_up_to_date_dms ) {
996 996
 				//if there is NO DMS for this plugin, obviously there's no schema to verify anyways
997 997
 				$verify_db = false;
998
-			}else{
998
+			} else{
999 999
 				$most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms );
1000 1000
 				$verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to );
1001 1001
 			}
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 						false,
1005 1005
 						$verify_db
1006 1006
 					);
1007
-			}else{
1007
+			} else{
1008 1008
 				//just loop through the addons to make sure their database is setup
1009 1009
 				foreach( EE_Registry::instance()->addons as $addon ) {
1010 1010
 					if( $addon->name() == $plugin_slug ) {
Please login to merge, or discard this patch.
Spacing   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * of this EE installation. Keys should be the name of the version the script upgraded to
83 83
 	 * @var EE_Data_Migration_Script_Base[]
84 84
 	 */
85
-	private $_data_migrations_ran =null;
85
+	private $_data_migrations_ran = null;
86 86
 	/**
87 87
 	 * The last ran script. It's nice to store this somewhere accessible, as its easiest
88 88
 	 * to know which was the last run by which is the newest wp option; but in most of the code
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	public static function instance() {
144 144
 		// check if class object is instantiated
145
-		if ( ! self::$_instance instanceof EE_Data_Migration_Manager ) {
145
+		if ( ! self::$_instance instanceof EE_Data_Migration_Manager) {
146 146
 			self::$_instance = new self();
147 147
 		}
148 148
 		return self::$_instance;
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * all new usages of the singleton should be made with Classname::instance()) and returns it
153 153
 	 * @return EE_Data_Migration_Manager
154 154
 	 */
155
-	public static function reset(){
155
+	public static function reset() {
156 156
 		self::$_instance = NULL;
157 157
 		return self::instance();
158 158
 	}
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	/**
163 163
 	 * constructor
164 164
 	 */
165
-	private function __construct(){
165
+	private function __construct() {
166 166
 		$this->stati_that_indicate_to_continue_migrations = array(
167 167
 			self::status_continue,
168 168
 			self::status_completed
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
 		);
182 182
 		//make sure we've included the base migration script, because we may need the EE_DMS_Unknown_1_0_0 class
183 183
 		//to be defined, because right now it doesn't get autoloaded on its own
184
-		EE_Registry::instance()->load_core( 'Data_Migration_Class_Base', array(), TRUE );
185
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Base', array(), TRUE );
186
-		EE_Registry::instance()->load_core( 'DMS_Unknown_1_0_0', array(), TRUE );
187
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage', array(), TRUE );
188
-		EE_Registry::instance()->load_core( 'Data_Migration_Script_Stage_Table', array(), TRUE );
189
-		$this->_table_manager = EE_Registry::instance()->create( 'TableManager', array(), true );
190
-		$this->_table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true );
184
+		EE_Registry::instance()->load_core('Data_Migration_Class_Base', array(), TRUE);
185
+		EE_Registry::instance()->load_core('Data_Migration_Script_Base', array(), TRUE);
186
+		EE_Registry::instance()->load_core('DMS_Unknown_1_0_0', array(), TRUE);
187
+		EE_Registry::instance()->load_core('Data_Migration_Script_Stage', array(), TRUE);
188
+		EE_Registry::instance()->load_core('Data_Migration_Script_Stage_Table', array(), TRUE);
189
+		$this->_table_manager = EE_Registry::instance()->create('TableManager', array(), true);
190
+		$this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
191 191
 	}
192 192
 
193 193
 
@@ -200,21 +200,21 @@  discard block
 block discarded – undo
200 200
 	 * @param string $option_name (see EE_Data_Migration_Manage::_save_migrations_ran() where the option name is set)
201 201
 	 * @return array where the first item is the plugin slug (eg 'Core','Calendar',etc) and the 2nd is the version of that plugin (eg '4.1.0')
202 202
 	 */
203
-	private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name){
203
+	private function _get_plugin_slug_and_version_string_from_dms_option_name($option_name) {
204 204
 		$plugin_slug_and_version_string = str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_name);
205 205
 		//check if $plugin_slug_and_version_string is like '4.1.0' (4.1-style) or 'Core.4.1.0' (4.2-style)
206
-		$parts = explode(".",$plugin_slug_and_version_string);
206
+		$parts = explode(".", $plugin_slug_and_version_string);
207 207
 
208
-		if(count($parts) == 4){
208
+		if (count($parts) == 4) {
209 209
 			//it's 4.2-style.eg Core.4.1.0
210
-			$plugin_slug = $parts[0];//eg Core
210
+			$plugin_slug = $parts[0]; //eg Core
211 211
 			$version_string = $parts[1].".".$parts[2].".".$parts[3]; //eg 4.1.0
212
-		}else{
212
+		} else {
213 213
 			//it's 4.1-style: eg 4.1.0
214 214
 			$plugin_slug = 'Core';
215
-			$version_string = $plugin_slug_and_version_string;//eg 4.1.0
215
+			$version_string = $plugin_slug_and_version_string; //eg 4.1.0
216 216
 		}
217
-		return array($plugin_slug,$version_string);
217
+		return array($plugin_slug, $version_string);
218 218
 	}
219 219
 
220 220
 	/**
@@ -225,21 +225,21 @@  discard block
 block discarded – undo
225 225
 	 * @return EE_Data_Migration_Script_Base
226 226
 	 * @throws EE_Error
227 227
 	 */
228
-	private function _get_dms_class_from_wp_option($dms_option_name,$dms_option_value){
228
+	private function _get_dms_class_from_wp_option($dms_option_name, $dms_option_value) {
229 229
 		$data_migration_data = maybe_unserialize($dms_option_value);
230
-		if(isset($data_migration_data['class']) && class_exists($data_migration_data['class'])){
230
+		if (isset($data_migration_data['class']) && class_exists($data_migration_data['class'])) {
231 231
 			$class = new $data_migration_data['class'];
232
-			if($class instanceof EE_Data_Migration_Script_Base){
232
+			if ($class instanceof EE_Data_Migration_Script_Base) {
233 233
 				$class->instantiate_from_array_of_properties($data_migration_data);
234 234
 				return $class;
235
-			}else{
235
+			} else {
236 236
 				//huh, so its an object but not a data migration script?? that shouldn't happen
237 237
 				//just leave it as an array (which will probably just get ignored)
238
-				throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'),$data_migration_data['class']));
238
+				throw new EE_Error(sprintf(__("Trying to retrieve DMS class from wp option. No DMS by the name '%s' exists", 'event_espresso'), $data_migration_data['class']));
239 239
 			}
240
-		}else{
240
+		} else {
241 241
 			//so the data doesn't specify a class. So it must either be a legacy array of info or some array (which we'll probably just ignore), or a class that no longer exists
242
-			throw new EE_Error(sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'),$dms_option_name));
242
+			throw new EE_Error(sprintf(__("The wp option  with key '%s' does not represent a DMS", 'event_espresso'), $dms_option_name));
243 243
 		}
244 244
 	}
245 245
 	/**
@@ -247,34 +247,34 @@  discard block
 block discarded – undo
247 247
 	 * the last ran which hasn't finished yet
248 248
 	 * @return array where each element should be an array of EE_Data_Migration_Script_Base (but also has a few legacy arrays in there - which should probably be ignored)
249 249
 	 */
250
-	public function get_data_migrations_ran(){
251
-		if( ! $this->_data_migrations_ran ){
250
+	public function get_data_migrations_ran() {
251
+		if ( ! $this->_data_migrations_ran) {
252 252
 			//setup autoloaders for each of the scripts in there
253 253
 			$this->get_all_data_migration_scripts_available();
254
-			$data_migrations_options = $this->get_all_migration_script_options();//get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
254
+			$data_migrations_options = $this->get_all_migration_script_options(); //get_option(EE_Data_Migration_Manager::data_migrations_option_name,get_option('espresso_data_migrations',array()));
255 255
 
256 256
 			$data_migrations_ran = array();
257 257
 			//convert into data migration script classes where possible
258
-			foreach($data_migrations_options as $data_migration_option){
259
-				list($plugin_slug,$version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']);
258
+			foreach ($data_migrations_options as $data_migration_option) {
259
+				list($plugin_slug, $version_string) = $this->_get_plugin_slug_and_version_string_from_dms_option_name($data_migration_option['option_name']);
260 260
 
261
-				try{
262
-					$class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'],$data_migration_option['option_value']);
261
+				try {
262
+					$class = $this->_get_dms_class_from_wp_option($data_migration_option['option_name'], $data_migration_option['option_value']);
263 263
 					$data_migrations_ran[$plugin_slug][$version_string] = $class;
264 264
 					//ok so far THIS is the 'last-ran-script'... unless we find another on next iteration
265 265
 					$this->_last_ran_script = $class;
266
-					if( ! $class->is_completed()){
266
+					if ( ! $class->is_completed()) {
267 267
 						//sometimes we also like to know which was the last incomplete script (or if there are any at all)
268 268
 						$this->_last_ran_incomplete_script = $class;
269 269
 					}
270
-				}catch(EE_Error $e){
270
+				} catch (EE_Error $e) {
271 271
 					//ok so its not a DMS. We'll just keep it, although other code will need to expect non-DMSs
272 272
 					$data_migrations_ran[$plugin_slug][$version_string] = maybe_unserialize($data_migration_option['option_value']);
273 273
 				}
274 274
 			}
275 275
 			//so here the array of $data_migrations_ran is actually a mix of classes and a few legacy arrays
276 276
 			$this->_data_migrations_ran = $data_migrations_ran;
277
-			 if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran) ){
277
+			 if ( ! $this->_data_migrations_ran || ! is_array($this->_data_migrations_ran)) {
278 278
 				$this->_data_migrations_ran = array();
279 279
 			}
280 280
 		}
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @param        $new_table
292 292
 	 * @return mixed string or int
293 293
 	 */
294
-	public function get_mapping_new_pk( $script_name, $old_table, $old_pk, $new_table){
294
+	public function get_mapping_new_pk($script_name, $old_table, $old_pk, $new_table) {
295 295
 		$script = EE_Registry::instance()->load_dms($script_name);
296 296
 		$mapping = $script->get_mapping_new_pk($old_table, $old_pk, $new_table);
297 297
 		return $mapping;
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 	 * option returned in this array is the most-recently ran DMS option
303 303
 	 * @return array
304 304
 	 */
305
-	 public function get_all_migration_script_options(){
305
+	 public function get_all_migration_script_options() {
306 306
 		global $wpdb;
307
-		return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC",ARRAY_A);
307
+		return $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id ASC", ARRAY_A);
308 308
 	}
309 309
 
310 310
 	/**
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
 	 * @return array where each value is the full folder path of a folder containing data migration scripts, WITH slashes at the end of the
313 313
 	 * folder name.
314 314
 	 */
315
-	public function get_data_migration_script_folders(){
316
-		return  apply_filters( 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders',array(EE_CORE.'data_migration_scripts') );
315
+	public function get_data_migration_script_folders() {
316
+		return  apply_filters('FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', array(EE_CORE.'data_migration_scripts'));
317 317
 	}
318 318
 
319 319
 	/**
@@ -325,11 +325,11 @@  discard block
 block discarded – undo
325 325
 	 * }
326 326
 	 * @throws EE_Error
327 327
 	 */
328
-	public function script_migrates_to_version($migration_script_name){
328
+	public function script_migrates_to_version($migration_script_name) {
329 329
 		$dms_info = $this->parse_dms_classname($migration_script_name);
330 330
 		return array(
331
-			'slug'=> $dms_info[ 'slug' ],
332
-			'version'=> $dms_info[ 'major_version' ] . "." . $dms_info[ 'minor_version' ] . "." . $dms_info[ 'micro_version' ] );
331
+			'slug'=> $dms_info['slug'],
332
+			'version'=> $dms_info['major_version'].".".$dms_info['minor_version'].".".$dms_info['micro_version'] );
333 333
 	}
334 334
 
335 335
 	/**
@@ -338,13 +338,13 @@  discard block
 block discarded – undo
338 338
 	 * @return array with keys 'slug','major_version','minor_version', and 'micro_version' (the last 3 are ints)
339 339
 	 * @throws EE_Error
340 340
 	 */
341
-	public function parse_dms_classname($classname){
341
+	public function parse_dms_classname($classname) {
342 342
 		$matches = array();
343
-		preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~',$classname,$matches);
344
-		if( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))){
345
-				throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"),$classname));
343
+		preg_match('~EE_DMS_(.*)_([0-9]*)_([0-9]*)_([0-9]*)~', $classname, $matches);
344
+		if ( ! $matches || ! (isset($matches[1]) && isset($matches[2]) && isset($matches[3]))) {
345
+				throw new EE_Error(sprintf(__("%s is not a valid Data Migration Script. The classname should be like EE_DMS_w_x_y_z, where w is either 'Core' or the slug of an addon and x, y and z are numbers, ", "event_espresso"), $classname));
346 346
 		}
347
-		return array('slug'=>$matches[1],'major_version'=>intval($matches[2]),'minor_version'=>intval($matches[3]),'micro_version'=>intval($matches[4]));
347
+		return array('slug'=>$matches[1], 'major_version'=>intval($matches[2]), 'minor_version'=>intval($matches[3]), 'micro_version'=>intval($matches[4]));
348 348
 	}
349 349
 	/**
350 350
 	 * Ensures that the option indicating the current DB version is set. This should only be
@@ -353,33 +353,33 @@  discard block
 block discarded – undo
353 353
 	 * to 4.1.x.
354 354
 	 * @return string of current db state
355 355
 	 */
356
-	public function ensure_current_database_state_is_set(){
357
-		$espresso_db_core_updates = get_option( 'espresso_db_update', array() );
356
+	public function ensure_current_database_state_is_set() {
357
+		$espresso_db_core_updates = get_option('espresso_db_update', array());
358 358
 		$db_state = get_option(EE_Data_Migration_Manager::current_database_state);
359
-		if( ! $db_state ){
359
+		if ( ! $db_state) {
360 360
 			//mark the DB as being in the state as the last version in there.
361 361
 			//this is done to trigger maintenance mode and do data migration scripts
362 362
 			//if the admin installed this version of EE over 3.1.x or 4.0.x
363 363
 			//otherwise, the normal maintenance mode code is fine
364 364
 			$previous_versions_installed = array_keys($espresso_db_core_updates);
365 365
 			$previous_version_installed = end($previous_versions_installed);
366
-			if(version_compare('4.1.0', $previous_version_installed)){
366
+			if (version_compare('4.1.0', $previous_version_installed)) {
367 367
 				//last installed version was less than 4.1
368 368
 				//so we want the data migrations to happen. SO, we're going to say the DB is at that state
369 369
 //				echo "4.1.0 is greater than $previous_version_installed! update the option";
370 370
 				$db_state = array('Core'=>$previous_version_installed);
371
-			}else{
371
+			} else {
372 372
 //					echo "4.1.0 is SMALLER than $previous_version_installed";
373 373
 					$db_state = array('Core'=>EVENT_ESPRESSO_VERSION);
374 374
 			}
375
-			update_option(EE_Data_Migration_Manager::current_database_state,$db_state);
375
+			update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
376 376
 		}
377 377
 		//in 4.1, $db_state would have only been a simple string like '4.1.0',
378 378
 		//but in 4.2+ it should be an array with at least key 'Core' and the value of that plugin's
379 379
 		//db, and possibly other keys for other addons like 'Calendar','Permissions',etc
380
-		if( ! is_array($db_state)){
380
+		if ( ! is_array($db_state)) {
381 381
 			$db_state = array('Core'=>$db_state);
382
-			update_option(EE_Data_Migration_Manager::current_database_state,$db_state);
382
+			update_option(EE_Data_Migration_Manager::current_database_state, $db_state);
383 383
 		}
384 384
 		return $db_state;
385 385
 	}
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 	 * or they don't apply), returns an empty array
391 391
 	 * @return EE_Data_Migration_Script_Base[]
392 392
 	 */
393
-	public function check_for_applicable_data_migration_scripts(){
393
+	public function check_for_applicable_data_migration_scripts() {
394 394
 		//get the option describing what options have already run
395 395
 		$scripts_ran = $this->get_data_migrations_ran();
396 396
 		//$scripts_ran = array('4.1.0.core'=>array('monkey'=>null));
@@ -403,62 +403,62 @@  discard block
 block discarded – undo
403 403
 		$iteration = 0;
404 404
 		$next_database_state_to_consider = $current_database_state;
405 405
 		$theoretical_database_state = NULL;
406
-		do{
406
+		do {
407 407
 			//the next state after the currently-considered one will start off looking the same as the current, but we may make additions...
408 408
 			$theoretical_database_state = $next_database_state_to_consider;
409 409
 			//the next db state to consider is "what would the DB be like had we run all the scripts we found that applied last time?)
410
-			foreach($script_class_and_filepaths_available as $classname => $filepath){
410
+			foreach ($script_class_and_filepaths_available as $classname => $filepath) {
411 411
 
412 412
 				$migrates_to_version = $this->script_migrates_to_version($classname);
413
-				$script_converts_plugin_slug = $migrates_to_version[ 'slug' ];
414
-				$script_converts_to_version = $migrates_to_version[ 'version' ];
413
+				$script_converts_plugin_slug = $migrates_to_version['slug'];
414
+				$script_converts_to_version = $migrates_to_version['version'];
415 415
 				//check if this version script is DONE or not; or if it's never been ran
416
-				if(		! $scripts_ran ||
416
+				if ( ! $scripts_ran ||
417 417
 						! isset($scripts_ran[$script_converts_plugin_slug]) ||
418
-						! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])){
418
+						! isset($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version])) {
419 419
 					//we haven't ran this conversion script before
420 420
 					//now check if it applies... note that we've added an autoloader for it on get_all_data_migration_scripts_available
421
-					$script = new $classname( $this->_get_table_manager(), $this->_get_table_analysis() );
421
+					$script = new $classname($this->_get_table_manager(), $this->_get_table_analysis());
422 422
 					/* @var $script EE_Data_Migration_Script_Base */
423 423
 					$can_migrate = $script->can_migrate_from_version($theoretical_database_state);
424
-					if($can_migrate){
424
+					if ($can_migrate) {
425 425
 						$script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script;
426 426
 						$migrates_to_version = $script->migrates_to_version();
427
-						$next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ];
427
+						$next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version'];
428 428
 						unset($script_class_and_filepaths_available[$classname]);
429 429
 					}
430
-				} elseif($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base){
430
+				} elseif ($scripts_ran[$script_converts_plugin_slug][$script_converts_to_version] instanceof EE_Data_Migration_Script_Base) {
431 431
 					//this script has been ran, or at least started
432 432
 					$script = $scripts_ran[$script_converts_plugin_slug][$script_converts_to_version];
433
-					if( $script->get_status() != self::status_completed){
433
+					if ($script->get_status() != self::status_completed) {
434 434
 						//this script is already underway... keep going with it
435 435
 						$script_classes_that_should_run_per_iteration[$iteration][$script->priority()][] = $script;
436 436
 						$migrates_to_version = $script->migrates_to_version();
437
-						$next_database_state_to_consider[ $migrates_to_version[ 'slug' ] ] = $migrates_to_version[ 'version' ];
437
+						$next_database_state_to_consider[$migrates_to_version['slug']] = $migrates_to_version['version'];
438 438
 						unset($script_class_and_filepaths_available[$classname]);
439
-					}else{
439
+					} else {
440 440
 						//it must have a status that indicates it has finished, so we don't want to try and run it again
441 441
 					}
442
-				}else{
442
+				} else {
443 443
 					//it exists but it's not  a proper data migration script
444 444
 					//maybe the script got renamed? or was simply removed from EE?
445 445
 					//either way, its certainly not runnable!
446 446
 				}
447 447
 			}
448 448
 			$iteration++;
449
-		}while( $next_database_state_to_consider != $theoretical_database_state && $iteration<6);
449
+		}while ($next_database_state_to_consider != $theoretical_database_state && $iteration < 6);
450 450
 		//ok we have all the scripts that should run, now let's make them into flat array
451 451
 		$scripts_that_should_run = array();
452
-		foreach($script_classes_that_should_run_per_iteration as $scripts_at_priority){
452
+		foreach ($script_classes_that_should_run_per_iteration as $scripts_at_priority) {
453 453
 			ksort($scripts_at_priority);
454
-			foreach($scripts_at_priority as $scripts){
455
-				foreach($scripts as $script){
454
+			foreach ($scripts_at_priority as $scripts) {
455
+				foreach ($scripts as $script) {
456 456
 					$scripts_that_should_run[get_class($script)] = $script;
457 457
 				}
458 458
 			}
459 459
 		}
460 460
 
461
-		do_action( 'AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run );
461
+		do_action('AHEE__EE_Data_Migration_Manager__check_for_applicable_data_migration_scripts__scripts_that_should_run', $scripts_that_should_run);
462 462
 		return $scripts_that_should_run;
463 463
 	}
464 464
 
@@ -472,14 +472,14 @@  discard block
 block discarded – undo
472 472
 	 * @param bool $include_completed_scripts
473 473
 	 * @return EE_Data_Migration_Script_Base
474 474
 	 */
475
-	public function get_last_ran_script($include_completed_scripts = false){
475
+	public function get_last_ran_script($include_completed_scripts = false) {
476 476
 		//make sure we've setup the class properties _last_ran_script and _last_ran_incomplete_script
477
-		if( ! $this->_data_migrations_ran){
477
+		if ( ! $this->_data_migrations_ran) {
478 478
 			$this->get_data_migrations_ran();
479 479
 		}
480
-		if($include_completed_scripts){
480
+		if ($include_completed_scripts) {
481 481
 			return $this->_last_ran_script;
482
-		}else{
482
+		} else {
483 483
 			return $this->_last_ran_incomplete_script;
484 484
 		}
485 485
 	}
@@ -502,19 +502,19 @@  discard block
 block discarded – undo
502 502
 	 * 		@type string $message string describing what was done during this step
503 503
 	 * }
504 504
 	 */
505
-	public function migration_step( $step_size = 0 ){
505
+	public function migration_step($step_size = 0) {
506 506
 
507 507
 		//bandaid fix for issue https://events.codebasehq.com/projects/event-espresso/tickets/7535
508
-		if ( class_exists( 'EE_CPT_Strategy' ) ) {
509
-			remove_action( 'pre_get_posts', array( EE_CPT_Strategy::instance(), 'pre_get_posts' ), 5 );
508
+		if (class_exists('EE_CPT_Strategy')) {
509
+			remove_action('pre_get_posts', array(EE_CPT_Strategy::instance(), 'pre_get_posts'), 5);
510 510
 		}
511 511
 
512
-		try{
512
+		try {
513 513
 			$currently_executing_script = $this->get_last_ran_script();
514
-			if( ! $currently_executing_script){
514
+			if ( ! $currently_executing_script) {
515 515
 				//Find the next script that needs to execute
516 516
 				$scripts = $this->check_for_applicable_data_migration_scripts();
517
-				if( ! $scripts ){
517
+				if ( ! $scripts) {
518 518
 					//huh, no more scripts to run... apparently we're done!
519 519
 					//but dont forget to make sure initial data is there
520 520
 					//we should be good to allow them to exit maintenance mode now
@@ -535,18 +535,18 @@  discard block
 block discarded – undo
535 535
 				//and add to the array/wp option showing the scripts ran
536 536
 //				$this->_data_migrations_ran[$this->script_migrates_to_version(get_class($currently_executing_script))] = $currently_executing_script;
537 537
 				$migrates_to = $this->script_migrates_to_version(get_class($currently_executing_script));
538
-				$plugin_slug = $migrates_to[ 'slug' ];
539
-				$version = $migrates_to[ 'version' ];
538
+				$plugin_slug = $migrates_to['slug'];
539
+				$version = $migrates_to['version'];
540 540
 				$this->_data_migrations_ran[$plugin_slug][$version] = $currently_executing_script;
541 541
 			}
542 542
 			$current_script_name = get_class($currently_executing_script);
543
-		}catch(Exception $e){
543
+		} catch (Exception $e) {
544 544
 			//an exception occurred while trying to get migration scripts
545 545
 
546
-			$message =  sprintf( __("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage() . '<br>', $e->getTraceAsString() );
546
+			$message = sprintf(__("Error Message: %sStack Trace:%s", "event_espresso"), $e->getMessage().'<br>', $e->getTraceAsString());
547 547
 			//record it on the array of data migration scripts ran. This will be overwritten next time we try and try to run data migrations
548 548
 			//but that's ok-- it's just an FYI to support that we couldn't even run any data migrations
549
-			$this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"),$message));
549
+			$this->add_error_to_migrations_ran(sprintf(__("Could not run data migrations because: %s", "event_espresso"), $message));
550 550
 			return array(
551 551
 				'records_to_migrate'=>1,
552 552
 				'records_migrated'=>0,
@@ -556,16 +556,16 @@  discard block
 block discarded – undo
556 556
 			);
557 557
 		}
558 558
 		//ok so we definitely have a data migration script
559
-		try{
559
+		try {
560 560
 			//how big of a bite do we want to take? Allow users to easily override via their wp-config
561
-			if( ! absint( $step_size ) > 0 ){
562
-				$step_size = defined( 'EE_MIGRATION_STEP_SIZE' ) && absint( EE_MIGRATION_STEP_SIZE ) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size;
561
+			if ( ! absint($step_size) > 0) {
562
+				$step_size = defined('EE_MIGRATION_STEP_SIZE') && absint(EE_MIGRATION_STEP_SIZE) ? EE_MIGRATION_STEP_SIZE : EE_Data_Migration_Manager::step_size;
563 563
 			}
564 564
 			//do what we came to do!
565 565
 			$currently_executing_script->migration_step($step_size);
566 566
 			//can we wrap it up and verify default data?
567 567
 			$init_dbs = false;
568
-			switch($currently_executing_script->get_status()){
568
+			switch ($currently_executing_script->get_status()) {
569 569
 				case EE_Data_Migration_Manager::status_continue:
570 570
 					$response_array = array(
571 571
 						'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
@@ -577,16 +577,16 @@  discard block
 block discarded – undo
577 577
 				case EE_Data_Migration_Manager::status_completed:
578 578
 					//ok so THAT script has completed
579 579
 					$this->update_current_database_state_to($this->script_migrates_to_version($current_script_name));
580
-					$response_array =  array(
580
+					$response_array = array(
581 581
 							'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
582 582
 							'records_migrated'=>$currently_executing_script->count_records_migrated(),
583 583
 							'status'=> EE_Data_Migration_Manager::status_completed,
584 584
 							'message'=>$currently_executing_script->get_feedback_message(),
585
-							'script'=> sprintf(__("%s Completed",'event_espresso'),$currently_executing_script->pretty_name())
585
+							'script'=> sprintf(__("%s Completed", 'event_espresso'), $currently_executing_script->pretty_name())
586 586
 						);
587 587
 					//check if there are any more after this one.
588 588
 					$scripts_remaining = $this->check_for_applicable_data_migration_scripts();
589
-					if( ! $scripts_remaining ){
589
+					if ( ! $scripts_remaining) {
590 590
 						//we should be good to allow them to exit maintenance mode now
591 591
 						EE_Maintenance_Mode::instance()->set_maintenance_level(intval(EE_Maintenance_Mode::level_0_not_in_maintenance));
592 592
 						////huh, no more scripts to run... apparently we're done!
@@ -600,39 +600,39 @@  discard block
 block discarded – undo
600 600
 						'records_to_migrate'=>$currently_executing_script->count_records_to_migrate(),
601 601
 						'records_migrated'=>$currently_executing_script->count_records_migrated(),
602 602
 						'status'=> $currently_executing_script->get_status(),
603
-						'message'=>  sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ",$currently_executing_script->get_errors())),
603
+						'message'=>  sprintf(__("Minor errors occurred during %s: %s", "event_espresso"), $currently_executing_script->pretty_name(), implode(", ", $currently_executing_script->get_errors())),
604 604
 						'script'=>$currently_executing_script->pretty_name()
605 605
 					);
606 606
 					break;
607 607
 			}
608
-		}catch(Exception $e){
608
+		} catch (Exception $e) {
609 609
 			//ok so some exception was thrown which killed the data migration script
610 610
 			//double-check we have a real script
611
-			if($currently_executing_script instanceof EE_Data_Migration_Script_Base){
611
+			if ($currently_executing_script instanceof EE_Data_Migration_Script_Base) {
612 612
 				$script_name = $currently_executing_script->pretty_name();
613 613
 				$currently_executing_script->set_broken();
614 614
 				$currently_executing_script->add_error($e->getMessage());
615
-			}else{
615
+			} else {
616 616
 				$script_name = __("Error getting Migration Script", "event_espresso");
617 617
 			}
618 618
 			$response_array = array(
619 619
 				'records_to_migrate'=>1,
620 620
 				'records_migrated'=>0,
621 621
 				'status'=>self::status_fatal_error,
622
-				'message'=>  sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"),$e->getMessage()),
622
+				'message'=>  sprintf(__("A fatal error occurred during the migration: %s", "event_espresso"), $e->getMessage()),
623 623
 				'script'=>$script_name
624 624
 			);
625 625
 		}
626 626
 		$successful_save = $this->_save_migrations_ran();
627
-		if($successful_save !== TRUE){
627
+		if ($successful_save !== TRUE) {
628 628
 			//ok so the current wp option didn't save. that's tricky, because we'd like to update it
629 629
 			//and mark it as having a fatal error, but remember- WE CAN'T SAVE THIS WP OPTION!
630 630
 			//however, if we throw an exception, and return that, then the next request
631 631
 			//won't have as much info in it, and it may be able to save
632
-			throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"),$successful_save));
632
+			throw new EE_Error(sprintf(__("The error '%s' occurred updating the status of the migration. This is a FATAL ERROR, but the error is preventing the system from remembering that. Please contact event espresso support.", "event_espresso"), $successful_save));
633 633
 		}
634 634
 		//if we're all done, initialize EE plugins' default data etc.
635
-		if( $init_dbs ) {
635
+		if ($init_dbs) {
636 636
 			$this->initialize_db_for_enqueued_ee_plugins();
637 637
 		}
638 638
 		return $response_array;
@@ -650,23 +650,23 @@  discard block
 block discarded – undo
650 650
 	 * 'message'=>a string, containing any message you want to show to the user. We may decide to split this up into errors, notifications, and successes
651 651
 	 * 'script'=>a pretty name of the script currently running
652 652
 	 */
653
-	public function response_to_migration_ajax_request(){
653
+	public function response_to_migration_ajax_request() {
654 654
 //		//start output buffer just to make sure we don't mess up the json
655 655
 		ob_start();
656
-		try{
656
+		try {
657 657
 			$response = $this->migration_step();
658
-		}catch(Exception $e){
658
+		} catch (Exception $e) {
659 659
 			$response = array(
660 660
 				'records_to_migrate'=>0,
661 661
 				'records_migrated'=>0,
662 662
 				'status'=> EE_Data_Migration_Manager::status_fatal_error,
663
-				'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"),$e->getMessage()),
663
+				'message'=> sprintf(__("Unknown fatal error occurred: %s", "event_espresso"), $e->getMessage()),
664 664
 				'script'=>'Unknown');
665 665
 			$this->add_error_to_migrations_ran($e->getMessage()."; Stack trace:".$e->getTraceAsString());
666 666
 		}
667 667
 		$warnings_etc = @ob_get_contents();
668 668
 		ob_end_clean();
669
-		$response['message'] .=$warnings_etc;
669
+		$response['message'] .= $warnings_etc;
670 670
 		return $response;
671 671
 	}
672 672
 
@@ -679,14 +679,14 @@  discard block
 block discarded – undo
679 679
 	 * }
680 680
 	 * @return void
681 681
 	 */
682
-	public function update_current_database_state_to($slug_and_version = null){
683
-		if( ! $slug_and_version ){
682
+	public function update_current_database_state_to($slug_and_version = null) {
683
+		if ( ! $slug_and_version) {
684 684
 			//no version was provided, assume it should be at the current code version
685 685
 			$slug_and_version = array('slug' => 'Core', 'version' => espresso_version());
686 686
 		}
687 687
 		$current_database_state = get_option(self::current_database_state);
688
-		$current_database_state[ $slug_and_version[ 'slug' ] ]=$slug_and_version[ 'version' ];
689
-		update_option(self::current_database_state,$current_database_state);
688
+		$current_database_state[$slug_and_version['slug']] = $slug_and_version['version'];
689
+		update_option(self::current_database_state, $current_database_state);
690 690
 	}
691 691
 
692 692
 	/**
@@ -697,20 +697,20 @@  discard block
 block discarded – undo
697 697
 	 * }
698 698
 	 * @return boolean
699 699
 	 */
700
-	public function database_needs_updating_to( $slug_and_version ) {
700
+	public function database_needs_updating_to($slug_and_version) {
701 701
 
702
-		$slug = $slug_and_version[ 'slug' ];
703
-		$version = $slug_and_version[ 'version' ];
702
+		$slug = $slug_and_version['slug'];
703
+		$version = $slug_and_version['version'];
704 704
 		$current_database_state = get_option(self::current_database_state);
705
-		if( ! isset( $current_database_state[ $slug ] ) ) {
705
+		if ( ! isset($current_database_state[$slug])) {
706 706
 			return true;
707
-		}else{
707
+		} else {
708 708
 			//just compare the first 3 parts of version string, eg "4.7.1", not "4.7.1.dev.032" because DBs shouldn't change on nano version changes
709
-			$version_parts_current_db_state = array_slice( explode('.', $current_database_state[ $slug ] ), 0, 3);
710
-			$version_parts_of_provided_db_state = array_slice( explode( '.', $version ), 0, 3 );
709
+			$version_parts_current_db_state = array_slice(explode('.', $current_database_state[$slug]), 0, 3);
710
+			$version_parts_of_provided_db_state = array_slice(explode('.', $version), 0, 3);
711 711
 			$needs_updating = false;
712
-			foreach($version_parts_current_db_state as $offset => $version_part_in_current_db_state ) {
713
-				if( $version_part_in_current_db_state < $version_parts_of_provided_db_state[ $offset ] ) {
712
+			foreach ($version_parts_current_db_state as $offset => $version_part_in_current_db_state) {
713
+				if ($version_part_in_current_db_state < $version_parts_of_provided_db_state[$offset]) {
714 714
 					$needs_updating = true;
715 715
 					break;
716 716
 				}
@@ -728,33 +728,33 @@  discard block
 block discarded – undo
728 728
      * @return array keys are expected classnames, values are their filepaths
729 729
      * @throws \EE_Error
730 730
      */
731
-	public function get_all_data_migration_scripts_available(){
732
-		if( ! $this->_data_migration_class_to_filepath_map){
731
+	public function get_all_data_migration_scripts_available() {
732
+		if ( ! $this->_data_migration_class_to_filepath_map) {
733 733
 			$this->_data_migration_class_to_filepath_map = array();
734
-			foreach($this->get_data_migration_script_folders() as $folder_path){
734
+			foreach ($this->get_data_migration_script_folders() as $folder_path) {
735 735
                 $folder_path = EEH_File::end_with_directory_separator($folder_path);
736
-				$files = glob( $folder_path. '*.dms.php' );
736
+				$files = glob($folder_path.'*.dms.php');
737 737
 
738
-				if ( empty( $files ) ) {
738
+				if (empty($files)) {
739 739
 					continue;
740 740
 				}
741 741
 
742
-				foreach($files as $file){
743
-					$pos_of_last_slash = strrpos($file,DS);
742
+				foreach ($files as $file) {
743
+					$pos_of_last_slash = strrpos($file, DS);
744 744
 					$classname = str_replace('.dms.php', '', substr($file, $pos_of_last_slash + 1));
745
-					$migrates_to = $this->script_migrates_to_version( $classname );
746
-					$slug = $migrates_to[ 'slug' ];
745
+					$migrates_to = $this->script_migrates_to_version($classname);
746
+					$slug = $migrates_to['slug'];
747 747
 					//check that the slug as contained in the DMS is associated with
748 748
 					//the slug of an addon or core
749
-					if( $slug !== 'Core' ){
750
-						if( ! EE_Registry::instance()->get_addon_by_name( $slug ) ) {
749
+					if ($slug !== 'Core') {
750
+						if ( ! EE_Registry::instance()->get_addon_by_name($slug)) {
751 751
 							EE_Error::doing_it_wrong(
752 752
 							    __FUNCTION__,
753 753
                                 sprintf(
754
-                                    __( 'The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso' ),
754
+                                    __('The data migration script "%s" migrates the "%s" data, but there is no EE addon with that name. There is only: %s. ', 'event_espresso'),
755 755
                                     $classname,
756 756
                                     $slug,
757
-                                    implode(', ', array_keys( EE_Registry::instance()->get_addons_by_name() ) )
757
+                                    implode(', ', array_keys(EE_Registry::instance()->get_addons_by_name()))
758 758
                                 ),
759 759
                                 '4.3.0.alpha.019'
760 760
                             );
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 	 * from each addon, and check if they need updating,
778 778
 	 * @return boolean
779 779
 	 */
780
-	public function addons_need_updating(){
780
+	public function addons_need_updating() {
781 781
 		return false;
782 782
 	}
783 783
 	/**
@@ -786,25 +786,25 @@  discard block
 block discarded – undo
786 786
 	 * @param string $error_message
787 787
 	 * @throws EE_Error
788 788
 	 */
789
-	public function add_error_to_migrations_ran($error_message){
789
+	public function add_error_to_migrations_ran($error_message) {
790 790
 		//get last-ran migration script
791 791
 		global $wpdb;
792
-		$last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1",ARRAY_A);
792
+		$last_migration_script_option = $wpdb->get_row("SELECT * FROM $wpdb->options WHERE option_name like '".EE_Data_Migration_Manager::data_migration_script_option_prefix."%' ORDER BY option_id DESC LIMIT 1", ARRAY_A);
793 793
 
794 794
 		$last_ran_migration_script_properties = isset($last_migration_script_option['option_value']) ? maybe_unserialize($last_migration_script_option['option_value']) : null;
795 795
 		//now, tread lightly because we're here because a FATAL non-catchable error
796 796
 		//was thrown last time when we were trying to run a data migration script
797 797
 		//so the fatal error could have happened while getting the migration script
798 798
 		//or doing running it...
799
-		$versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix,"",$last_migration_script_option['option_name']) : null;
799
+		$versions_migrated_to = isset($last_migration_script_option['option_name']) ? str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $last_migration_script_option['option_name']) : null;
800 800
 
801 801
 		//check if it THINKS its a data migration script and especially if it's one that HASN'T finished yet
802 802
 		//because if it has finished, then it obviously couldn't be the cause of this error, right? (because its all done)
803
-		if(isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed){
803
+		if (isset($last_ran_migration_script_properties['class']) && isset($last_ran_migration_script_properties['_status']) && $last_ran_migration_script_properties['_status'] != self::status_completed) {
804 804
 			//ok then just add this error to its list of errors
805 805
 			$last_ran_migration_script_properties['_errors'][] = $error_message;
806 806
 			$last_ran_migration_script_properties['_status'] = self::status_fatal_error;
807
-		}else{
807
+		} else {
808 808
 			//so we don't even know which script was last running
809 809
 			//use the data migration error stub, which is designed specifically for this type of thing
810 810
 			$general_migration_error = new EE_DMS_Unknown_1_0_0();
@@ -814,39 +814,39 @@  discard block
 block discarded – undo
814 814
 			$versions_migrated_to = 'Unknown.1.0.0';
815 815
 			//now just to make sure appears as last (in case the were previously a fatal error like this)
816 816
 			//delete the old one
817
-			delete_option( self::data_migration_script_option_prefix . $versions_migrated_to );
817
+			delete_option(self::data_migration_script_option_prefix.$versions_migrated_to);
818 818
 		}
819
-		update_option(self::data_migration_script_option_prefix.$versions_migrated_to,$last_ran_migration_script_properties);
819
+		update_option(self::data_migration_script_option_prefix.$versions_migrated_to, $last_ran_migration_script_properties);
820 820
 
821 821
 	}
822 822
 	/**
823 823
 	 * saves what data migrations have ran to the database
824 824
 	 * @return mixed TRUE if successfully saved migrations ran, string if an error occurred
825 825
 	 */
826
-	protected function _save_migrations_ran(){
827
-		if($this->_data_migrations_ran == null){
826
+	protected function _save_migrations_ran() {
827
+		if ($this->_data_migrations_ran == null) {
828 828
 			$this->get_data_migrations_ran();
829 829
 		}
830 830
 		//now, we don't want to save actual classes to the DB because that's messy
831 831
 		$successful_updates = true;
832
-		foreach($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin){
833
-			foreach($migrations_ran_for_plugin as $version_string => $array_or_migration_obj){
832
+		foreach ($this->_data_migrations_ran as $plugin_slug => $migrations_ran_for_plugin) {
833
+			foreach ($migrations_ran_for_plugin as $version_string => $array_or_migration_obj) {
834 834
 	//			echo "saving migration script to $version_string<br>";
835 835
 				$plugin_slug_for_use_in_option_name = $plugin_slug.".";
836 836
 				$option_name = self::data_migration_script_option_prefix.$plugin_slug_for_use_in_option_name.$version_string;
837 837
 				$old_option_value = get_option($option_name);
838
-				if($array_or_migration_obj instanceof EE_Data_Migration_Script_Base){
838
+				if ($array_or_migration_obj instanceof EE_Data_Migration_Script_Base) {
839 839
 					$script_array_for_saving = $array_or_migration_obj->properties_as_array();
840
-					if( $old_option_value != $script_array_for_saving){
841
-						$successful_updates = update_option($option_name,$script_array_for_saving);
840
+					if ($old_option_value != $script_array_for_saving) {
841
+						$successful_updates = update_option($option_name, $script_array_for_saving);
842 842
 					}
843
-				}else{//we don't know what this array-thing is. So just save it as-is
843
+				} else {//we don't know what this array-thing is. So just save it as-is
844 844
 	//				$array_of_migrations[$version_string] = $array_or_migration_obj;
845
-					if($old_option_value != $array_or_migration_obj){
846
-						$successful_updates = update_option($option_name,$array_or_migration_obj);
845
+					if ($old_option_value != $array_or_migration_obj) {
846
+						$successful_updates = update_option($option_name, $array_or_migration_obj);
847 847
 					}
848 848
 				}
849
-				if( ! $successful_updates ){
849
+				if ( ! $successful_updates) {
850 850
 					global $wpdb;
851 851
 					return $wpdb->last_error;
852 852
 				}
@@ -870,17 +870,17 @@  discard block
 block discarded – undo
870 870
 	 * @return EE_Data_Migration_Script_Base
871 871
 	 * @throws EE_Error
872 872
 	 */
873
-	function _instantiate_script_from_properties_array($properties_array){
874
-		if( ! isset($properties_array['class'])){
875
-			throw new EE_Error(sprintf(__("Properties array  has no 'class' properties. Here's what it has: %s", "event_espresso"),implode(",",$properties_array)));
873
+	function _instantiate_script_from_properties_array($properties_array) {
874
+		if ( ! isset($properties_array['class'])) {
875
+			throw new EE_Error(sprintf(__("Properties array  has no 'class' properties. Here's what it has: %s", "event_espresso"), implode(",", $properties_array)));
876 876
 		}
877 877
 		$class_name = $properties_array['class'];
878
-		if( ! class_exists($class_name)){
879
-			throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"),$class_name));
878
+		if ( ! class_exists($class_name)) {
879
+			throw new EE_Error(sprintf(__("There is no migration script named %s", "event_espresso"), $class_name));
880 880
 		}
881 881
 		$class = new $class_name;
882
-		if( ! $class instanceof EE_Data_Migration_Script_Base){
883
-			throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"),$class_name,get_class($class)));
882
+		if ( ! $class instanceof EE_Data_Migration_Script_Base) {
883
+			throw new EE_Error(sprintf(__("Class '%s' is supposed to be a migration script. Its not, its a '%s'", "event_espresso"), $class_name, get_class($class)));
884 884
 		}
885 885
 		$class->instantiate_from_array_of_properties($properties_array);
886 886
 		return $class;
@@ -892,25 +892,25 @@  discard block
 block discarded – undo
892 892
 	 * @param string $plugin_slug the slug for the ee plugin we are searching for. Default is 'Core'
893 893
 	 * @return string
894 894
 	 */
895
-	public function get_most_up_to_date_dms($plugin_slug = 'Core'){
895
+	public function get_most_up_to_date_dms($plugin_slug = 'Core') {
896 896
 		$class_to_filepath_map = $this->get_all_data_migration_scripts_available();
897 897
 		$most_up_to_date_dms_classname = NULL;
898
-		foreach($class_to_filepath_map as $classname => $filepath){
899
-			if($most_up_to_date_dms_classname === NULL){
898
+		foreach ($class_to_filepath_map as $classname => $filepath) {
899
+			if ($most_up_to_date_dms_classname === NULL) {
900 900
 				$migrates_to = $this->script_migrates_to_version($classname);
901
-				$this_plugin_slug = $migrates_to[ 'slug' ];
901
+				$this_plugin_slug = $migrates_to['slug'];
902 902
 //				$version_string = $migrates_to[ 'version' ];
903 903
 //				$details = $this->parse_dms_classname($classname);
904
-				if($this_plugin_slug == $plugin_slug){
904
+				if ($this_plugin_slug == $plugin_slug) {
905 905
 					//if it's for core, it wins
906 906
 					$most_up_to_date_dms_classname = $classname;
907 907
 				}
908 908
 				//if it wasn't for core, we must keep searching for one that is!
909 909
 				continue;
910
-			}else{
911
-				$champion_migrates_to= $this->script_migrates_to_version($most_up_to_date_dms_classname);
910
+			} else {
911
+				$champion_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms_classname);
912 912
 				$contender_migrates_to = $this->script_migrates_to_version($classname);
913
-				if($contender_migrates_to[ 'slug' ] == $plugin_slug && version_compare($champion_migrates_to[ 'version' ], $contender_migrates_to[ 'version' ], '<')){
913
+				if ($contender_migrates_to['slug'] == $plugin_slug && version_compare($champion_migrates_to['version'], $contender_migrates_to['version'], '<')) {
914 914
 					//so the contenders version is higher and its for Core
915 915
 					$most_up_to_date_dms_classname = $classname;
916 916
 				}
@@ -930,11 +930,11 @@  discard block
 block discarded – undo
930 930
 	 * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
931 931
 	 * @return EE_Data_Migration_Script_Base
932 932
 	 */
933
-	public function get_migration_ran( $version, $plugin_slug = 'Core' ) {
933
+	public function get_migration_ran($version, $plugin_slug = 'Core') {
934 934
 		$migrations_ran = $this->get_data_migrations_ran();
935
-		if( isset( $migrations_ran[ $plugin_slug ] ) && isset( $migrations_ran[ $plugin_slug ][ $version ] ) ){
936
-			return $migrations_ran[ $plugin_slug ][ $version ];
937
-		}else{
935
+		if (isset($migrations_ran[$plugin_slug]) && isset($migrations_ran[$plugin_slug][$version])) {
936
+			return $migrations_ran[$plugin_slug][$version];
937
+		} else {
938 938
 			return NULL;
939 939
 		}
940 940
 	}
@@ -946,20 +946,20 @@  discard block
 block discarded – undo
946 946
 	 * @return bool
947 947
 	 * @throws \EE_Error
948 948
 	 */
949
-	public function reattempt(){
949
+	public function reattempt() {
950 950
 		//find if the last-ran script was borked
951 951
 		//set it as being non-borked (we shouldn't ever get DMSs that we don't recognize)
952 952
 		//add an 'error' saying that we attempted to reset
953 953
 		//does it have a stage that was borked too? if so make it no longer borked
954 954
 		//add an 'error' saying we attempted to reset
955 955
 		$last_ran_script = $this->get_last_ran_script();
956
-		if( $last_ran_script instanceof EE_DMS_Unknown_1_0_0 ){
956
+		if ($last_ran_script instanceof EE_DMS_Unknown_1_0_0) {
957 957
 			//if it was an error DMS, just mark it as complete (if another error occurs it will overwrite it)
958 958
 			$last_ran_script->set_completed();
959
-		}elseif( $last_ran_script instanceof EE_Data_Migration_Script_Base ) {
959
+		}elseif ($last_ran_script instanceof EE_Data_Migration_Script_Base) {
960 960
 			$last_ran_script->reattempt();
961
-		}else{
962
-			throw new EE_Error( sprintf( __( 'Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso' ), print_r( $last_ran_script, true ) ) );
961
+		} else {
962
+			throw new EE_Error(sprintf(__('Unable to reattempt the last ran migration script because it was not a valid migration script. || It was %s', 'event_espresso'), print_r($last_ran_script, true)));
963 963
 		}
964 964
 		return $this->_save_migrations_ran();
965 965
 	}
@@ -969,19 +969,19 @@  discard block
 block discarded – undo
969 969
 	 * @param string $plugin_slug like 'Core', 'Mailchimp', 'Calendar', etc
970 970
 	 * @return boolean
971 971
 	 */
972
-	public function migration_has_ran( $version, $plugin_slug = 'Core' ) {
973
-		return $this->get_migration_ran( $version, $plugin_slug ) !== NULL;
972
+	public function migration_has_ran($version, $plugin_slug = 'Core') {
973
+		return $this->get_migration_ran($version, $plugin_slug) !== NULL;
974 974
 	}
975 975
 	/**
976 976
 	 * Enqueues this ee plugin to have its data initialized
977 977
 	 * @param string $plugin_slug either 'Core' or EE_Addon::name()'s return value
978 978
 	 */
979
-	public function enqueue_db_initialization_for( $plugin_slug ) {
979
+	public function enqueue_db_initialization_for($plugin_slug) {
980 980
 		$queue = $this->get_db_initialization_queue();
981
-		if( ! in_array( $plugin_slug, $queue ) ) {
981
+		if ( ! in_array($plugin_slug, $queue)) {
982 982
 			$queue[] = $plugin_slug;
983 983
 		}
984
-		update_option( self::db_init_queue_option_name, $queue );
984
+		update_option(self::db_init_queue_option_name, $queue);
985 985
 	}
986 986
 	/**
987 987
 	 * Calls EE_Addon::initialize_db_if_no_migrations_required() on each addon
@@ -991,26 +991,26 @@  discard block
 block discarded – undo
991 991
 	public function initialize_db_for_enqueued_ee_plugins() {
992 992
 //		EEH_Debug_Tools::instance()->start_timer( 'initialize_db_for_enqueued_ee_plugins' );
993 993
 		$queue = $this->get_db_initialization_queue();
994
-		foreach( $queue as $plugin_slug ) {
995
-			$most_up_to_date_dms = $this->get_most_up_to_date_dms( $plugin_slug );
996
-			if( ! $most_up_to_date_dms ) {
994
+		foreach ($queue as $plugin_slug) {
995
+			$most_up_to_date_dms = $this->get_most_up_to_date_dms($plugin_slug);
996
+			if ( ! $most_up_to_date_dms) {
997 997
 				//if there is NO DMS for this plugin, obviously there's no schema to verify anyways
998 998
 				$verify_db = false;
999
-			}else{
1000
-				$most_up_to_date_dms_migrates_to = $this->script_migrates_to_version( $most_up_to_date_dms );
1001
-				$verify_db = $this->database_needs_updating_to( $most_up_to_date_dms_migrates_to );
999
+			} else {
1000
+				$most_up_to_date_dms_migrates_to = $this->script_migrates_to_version($most_up_to_date_dms);
1001
+				$verify_db = $this->database_needs_updating_to($most_up_to_date_dms_migrates_to);
1002 1002
 			}
1003
-			if( $plugin_slug == 'Core' ){
1003
+			if ($plugin_slug == 'Core') {
1004 1004
 				EE_System::instance()->initialize_db_if_no_migrations_required(
1005 1005
 						false,
1006 1006
 						$verify_db
1007 1007
 					);
1008
-			}else{
1008
+			} else {
1009 1009
 				//just loop through the addons to make sure their database is setup
1010
-				foreach( EE_Registry::instance()->addons as $addon ) {
1011
-					if( $addon->name() == $plugin_slug ) {
1010
+				foreach (EE_Registry::instance()->addons as $addon) {
1011
+					if ($addon->name() == $plugin_slug) {
1012 1012
 
1013
-						$addon->initialize_db_if_no_migrations_required( $verify_db );
1013
+						$addon->initialize_db_if_no_migrations_required($verify_db);
1014 1014
 						break;
1015 1015
 					}
1016 1016
 				}
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
 //		EEH_Debug_Tools::instance()->show_times();
1021 1021
 		//because we just initialized the DBs for the enqueued ee plugins
1022 1022
 		//we don't need to keep remembering which ones needed to be initialized
1023
-		delete_option( self::db_init_queue_option_name );
1023
+		delete_option(self::db_init_queue_option_name);
1024 1024
 	}
1025 1025
 
1026 1026
 	/**
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 	 * 'Core', or the return value of EE_Addon::name() for an addon
1030 1030
 	 * @return array
1031 1031
 	 */
1032
-	public function get_db_initialization_queue(){
1033
-		return get_option ( self::db_init_queue_option_name, array() );
1032
+	public function get_db_initialization_queue() {
1033
+		return get_option(self::db_init_queue_option_name, array());
1034 1034
 	}
1035 1035
 
1036 1036
 	/**
@@ -1039,13 +1039,13 @@  discard block
 block discarded – undo
1039 1039
 	 * @throws \EE_Error
1040 1040
 	 */
1041 1041
 	protected function _get_table_analysis() {
1042
-		if( $this->_table_analysis instanceof TableAnalysis ) {
1042
+		if ($this->_table_analysis instanceof TableAnalysis) {
1043 1043
 			return $this->_table_analysis;
1044 1044
 		} else {
1045 1045
 			throw new \EE_Error(
1046 1046
 				sprintf(
1047
-					__( 'Table analysis class on class %1$s is not set properly.', 'event_espresso'),
1048
-					get_class( $this )
1047
+					__('Table analysis class on class %1$s is not set properly.', 'event_espresso'),
1048
+					get_class($this)
1049 1049
 				)
1050 1050
 			);
1051 1051
 		}
@@ -1057,13 +1057,13 @@  discard block
 block discarded – undo
1057 1057
 	 * @throws \EE_Error
1058 1058
 	 */
1059 1059
 	protected function _get_table_manager() {
1060
-		if( $this->_table_manager instanceof TableManager ) {
1060
+		if ($this->_table_manager instanceof TableManager) {
1061 1061
 			return $this->_table_manager;
1062 1062
 		} else {
1063 1063
 			throw new \EE_Error(
1064 1064
 				sprintf(
1065
-					__( 'Table manager class on class %1$s is not set properly.', 'event_espresso'),
1066
-					get_class( $this )
1065
+					__('Table manager class on class %1$s is not set properly.', 'event_espresso'),
1066
+					get_class($this)
1067 1067
 				)
1068 1068
 			);
1069 1069
 		}
Please login to merge, or discard this patch.
modules/single_page_checkout/inc/EE_SPCO_JSON_Response.php 2 patches
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -107,71 +107,71 @@  discard block
 block discarded – undo
107 107
 	public function __toString() {
108 108
 		$JSON_response = array();
109 109
 		// grab notices
110
-		$notices = EE_Error::get_notices( FALSE );
111
-		$this->set_attention( isset( $notices['attention'] ) ? $notices['attention'] : '' );
112
-		$this->set_errors( isset( $notices['errors'] ) ? $notices['errors'] : '' );
113
-		$this->set_success( isset( $notices['success'] ) ? $notices['success'] : '' );
110
+		$notices = EE_Error::get_notices(FALSE);
111
+		$this->set_attention(isset($notices['attention']) ? $notices['attention'] : '');
112
+		$this->set_errors(isset($notices['errors']) ? $notices['errors'] : '');
113
+		$this->set_success(isset($notices['success']) ? $notices['success'] : '');
114 114
 		// add notices to JSON response, but only if they exist
115
-		if ( $this->attention() ) {
115
+		if ($this->attention()) {
116 116
 			$JSON_response['attention'] = $this->attention();
117 117
 		}
118
-		if ( $this->errors() ) {
118
+		if ($this->errors()) {
119 119
 			$JSON_response['errors'] = $this->errors();
120 120
 		}
121
-		if ( $this->unexpected_errors() ) {
121
+		if ($this->unexpected_errors()) {
122 122
 			$JSON_response['unexpected_errors'] = $this->unexpected_errors();
123 123
 		}
124
-		if ( $this->success() ) {
124
+		if ($this->success()) {
125 125
 			$JSON_response['success'] = $this->success();
126 126
 		}
127 127
 		// but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked
128
-		if ( ! isset( $JSON_response[ 'attention' ] ) && ! isset( $JSON_response[ 'errors' ] ) && ! isset( $JSON_response[ 'success' ] ) ) {
128
+		if ( ! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) {
129 129
 			$JSON_response['success'] = null;
130 130
 		}
131 131
 		// set redirect_url, IF it exists
132
-		if ( $this->redirect_url() ) {
132
+		if ($this->redirect_url()) {
133 133
 			$JSON_response['redirect_url'] = $this->redirect_url();
134 134
 		}
135 135
 		// set registration_time_limit, IF it exists
136
-		if ( $this->registration_time_limit() ) {
136
+		if ($this->registration_time_limit()) {
137 137
 			$JSON_response['registration_time_limit'] = $this->registration_time_limit();
138 138
 		}
139 139
 		// set payment_amount, IF it exists
140
-		if ( $this->payment_amount() !== null ) {
141
-			$JSON_response[ 'payment_amount' ] = $this->payment_amount();
140
+		if ($this->payment_amount() !== null) {
141
+			$JSON_response['payment_amount'] = $this->payment_amount();
142 142
 		}
143 143
 		// grab generic return data
144 144
 		$return_data = $this->return_data();
145 145
 		// add billing form validation rules
146
-		if ( $this->validation_rules() ) {
146
+		if ($this->validation_rules()) {
147 147
 			$return_data['validation_rules'] = $this->validation_rules();
148 148
 		}
149 149
 		// set reg_step_html, IF it exists
150
-		if ( $this->reg_step_html() ) {
150
+		if ($this->reg_step_html()) {
151 151
 			$return_data['reg_step_html'] = $this->reg_step_html();
152 152
 		}
153 153
 		// set method of payment, IF it exists
154
-		if ( $this->method_of_payment() ) {
154
+		if ($this->method_of_payment()) {
155 155
 			$return_data['method_of_payment'] = $this->method_of_payment();
156 156
 		}
157 157
 		// set "plz_select_method_of_payment" message, IF it exists
158
-		if ( $this->plz_select_method_of_payment() ) {
158
+		if ($this->plz_select_method_of_payment()) {
159 159
 			$return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment();
160 160
 		}
161 161
 		// set redirect_form, IF it exists
162
-		if ( $this->redirect_form() ) {
162
+		if ($this->redirect_form()) {
163 163
 			$return_data['redirect_form'] = $this->redirect_form();
164 164
 		}
165 165
 		// and finally, add return_data array to main JSON response array, IF it contains anything
166 166
 		// why did we add some of the above properties to the return data array?
167 167
 		// because it is easier and cleaner in the Javascript to deal with this way
168
-		if ( ! empty( $return_data )) {
168
+		if ( ! empty($return_data)) {
169 169
 			$JSON_response['return_data'] = $return_data;
170 170
 		}
171 171
 		// filter final array
172
-		$JSON_response = apply_filters( 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response );
172
+		$JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response);
173 173
 		// return encoded array
174
-		return wp_json_encode( $JSON_response );
174
+		return wp_json_encode($JSON_response);
175 175
 	}
176 176
 
177 177
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	/**
180 180
 	 * @param string $attention
181 181
 	 */
182
-	public function set_attention( $attention ) {
182
+	public function set_attention($attention) {
183 183
 		$this->_attention = $attention;
184 184
 	}
185 185
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	/**
198 198
 	 * @param string $errors
199 199
 	 */
200
-	public function set_errors( $errors ) {
200
+	public function set_errors($errors) {
201 201
 		$this->_errors = $errors;
202 202
 	}
203 203
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	/**
225 225
 	 * @param string $unexpected_errors
226 226
 	 */
227
-	public function set_unexpected_errors( $unexpected_errors ) {
227
+	public function set_unexpected_errors($unexpected_errors) {
228 228
 		$this->_unexpected_errors = $unexpected_errors;
229 229
 	}
230 230
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	/**
234 234
 	 * @param string $success
235 235
 	 */
236
-	public function set_success( $success ) {
236
+	public function set_success($success) {
237 237
 		$this->_success = $success;
238 238
 	}
239 239
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	/**
252 252
 	 * @param string $method_of_payment
253 253
 	 */
254
-	public function set_method_of_payment( $method_of_payment ) {
254
+	public function set_method_of_payment($method_of_payment) {
255 255
 		$this->_method_of_payment = $method_of_payment;
256 256
 	}
257 257
 
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 	/**
279 279
 	 * @param float $payment_amount
280 280
 	 */
281
-	public function set_payment_amount( $payment_amount ) {
282
-		$this->_payment_amount = EEH_Money::convert_to_float_from_localized_money( $payment_amount );
281
+	public function set_payment_amount($payment_amount) {
282
+		$this->_payment_amount = EEH_Money::convert_to_float_from_localized_money($payment_amount);
283 283
 	}
284 284
 
285 285
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	/**
288 288
 	 * @param string $next_step_html
289 289
 	 */
290
-	public function set_reg_step_html( $next_step_html ) {
290
+	public function set_reg_step_html($next_step_html) {
291 291
 		$this->_reg_step_html = $next_step_html;
292 292
 	}
293 293
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	/**
306 306
 	 * @param string $redirect_form
307 307
 	 */
308
-	public function set_redirect_form( $redirect_form ) {
308
+	public function set_redirect_form($redirect_form) {
309 309
 		$this->_redirect_form = $redirect_form;
310 310
 	}
311 311
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 * @return string
316 316
 	 */
317 317
 	public function redirect_form() {
318
-		return ! empty( $this->_redirect_form ) ? $this->_redirect_form : FALSE;
318
+		return ! empty($this->_redirect_form) ? $this->_redirect_form : FALSE;
319 319
 	}
320 320
 
321 321
 
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	/**
324 324
 	 * @param string $plz_select_method_of_payment
325 325
 	 */
326
-	public function set_plz_select_method_of_payment( $plz_select_method_of_payment ) {
326
+	public function set_plz_select_method_of_payment($plz_select_method_of_payment) {
327 327
 		$this->_plz_select_method_of_payment = $plz_select_method_of_payment;
328 328
 	}
329 329
 
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	/**
342 342
 	 * @param string $redirect_url
343 343
 	 */
344
-	public function set_redirect_url( $redirect_url ) {
344
+	public function set_redirect_url($redirect_url) {
345 345
 		$this->_redirect_url = $redirect_url;
346 346
 	}
347 347
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	/**
369 369
 	 * @param string $registration_time_limit
370 370
 	 */
371
-	public function set_registration_time_limit( $registration_time_limit ) {
371
+	public function set_registration_time_limit($registration_time_limit) {
372 372
 		$this->_registration_time_limit = $registration_time_limit;
373 373
 	}
374 374
 
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 	/**
378 378
 	 * @param array $return_data
379 379
 	 */
380
-	public function set_return_data( $return_data ) {
381
-		$this->_return_data = array_merge( $this->_return_data, $return_data );
380
+	public function set_return_data($return_data) {
381
+		$this->_return_data = array_merge($this->_return_data, $return_data);
382 382
 	}
383 383
 
384 384
 
@@ -395,9 +395,9 @@  discard block
 block discarded – undo
395 395
 	/**
396 396
 	 * @param array $validation_rules
397 397
 	 */
398
-	public function add_validation_rules( $validation_rules = array() ) {
399
-		if ( is_array( $validation_rules ) && ! empty( $validation_rules )) {
400
-			$this->_validation_rules = array_merge( $this->_validation_rules, $validation_rules );
398
+	public function add_validation_rules($validation_rules = array()) {
399
+		if (is_array($validation_rules) && ! empty($validation_rules)) {
400
+			$this->_validation_rules = array_merge($this->_validation_rules, $validation_rules);
401 401
 		}
402 402
 	}
403 403
 
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	 * @return array | bool
408 408
 	 */
409 409
 	public function validation_rules() {
410
-		return ! empty( $this->_validation_rules ) ? $this->_validation_rules : FALSE;
410
+		return ! empty($this->_validation_rules) ? $this->_validation_rules : FALSE;
411 411
 	}
412 412
 
413 413
 
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
  /**
3
- *
4
- * Class EE_SPCO_JSON_Response
5
- *
6
- * Description
7
- *
8
- * @package         Event Espresso
9
- * @subpackage    core
10
- * @author				Brent Christensen
11
- * 
12
- *
13
- */
3
+  *
4
+  * Class EE_SPCO_JSON_Response
5
+  *
6
+  * Description
7
+  *
8
+  * @package         Event Espresso
9
+  * @subpackage    core
10
+  * @author				Brent Christensen
11
+  * 
12
+  *
13
+  */
14 14
 class EE_SPCO_JSON_Response {
15 15
 
16 16
 	/**
Please login to merge, or discard this patch.