Completed
Branch BUG/fix-ee-rest-debug-headers (1355bc)
by
unknown
03:29 queued 18s
created
4_5_0_stages/EE_DMS_4_5_0_update_wp_user_for_question_groups.dmsstage.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -9,39 +9,39 @@
 block discarded – undo
9 9
 */
10 10
 class EE_DMS_4_5_0_update_wp_user_for_question_groups extends EE_Data_Migration_Script_Stage_Table
11 11
 {
12
-    public function __construct()
13
-    {
14
-        global $wpdb;
15
-        $this->_pretty_name = esc_html__("Question Groups", "event_espresso");
16
-        $this->_old_table = $wpdb->prefix . "esp_question_group";
17
-        parent::__construct();
18
-    }
19
-    protected function _migrate_old_row($old_row)
20
-    {
21
-        // foreach ticket row we add the id for the current logged in user.
22
-        global $wpdb;
23
-        $user_id = EEH_Activation::get_default_creator_id();
24
-        $updated = $wpdb->update(
25
-            $this->_old_table,
26
-            array('QSG_wp_user' => $user_id),
27
-            array('QSG_ID' => $old_row['QSG_ID']),
28
-            array('%d',// QSG_wp_user
29
-                    ),
30
-            array('%d',// QSG_ID
31
-                    )
32
-        );
33
-        if (false === $updated) {
34
-            $this->add_error(
35
-                sprintf(
36
-                    esc_html__(
37
-                        "Error in updating table %s setting QSG_wp_user = %d where QSG_ID = %d",
38
-                        'event_espresso'
39
-                    ),
40
-                    $this->_old_table,
41
-                    $user_id,
42
-                    $old_row['QSG_ID']
43
-                )
44
-            );
45
-        }
46
-    }
12
+	public function __construct()
13
+	{
14
+		global $wpdb;
15
+		$this->_pretty_name = esc_html__("Question Groups", "event_espresso");
16
+		$this->_old_table = $wpdb->prefix . "esp_question_group";
17
+		parent::__construct();
18
+	}
19
+	protected function _migrate_old_row($old_row)
20
+	{
21
+		// foreach ticket row we add the id for the current logged in user.
22
+		global $wpdb;
23
+		$user_id = EEH_Activation::get_default_creator_id();
24
+		$updated = $wpdb->update(
25
+			$this->_old_table,
26
+			array('QSG_wp_user' => $user_id),
27
+			array('QSG_ID' => $old_row['QSG_ID']),
28
+			array('%d',// QSG_wp_user
29
+					),
30
+			array('%d',// QSG_ID
31
+					)
32
+		);
33
+		if (false === $updated) {
34
+			$this->add_error(
35
+				sprintf(
36
+					esc_html__(
37
+						"Error in updating table %s setting QSG_wp_user = %d where QSG_ID = %d",
38
+						'event_espresso'
39
+					),
40
+					$this->_old_table,
41
+					$user_id,
42
+					$old_row['QSG_ID']
43
+				)
44
+			);
45
+		}
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     {
14 14
         global $wpdb;
15 15
         $this->_pretty_name = esc_html__("Question Groups", "event_espresso");
16
-        $this->_old_table = $wpdb->prefix . "esp_question_group";
16
+        $this->_old_table = $wpdb->prefix."esp_question_group";
17 17
         parent::__construct();
18 18
     }
19 19
     protected function _migrate_old_row($old_row)
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
             $this->_old_table,
26 26
             array('QSG_wp_user' => $user_id),
27 27
             array('QSG_ID' => $old_row['QSG_ID']),
28
-            array('%d',// QSG_wp_user
28
+            array('%d', // QSG_wp_user
29 29
                     ),
30
-            array('%d',// QSG_ID
30
+            array('%d', // QSG_ID
31 31
                     )
32 32
         );
33 33
         if (false === $updated) {
Please login to merge, or discard this patch.
4_5_0_stages/EE_DMS_4_5_0_invoice_settings.dmsstage.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
     protected function _migration_step($num_items = 1)
55 55
     {
56 56
         // if this isn't set then something is really wrong
57
-        if (! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
57
+        if ( ! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
58 58
             throw new EE_Error(esc_html__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
59 59
         }
60 60
         $invoice_settings = isset(EE_Config::instance()->gateway->payment_settings['Invoice']) ? EE_Config::instance()->gateway->payment_settings['Invoice'] : null;
61
-        if (! $invoice_settings) {
61
+        if ( ! $invoice_settings) {
62 62
             $this->add_error(esc_html__('Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso'));
63 63
         } else {
64 64
             $invoice_settings['template_payment_instructions'] = $invoice_settings['pdf_instructions'];
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
                 );
94 94
             }
95 95
             $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
96
-            $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true);
97
-            $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true);
96
+            $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', null, false, false, true);
97
+            $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', null, false, false, true);
98 98
             if ($overridden_invoice_body || $overridden_receipt_body) {
99 99
                 new PersistentAdminNotice(
100 100
                     'invoice_overriding_templates',
Please login to merge, or discard this patch.
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -16,97 +16,97 @@
 block discarded – undo
16 16
  */
17 17
 class EE_DMS_4_5_0_invoice_settings extends EE_Data_Migration_Script_Stage
18 18
 {
19
-    /**
20
-     * Just initializes the status of the migration
21
-     */
22
-    public function __construct()
23
-    {
24
-        $this->_pretty_name = esc_html__('Update Invoice Gateway Settings', 'event_espresso');
25
-        parent::__construct();
26
-    }
19
+	/**
20
+	 * Just initializes the status of the migration
21
+	 */
22
+	public function __construct()
23
+	{
24
+		$this->_pretty_name = esc_html__('Update Invoice Gateway Settings', 'event_espresso');
25
+		parent::__construct();
26
+	}
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * _count_records_to_migrate
32
-     * Counts the records to migrate; the public version may cache it
33
-     *
34
-     * @access protected
35
-     * @return int
36
-     */
37
-    protected function _count_records_to_migrate()
38
-    {
39
-        return 1;
40
-    }
30
+	/**
31
+	 * _count_records_to_migrate
32
+	 * Counts the records to migrate; the public version may cache it
33
+	 *
34
+	 * @access protected
35
+	 * @return int
36
+	 */
37
+	protected function _count_records_to_migrate()
38
+	{
39
+		return 1;
40
+	}
41 41
 
42 42
 
43 43
 
44
-    /**
45
-     *    _migration_step
46
-     *
47
-     * @access protected
48
-     * @param int $num_items
49
-     * @throws EE_Error
50
-     * @return int number of items ACTUALLY migrated
51
-     * @throws InvalidDataTypeException
52
-     */
53
-    protected function _migration_step($num_items = 1)
54
-    {
55
-        // if this isn't set then something is really wrong
56
-        if (! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
57
-            throw new EE_Error(esc_html__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
58
-        }
59
-        $invoice_settings = isset(EE_Config::instance()->gateway->payment_settings['Invoice']) ? EE_Config::instance()->gateway->payment_settings['Invoice'] : null;
60
-        if (! $invoice_settings) {
61
-            $this->add_error(esc_html__('Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso'));
62
-        } else {
63
-            $invoice_settings['template_payment_instructions'] = $invoice_settings['pdf_instructions'];
64
-            $invoice_settings['template_invoice_payee_name'] = $invoice_settings['payable_to'];
65
-            $invoice_settings['template_invoice_address'] = $invoice_settings['payment_address'];
66
-            $invoice_settings['template_invoice_email'] = '';
67
-            $invoice_settings['template_invoice_tax_number'] = '';
68
-            unset($invoice_settings['pdf_instructions']);
69
-            unset($invoice_settings['payable_to']);
70
-            unset($invoice_settings['payment_address']);
71
-            EE_Config::instance()->gateway->payment_settings['Invoice'] = $invoice_settings;
72
-            EE_Config::instance()->update_espresso_config(false, false);
44
+	/**
45
+	 *    _migration_step
46
+	 *
47
+	 * @access protected
48
+	 * @param int $num_items
49
+	 * @throws EE_Error
50
+	 * @return int number of items ACTUALLY migrated
51
+	 * @throws InvalidDataTypeException
52
+	 */
53
+	protected function _migration_step($num_items = 1)
54
+	{
55
+		// if this isn't set then something is really wrong
56
+		if (! EE_Config::instance()->gateway instanceof EE_Gateway_Config) {
57
+			throw new EE_Error(esc_html__('It appears the Event Espresso Core Configuration is not setup correctly.', 'event_espresso'));
58
+		}
59
+		$invoice_settings = isset(EE_Config::instance()->gateway->payment_settings['Invoice']) ? EE_Config::instance()->gateway->payment_settings['Invoice'] : null;
60
+		if (! $invoice_settings) {
61
+			$this->add_error(esc_html__('Could not migrate EE4.4 invoice settings to EE4.5 because they didnt exist', 'event_espresso'));
62
+		} else {
63
+			$invoice_settings['template_payment_instructions'] = $invoice_settings['pdf_instructions'];
64
+			$invoice_settings['template_invoice_payee_name'] = $invoice_settings['payable_to'];
65
+			$invoice_settings['template_invoice_address'] = $invoice_settings['payment_address'];
66
+			$invoice_settings['template_invoice_email'] = '';
67
+			$invoice_settings['template_invoice_tax_number'] = '';
68
+			unset($invoice_settings['pdf_instructions']);
69
+			unset($invoice_settings['payable_to']);
70
+			unset($invoice_settings['payment_address']);
71
+			EE_Config::instance()->gateway->payment_settings['Invoice'] = $invoice_settings;
72
+			EE_Config::instance()->update_espresso_config(false, false);
73 73
 
74
-            // @todo: check 'invoice_css' too because we can't easily affect that so we might need to set a persistent notice
75
-            // (why is it tough to change? because we want to update the receipt and invoice message template, but
76
-            // message templates are only initialized AFTER migrations and those two are new in 4.5. So if we wanted to
77
-            // update them from a DMS, we'd need to have the DMS create the message templates which is quite a lot of code;
78
-            // also we don't want to build a dependency on the messages code because it is likely to change soon
79
-            if (
80
-                isset($invoice_settings['invoice_css'])
81
-                && ! in_array($invoice_settings['invoice_css'], ['', 'simple.css'])
82
-            ) {
83
-                new PersistentAdminNotice(
84
-                    'invoice_css_not_updated',
85
-                    sprintf(
86
-                        esc_html__(
87
-                            'You had previously set your Invoice Payment Method\'s stylesheet to be %1$s, but that setting has moved. PDF and HTML Invoices and Receipts are now Messages, which means you can easily modify them from your Wordpress Dashboard instead of using filters or uploading template files. Please visit Messages -> Receipt and Messages -> Invoice to change their stylesheets.',
88
-                            'event_espresso'
89
-                        ),
90
-                        $invoice_settings['invoice_css']
91
-                    )
92
-                );
93
-            }
94
-            $templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
95
-            $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true);
96
-            $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true);
97
-            if ($overridden_invoice_body || $overridden_receipt_body) {
98
-                new PersistentAdminNotice(
99
-                    'invoice_overriding_templates',
100
-                    esc_html__(
101
-                        'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents. We recommend deleting your old Invoice/Receipt templates and modifying the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.',
102
-                        'event_espresso'
103
-                    ),
104
-                    true
105
-                );
106
-            }
107
-        }
108
-        // regardless of whether it worked or not, we ought to continue the migration
109
-        $this->set_completed();
110
-        return 1;
111
-    }
74
+			// @todo: check 'invoice_css' too because we can't easily affect that so we might need to set a persistent notice
75
+			// (why is it tough to change? because we want to update the receipt and invoice message template, but
76
+			// message templates are only initialized AFTER migrations and those two are new in 4.5. So if we wanted to
77
+			// update them from a DMS, we'd need to have the DMS create the message templates which is quite a lot of code;
78
+			// also we don't want to build a dependency on the messages code because it is likely to change soon
79
+			if (
80
+				isset($invoice_settings['invoice_css'])
81
+				&& ! in_array($invoice_settings['invoice_css'], ['', 'simple.css'])
82
+			) {
83
+				new PersistentAdminNotice(
84
+					'invoice_css_not_updated',
85
+					sprintf(
86
+						esc_html__(
87
+							'You had previously set your Invoice Payment Method\'s stylesheet to be %1$s, but that setting has moved. PDF and HTML Invoices and Receipts are now Messages, which means you can easily modify them from your Wordpress Dashboard instead of using filters or uploading template files. Please visit Messages -> Receipt and Messages -> Invoice to change their stylesheets.',
88
+							'event_espresso'
89
+						),
90
+						$invoice_settings['invoice_css']
91
+					)
92
+				);
93
+			}
94
+			$templates_relative_path = 'modules/gateways/Invoice/lib/templates/';
95
+			$overridden_invoice_body = EEH_Template::locate_template($templates_relative_path . 'invoice_body.template.php', null, false, false, true);
96
+			$overridden_receipt_body = EEH_Template::locate_template($templates_relative_path . 'receipt_body.template.php', null, false, false, true);
97
+			if ($overridden_invoice_body || $overridden_receipt_body) {
98
+				new PersistentAdminNotice(
99
+					'invoice_overriding_templates',
100
+					esc_html__(
101
+						'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents. We recommend deleting your old Invoice/Receipt templates and modifying the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.',
102
+						'event_espresso'
103
+					),
104
+					true
105
+				);
106
+			}
107
+		}
108
+		// regardless of whether it worked or not, we ought to continue the migration
109
+		$this->set_completed();
110
+		return 1;
111
+	}
112 112
 }
Please login to merge, or discard this patch.
4_5_0_stages/EE_DMS_4_5_0_update_wp_user_for_tickets.dmsstage.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -9,39 +9,39 @@
 block discarded – undo
9 9
 */
10 10
 class EE_DMS_4_5_0_update_wp_user_for_tickets extends EE_Data_Migration_Script_Stage_Table
11 11
 {
12
-    public function __construct()
13
-    {
14
-        global $wpdb;
15
-        $this->_pretty_name = esc_html__("Tickets", "event_espresso");
16
-        $this->_old_table = $wpdb->prefix . "esp_ticket";
17
-        parent::__construct();
18
-    }
19
-    protected function _migrate_old_row($old_row)
20
-    {
21
-        // foreach ticket row we add the id for the current logged in user.
22
-        global $wpdb;
23
-        $user_id = EEH_Activation::get_default_creator_id();
24
-        $updated = $wpdb->update(
25
-            $this->_old_table,
26
-            array('TKT_wp_user' => $user_id),
27
-            array('TKT_ID' => $old_row['TKT_ID']),
28
-            array('%d',// TKT_wp_user
29
-                    ),
30
-            array('%d',// TKT_ID
31
-                    )
32
-        );
33
-        if (false === $updated) {
34
-            $this->add_error(
35
-                sprintf(
36
-                    esc_html__(
37
-                        "Error in updating table %s setting TKT_wp_user = %d where TKT_ID = %d",
38
-                        'event_espresso'
39
-                    ),
40
-                    $this->_old_table,
41
-                    $user_id,
42
-                    $old_row['TKT_ID']
43
-                )
44
-            );
45
-        }
46
-    }
12
+	public function __construct()
13
+	{
14
+		global $wpdb;
15
+		$this->_pretty_name = esc_html__("Tickets", "event_espresso");
16
+		$this->_old_table = $wpdb->prefix . "esp_ticket";
17
+		parent::__construct();
18
+	}
19
+	protected function _migrate_old_row($old_row)
20
+	{
21
+		// foreach ticket row we add the id for the current logged in user.
22
+		global $wpdb;
23
+		$user_id = EEH_Activation::get_default_creator_id();
24
+		$updated = $wpdb->update(
25
+			$this->_old_table,
26
+			array('TKT_wp_user' => $user_id),
27
+			array('TKT_ID' => $old_row['TKT_ID']),
28
+			array('%d',// TKT_wp_user
29
+					),
30
+			array('%d',// TKT_ID
31
+					)
32
+		);
33
+		if (false === $updated) {
34
+			$this->add_error(
35
+				sprintf(
36
+					esc_html__(
37
+						"Error in updating table %s setting TKT_wp_user = %d where TKT_ID = %d",
38
+						'event_espresso'
39
+					),
40
+					$this->_old_table,
41
+					$user_id,
42
+					$old_row['TKT_ID']
43
+				)
44
+			);
45
+		}
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     {
14 14
         global $wpdb;
15 15
         $this->_pretty_name = esc_html__("Tickets", "event_espresso");
16
-        $this->_old_table = $wpdb->prefix . "esp_ticket";
16
+        $this->_old_table = $wpdb->prefix."esp_ticket";
17 17
         parent::__construct();
18 18
     }
19 19
     protected function _migrate_old_row($old_row)
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
             $this->_old_table,
26 26
             array('TKT_wp_user' => $user_id),
27 27
             array('TKT_ID' => $old_row['TKT_ID']),
28
-            array('%d',// TKT_wp_user
28
+            array('%d', // TKT_wp_user
29 29
                     ),
30
-            array('%d',// TKT_ID
30
+            array('%d', // TKT_ID
31 31
                     )
32 32
         );
33 33
         if (false === $updated) {
Please login to merge, or discard this patch.
4_5_0_stages/EE_DMS_4_5_0_update_wp_user_for_price_types.dmsstage.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -9,36 +9,36 @@
 block discarded – undo
9 9
 */
10 10
 class EE_DMS_4_5_0_update_wp_user_for_price_types extends EE_Data_Migration_Script_Stage_Table
11 11
 {
12
-    public function __construct()
13
-    {
14
-        global $wpdb;
15
-        $this->_pretty_name = esc_html__("Price Types", "event_espresso");
16
-        $this->_old_table = $wpdb->prefix . "esp_price_type";
17
-        parent::__construct();
18
-    }
19
-    protected function _migrate_old_row($old_row)
20
-    {
21
-        // foreach ticket row we add the id for the current logged in user.
22
-        global $wpdb;
23
-        $user_id = EEH_Activation::get_default_creator_id();
24
-        $updated = $wpdb->update(
25
-            $this->_old_table,
26
-            array('PRT_wp_user' => $user_id),
27
-            array('PRT_ID' => $old_row['PRT_ID']),
28
-            array('%d',// PRT_wp_user
29
-                    ),
30
-            array('%d',// PRT_ID
31
-                    )
32
-        );
33
-        if (false === $updated) {
34
-            $this->add_error(
35
-                sprintf(
36
-                    esc_html__("Error in updating table %s setting PRT_wp_user = %d where PRT_ID = %d", 'event_espresso'),
37
-                    $this->_old_table,
38
-                    $user_id,
39
-                    $old_row['PRT_ID']
40
-                )
41
-            );
42
-        }
43
-    }
12
+	public function __construct()
13
+	{
14
+		global $wpdb;
15
+		$this->_pretty_name = esc_html__("Price Types", "event_espresso");
16
+		$this->_old_table = $wpdb->prefix . "esp_price_type";
17
+		parent::__construct();
18
+	}
19
+	protected function _migrate_old_row($old_row)
20
+	{
21
+		// foreach ticket row we add the id for the current logged in user.
22
+		global $wpdb;
23
+		$user_id = EEH_Activation::get_default_creator_id();
24
+		$updated = $wpdb->update(
25
+			$this->_old_table,
26
+			array('PRT_wp_user' => $user_id),
27
+			array('PRT_ID' => $old_row['PRT_ID']),
28
+			array('%d',// PRT_wp_user
29
+					),
30
+			array('%d',// PRT_ID
31
+					)
32
+		);
33
+		if (false === $updated) {
34
+			$this->add_error(
35
+				sprintf(
36
+					esc_html__("Error in updating table %s setting PRT_wp_user = %d where PRT_ID = %d", 'event_espresso'),
37
+					$this->_old_table,
38
+					$user_id,
39
+					$old_row['PRT_ID']
40
+				)
41
+			);
42
+		}
43
+	}
44 44
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     {
14 14
         global $wpdb;
15 15
         $this->_pretty_name = esc_html__("Price Types", "event_espresso");
16
-        $this->_old_table = $wpdb->prefix . "esp_price_type";
16
+        $this->_old_table = $wpdb->prefix."esp_price_type";
17 17
         parent::__construct();
18 18
     }
19 19
     protected function _migrate_old_row($old_row)
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
             $this->_old_table,
26 26
             array('PRT_wp_user' => $user_id),
27 27
             array('PRT_ID' => $old_row['PRT_ID']),
28
-            array('%d',// PRT_wp_user
28
+            array('%d', // PRT_wp_user
29 29
                     ),
30
-            array('%d',// PRT_ID
30
+            array('%d', // PRT_ID
31 31
                     )
32 32
         );
33 33
         if (false === $updated) {
Please login to merge, or discard this patch.
4_5_0_stages/EE_DMS_4_5_0_update_wp_user_for_prices.dmsstage.php 2 patches
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -9,39 +9,39 @@
 block discarded – undo
9 9
 */
10 10
 class EE_DMS_4_5_0_update_wp_user_for_prices extends EE_Data_Migration_Script_Stage_Table
11 11
 {
12
-    public function __construct()
13
-    {
14
-        global $wpdb;
15
-        $this->_pretty_name = esc_html__("Prices", "event_espresso");
16
-        $this->_old_table = $wpdb->prefix . "esp_price";
17
-        parent::__construct();
18
-    }
19
-    protected function _migrate_old_row($old_row)
20
-    {
21
-        // foreach ticket row we add the id for the current logged in user.
22
-        global $wpdb;
23
-        $user_id = EEH_Activation::get_default_creator_id();
24
-        $updated = $wpdb->update(
25
-            $this->_old_table,
26
-            array('PRC_wp_user' => $user_id),
27
-            array('PRC_ID' => $old_row['PRC_ID']),
28
-            array('%d',// PRC_wp_user
29
-                    ),
30
-            array('%d',// PRC_ID
31
-                    )
32
-        );
33
-        if (false === $updated) {
34
-            $this->add_error(
35
-                sprintf(
36
-                    esc_html__(
37
-                        "Error in updating table %s setting PRC_wp_user = %d where PRC_ID = %d",
38
-                        'event_espresso'
39
-                    ),
40
-                    $this->_old_table,
41
-                    $user_id,
42
-                    $old_row['PRC_ID']
43
-                )
44
-            );
45
-        }
46
-    }
12
+	public function __construct()
13
+	{
14
+		global $wpdb;
15
+		$this->_pretty_name = esc_html__("Prices", "event_espresso");
16
+		$this->_old_table = $wpdb->prefix . "esp_price";
17
+		parent::__construct();
18
+	}
19
+	protected function _migrate_old_row($old_row)
20
+	{
21
+		// foreach ticket row we add the id for the current logged in user.
22
+		global $wpdb;
23
+		$user_id = EEH_Activation::get_default_creator_id();
24
+		$updated = $wpdb->update(
25
+			$this->_old_table,
26
+			array('PRC_wp_user' => $user_id),
27
+			array('PRC_ID' => $old_row['PRC_ID']),
28
+			array('%d',// PRC_wp_user
29
+					),
30
+			array('%d',// PRC_ID
31
+					)
32
+		);
33
+		if (false === $updated) {
34
+			$this->add_error(
35
+				sprintf(
36
+					esc_html__(
37
+						"Error in updating table %s setting PRC_wp_user = %d where PRC_ID = %d",
38
+						'event_espresso'
39
+					),
40
+					$this->_old_table,
41
+					$user_id,
42
+					$old_row['PRC_ID']
43
+				)
44
+			);
45
+		}
46
+	}
47 47
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     {
14 14
         global $wpdb;
15 15
         $this->_pretty_name = esc_html__("Prices", "event_espresso");
16
-        $this->_old_table = $wpdb->prefix . "esp_price";
16
+        $this->_old_table = $wpdb->prefix."esp_price";
17 17
         parent::__construct();
18 18
     }
19 19
     protected function _migrate_old_row($old_row)
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
             $this->_old_table,
26 26
             array('PRC_wp_user' => $user_id),
27 27
             array('PRC_ID' => $old_row['PRC_ID']),
28
-            array('%d',// PRC_wp_user
28
+            array('%d', // PRC_wp_user
29 29
                     ),
30
-            array('%d',// PRC_ID
30
+            array('%d', // PRC_ID
31 31
                     )
32 32
         );
33 33
         if (false === $updated) {
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_5_0.dms.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,12 +15,12 @@  discard block
 block discarded – undo
15 15
 // unfortunately, this needs to be done upon INCLUSION of this file,
16 16
 // instead of construction, because it only gets constructed on first page load
17 17
 // (all other times it gets resurrected from a wordpress option)
18
-$stages = glob(EE_CORE . 'data_migration_scripts/4_5_0_stages/*');
18
+$stages = glob(EE_CORE.'data_migration_scripts/4_5_0_stages/*');
19 19
 $class_to_filepath = array();
20 20
 foreach ($stages as $filepath) {
21 21
     $matches = array();
22 22
     preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches);
23
-    $class_to_filepath[ $matches[1] ] = $filepath;
23
+    $class_to_filepath[$matches[1]] = $filepath;
24 24
 }
25 25
 // give addons a chance to autoload their stages too
26 26
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages', $class_to_filepath);
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
         if (version_compare($version_string, '4.5.0.decaf', '<') && version_compare($version_string, '4.3.0.decaf', '>=')) {
62 62
 //          echo "$version_string can be migrated from";
63 63
             return true;
64
-        } elseif (! $version_string) {
64
+        } elseif ( ! $version_string) {
65 65
 //          echo "no version string provided: $version_string";
66 66
             // no version string provided... this must be pre 4.3
67
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
67
+            return false; // changed mind. dont want people thinking they should migrate yet because they cant
68 68
         } else {
69 69
 //          echo "$version_string doesnt apply";
70 70
             return false;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     public function schema_changes_before_migration()
77 77
     {
78 78
         // relies on 4.1's EEH_Activation::create_table
79
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
79
+        require_once(EE_HELPERS.'EEH_Activation.helper.php');
80 80
         $table_name = 'esp_answer';
81 81
         $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
82 82
 					REG_ID int(10) unsigned NOT NULL,
@@ -481,18 +481,18 @@  discard block
 block discarded – undo
481 481
     public function insert_default_price_types()
482 482
     {
483 483
         global $wpdb;
484
-        $price_type_table = $wpdb->prefix . "esp_price_type";
484
+        $price_type_table = $wpdb->prefix."esp_price_type";
485 485
         if ($this->_get_table_analysis()->tableExists($price_type_table)) {
486
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
486
+            $SQL = 'SELECT COUNT(PRT_ID) FROM '.$price_type_table;
487 487
             $price_types_exist = $wpdb->get_var($SQL);
488
-            if (! $price_types_exist) {
488
+            if ( ! $price_types_exist) {
489 489
                 $user_id = EEH_Activation::get_default_creator_id();
490 490
                 $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES
491
-							(1, '" . esc_html__('Base Price', 'event_espresso') . "', 1,  0, 0, $user_id, 0),
492
-							(2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2,  1, 20, $user_id, 0),
493
-							(3, '" . esc_html__('Dollar Discount', 'event_espresso') . "', 2,  0, 30, $user_id, 0),
494
-							(4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, $user_id,  0),
495
-							(5, '" . esc_html__('Dollar Surcharge', 'event_espresso') . "', 3,  0, 50, $user_id, 0);";
491
+							(1, '".esc_html__('Base Price', 'event_espresso')."', 1,  0, 0, $user_id, 0),
492
+							(2, '".esc_html__('Percent Discount', 'event_espresso')."', 2,  1, 20, $user_id, 0),
493
+							(3, '".esc_html__('Dollar Discount', 'event_espresso')."', 2,  0, 30, $user_id, 0),
494
+							(4, '".esc_html__('Percent Surcharge', 'event_espresso')."', 3,  1, 40, $user_id,  0),
495
+							(5, '".esc_html__('Dollar Surcharge', 'event_espresso')."', 3,  0, 50, $user_id, 0);";
496 496
                 $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL);
497 497
                 $wpdb->query($SQL);
498 498
             }
@@ -513,11 +513,11 @@  discard block
 block discarded – undo
513 513
     public function insert_default_prices()
514 514
     {
515 515
         global $wpdb;
516
-        $price_table = $wpdb->prefix . "esp_price";
516
+        $price_table = $wpdb->prefix."esp_price";
517 517
         if ($this->_get_table_analysis()->tableExists($price_table)) {
518
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
518
+            $SQL = 'SELECT COUNT(PRC_ID) FROM '.$price_table;
519 519
             $prices_exist = $wpdb->get_var($SQL);
520
-            if (! $prices_exist) {
520
+            if ( ! $prices_exist) {
521 521
                 $user_id = EEH_Activation::get_default_creator_id();
522 522
                 $SQL = "INSERT INTO $price_table
523 523
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_wp_user, PRC_order, PRC_deleted, PRC_parent ) VALUES
@@ -540,11 +540,11 @@  discard block
 block discarded – undo
540 540
     public function insert_default_tickets()
541 541
     {
542 542
         global $wpdb;
543
-        $ticket_table = $wpdb->prefix . "esp_ticket";
543
+        $ticket_table = $wpdb->prefix."esp_ticket";
544 544
         if ($this->_get_table_analysis()->tableExists($ticket_table)) {
545
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
545
+            $SQL = 'SELECT COUNT(TKT_ID) FROM '.$ticket_table;
546 546
             $tickets_exist = $wpdb->get_var($SQL);
547
-            if (! $tickets_exist) {
547
+            if ( ! $tickets_exist) {
548 548
                 $user_id = EEH_Activation::get_default_creator_id();
549 549
                 $SQL = "INSERT INTO $ticket_table
550 550
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_wp_user, TKT_deleted ) VALUES
@@ -555,11 +555,11 @@  discard block
 block discarded – undo
555 555
                 $wpdb->query($SQL);
556 556
             }
557 557
         }
558
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
558
+        $ticket_price_table = $wpdb->prefix."esp_ticket_price";
559 559
         if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
560
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
560
+            $SQL = 'SELECT COUNT(TKP_ID) FROM '.$ticket_price_table;
561 561
             $ticket_prc_exist = $wpdb->get_var($SQL);
562
-            if (! $ticket_prc_exist) {
562
+            if ( ! $ticket_prc_exist) {
563 563
                 $SQL = "INSERT INTO $ticket_price_table
564 564
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
565 565
 				( 1, 1, 1 )
Please login to merge, or discard this patch.
Indentation   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
 $stages = glob(EE_CORE . 'data_migration_scripts/4_5_0_stages/*');
19 19
 $class_to_filepath = array();
20 20
 foreach ($stages as $filepath) {
21
-    $matches = array();
22
-    preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches);
23
-    $class_to_filepath[ $matches[1] ] = $filepath;
21
+	$matches = array();
22
+	preg_match('~4_5_0_stages/(.*).dmsstage.php~', $filepath, $matches);
23
+	$class_to_filepath[ $matches[1] ] = $filepath;
24 24
 }
25 25
 // give addons a chance to autoload their stages too
26 26
 $class_to_filepath = apply_filters('FHEE__EE_DMS_4_5_0__autoloaded_stages', $class_to_filepath);
@@ -30,59 +30,59 @@  discard block
 block discarded – undo
30 30
 
31 31
 class EE_DMS_Core_4_5_0 extends EE_Data_Migration_Script_Base
32 32
 {
33
-    /**
34
-     * EE_DMS_Core_4_5_0 constructor.
35
-     *
36
-     * @param TableManager  $table_manager
37
-     * @param TableAnalysis $table_analysis
38
-     */
39
-    public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
40
-    {
41
-        $this->_pretty_name = esc_html__("Data Update to Event Espresso 4.5.0", "event_espresso");
42
-        $this->_priority = 10;
43
-        $this->_migration_stages = array(
44
-            new EE_DMS_4_5_0_update_wp_user_for_tickets(),
45
-            new EE_DMS_4_5_0_update_wp_user_for_prices(),
46
-            new EE_DMS_4_5_0_update_wp_user_for_price_types(),
47
-            new EE_DMS_4_5_0_update_wp_user_for_question_groups(),
48
-            new EE_DMS_4_5_0_invoice_settings(),
49
-        );
50
-        parent::__construct($table_manager, $table_analysis);
51
-    }
33
+	/**
34
+	 * EE_DMS_Core_4_5_0 constructor.
35
+	 *
36
+	 * @param TableManager  $table_manager
37
+	 * @param TableAnalysis $table_analysis
38
+	 */
39
+	public function __construct(TableManager $table_manager = null, TableAnalysis $table_analysis = null)
40
+	{
41
+		$this->_pretty_name = esc_html__("Data Update to Event Espresso 4.5.0", "event_espresso");
42
+		$this->_priority = 10;
43
+		$this->_migration_stages = array(
44
+			new EE_DMS_4_5_0_update_wp_user_for_tickets(),
45
+			new EE_DMS_4_5_0_update_wp_user_for_prices(),
46
+			new EE_DMS_4_5_0_update_wp_user_for_price_types(),
47
+			new EE_DMS_4_5_0_update_wp_user_for_question_groups(),
48
+			new EE_DMS_4_5_0_invoice_settings(),
49
+		);
50
+		parent::__construct($table_manager, $table_analysis);
51
+	}
52 52
 
53 53
 
54 54
 
55
-    public function can_migrate_from_version($version_array)
56
-    {
57
-        $version_string = $version_array['Core'];
58
-        if (version_compare($version_string, '4.5.0.decaf', '<') && version_compare($version_string, '4.3.0.decaf', '>=')) {
55
+	public function can_migrate_from_version($version_array)
56
+	{
57
+		$version_string = $version_array['Core'];
58
+		if (version_compare($version_string, '4.5.0.decaf', '<') && version_compare($version_string, '4.3.0.decaf', '>=')) {
59 59
 //          echo "$version_string can be migrated from";
60
-            return true;
61
-        } elseif (! $version_string) {
60
+			return true;
61
+		} elseif (! $version_string) {
62 62
 //          echo "no version string provided: $version_string";
63
-            // no version string provided... this must be pre 4.3
64
-            return false;// changed mind. dont want people thinking they should migrate yet because they cant
65
-        } else {
63
+			// no version string provided... this must be pre 4.3
64
+			return false;// changed mind. dont want people thinking they should migrate yet because they cant
65
+		} else {
66 66
 //          echo "$version_string doesnt apply";
67
-            return false;
68
-        }
69
-    }
67
+			return false;
68
+		}
69
+	}
70 70
 
71 71
 
72 72
 
73
-    public function schema_changes_before_migration()
74
-    {
75
-        // relies on 4.1's EEH_Activation::create_table
76
-        require_once(EE_HELPERS . 'EEH_Activation.helper.php');
77
-        $table_name = 'esp_answer';
78
-        $sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
73
+	public function schema_changes_before_migration()
74
+	{
75
+		// relies on 4.1's EEH_Activation::create_table
76
+		require_once(EE_HELPERS . 'EEH_Activation.helper.php');
77
+		$table_name = 'esp_answer';
78
+		$sql = "ANS_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
79 79
 					REG_ID int(10) unsigned NOT NULL,
80 80
 					QST_ID int(10) unsigned NOT NULL,
81 81
 					ANS_value text NOT NULL,
82 82
 					PRIMARY KEY  (ANS_ID)";
83
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
84
-        $table_name = 'esp_attendee_meta';
85
-        $sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
83
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
84
+		$table_name = 'esp_attendee_meta';
85
+		$sql = "ATTM_ID int(10) unsigned NOT	NULL AUTO_INCREMENT,
86 86
 						ATT_ID bigint(20) unsigned NOT NULL,
87 87
 						ATT_fname varchar(45) NOT NULL,
88 88
 						ATT_lname varchar(45) NOT	NULL,
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 								KEY ATT_fname (ATT_fname),
99 99
 								KEY ATT_lname (ATT_lname),
100 100
 								KEY ATT_email (ATT_email(191))";
101
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
102
-        $table_name = 'esp_country';
103
-        $sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
101
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
102
+		$table_name = 'esp_country';
103
+		$sql = "CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
104 104
 					  CNT_ISO3 varchar(3) COLLATE utf8_bin NOT NULL,
105 105
 					  RGN_ID tinyint(3) unsigned DEFAULT NULL,
106 106
 					  CNT_name varchar(45) COLLATE utf8_bin NOT NULL,
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 					  CNT_is_EU tinyint(1) DEFAULT '0',
117 117
 					  CNT_active tinyint(1) DEFAULT '0',
118 118
 					  PRIMARY KEY  (CNT_ISO)";
119
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
120
-        $table_name = 'esp_datetime';
121
-        $sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
119
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
120
+		$table_name = 'esp_datetime';
121
+		$sql = "DTT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
122 122
 				  EVT_ID bigint(20) unsigned NOT NULL,
123 123
 				  DTT_name varchar(255) NOT NULL DEFAULT '',
124 124
 				  DTT_description text NOT NULL,
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 						PRIMARY KEY  (DTT_ID),
134 134
 						KEY EVT_ID (EVT_ID),
135 135
 						KEY DTT_is_primary (DTT_is_primary)";
136
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
137
-        $table_name = 'esp_event_meta';
138
-        $sql = "
136
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
137
+		$table_name = 'esp_event_meta';
138
+		$sql = "
139 139
 			EVTM_ID int(10) NOT NULL AUTO_INCREMENT,
140 140
 			EVT_ID bigint(20) unsigned NOT NULL,
141 141
 			EVT_display_desc tinyint(1) unsigned NOT NULL DEFAULT 1,
@@ -150,31 +150,31 @@  discard block
 block discarded – undo
150 150
 			EVT_external_URL varchar(200) NULL,
151 151
 			EVT_donations tinyint(1) NULL,
152 152
 			PRIMARY KEY  (EVTM_ID)";
153
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
154
-        $table_name = 'esp_event_question_group';
155
-        $sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
153
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
154
+		$table_name = 'esp_event_question_group';
155
+		$sql = "EQG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
156 156
 					EVT_ID bigint(20) unsigned NOT NULL,
157 157
 					QSG_ID int(10) unsigned NOT NULL,
158 158
 					EQG_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
159 159
 					PRIMARY KEY  (EQG_ID)";
160
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
161
-        $table_name = 'esp_event_venue';
162
-        $sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
160
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
161
+		$table_name = 'esp_event_venue';
162
+		$sql = "EVV_ID int(11) NOT NULL AUTO_INCREMENT,
163 163
 				EVT_ID bigint(20) unsigned NOT NULL,
164 164
 				VNU_ID bigint(20) unsigned NOT NULL,
165 165
 				EVV_primary tinyint(1) unsigned NOT NULL DEFAULT 0,
166 166
 				PRIMARY KEY  (EVV_ID)";
167
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
168
-        $table_name = 'esp_extra_meta';
169
-        $sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
167
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
168
+		$table_name = 'esp_extra_meta';
169
+		$sql = "EXM_ID int(11) NOT NULL AUTO_INCREMENT,
170 170
 				OBJ_ID int(11) DEFAULT NULL,
171 171
 				EXM_type varchar(45) DEFAULT NULL,
172 172
 				EXM_key varchar(45) DEFAULT NULL,
173 173
 				EXM_value text,
174 174
 				PRIMARY KEY  (EXM_ID)";
175
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
176
-        $table_name = 'esp_line_item';
177
-        $sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
175
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
176
+		$table_name = 'esp_line_item';
177
+		$sql = "LIN_ID int(11) NOT NULL AUTO_INCREMENT,
178 178
 				LIN_code varchar(245) NOT NULL DEFAULT '',
179 179
 				TXN_ID int(11) DEFAULT NULL,
180 180
 				LIN_name varchar(245) NOT NULL DEFAULT '',
@@ -190,19 +190,19 @@  discard block
 block discarded – undo
190 190
 				OBJ_ID int(11) DEFAULT NULL,
191 191
 				OBJ_type varchar(45)DEFAULT NULL,
192 192
 				PRIMARY KEY  (LIN_ID)";
193
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
194
-        $table_name = 'esp_message_template';
195
-        $sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
193
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
194
+		$table_name = 'esp_message_template';
195
+		$sql = "MTP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
196 196
 					GRP_ID int(10) unsigned NOT NULL,
197 197
 					MTP_context varchar(50) NOT NULL,
198 198
 					MTP_template_field varchar(30) NOT NULL,
199 199
 					MTP_content text NOT NULL,
200 200
 					PRIMARY KEY  (MTP_ID),
201 201
 					KEY GRP_ID (GRP_ID)";
202
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
203
-        $this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
204
-        $table_name = 'esp_message_template_group';
205
-        $sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
202
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
203
+		$this->_get_table_manager()->dropIndex('esp_message_template_group', 'EVT_ID');
204
+		$table_name = 'esp_message_template_group';
205
+		$sql = "GRP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
206 206
 					MTP_user_id int(10) NOT NULL DEFAULT '1',
207 207
 					MTP_name varchar(245) NOT NULL DEFAULT '',
208 208
 					MTP_description varchar(245) NOT NULL DEFAULT '',
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
 					MTP_is_active tinyint(1) NOT NULL DEFAULT '1',
215 215
 					PRIMARY KEY  (GRP_ID),
216 216
 					KEY MTP_user_id (MTP_user_id)";
217
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
218
-        $table_name = 'esp_event_message_template';
219
-        $sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
217
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
218
+		$table_name = 'esp_event_message_template';
219
+		$sql = "EMT_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT,
220 220
 					EVT_ID bigint(20) unsigned NOT NULL DEFAULT 0,
221 221
 					GRP_ID int(10) unsigned NOT NULL DEFAULT 0,
222 222
 					PRIMARY KEY  (EMT_ID),
223 223
 					KEY EVT_ID (EVT_ID),
224 224
 					KEY GRP_ID (GRP_ID)";
225
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
226
-        $table_name = 'esp_payment';
227
-        $sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
225
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
226
+		$table_name = 'esp_payment';
227
+		$sql = "PAY_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
228 228
 					TXN_ID int(10) unsigned DEFAULT NULL,
229 229
 					STS_ID varchar(3) COLLATE utf8_bin DEFAULT NULL,
230 230
 					PAY_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@@ -240,28 +240,28 @@  discard block
 block discarded – undo
240 240
 					PRIMARY KEY  (PAY_ID),
241 241
 					KEY TXN_ID (TXN_ID),
242 242
 					KEY PAY_timestamp (PAY_timestamp)";
243
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
244
-        $table_name = "esp_ticket_price";
245
-        $sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
243
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
244
+		$table_name = "esp_ticket_price";
245
+		$sql = "TKP_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
246 246
 					  TKT_ID int(10) unsigned NOT NULL,
247 247
 					  PRC_ID int(10) unsigned NOT NULL,
248 248
 					  PRIMARY KEY  (TKP_ID)";
249
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
250
-        $table_name = "esp_datetime_ticket";
251
-        $sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
249
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
250
+		$table_name = "esp_datetime_ticket";
251
+		$sql = "DTK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
252 252
 					  DTT_ID int(10) unsigned NOT NULL,
253 253
 					  TKT_ID int(10) unsigned NOT NULL,
254 254
 					  PRIMARY KEY  (DTK_ID)";
255
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
256
-        $table_name = "esp_ticket_template";
257
-        $sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
255
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
256
+		$table_name = "esp_ticket_template";
257
+		$sql = "TTM_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
258 258
 					  TTM_name varchar(45) NOT NULL,
259 259
 					  TTM_description text,
260 260
 					  TTM_file varchar(45),
261 261
 					  PRIMARY KEY  (TTM_ID)";
262
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
263
-        $table_name = 'esp_question';
264
-        $sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
262
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
263
+		$table_name = 'esp_question';
264
+		$sql = 'QST_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
265 265
 					QST_display_text text NOT NULL,
266 266
 					QST_admin_label varchar(255) NOT NULL,
267 267
 					QST_system varchar(25) DEFAULT NULL,
@@ -273,25 +273,25 @@  discard block
 block discarded – undo
273 273
 					QST_wp_user bigint(20) unsigned NULL,
274 274
 					QST_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
275 275
 					PRIMARY KEY  (QST_ID)';
276
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
277
-        $table_name = 'esp_question_group_question';
278
-        $sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
276
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
277
+		$table_name = 'esp_question_group_question';
278
+		$sql = "QGQ_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
279 279
 					QSG_ID int(10) unsigned NOT NULL,
280 280
 					QST_ID int(10) unsigned NOT NULL,
281 281
 					QGQ_order int(10) unsigned NOT NULL DEFAULT 0,
282 282
 					PRIMARY KEY  (QGQ_ID) ";
283
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
284
-        $table_name = 'esp_question_option';
285
-        $sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
283
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
284
+		$table_name = 'esp_question_option';
285
+		$sql = "QSO_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
286 286
 					QSO_value varchar(255) NOT NULL,
287 287
 					QSO_desc text NOT NULL,
288 288
 					QST_ID int(10) unsigned NOT NULL,
289 289
 					QSO_order int(10) unsigned NOT NULL DEFAULT 0,
290 290
 					QSO_deleted tinyint(1) unsigned NOT NULL DEFAULT 0,
291 291
 					PRIMARY KEY  (QSO_ID)";
292
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
293
-        $table_name = 'esp_registration';
294
-        $sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
292
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
293
+		$table_name = 'esp_registration';
294
+		$sql = "REG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
295 295
 					  EVT_ID bigint(20) unsigned NOT NULL,
296 296
 					  ATT_ID bigint(20) unsigned NOT NULL,
297 297
 					  TXN_ID int(10) unsigned NOT NULL,
@@ -314,25 +314,25 @@  discard block
 block discarded – undo
314 314
 					  KEY STS_ID (STS_ID),
315 315
 					  KEY REG_url_link (REG_url_link),
316 316
 					  KEY REG_code (REG_code)";
317
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
318
-        $table_name = 'esp_checkin';
319
-        $sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
317
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
318
+		$table_name = 'esp_checkin';
319
+		$sql = "CHK_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
320 320
 					REG_ID int(10) unsigned NOT NULL,
321 321
 					DTT_ID int(10) unsigned NOT NULL,
322 322
 					CHK_in tinyint(1) unsigned NOT NULL DEFAULT 1,
323 323
 					CHK_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
324 324
 					PRIMARY KEY  (CHK_ID)";
325
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
326
-        $table_name = 'esp_state';
327
-        $sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
325
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
326
+		$table_name = 'esp_state';
327
+		$sql = "STA_ID smallint(5) unsigned NOT NULL AUTO_INCREMENT,
328 328
 					  CNT_ISO varchar(2) COLLATE utf8_bin NOT NULL,
329 329
 					  STA_abbrev varchar(6) COLLATE utf8_bin NOT NULL,
330 330
 					  STA_name varchar(100) COLLATE utf8_bin NOT NULL,
331 331
 					  STA_active tinyint(1) DEFAULT '1',
332 332
 					  PRIMARY KEY  (STA_ID)";
333
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
334
-        $table_name = 'esp_status';
335
-        $sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
333
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
334
+		$table_name = 'esp_status';
335
+		$sql = "STS_ID varchar(3) COLLATE utf8_bin NOT NULL,
336 336
 					  STS_code varchar(45) COLLATE utf8_bin NOT NULL,
337 337
 					  STS_type set('event','registration','transaction','payment','email') COLLATE utf8_bin NOT NULL,
338 338
 					  STS_can_edit tinyint(1) NOT NULL DEFAULT 0,
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
 					  STS_open tinyint(1) NOT NULL DEFAULT 1,
341 341
 					  UNIQUE KEY STS_ID_UNIQUE (STS_ID),
342 342
 					  KEY STS_type (STS_type)";
343
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
344
-        $table_name = 'esp_transaction';
345
-        $sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
343
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
344
+		$table_name = 'esp_transaction';
345
+		$sql = "TXN_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
346 346
 					  TXN_timestamp datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
347 347
 					  TXN_total decimal(10,3) DEFAULT '0.00',
348 348
 					  TXN_paid decimal(10,3) NOT NULL DEFAULT '0.00',
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
 					  PRIMARY KEY  (TXN_ID),
354 354
 					  KEY TXN_timestamp (TXN_timestamp),
355 355
 					  KEY STS_ID (STS_ID)";
356
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
357
-        $table_name = 'esp_venue_meta';
358
-        $sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
356
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
357
+		$table_name = 'esp_venue_meta';
358
+		$sql = "VNUM_ID int(11) NOT NULL AUTO_INCREMENT,
359 359
 			VNU_ID bigint(20) unsigned NOT NULL DEFAULT 0,
360 360
 			VNU_address varchar(255) DEFAULT NULL,
361 361
 			VNU_address2 varchar(255) DEFAULT NULL,
@@ -373,10 +373,10 @@  discard block
 block discarded – undo
373 373
 			PRIMARY KEY  (VNUM_ID),
374 374
 			KEY STA_ID (STA_ID),
375 375
 			KEY CNT_ISO (CNT_ISO)";
376
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
377
-        // modified tables
378
-        $table_name = "esp_price";
379
-        $sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
376
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
377
+		// modified tables
378
+		$table_name = "esp_price";
379
+		$sql = "PRC_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
380 380
 					  PRT_ID tinyint(3) unsigned NOT NULL,
381 381
 					  PRC_amount decimal(10,3) NOT NULL DEFAULT '0.00',
382 382
 					  PRC_name varchar(245) NOT NULL,
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
 					  PRC_wp_user bigint(20) unsigned NULL,
389 389
 					  PRC_parent int(10) unsigned DEFAULT 0,
390 390
 					  PRIMARY KEY  (PRC_ID)";
391
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
-        $table_name = "esp_price_type";
393
-        $sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
391
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
392
+		$table_name = "esp_price_type";
393
+		$sql = "PRT_ID tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
394 394
 				  PRT_name varchar(45) NOT NULL,
395 395
 				  PBT_ID tinyint(3) unsigned NOT NULL DEFAULT '1',
396 396
 				  PRT_is_percent tinyint(1) NOT NULL DEFAULT '0',
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
 				  PRT_deleted tinyint(1) NOT NULL DEFAULT '0',
400 400
 				  UNIQUE KEY PRT_name_UNIQUE (PRT_name),
401 401
 				  PRIMARY KEY  (PRT_ID)";
402
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
403
-        $table_name = "esp_ticket";
404
-        $sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
402
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB ');
403
+		$table_name = "esp_ticket";
404
+		$sql = "TKT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
405 405
 					  TTM_ID int(10) unsigned NOT NULL,
406 406
 					  TKT_name varchar(245) NOT NULL DEFAULT '',
407 407
 					  TKT_description text NOT NULL,
@@ -422,10 +422,10 @@  discard block
 block discarded – undo
422 422
 					  TKT_parent int(10) unsigned DEFAULT '0',
423 423
 					  TKT_deleted tinyint(1) NOT NULL DEFAULT '0',
424 424
 					  PRIMARY KEY  (TKT_ID)";
425
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
426
-        $this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
427
-        $table_name = 'esp_question_group';
428
-        $sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
425
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
426
+		$this->_get_table_manager()->dropIndex('esp_question_group', 'QSG_identifier_UNIQUE');
427
+		$table_name = 'esp_question_group';
428
+		$sql = 'QSG_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
429 429
 					QSG_name varchar(255) NOT NULL,
430 430
 					QSG_identifier varchar(100) NOT NULL,
431 431
 					QSG_desc text NULL,
@@ -437,133 +437,133 @@  discard block
 block discarded – undo
437 437
 					QSG_wp_user bigint(20) unsigned NULL,
438 438
 					PRIMARY KEY  (QSG_ID),
439 439
 					UNIQUE KEY QSG_identifier_UNIQUE (QSG_identifier ASC)';
440
-        $this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
441
-        $script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
442
-        // (because many need to convert old string states to foreign keys into the states table)
443
-        $script_4_1_defaults->insert_default_states();
444
-        $script_4_1_defaults->insert_default_countries();
445
-        // schema on price, price_types and tickets has changed so use the DEFAULT method in here instead of 4.1's and later.
446
-        $this->insert_default_price_types();
447
-        $this->insert_default_prices();
448
-        $this->insert_default_tickets();
449
-        // setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
450
-        EE_Config::instance()->update_espresso_config(false, true);
451
-        return true;
452
-    }
440
+		$this->_table_should_exist_previously($table_name, $sql, 'ENGINE=InnoDB');
441
+		$script_4_1_defaults = EE_Registry::instance()->load_dms('Core_4_1_0');
442
+		// (because many need to convert old string states to foreign keys into the states table)
443
+		$script_4_1_defaults->insert_default_states();
444
+		$script_4_1_defaults->insert_default_countries();
445
+		// schema on price, price_types and tickets has changed so use the DEFAULT method in here instead of 4.1's and later.
446
+		$this->insert_default_price_types();
447
+		$this->insert_default_prices();
448
+		$this->insert_default_tickets();
449
+		// setting up the config wp option pretty well counts as a 'schema change', or at least should happen ehre
450
+		EE_Config::instance()->update_espresso_config(false, true);
451
+		return true;
452
+	}
453 453
 
454 454
 
455 455
 
456
-    /**
457
-     * @return boolean
458
-     */
459
-    public function schema_changes_after_migration()
460
-    {
461
-        return true;
462
-    }
456
+	/**
457
+	 * @return boolean
458
+	 */
459
+	public function schema_changes_after_migration()
460
+	{
461
+		return true;
462
+	}
463 463
 
464 464
 
465 465
 
466
-    public function migration_page_hooks()
467
-    {
468
-    }
466
+	public function migration_page_hooks()
467
+	{
468
+	}
469 469
 
470 470
 
471 471
 
472
-    /**
473
-     * insert_default_price_types
474
-     *
475
-     * @since 4.5.0
476
-     * @return void
477
-     */
478
-    public function insert_default_price_types()
479
-    {
480
-        global $wpdb;
481
-        $price_type_table = $wpdb->prefix . "esp_price_type";
482
-        if ($this->_get_table_analysis()->tableExists($price_type_table)) {
483
-            $SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
484
-            $price_types_exist = $wpdb->get_var($SQL);
485
-            if (! $price_types_exist) {
486
-                $user_id = EEH_Activation::get_default_creator_id();
487
-                $SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES
472
+	/**
473
+	 * insert_default_price_types
474
+	 *
475
+	 * @since 4.5.0
476
+	 * @return void
477
+	 */
478
+	public function insert_default_price_types()
479
+	{
480
+		global $wpdb;
481
+		$price_type_table = $wpdb->prefix . "esp_price_type";
482
+		if ($this->_get_table_analysis()->tableExists($price_type_table)) {
483
+			$SQL = 'SELECT COUNT(PRT_ID) FROM ' . $price_type_table;
484
+			$price_types_exist = $wpdb->get_var($SQL);
485
+			if (! $price_types_exist) {
486
+				$user_id = EEH_Activation::get_default_creator_id();
487
+				$SQL = "INSERT INTO $price_type_table ( PRT_ID, PRT_name, PBT_ID, PRT_is_percent, PRT_order, PRT_wp_user, PRT_deleted ) VALUES
488 488
 							(1, '" . esc_html__('Base Price', 'event_espresso') . "', 1,  0, 0, $user_id, 0),
489 489
 							(2, '" . esc_html__('Percent Discount', 'event_espresso') . "', 2,  1, 20, $user_id, 0),
490 490
 							(3, '" . esc_html__('Dollar Discount', 'event_espresso') . "', 2,  0, 30, $user_id, 0),
491 491
 							(4, '" . esc_html__('Percent Surcharge', 'event_espresso') . "', 3,  1, 40, $user_id,  0),
492 492
 							(5, '" . esc_html__('Dollar Surcharge', 'event_espresso') . "', 3,  0, 50, $user_id, 0);";
493
-                $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL);
494
-                $wpdb->query($SQL);
495
-            }
496
-        }
497
-    }
493
+				$SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_price_types__SQL', $SQL);
494
+				$wpdb->query($SQL);
495
+			}
496
+		}
497
+	}
498 498
 
499 499
 
500 500
 
501
-    /**
502
-     * insert DEFAULT prices.
503
-     *  If we're INSTALLING 4.x CAF, then we add a few extra DEFAULT prices
504
-     * when EEH_Activaion's initialize_db_content is called via  ahook in
505
-     * EE_Brewing_regular
506
-     *
507
-     * @since 4.5.0
508
-     * @return void
509
-     */
510
-    public function insert_default_prices()
511
-    {
512
-        global $wpdb;
513
-        $price_table = $wpdb->prefix . "esp_price";
514
-        if ($this->_get_table_analysis()->tableExists($price_table)) {
515
-            $SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
516
-            $prices_exist = $wpdb->get_var($SQL);
517
-            if (! $prices_exist) {
518
-                $user_id = EEH_Activation::get_default_creator_id();
519
-                $SQL = "INSERT INTO $price_table
501
+	/**
502
+	 * insert DEFAULT prices.
503
+	 *  If we're INSTALLING 4.x CAF, then we add a few extra DEFAULT prices
504
+	 * when EEH_Activaion's initialize_db_content is called via  ahook in
505
+	 * EE_Brewing_regular
506
+	 *
507
+	 * @since 4.5.0
508
+	 * @return void
509
+	 */
510
+	public function insert_default_prices()
511
+	{
512
+		global $wpdb;
513
+		$price_table = $wpdb->prefix . "esp_price";
514
+		if ($this->_get_table_analysis()->tableExists($price_table)) {
515
+			$SQL = 'SELECT COUNT(PRC_ID) FROM ' . $price_table;
516
+			$prices_exist = $wpdb->get_var($SQL);
517
+			if (! $prices_exist) {
518
+				$user_id = EEH_Activation::get_default_creator_id();
519
+				$SQL = "INSERT INTO $price_table
520 520
 							(PRC_ID, PRT_ID, PRC_amount, PRC_name, PRC_desc,  PRC_is_default, PRC_overrides, PRC_wp_user, PRC_order, PRC_deleted, PRC_parent ) VALUES
521 521
 							(1, 1, '0.00', 'Admission', '', 1, NULL, $user_id, 0, 0, 0);";
522
-                $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL);
523
-                $wpdb->query($SQL);
524
-            }
525
-        }
526
-    }
522
+				$SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_prices__SQL', $SQL);
523
+				$wpdb->query($SQL);
524
+			}
525
+		}
526
+	}
527 527
 
528 528
 
529 529
 
530
-    /**
531
-     * insert DEFAULT ticket
532
-     * Almost identical to EE_DMS_Core_4_3_0::insert_default_tickets, except is aware of the TKT_wp_user field
533
-     *
534
-     * @since 4.5.0
535
-     * @return void
536
-     */
537
-    public function insert_default_tickets()
538
-    {
539
-        global $wpdb;
540
-        $ticket_table = $wpdb->prefix . "esp_ticket";
541
-        if ($this->_get_table_analysis()->tableExists($ticket_table)) {
542
-            $SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
543
-            $tickets_exist = $wpdb->get_var($SQL);
544
-            if (! $tickets_exist) {
545
-                $user_id = EEH_Activation::get_default_creator_id();
546
-                $SQL = "INSERT INTO $ticket_table
530
+	/**
531
+	 * insert DEFAULT ticket
532
+	 * Almost identical to EE_DMS_Core_4_3_0::insert_default_tickets, except is aware of the TKT_wp_user field
533
+	 *
534
+	 * @since 4.5.0
535
+	 * @return void
536
+	 */
537
+	public function insert_default_tickets()
538
+	{
539
+		global $wpdb;
540
+		$ticket_table = $wpdb->prefix . "esp_ticket";
541
+		if ($this->_get_table_analysis()->tableExists($ticket_table)) {
542
+			$SQL = 'SELECT COUNT(TKT_ID) FROM ' . $ticket_table;
543
+			$tickets_exist = $wpdb->get_var($SQL);
544
+			if (! $tickets_exist) {
545
+				$user_id = EEH_Activation::get_default_creator_id();
546
+				$SQL = "INSERT INTO $ticket_table
547 547
 					( TKT_ID, TTM_ID, TKT_name, TKT_description, TKT_qty, TKT_sold, TKT_uses, TKT_required, TKT_min, TKT_max, TKT_price, TKT_start_date, TKT_end_date, TKT_taxable, TKT_order, TKT_row, TKT_is_default, TKT_parent, TKT_wp_user, TKT_deleted ) VALUES
548 548
 					( 1, 0, '"
549
-                       . esc_html__("Free Ticket", "event_espresso")
550
-                       . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);";
551
-                $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL);
552
-                $wpdb->query($SQL);
553
-            }
554
-        }
555
-        $ticket_price_table = $wpdb->prefix . "esp_ticket_price";
556
-        if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
557
-            $SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
558
-            $ticket_prc_exist = $wpdb->get_var($SQL);
559
-            if (! $ticket_prc_exist) {
560
-                $SQL = "INSERT INTO $ticket_price_table
549
+					   . esc_html__("Free Ticket", "event_espresso")
550
+					   . "', '', 100, 0, -1, 0, 0, -1, 0.00, '0000-00-00 00:00:00', '0000-00-00 00:00:00', 0, 0, 1, 1, 0, $user_id, 0);";
551
+				$SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL', $SQL);
552
+				$wpdb->query($SQL);
553
+			}
554
+		}
555
+		$ticket_price_table = $wpdb->prefix . "esp_ticket_price";
556
+		if ($this->_get_table_analysis()->tableExists($ticket_price_table)) {
557
+			$SQL = 'SELECT COUNT(TKP_ID) FROM ' . $ticket_price_table;
558
+			$ticket_prc_exist = $wpdb->get_var($SQL);
559
+			if (! $ticket_prc_exist) {
560
+				$SQL = "INSERT INTO $ticket_price_table
561 561
 				( TKP_ID, TKT_ID, PRC_ID ) VALUES
562 562
 				( 1, 1, 1 )
563 563
 				";
564
-                $SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL);
565
-                $wpdb->query($SQL);
566
-            }
567
-        }
568
-    }
564
+				$SQL = apply_filters('FHEE__EE_DMS_4_5_0__insert_default_tickets__SQL__ticket_price', $SQL);
565
+				$wpdb->query($SQL);
566
+			}
567
+		}
568
+	}
569 569
 }
Please login to merge, or discard this patch.
4_9_0_stages/EE_DMS_4_9_0_Email_System_Question.dmsstage.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     {
24 24
         global $wpdb;
25 25
         $this->_pretty_name = esc_html__('Email - System Question', 'event_espresso');
26
-        $this->_old_table = $wpdb->prefix . 'esp_question';
26
+        $this->_old_table = $wpdb->prefix.'esp_question';
27 27
         $this->_extra_where_sql = "WHERE QST_system = 'email'";
28 28
         parent::__construct();
29 29
     }
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
             global $wpdb;
42 42
             $success = $wpdb->update(
43 43
                 $this->_old_table,
44
-                array( 'QST_type' => 'EMAIL' ),  // data
45
-                array( 'QST_ID' => $question['QST_ID'] ),  // where
46
-                array( '%s' ),   // data format
47
-                array( '%d' )  // where format
44
+                array('QST_type' => 'EMAIL'), // data
45
+                array('QST_ID' => $question['QST_ID']), // where
46
+                array('%s'), // data format
47
+                array('%d')  // where format
48 48
             );
49
-            if (! $success) {
49
+            if ( ! $success) {
50 50
                 $this->add_error(
51 51
                     sprintf(
52 52
                         esc_html__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -11,48 +11,48 @@
 block discarded – undo
11 11
  */
12 12
 class EE_DMS_4_9_0_Email_System_Question extends EE_Data_Migration_Script_Stage_Table
13 13
 {
14
-    /**
15
-     * Just initializes the status of the migration
16
-     *
17
-     * @return EE_DMS_4_9_0_Email_System_Question
18
-     */
19
-    public function __construct()
20
-    {
21
-        global $wpdb;
22
-        $this->_pretty_name = esc_html__('Email - System Question', 'event_espresso');
23
-        $this->_old_table = $wpdb->prefix . 'esp_question';
24
-        $this->_extra_where_sql = "WHERE QST_system = 'email'";
25
-        parent::__construct();
26
-    }
14
+	/**
15
+	 * Just initializes the status of the migration
16
+	 *
17
+	 * @return EE_DMS_4_9_0_Email_System_Question
18
+	 */
19
+	public function __construct()
20
+	{
21
+		global $wpdb;
22
+		$this->_pretty_name = esc_html__('Email - System Question', 'event_espresso');
23
+		$this->_old_table = $wpdb->prefix . 'esp_question';
24
+		$this->_extra_where_sql = "WHERE QST_system = 'email'";
25
+		parent::__construct();
26
+	}
27 27
 
28 28
 
29 29
 
30
-    /**
31
-     * updates the question with the new question type
32
-     * @param array $question an associative array where keys are column names and values are their values.
33
-     * @return null
34
-     */
35
-    protected function _migrate_old_row($question)
36
-    {
37
-        if ($question['QST_ID'] && $question['QST_system'] == 'email') {
38
-            global $wpdb;
39
-            $success = $wpdb->update(
40
-                $this->_old_table,
41
-                array( 'QST_type' => 'EMAIL' ),  // data
42
-                array( 'QST_ID' => $question['QST_ID'] ),  // where
43
-                array( '%s' ),   // data format
44
-                array( '%d' )  // where format
45
-            );
46
-            if (! $success) {
47
-                $this->add_error(
48
-                    sprintf(
49
-                        esc_html__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
50
-                        wp_json_encode($question['QST_system']),
51
-                        $question['QST_ID'],
52
-                        $wpdb->last_error
53
-                    )
54
-                );
55
-            }
56
-        }
57
-    }
30
+	/**
31
+	 * updates the question with the new question type
32
+	 * @param array $question an associative array where keys are column names and values are their values.
33
+	 * @return null
34
+	 */
35
+	protected function _migrate_old_row($question)
36
+	{
37
+		if ($question['QST_ID'] && $question['QST_system'] == 'email') {
38
+			global $wpdb;
39
+			$success = $wpdb->update(
40
+				$this->_old_table,
41
+				array( 'QST_type' => 'EMAIL' ),  // data
42
+				array( 'QST_ID' => $question['QST_ID'] ),  // where
43
+				array( '%s' ),   // data format
44
+				array( '%d' )  // where format
45
+			);
46
+			if (! $success) {
47
+				$this->add_error(
48
+					sprintf(
49
+						esc_html__('Could not update question system name "%1$s" for question ID=%2$d because "%3$s"', 'event_espresso'),
50
+						wp_json_encode($question['QST_system']),
51
+						$question['QST_ID'],
52
+						$wpdb->last_error
53
+					)
54
+				);
55
+			}
56
+		}
57
+	}
58 58
 }
Please login to merge, or discard this patch.
core/db_classes/EE_CPT_Base.class.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public function wp_post()
41 41
     {
42 42
         global $wpdb;
43
-        if (! $this->_wp_post instanceof WP_Post) {
43
+        if ( ! $this->_wp_post instanceof WP_Post) {
44 44
             if ($this->ID()) {
45 45
                 $this->_wp_post = get_post($this->ID());
46 46
             } else {
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             }
67 67
             // and let's make retrieving the EE CPT object easy too
68 68
             $classname = get_class($this);
69
-            if (! isset($this->_wp_post->{$classname})) {
69
+            if ( ! isset($this->_wp_post->{$classname})) {
70 70
                 $this->_wp_post->{$classname} = $this;
71 71
             }
72 72
         }
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
      */
148 148
     public function remove_relation_to_term_taxonomy($term_taxonomy)
149 149
     {
150
-        if (! $term_taxonomy) {
150
+        if ( ! $term_taxonomy) {
151 151
             EE_Error::add_error(
152 152
                 sprintf(
153 153
                     esc_html__(
@@ -228,10 +228,10 @@  discard block
 block discarded – undo
228 228
     {
229 229
         // first let's see if we already have the _feature_image property set AND if it has a cached element on it FOR the given size
230 230
         $attr_key = is_array($attr) ? implode('_', $attr) : $attr;
231
-        $cache_key = is_array($size) ? implode('_', $size) . $attr_key : $size . $attr_key;
232
-        $this->_feature_image[ $cache_key ] = isset($this->_feature_image[ $cache_key ])
233
-            ? $this->_feature_image[ $cache_key ] : $this->get_model()->get_feature_image($this->ID(), $size, $attr);
234
-        return $this->_feature_image[ $cache_key ];
231
+        $cache_key = is_array($size) ? implode('_', $size).$attr_key : $size.$attr_key;
232
+        $this->_feature_image[$cache_key] = isset($this->_feature_image[$cache_key])
233
+            ? $this->_feature_image[$cache_key] : $this->get_model()->get_feature_image($this->ID(), $size, $attr);
234
+        return $this->_feature_image[$cache_key];
235 235
     }
236 236
 
237 237
 
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
             foreach ($related_obj_names as $related_name) {
299 299
                 // related_obj_name so we're saving a revision on an object related to this object
300 300
                 // do we have $where_query params for this related object?  If we do then we include that.
301
-                $cols_n_values = isset($where_query[ $related_name ]) ? $where_query[ $related_name ] : array();
301
+                $cols_n_values = isset($where_query[$related_name]) ? $where_query[$related_name] : array();
302 302
                 $where_params = ! empty($cols_n_values) ? array($cols_n_values) : array();
303 303
                 $related_objs = $this->get_many_related($related_name, $where_params);
304 304
                 $revision_related_objs = $revision_obj->get_many_related($related_name, $where_params);
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
      */
348 348
     public function update_post_meta($meta_key, $meta_value, $prev_value = null)
349 349
     {
350
-        if (! $this->ID()) {
350
+        if ( ! $this->ID()) {
351 351
             $this->save();
352 352
         }
353 353
         return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value);
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
      */
382 382
     public function delete_post_meta($meta_key, $meta_value = '')
383 383
     {
384
-        if (! $this->ID()) {
384
+        if ( ! $this->ID()) {
385 385
             // there are obviously no postmetas for this if it's not saved
386 386
             // so let's just report this as a success
387 387
             return true;
Please login to merge, or discard this patch.
Indentation   +428 added lines, -428 removed lines patch added patch discarded remove patch
@@ -13,432 +13,432 @@
 block discarded – undo
13 13
  */
14 14
 abstract class EE_CPT_Base extends EE_Soft_Delete_Base_Class
15 15
 {
16
-    /**
17
-     * This is a property for holding cached feature images on CPT objects.  Cache's are set on the first
18
-     * "feature_image()" method call.  Each key in the array corresponds to the requested size.
19
-     *
20
-     * @var array
21
-     */
22
-    protected $_feature_image = array();
23
-
24
-    /**
25
-     * @var WP_Post the WP_Post that corresponds with this CPT model object
26
-     */
27
-    protected $_wp_post;
28
-
29
-
30
-    abstract public function wp_user();
31
-
32
-
33
-    /**
34
-     * Returns the WP post associated with this CPT model object. If this CPT is saved, fetches it
35
-     * from the DB. Otherwise, create an unsaved WP_POst object. Caches the post internally.
36
-     *
37
-     * @return WP_Post
38
-     */
39
-    public function wp_post()
40
-    {
41
-        global $wpdb;
42
-        if (! $this->_wp_post instanceof WP_Post) {
43
-            if ($this->ID()) {
44
-                $this->_wp_post = get_post($this->ID());
45
-            } else {
46
-                $simulated_db_result = new stdClass();
47
-                foreach ($this->get_model()->field_settings(true) as $field_name => $field_obj) {
48
-                    if (
49
-                        $this->get_model()->get_table_obj_by_alias($field_obj->get_table_alias())->get_table_name()
50
-                        === $wpdb->posts
51
-                    ) {
52
-                        $column = $field_obj->get_table_column();
53
-
54
-                        if ($field_obj instanceof EE_Datetime_Field) {
55
-                            $value_on_model_obj = $this->get_DateTime_object($field_name);
56
-                        } elseif ($field_obj->is_db_only_field()) {
57
-                            $value_on_model_obj = $field_obj->get_default_value();
58
-                        } else {
59
-                            $value_on_model_obj = $this->get_raw($field_name);
60
-                        }
61
-                        $simulated_db_result->{$column} = $field_obj->prepare_for_use_in_db($value_on_model_obj);
62
-                    }
63
-                }
64
-                $this->_wp_post = new WP_Post($simulated_db_result);
65
-            }
66
-            // and let's make retrieving the EE CPT object easy too
67
-            $classname = get_class($this);
68
-            if (! isset($this->_wp_post->{$classname})) {
69
-                $this->_wp_post->{$classname} = $this;
70
-            }
71
-        }
72
-        return $this->_wp_post;
73
-    }
74
-
75
-    /**
76
-     * When fetching a new value for a post field that uses the global $post for rendering,
77
-     * set the global $post temporarily to be this model object; and afterwards restore it
78
-     *
79
-     * @param string $fieldname
80
-     * @param bool   $pretty
81
-     * @param string $extra_cache_ref
82
-     * @return mixed
83
-     */
84
-    protected function _get_fresh_property($fieldname, $pretty = false, $extra_cache_ref = null)
85
-    {
86
-        global $post;
87
-
88
-        if (
89
-            $pretty
90
-            && (
91
-                ! (
92
-                    $post instanceof WP_Post
93
-                    && $post->ID
94
-                )
95
-                || (int) $post->ID !== $this->ID()
96
-            )
97
-            && $this->get_model()->field_settings_for($fieldname) instanceof EE_Post_Content_Field
98
-        ) {
99
-            $old_post = $post;
100
-            $post = $this->wp_post();
101
-            $return_value = parent::_get_fresh_property($fieldname, $pretty, $extra_cache_ref);
102
-            $post = $old_post;
103
-        } else {
104
-            $return_value = parent::_get_fresh_property($fieldname, $pretty, $extra_cache_ref);
105
-        }
106
-        return $return_value;
107
-    }
108
-
109
-    /**
110
-     * Adds to the specified event category. If it category doesn't exist, creates it.
111
-     *
112
-     * @param string $category_name
113
-     * @param string $category_description    optional
114
-     * @param int    $parent_term_taxonomy_id optional
115
-     * @return EE_Term_Taxonomy
116
-     */
117
-    public function add_event_category($category_name, $category_description = null, $parent_term_taxonomy_id = null)
118
-    {
119
-        return $this->get_model()->add_event_category(
120
-            $this,
121
-            $category_name,
122
-            $category_description,
123
-            $parent_term_taxonomy_id
124
-        );
125
-    }
126
-
127
-
128
-    /**
129
-     * Removes the event category by specified name from being related ot this event
130
-     *
131
-     * @param string $category_name
132
-     * @return bool
133
-     */
134
-    public function remove_event_category($category_name)
135
-    {
136
-        return $this->get_model()->remove_event_category($this, $category_name);
137
-    }
138
-
139
-
140
-    /**
141
-     * Removes the relation to the specified term taxonomy, and maintains the
142
-     * data integrity of the term taxonomy provided
143
-     *
144
-     * @param EE_Term_Taxonomy $term_taxonomy
145
-     * @return EE_Base_Class the relation was removed from
146
-     */
147
-    public function remove_relation_to_term_taxonomy($term_taxonomy)
148
-    {
149
-        if (! $term_taxonomy) {
150
-            EE_Error::add_error(
151
-                sprintf(
152
-                    esc_html__(
153
-                        "No Term_Taxonomy provided which to remove from model object of type %s and id %d",
154
-                        "event_espresso"
155
-                    ),
156
-                    get_class($this),
157
-                    $this->ID()
158
-                ),
159
-                __FILE__,
160
-                __FUNCTION__,
161
-                __LINE__
162
-            );
163
-            return null;
164
-        }
165
-        $term_taxonomy->set_count($term_taxonomy->count() - 1);
166
-        $term_taxonomy->save();
167
-        return $this->_remove_relation_to($term_taxonomy, 'Term_Taxonomy');
168
-    }
169
-
170
-
171
-    /**
172
-     * The main purpose of this method is to return the post type for the model object
173
-     *
174
-     * @access public
175
-     * @return string
176
-     */
177
-    public function post_type()
178
-    {
179
-        return $this->get_model()->post_type();
180
-    }
181
-
182
-
183
-    /**
184
-     * The main purpose of this method is to return the parent for the model object
185
-     *
186
-     * @access public
187
-     * @return int
188
-     */
189
-    public function parent()
190
-    {
191
-        return $this->get('parent');
192
-    }
193
-
194
-
195
-    /**
196
-     * return the _status property
197
-     *
198
-     * @return string
199
-     */
200
-    public function status()
201
-    {
202
-        return $this->get('status');
203
-    }
204
-
205
-
206
-    /**
207
-     * @param string $status
208
-     */
209
-    public function set_status($status)
210
-    {
211
-        $this->set('status', $status);
212
-    }
213
-
214
-
215
-    /**
216
-     * This calls the equivalent model method for retrieving the feature image which in turn is a wrapper for
217
-     * WordPress' get_the_post_thumbnail() function.
218
-     *
219
-     * @link   http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail
220
-     * @access protected
221
-     * @param string|array $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array
222
-     *                           representing width and height in pixels (i.e. array(32,32) ).
223
-     * @param string|array $attr Optional. Query string or array of attributes.
224
-     * @return string HTML image element
225
-     */
226
-    protected function _get_feature_image($size, $attr)
227
-    {
228
-        // first let's see if we already have the _feature_image property set AND if it has a cached element on it FOR the given size
229
-        $attr_key = is_array($attr) ? implode('_', $attr) : $attr;
230
-        $cache_key = is_array($size) ? implode('_', $size) . $attr_key : $size . $attr_key;
231
-        $this->_feature_image[ $cache_key ] = isset($this->_feature_image[ $cache_key ])
232
-            ? $this->_feature_image[ $cache_key ] : $this->get_model()->get_feature_image($this->ID(), $size, $attr);
233
-        return $this->_feature_image[ $cache_key ];
234
-    }
235
-
236
-
237
-    /**
238
-     * See _get_feature_image. Returns the HTML to display a featured image
239
-     *
240
-     * @param string       $size
241
-     * @param string|array $attr
242
-     * @return string of html
243
-     */
244
-    public function feature_image($size = 'thumbnail', $attr = '')
245
-    {
246
-        return $this->_get_feature_image($size, $attr);
247
-    }
248
-
249
-
250
-    /**
251
-     * This uses the wp "wp_get_attachment_image_src()" function to return the feature image for the current class
252
-     * using the given size params.
253
-     *
254
-     * @param  string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array
255
-     *                            representing width and height in pixels eg. array(32,32).
256
-     * @return string|boolean          the url of the image or false if not found
257
-     */
258
-    public function feature_image_url($size = 'thumbnail')
259
-    {
260
-        $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($this->ID()), $size);
261
-        return ! empty($attachment) ? $attachment[0] : false;
262
-    }
263
-
264
-
265
-    /**
266
-     * This is a method for restoring this_obj using details from the given $revision_id
267
-     *
268
-     * @param int   $revision_id       ID of the revision we're getting data from
269
-     * @param array $related_obj_names if included this will be used to restore for related obj
270
-     *                                 if not included then we just do restore on the meta.
271
-     *                                 We will accept an array of related_obj_names for restoration here.
272
-     * @param array $where_query       You can optionally include an array of key=>value pairs
273
-     *                                 that allow you to further constrict the relation to being added.
274
-     *                                 However, keep in mind that the columns (keys) given
275
-     *                                 must match a column on the JOIN table and currently
276
-     *                                 only the HABTM models accept these additional conditions.
277
-     *                                 Also remember that if an exact match isn't found for these extra cols/val pairs,
278
-     *                                 then a NEW row is created in the join table.
279
-     *                                 This array is INDEXED by RELATED OBJ NAME (so it corresponds with the obj_names
280
-     *                                 sent);
281
-     * @return void
282
-     */
283
-    public function restore_revision($revision_id, $related_obj_names = array(), $where_query = array())
284
-    {
285
-        // get revision object
286
-        $revision_obj = $this->get_model()->get_one_by_ID($revision_id);
287
-        if ($revision_obj instanceof EE_CPT_Base) {
288
-            // no related_obj_name so we assume we're saving a revision on this object.
289
-            if (empty($related_obj_names)) {
290
-                $fields = $this->get_model()->get_meta_table_fields();
291
-                foreach ($fields as $field) {
292
-                    $this->set($field, $revision_obj->get($field));
293
-                }
294
-                $this->save();
295
-            }
296
-            $related_obj_names = (array) $related_obj_names;
297
-            foreach ($related_obj_names as $related_name) {
298
-                // related_obj_name so we're saving a revision on an object related to this object
299
-                // do we have $where_query params for this related object?  If we do then we include that.
300
-                $cols_n_values = isset($where_query[ $related_name ]) ? $where_query[ $related_name ] : array();
301
-                $where_params = ! empty($cols_n_values) ? array($cols_n_values) : array();
302
-                $related_objs = $this->get_many_related($related_name, $where_params);
303
-                $revision_related_objs = $revision_obj->get_many_related($related_name, $where_params);
304
-                // load helper
305
-                // remove related objs from this object that are not in revision
306
-                // array_diff *should* work cause I think objects are indexed by ID?
307
-                $related_to_remove = EEH_Array::object_array_diff($related_objs, $revision_related_objs);
308
-                foreach ($related_to_remove as $rr) {
309
-                    $this->_remove_relation_to($rr, $related_name, $cols_n_values);
310
-                }
311
-                // add all related objs attached to revision to this object
312
-                foreach ($revision_related_objs as $r_obj) {
313
-                    $this->_add_relation_to($r_obj, $related_name, $cols_n_values);
314
-                }
315
-            }
316
-        }
317
-    }
318
-
319
-
320
-    /**
321
-     * Wrapper for get_post_meta, http://codex.wordpress.org/Function_Reference/get_post_meta
322
-     *
323
-     * @param string  $meta_key
324
-     * @param boolean $single
325
-     * @return mixed <ul><li>If only $id is set it will return all meta values in an associative array.</li>
326
-     * <li>If $single is set to false, or left blank, the function returns an array containing all values of the
327
-     * specified key.</li>
328
-     * <li>If $single is set to true, the function returns the first value of the specified key (not in an
329
-     * array</li></ul>
330
-     */
331
-    public function get_post_meta($meta_key = null, $single = false)
332
-    {
333
-        return get_post_meta($this->ID(), $meta_key, $single);
334
-    }
335
-
336
-
337
-    /**
338
-     * Wrapper for update_post_meta, http://codex.wordpress.org/Function_Reference/update_post_meta
339
-     *
340
-     * @param string $meta_key
341
-     * @param mixed  $meta_value
342
-     * @param mixed  $prev_value
343
-     * @return mixed Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure.
344
-     *               NOTE: If the meta_value passed to this function is the same as the value that is already in the
345
-     *               database, this function returns false.
346
-     */
347
-    public function update_post_meta($meta_key, $meta_value, $prev_value = null)
348
-    {
349
-        if (! $this->ID()) {
350
-            $this->save();
351
-        }
352
-        return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value);
353
-    }
354
-
355
-
356
-    /**
357
-     * Wrapper for add_post_meta, http://codex.wordpress.org/Function_Reference/add_post_meta
358
-     *
359
-     * @param mixed $meta_key
360
-     * @param mixed $meta_value
361
-     * @param bool  $unique . If postmeta for this $meta_key already exists, whether to add an additional item or not
362
-     * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given
363
-     *                 key already exists, in which case false is returned.
364
-     */
365
-    public function add_post_meta($meta_key, $meta_value, $unique = false)
366
-    {
367
-        if ($this->ID()) {
368
-            $this->save();
369
-        }
370
-        return add_post_meta($this->ID(), $meta_key, $meta_value, $unique);
371
-    }
372
-
373
-
374
-    /**
375
-     * Wrapper for delete_post_meta, http://codex.wordpress.org/Function_Reference/delete_post_meta
376
-     *
377
-     * @param mixed $meta_key
378
-     * @param mixed $meta_value
379
-     * @return boolean False for failure. True for success.
380
-     */
381
-    public function delete_post_meta($meta_key, $meta_value = '')
382
-    {
383
-        if (! $this->ID()) {
384
-            // there are obviously no postmetas for this if it's not saved
385
-            // so let's just report this as a success
386
-            return true;
387
-        }
388
-        return delete_post_meta($this->ID(), $meta_key, $meta_value);
389
-    }
390
-
391
-
392
-    /**
393
-     * Gets the URL for viewing this event on the front-end
394
-     *
395
-     * @return string
396
-     */
397
-    public function get_permalink()
398
-    {
399
-        return get_permalink($this->ID());
400
-    }
401
-
402
-
403
-    /**
404
-     * Gets all the term-taxonomies for this CPT
405
-     *
406
-     * @param array $query_params
407
-     * @return EE_Term_Taxonomy
408
-     */
409
-    public function term_taxonomies($query_params = array())
410
-    {
411
-        return $this->get_many_related('Term_Taxonomy', $query_params);
412
-    }
413
-
414
-
415
-    /**
416
-     * @return mixed
417
-     */
418
-    public function get_custom_post_statuses()
419
-    {
420
-        return $this->get_model()->get_custom_post_statuses();
421
-    }
422
-
423
-
424
-    /**
425
-     * @return mixed
426
-     */
427
-    public function get_all_post_statuses()
428
-    {
429
-        return $this->get_model()->get_status_array();
430
-    }
431
-
432
-
433
-    /**
434
-     * Don't serialize the WP Post. That's just duplicate data and we want to avoid recursion
435
-     *
436
-     * @return array
437
-     */
438
-    public function __sleep()
439
-    {
440
-        $properties_to_serialize = parent::__sleep();
441
-        $properties_to_serialize = array_diff($properties_to_serialize, array('_wp_post'));
442
-        return $properties_to_serialize;
443
-    }
16
+	/**
17
+	 * This is a property for holding cached feature images on CPT objects.  Cache's are set on the first
18
+	 * "feature_image()" method call.  Each key in the array corresponds to the requested size.
19
+	 *
20
+	 * @var array
21
+	 */
22
+	protected $_feature_image = array();
23
+
24
+	/**
25
+	 * @var WP_Post the WP_Post that corresponds with this CPT model object
26
+	 */
27
+	protected $_wp_post;
28
+
29
+
30
+	abstract public function wp_user();
31
+
32
+
33
+	/**
34
+	 * Returns the WP post associated with this CPT model object. If this CPT is saved, fetches it
35
+	 * from the DB. Otherwise, create an unsaved WP_POst object. Caches the post internally.
36
+	 *
37
+	 * @return WP_Post
38
+	 */
39
+	public function wp_post()
40
+	{
41
+		global $wpdb;
42
+		if (! $this->_wp_post instanceof WP_Post) {
43
+			if ($this->ID()) {
44
+				$this->_wp_post = get_post($this->ID());
45
+			} else {
46
+				$simulated_db_result = new stdClass();
47
+				foreach ($this->get_model()->field_settings(true) as $field_name => $field_obj) {
48
+					if (
49
+						$this->get_model()->get_table_obj_by_alias($field_obj->get_table_alias())->get_table_name()
50
+						=== $wpdb->posts
51
+					) {
52
+						$column = $field_obj->get_table_column();
53
+
54
+						if ($field_obj instanceof EE_Datetime_Field) {
55
+							$value_on_model_obj = $this->get_DateTime_object($field_name);
56
+						} elseif ($field_obj->is_db_only_field()) {
57
+							$value_on_model_obj = $field_obj->get_default_value();
58
+						} else {
59
+							$value_on_model_obj = $this->get_raw($field_name);
60
+						}
61
+						$simulated_db_result->{$column} = $field_obj->prepare_for_use_in_db($value_on_model_obj);
62
+					}
63
+				}
64
+				$this->_wp_post = new WP_Post($simulated_db_result);
65
+			}
66
+			// and let's make retrieving the EE CPT object easy too
67
+			$classname = get_class($this);
68
+			if (! isset($this->_wp_post->{$classname})) {
69
+				$this->_wp_post->{$classname} = $this;
70
+			}
71
+		}
72
+		return $this->_wp_post;
73
+	}
74
+
75
+	/**
76
+	 * When fetching a new value for a post field that uses the global $post for rendering,
77
+	 * set the global $post temporarily to be this model object; and afterwards restore it
78
+	 *
79
+	 * @param string $fieldname
80
+	 * @param bool   $pretty
81
+	 * @param string $extra_cache_ref
82
+	 * @return mixed
83
+	 */
84
+	protected function _get_fresh_property($fieldname, $pretty = false, $extra_cache_ref = null)
85
+	{
86
+		global $post;
87
+
88
+		if (
89
+			$pretty
90
+			&& (
91
+				! (
92
+					$post instanceof WP_Post
93
+					&& $post->ID
94
+				)
95
+				|| (int) $post->ID !== $this->ID()
96
+			)
97
+			&& $this->get_model()->field_settings_for($fieldname) instanceof EE_Post_Content_Field
98
+		) {
99
+			$old_post = $post;
100
+			$post = $this->wp_post();
101
+			$return_value = parent::_get_fresh_property($fieldname, $pretty, $extra_cache_ref);
102
+			$post = $old_post;
103
+		} else {
104
+			$return_value = parent::_get_fresh_property($fieldname, $pretty, $extra_cache_ref);
105
+		}
106
+		return $return_value;
107
+	}
108
+
109
+	/**
110
+	 * Adds to the specified event category. If it category doesn't exist, creates it.
111
+	 *
112
+	 * @param string $category_name
113
+	 * @param string $category_description    optional
114
+	 * @param int    $parent_term_taxonomy_id optional
115
+	 * @return EE_Term_Taxonomy
116
+	 */
117
+	public function add_event_category($category_name, $category_description = null, $parent_term_taxonomy_id = null)
118
+	{
119
+		return $this->get_model()->add_event_category(
120
+			$this,
121
+			$category_name,
122
+			$category_description,
123
+			$parent_term_taxonomy_id
124
+		);
125
+	}
126
+
127
+
128
+	/**
129
+	 * Removes the event category by specified name from being related ot this event
130
+	 *
131
+	 * @param string $category_name
132
+	 * @return bool
133
+	 */
134
+	public function remove_event_category($category_name)
135
+	{
136
+		return $this->get_model()->remove_event_category($this, $category_name);
137
+	}
138
+
139
+
140
+	/**
141
+	 * Removes the relation to the specified term taxonomy, and maintains the
142
+	 * data integrity of the term taxonomy provided
143
+	 *
144
+	 * @param EE_Term_Taxonomy $term_taxonomy
145
+	 * @return EE_Base_Class the relation was removed from
146
+	 */
147
+	public function remove_relation_to_term_taxonomy($term_taxonomy)
148
+	{
149
+		if (! $term_taxonomy) {
150
+			EE_Error::add_error(
151
+				sprintf(
152
+					esc_html__(
153
+						"No Term_Taxonomy provided which to remove from model object of type %s and id %d",
154
+						"event_espresso"
155
+					),
156
+					get_class($this),
157
+					$this->ID()
158
+				),
159
+				__FILE__,
160
+				__FUNCTION__,
161
+				__LINE__
162
+			);
163
+			return null;
164
+		}
165
+		$term_taxonomy->set_count($term_taxonomy->count() - 1);
166
+		$term_taxonomy->save();
167
+		return $this->_remove_relation_to($term_taxonomy, 'Term_Taxonomy');
168
+	}
169
+
170
+
171
+	/**
172
+	 * The main purpose of this method is to return the post type for the model object
173
+	 *
174
+	 * @access public
175
+	 * @return string
176
+	 */
177
+	public function post_type()
178
+	{
179
+		return $this->get_model()->post_type();
180
+	}
181
+
182
+
183
+	/**
184
+	 * The main purpose of this method is to return the parent for the model object
185
+	 *
186
+	 * @access public
187
+	 * @return int
188
+	 */
189
+	public function parent()
190
+	{
191
+		return $this->get('parent');
192
+	}
193
+
194
+
195
+	/**
196
+	 * return the _status property
197
+	 *
198
+	 * @return string
199
+	 */
200
+	public function status()
201
+	{
202
+		return $this->get('status');
203
+	}
204
+
205
+
206
+	/**
207
+	 * @param string $status
208
+	 */
209
+	public function set_status($status)
210
+	{
211
+		$this->set('status', $status);
212
+	}
213
+
214
+
215
+	/**
216
+	 * This calls the equivalent model method for retrieving the feature image which in turn is a wrapper for
217
+	 * WordPress' get_the_post_thumbnail() function.
218
+	 *
219
+	 * @link   http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail
220
+	 * @access protected
221
+	 * @param string|array $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array
222
+	 *                           representing width and height in pixels (i.e. array(32,32) ).
223
+	 * @param string|array $attr Optional. Query string or array of attributes.
224
+	 * @return string HTML image element
225
+	 */
226
+	protected function _get_feature_image($size, $attr)
227
+	{
228
+		// first let's see if we already have the _feature_image property set AND if it has a cached element on it FOR the given size
229
+		$attr_key = is_array($attr) ? implode('_', $attr) : $attr;
230
+		$cache_key = is_array($size) ? implode('_', $size) . $attr_key : $size . $attr_key;
231
+		$this->_feature_image[ $cache_key ] = isset($this->_feature_image[ $cache_key ])
232
+			? $this->_feature_image[ $cache_key ] : $this->get_model()->get_feature_image($this->ID(), $size, $attr);
233
+		return $this->_feature_image[ $cache_key ];
234
+	}
235
+
236
+
237
+	/**
238
+	 * See _get_feature_image. Returns the HTML to display a featured image
239
+	 *
240
+	 * @param string       $size
241
+	 * @param string|array $attr
242
+	 * @return string of html
243
+	 */
244
+	public function feature_image($size = 'thumbnail', $attr = '')
245
+	{
246
+		return $this->_get_feature_image($size, $attr);
247
+	}
248
+
249
+
250
+	/**
251
+	 * This uses the wp "wp_get_attachment_image_src()" function to return the feature image for the current class
252
+	 * using the given size params.
253
+	 *
254
+	 * @param  string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array
255
+	 *                            representing width and height in pixels eg. array(32,32).
256
+	 * @return string|boolean          the url of the image or false if not found
257
+	 */
258
+	public function feature_image_url($size = 'thumbnail')
259
+	{
260
+		$attachment = wp_get_attachment_image_src(get_post_thumbnail_id($this->ID()), $size);
261
+		return ! empty($attachment) ? $attachment[0] : false;
262
+	}
263
+
264
+
265
+	/**
266
+	 * This is a method for restoring this_obj using details from the given $revision_id
267
+	 *
268
+	 * @param int   $revision_id       ID of the revision we're getting data from
269
+	 * @param array $related_obj_names if included this will be used to restore for related obj
270
+	 *                                 if not included then we just do restore on the meta.
271
+	 *                                 We will accept an array of related_obj_names for restoration here.
272
+	 * @param array $where_query       You can optionally include an array of key=>value pairs
273
+	 *                                 that allow you to further constrict the relation to being added.
274
+	 *                                 However, keep in mind that the columns (keys) given
275
+	 *                                 must match a column on the JOIN table and currently
276
+	 *                                 only the HABTM models accept these additional conditions.
277
+	 *                                 Also remember that if an exact match isn't found for these extra cols/val pairs,
278
+	 *                                 then a NEW row is created in the join table.
279
+	 *                                 This array is INDEXED by RELATED OBJ NAME (so it corresponds with the obj_names
280
+	 *                                 sent);
281
+	 * @return void
282
+	 */
283
+	public function restore_revision($revision_id, $related_obj_names = array(), $where_query = array())
284
+	{
285
+		// get revision object
286
+		$revision_obj = $this->get_model()->get_one_by_ID($revision_id);
287
+		if ($revision_obj instanceof EE_CPT_Base) {
288
+			// no related_obj_name so we assume we're saving a revision on this object.
289
+			if (empty($related_obj_names)) {
290
+				$fields = $this->get_model()->get_meta_table_fields();
291
+				foreach ($fields as $field) {
292
+					$this->set($field, $revision_obj->get($field));
293
+				}
294
+				$this->save();
295
+			}
296
+			$related_obj_names = (array) $related_obj_names;
297
+			foreach ($related_obj_names as $related_name) {
298
+				// related_obj_name so we're saving a revision on an object related to this object
299
+				// do we have $where_query params for this related object?  If we do then we include that.
300
+				$cols_n_values = isset($where_query[ $related_name ]) ? $where_query[ $related_name ] : array();
301
+				$where_params = ! empty($cols_n_values) ? array($cols_n_values) : array();
302
+				$related_objs = $this->get_many_related($related_name, $where_params);
303
+				$revision_related_objs = $revision_obj->get_many_related($related_name, $where_params);
304
+				// load helper
305
+				// remove related objs from this object that are not in revision
306
+				// array_diff *should* work cause I think objects are indexed by ID?
307
+				$related_to_remove = EEH_Array::object_array_diff($related_objs, $revision_related_objs);
308
+				foreach ($related_to_remove as $rr) {
309
+					$this->_remove_relation_to($rr, $related_name, $cols_n_values);
310
+				}
311
+				// add all related objs attached to revision to this object
312
+				foreach ($revision_related_objs as $r_obj) {
313
+					$this->_add_relation_to($r_obj, $related_name, $cols_n_values);
314
+				}
315
+			}
316
+		}
317
+	}
318
+
319
+
320
+	/**
321
+	 * Wrapper for get_post_meta, http://codex.wordpress.org/Function_Reference/get_post_meta
322
+	 *
323
+	 * @param string  $meta_key
324
+	 * @param boolean $single
325
+	 * @return mixed <ul><li>If only $id is set it will return all meta values in an associative array.</li>
326
+	 * <li>If $single is set to false, or left blank, the function returns an array containing all values of the
327
+	 * specified key.</li>
328
+	 * <li>If $single is set to true, the function returns the first value of the specified key (not in an
329
+	 * array</li></ul>
330
+	 */
331
+	public function get_post_meta($meta_key = null, $single = false)
332
+	{
333
+		return get_post_meta($this->ID(), $meta_key, $single);
334
+	}
335
+
336
+
337
+	/**
338
+	 * Wrapper for update_post_meta, http://codex.wordpress.org/Function_Reference/update_post_meta
339
+	 *
340
+	 * @param string $meta_key
341
+	 * @param mixed  $meta_value
342
+	 * @param mixed  $prev_value
343
+	 * @return mixed Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure.
344
+	 *               NOTE: If the meta_value passed to this function is the same as the value that is already in the
345
+	 *               database, this function returns false.
346
+	 */
347
+	public function update_post_meta($meta_key, $meta_value, $prev_value = null)
348
+	{
349
+		if (! $this->ID()) {
350
+			$this->save();
351
+		}
352
+		return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value);
353
+	}
354
+
355
+
356
+	/**
357
+	 * Wrapper for add_post_meta, http://codex.wordpress.org/Function_Reference/add_post_meta
358
+	 *
359
+	 * @param mixed $meta_key
360
+	 * @param mixed $meta_value
361
+	 * @param bool  $unique . If postmeta for this $meta_key already exists, whether to add an additional item or not
362
+	 * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given
363
+	 *                 key already exists, in which case false is returned.
364
+	 */
365
+	public function add_post_meta($meta_key, $meta_value, $unique = false)
366
+	{
367
+		if ($this->ID()) {
368
+			$this->save();
369
+		}
370
+		return add_post_meta($this->ID(), $meta_key, $meta_value, $unique);
371
+	}
372
+
373
+
374
+	/**
375
+	 * Wrapper for delete_post_meta, http://codex.wordpress.org/Function_Reference/delete_post_meta
376
+	 *
377
+	 * @param mixed $meta_key
378
+	 * @param mixed $meta_value
379
+	 * @return boolean False for failure. True for success.
380
+	 */
381
+	public function delete_post_meta($meta_key, $meta_value = '')
382
+	{
383
+		if (! $this->ID()) {
384
+			// there are obviously no postmetas for this if it's not saved
385
+			// so let's just report this as a success
386
+			return true;
387
+		}
388
+		return delete_post_meta($this->ID(), $meta_key, $meta_value);
389
+	}
390
+
391
+
392
+	/**
393
+	 * Gets the URL for viewing this event on the front-end
394
+	 *
395
+	 * @return string
396
+	 */
397
+	public function get_permalink()
398
+	{
399
+		return get_permalink($this->ID());
400
+	}
401
+
402
+
403
+	/**
404
+	 * Gets all the term-taxonomies for this CPT
405
+	 *
406
+	 * @param array $query_params
407
+	 * @return EE_Term_Taxonomy
408
+	 */
409
+	public function term_taxonomies($query_params = array())
410
+	{
411
+		return $this->get_many_related('Term_Taxonomy', $query_params);
412
+	}
413
+
414
+
415
+	/**
416
+	 * @return mixed
417
+	 */
418
+	public function get_custom_post_statuses()
419
+	{
420
+		return $this->get_model()->get_custom_post_statuses();
421
+	}
422
+
423
+
424
+	/**
425
+	 * @return mixed
426
+	 */
427
+	public function get_all_post_statuses()
428
+	{
429
+		return $this->get_model()->get_status_array();
430
+	}
431
+
432
+
433
+	/**
434
+	 * Don't serialize the WP Post. That's just duplicate data and we want to avoid recursion
435
+	 *
436
+	 * @return array
437
+	 */
438
+	public function __sleep()
439
+	{
440
+		$properties_to_serialize = parent::__sleep();
441
+		$properties_to_serialize = array_diff($properties_to_serialize, array('_wp_post'));
442
+		return $properties_to_serialize;
443
+	}
444 444
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Message.class.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     {
52 52
         $has_object = parent::_check_for_object($props_n_values, __CLASS__);
53 53
         // if object doesn't exist, let's generate a unique token on instantiation so that its available even before saving to db.
54
-        if (! $has_object) {
54
+        if ( ! $has_object) {
55 55
             EE_Registry::instance()->load_helper('URL');
56 56
             $props_n_values['MSG_token'] = EEH_URL::generate_unique_token();
57 57
         }
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
     {
220 220
         $label_type = $plural ? 'plural' : 'singular';
221 221
         $messenger = $this->messenger_object();
222
-        return $messenger instanceof EE_messenger ? $messenger->label[ $label_type ] : $this->messenger();
222
+        return $messenger instanceof EE_messenger ? $messenger->label[$label_type] : $this->messenger();
223 223
     }
224 224
 
225 225
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
                 $this->messenger(),
337 337
                 $this->message_type()
338 338
             );
339
-            if (! $valid && $throw_exceptions) {
339
+            if ( ! $valid && $throw_exceptions) {
340 340
                 throw new EE_Error(
341 341
                     sprintf(
342 342
                         esc_html__(
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
         $label_type = $plural ? 'plural' : 'singular';
367 367
         $message_type = $this->message_type_object();
368 368
         return $message_type instanceof EE_message_type
369
-            ? $message_type->label[ $label_type ]
369
+            ? $message_type->label[$label_type]
370 370
             : str_replace(
371 371
                 '_',
372 372
                 ' ',
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
         /** @type EE_Message_Resource_Manager $message_resource_manager */
398 398
         $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
399 399
         $contexts = $message_resource_manager->get_all_contexts();
400
-        return isset($contexts[ $this->context() ]) ? $contexts[ $this->context() ] : $this->context();
400
+        return isset($contexts[$this->context()]) ? $contexts[$this->context()] : $this->context();
401 401
     }
402 402
 
403 403
 
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
      */
453 453
     public function recipient_object()
454 454
     {
455
-        if (! $this->recipient_type() || ! $this->recipient_ID()) {
455
+        if ( ! $this->recipient_type() || ! $this->recipient_ID()) {
456 456
             return null;
457 457
         }
458 458
 
@@ -736,13 +736,13 @@  discard block
 block discarded – undo
736 736
         /**
737 737
          * This is deprecated functionality that will be removed eventually but included here now for backward compat.
738 738
          */
739
-        if (! empty($this->template_pack)) {
739
+        if ( ! empty($this->template_pack)) {
740 740
             return $this->template_pack;
741 741
         }
742 742
         /** @type EE_Message_Template_Group $grp */
743 743
         $grp = $this->get_first_related('Message_Template_Group');
744 744
         // if no group then let's try to get the first related group by internal messenger and message type (will use global grp).
745
-        if (! $grp instanceof EE_Message_Template_Group) {
745
+        if ( ! $grp instanceof EE_Message_Template_Group) {
746 746
             $grp = EEM_Message_Template_Group::instance()->get_one(
747 747
                 array(
748 748
                     array(
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
         /**
769 769
          * This is deprecated functionality that will be removed eventually but included here now for backward compat.
770 770
          */
771
-        if (! empty($this->template_variation)) {
771
+        if ( ! empty($this->template_variation)) {
772 772
             return $this->template_variation;
773 773
         }
774 774
 
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
         $grp = $this->get_first_related('Message_Template_Group');
777 777
 
778 778
         // if no group then let's try to get the first related group by internal messenger and message type (will use global grp).
779
-        if (! $grp instanceof EE_Message_Template_Group) {
779
+        if ( ! $grp instanceof EE_Message_Template_Group) {
780 780
             $grp = EEM_Message_Template_Group::instance()->get_one(
781 781
                 array(
782 782
                     array(
Please login to merge, or discard this patch.
Indentation   +869 added lines, -869 removed lines patch added patch discarded remove patch
@@ -9,877 +9,877 @@
 block discarded – undo
9 9
  */
10 10
 class EE_Message extends EE_Base_Class implements EEI_Admin_Links
11 11
 {
12
-    /**
13
-     * @deprecated 4.9.0  Added for backward compat with add-on's
14
-     * @type null
15
-     */
16
-    public $template_pack;
17
-
18
-    /**
19
-     * @deprecated 4.9.0 Added for backward compat with add-on's
20
-     * @type null
21
-     */
22
-    public $template_variation;
23
-
24
-    /**
25
-     * @deprecated 4.9.0 Added for backward compat with add-on's
26
-     * @type string
27
-     */
28
-    public $content = '';
29
-
30
-
31
-    /**
32
-     * @type EE_messenger $_messenger
33
-     */
34
-    protected $_messenger = null;
35
-
36
-    /**
37
-     * @type EE_message_type $_message_type
38
-     */
39
-    protected $_message_type = null;
40
-
41
-
42
-    /**
43
-     * @param array  $props_n_values
44
-     * @param string $timezone
45
-     * @param array  $date_formats incoming date formats in an array.  First value is the date_format, second is time
46
-     *                             format.
47
-     * @return EE_Message
48
-     */
49
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
50
-    {
51
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
52
-        // if object doesn't exist, let's generate a unique token on instantiation so that its available even before saving to db.
53
-        if (! $has_object) {
54
-            EE_Registry::instance()->load_helper('URL');
55
-            $props_n_values['MSG_token'] = EEH_URL::generate_unique_token();
56
-        }
57
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
58
-    }
59
-
60
-
61
-    /**
62
-     * @param array  $props_n_values
63
-     * @param string $timezone
64
-     * @return EE_Message
65
-     */
66
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
67
-    {
68
-        return new self($props_n_values, true, $timezone);
69
-    }
70
-
71
-
72
-    /**
73
-     * Gets MSG_token
74
-     *
75
-     * @return int
76
-     */
77
-    public function MSG_token()
78
-    {
79
-        return $this->get('MSG_token');
80
-    }
81
-
82
-
83
-    /**
84
-     * Sets MSG_token
85
-     *
86
-     * @param int $MSG_token
87
-     */
88
-    public function set_MSG_token($MSG_token)
89
-    {
90
-        $this->set('MSG_token', $MSG_token);
91
-    }
92
-
93
-
94
-    /**
95
-     * Gets GRP_ID
96
-     *
97
-     * @return int
98
-     */
99
-    public function GRP_ID()
100
-    {
101
-        return $this->get('GRP_ID');
102
-    }
103
-
104
-
105
-    /**
106
-     * Sets GRP_ID
107
-     *
108
-     * @param int $GRP_ID
109
-     */
110
-    public function set_GRP_ID($GRP_ID)
111
-    {
112
-        $this->set('GRP_ID', $GRP_ID);
113
-    }
114
-
115
-
116
-    /**
117
-     * Gets TXN_ID
118
-     *
119
-     * @return int
120
-     */
121
-    public function TXN_ID()
122
-    {
123
-        return $this->get('TXN_ID');
124
-    }
125
-
126
-
127
-    /**
128
-     * Sets TXN_ID
129
-     *
130
-     * @param int $TXN_ID
131
-     */
132
-    public function set_TXN_ID($TXN_ID)
133
-    {
134
-        $this->set('TXN_ID', $TXN_ID);
135
-    }
136
-
137
-
138
-    /**
139
-     * Gets messenger
140
-     *
141
-     * @return string
142
-     */
143
-    public function messenger()
144
-    {
145
-        return $this->get('MSG_messenger');
146
-    }
147
-
148
-
149
-    /**
150
-     * Sets messenger
151
-     *
152
-     * @param string $messenger
153
-     */
154
-    public function set_messenger($messenger)
155
-    {
156
-        $this->set('MSG_messenger', $messenger);
157
-    }
158
-
159
-
160
-    /**
161
-     * Returns corresponding messenger object for the set messenger on this message
162
-     *
163
-     * @return EE_messenger | null
164
-     */
165
-    public function messenger_object()
166
-    {
167
-        return $this->_messenger;
168
-    }
169
-
170
-
171
-    /**
172
-     * Sets messenger
173
-     *
174
-     * @param EE_messenger $messenger
175
-     */
176
-    public function set_messenger_object(EE_messenger $messenger)
177
-    {
178
-        $this->_messenger = $messenger;
179
-    }
180
-
181
-
182
-    /**
183
-     * validates messenger
184
-     *
185
-     * @param bool $throw_exceptions
186
-     * @return bool
187
-     * @throws \EE_Error
188
-     */
189
-    public function valid_messenger($throw_exceptions = false)
190
-    {
191
-        if ($this->_messenger instanceof EE_messenger) {
192
-            return true;
193
-        }
194
-        if ($throw_exceptions) {
195
-            throw new EE_Error(
196
-                sprintf(
197
-                    esc_html__(
198
-                        'The "%1$s" messenger set for this message is missing or invalid. Please double-check the spelling and verify that the correct files exist.',
199
-                        'event_espresso'
200
-                    ),
201
-                    $this->messenger()
202
-                )
203
-            );
204
-        }
205
-        return false;
206
-    }
207
-
208
-
209
-    /**
210
-     * This returns the set localized label for the messenger on this message.
211
-     * Note, if unable to retrieve the EE_messenger object then will just return the messenger slug saved
212
-     * with this message.
213
-     *
214
-     * @param   bool $plural whether to return the plural label or not.
215
-     * @return string
216
-     */
217
-    public function messenger_label($plural = false)
218
-    {
219
-        $label_type = $plural ? 'plural' : 'singular';
220
-        $messenger = $this->messenger_object();
221
-        return $messenger instanceof EE_messenger ? $messenger->label[ $label_type ] : $this->messenger();
222
-    }
223
-
224
-
225
-    /**
226
-     * Gets message_type
227
-     *
228
-     * @return string
229
-     */
230
-    public function message_type()
231
-    {
232
-        return $this->get('MSG_message_type');
233
-    }
234
-
235
-
236
-    /**
237
-     * Sets message_type
238
-     *
239
-     * @param string $message_type
240
-     */
241
-    public function set_message_type($message_type)
242
-    {
243
-        $this->set('MSG_message_type', $message_type);
244
-    }
245
-
246
-
247
-    /**
248
-     * Returns the message type object for the set message type on this message
249
-     *
250
-     * @return EE_message_type | null
251
-     */
252
-    public function message_type_object()
253
-    {
254
-        return $this->_message_type;
255
-    }
256
-
257
-
258
-    /**
259
-     * Sets message_type
260
-     *
261
-     * @param EE_message_type $message_type
262
-     * @param bool            $set_priority   This indicates whether to set the priority to whatever the priority is on
263
-     *                                        the message type or not.
264
-     */
265
-    public function set_message_type_object(EE_message_type $message_type, $set_priority = false)
266
-    {
267
-        $this->_message_type = $message_type;
268
-        if ($set_priority) {
269
-            $this->set_priority($this->_message_type->get_priority());
270
-        }
271
-    }
272
-
273
-
274
-    /**
275
-     * validates message_type
276
-     *
277
-     * @param bool $throw_exceptions
278
-     * @return bool
279
-     * @throws \EE_Error
280
-     */
281
-    public function valid_message_type($throw_exceptions = false)
282
-    {
283
-        if ($this->_message_type instanceof EE_message_type) {
284
-            return true;
285
-        }
286
-        if ($throw_exceptions) {
287
-            throw new EE_Error(
288
-                sprintf(
289
-                    esc_html__(
290
-                        'The %1$s message type set for this message is missing or invalid. Please double-check the spelling and verify that the correct files exist.',
291
-                        'event_espresso'
292
-                    ),
293
-                    $this->message_type()
294
-                )
295
-            );
296
-        }
297
-        return false;
298
-    }
299
-
300
-
301
-    /**
302
-     * validates messenger and message_type (that they are valid EE_messenger and EE_message_type objects).
303
-     *
304
-     * @param bool $throw_exceptions
305
-     * @return bool
306
-     * @throws \EE_Error
307
-     */
308
-    public function is_valid($throw_exceptions = false)
309
-    {
310
-        if ($this->valid_messenger($throw_exceptions) && $this->valid_message_type($throw_exceptions)) {
311
-            return true;
312
-        }
313
-        return false;
314
-    }
315
-
316
-
317
-    /**
318
-     * This validates whether the internal messenger and message type objects are valid for sending.
319
-     * Three checks are done:
320
-     * 1. There is a valid messenger object.
321
-     * 2. There is a valid message type object.
322
-     * 3. The message type object is active for the messenger.
323
-     *
324
-     * @throws EE_Error  But only if $throw_exceptions is set to true.
325
-     * @param bool $throw_exceptions
326
-     * @return bool
327
-     */
328
-    public function is_valid_for_sending_or_generation($throw_exceptions = false)
329
-    {
330
-        $valid = false;
331
-        if ($this->is_valid($throw_exceptions)) {
332
-            /** @var EE_Message_Resource_Manager $message_resource_manager */
333
-            $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
334
-            $valid = $message_resource_manager->is_message_type_active_for_messenger(
335
-                $this->messenger(),
336
-                $this->message_type()
337
-            );
338
-            if (! $valid && $throw_exceptions) {
339
-                throw new EE_Error(
340
-                    sprintf(
341
-                        esc_html__(
342
-                            'The %1$s message type is not a valid message type for the %2$s messenger so it will not be sent.',
343
-                            'event_espresso'
344
-                        ),
345
-                        $this->message_type(),
346
-                        $this->messenger()
347
-                    )
348
-                );
349
-            }
350
-        }
351
-        return $valid;
352
-    }
353
-
354
-
355
-    /**
356
-     * This returns the set localized label for the message type on this message.
357
-     * Note, if unable to retrieve the EE_message_type object then will just return the message type slug saved
358
-     * with this message.
359
-     *
360
-     * @param   bool $plural whether to return the plural label or not.
361
-     * @return string
362
-     */
363
-    public function message_type_label($plural = false)
364
-    {
365
-        $label_type = $plural ? 'plural' : 'singular';
366
-        $message_type = $this->message_type_object();
367
-        return $message_type instanceof EE_message_type
368
-            ? $message_type->label[ $label_type ]
369
-            : str_replace(
370
-                '_',
371
-                ' ',
372
-                $this->message_type()
373
-            );
374
-    }
375
-
376
-
377
-    /**
378
-     * Gets context
379
-     *
380
-     * @return string
381
-     */
382
-    public function context()
383
-    {
384
-        return $this->get('MSG_context');
385
-    }
386
-
387
-
388
-    /**
389
-     * This returns the corresponding localized label for the given context slug, if possible from installed message
390
-     * types. Otherwise, this will just return the set context slug on this object.
391
-     *
392
-     * @return string
393
-     */
394
-    public function context_label()
395
-    {
396
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
397
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
398
-        $contexts = $message_resource_manager->get_all_contexts();
399
-        return isset($contexts[ $this->context() ]) ? $contexts[ $this->context() ] : $this->context();
400
-    }
401
-
402
-
403
-    /**
404
-     * Sets context
405
-     *
406
-     * @param string $context
407
-     */
408
-    public function set_context($context)
409
-    {
410
-        $this->set('MSG_context', $context);
411
-    }
412
-
413
-
414
-    /**
415
-     * Gets recipient_ID
416
-     *
417
-     * @return int
418
-     */
419
-    public function recipient_ID()
420
-    {
421
-        return $this->get('MSG_recipient_ID');
422
-    }
423
-
424
-
425
-    /**
426
-     * Sets recipient_ID
427
-     *
428
-     * @param string $recipient_ID
429
-     */
430
-    public function set_recipient_ID($recipient_ID)
431
-    {
432
-        $this->set('MSG_recipient_ID', $recipient_ID);
433
-    }
434
-
435
-
436
-    /**
437
-     * Gets recipient_type
438
-     *
439
-     * @return string
440
-     */
441
-    public function recipient_type()
442
-    {
443
-        return $this->get('MSG_recipient_type');
444
-    }
445
-
446
-
447
-    /**
448
-     * Return the related object matching the recipient type and ID.
449
-     *
450
-     * @return EE_Base_Class | null
451
-     */
452
-    public function recipient_object()
453
-    {
454
-        if (! $this->recipient_type() || ! $this->recipient_ID()) {
455
-            return null;
456
-        }
457
-
458
-        return $this->get_first_related($this->recipient_type());
459
-    }
460
-
461
-
462
-    /**
463
-     * Sets recipient_type
464
-     *
465
-     * @param string $recipient_type
466
-     */
467
-    public function set_recipient_type($recipient_type)
468
-    {
469
-        $this->set('MSG_recipient_type', $recipient_type);
470
-    }
471
-
472
-
473
-    /**
474
-     * Gets content
475
-     *
476
-     * @return string
477
-     */
478
-    public function content()
479
-    {
480
-        return $this->get('MSG_content');
481
-    }
482
-
483
-
484
-    /**
485
-     * Sets content
486
-     *
487
-     * @param string $content
488
-     */
489
-    public function set_content($content)
490
-    {
491
-        $this->set('MSG_content', $content);
492
-    }
493
-
494
-
495
-    /**
496
-     * Gets subject
497
-     *
498
-     * @return string
499
-     */
500
-    public function subject()
501
-    {
502
-        return $this->get('MSG_subject');
503
-    }
504
-
505
-
506
-    /**
507
-     * Sets subject
508
-     *
509
-     * @param string $subject
510
-     */
511
-    public function set_subject($subject)
512
-    {
513
-        $this->set('MSG_subject', $subject);
514
-    }
515
-
516
-
517
-    /**
518
-     * Gets to
519
-     *
520
-     * @return string
521
-     */
522
-    public function to()
523
-    {
524
-        $to = $this->get('MSG_to');
525
-        return empty($to) ? esc_html__('No recipient', 'event_espresso') : $to;
526
-    }
527
-
528
-
529
-    /**
530
-     * Sets to
531
-     *
532
-     * @param string $to
533
-     */
534
-    public function set_to($to)
535
-    {
536
-        $this->set('MSG_to', $to);
537
-    }
538
-
539
-
540
-    /**
541
-     * Gets from
542
-     *
543
-     * @return string
544
-     */
545
-    public function from()
546
-    {
547
-        return $this->get('MSG_from');
548
-    }
549
-
550
-
551
-    /**
552
-     * Sets from
553
-     *
554
-     * @param string $from
555
-     */
556
-    public function set_from($from)
557
-    {
558
-        $this->set('MSG_from', $from);
559
-    }
560
-
561
-
562
-    /**
563
-     * Gets priority
564
-     *
565
-     * @return int
566
-     */
567
-    public function priority()
568
-    {
569
-        return $this->get('MSG_priority');
570
-    }
571
-
572
-
573
-    /**
574
-     * Sets priority
575
-     * Note.  Send Now Messengers always override any priority that may be set on a Message.  So
576
-     * this method calls the send_now method to verify that.
577
-     *
578
-     * @param int $priority
579
-     */
580
-    public function set_priority($priority)
581
-    {
582
-        $priority = $this->send_now() ? EEM_Message::priority_high : $priority;
583
-        parent::set('MSG_priority', $priority);
584
-    }
585
-
586
-
587
-    /**
588
-     * Overrides parent::set method so we can capture any sets for priority.
589
-     *
590
-     * @see parent::set() for phpdocs
591
-     * @param string $field_name
592
-     * @param mixed  $field_value
593
-     * @param bool   $use_default
594
-     * @throws EE_Error
595
-     */
596
-    public function set($field_name, $field_value, $use_default = false)
597
-    {
598
-        if ($field_name === 'MSG_priority') {
599
-            $this->set_priority($field_value);
600
-        }
601
-        parent::set($field_name, $field_value, $use_default);
602
-    }
603
-
604
-
605
-    /**
606
-     * @return bool
607
-     * @throws \EE_Error
608
-     */
609
-    public function send_now()
610
-    {
611
-        $send_now = $this->valid_messenger() && $this->messenger_object()->send_now() ? EEM_Message::priority_high
612
-            : $this->priority();
613
-        return $send_now === EEM_Message::priority_high ? true : false;
614
-    }
615
-
616
-
617
-    /**
618
-     * Gets STS_ID
619
-     *
620
-     * @return string
621
-     */
622
-    public function STS_ID()
623
-    {
624
-        return $this->get('STS_ID');
625
-    }
626
-
627
-
628
-    /**
629
-     * Sets STS_ID
630
-     *
631
-     * @param string $STS_ID
632
-     */
633
-    public function set_STS_ID($STS_ID)
634
-    {
635
-        $this->set('STS_ID', $STS_ID);
636
-    }
637
-
638
-
639
-    /**
640
-     * Gets created
641
-     *
642
-     * @return string
643
-     */
644
-    public function created()
645
-    {
646
-        return $this->get('MSG_created');
647
-    }
648
-
649
-
650
-    /**
651
-     * Sets created
652
-     *
653
-     * @param string $created
654
-     */
655
-    public function set_created($created)
656
-    {
657
-        $this->set('MSG_created', $created);
658
-    }
659
-
660
-
661
-    /**
662
-     * Gets modified
663
-     *
664
-     * @return string
665
-     */
666
-    public function modified()
667
-    {
668
-        return $this->get('MSG_modified');
669
-    }
670
-
671
-
672
-    /**
673
-     * Sets modified
674
-     *
675
-     * @param string $modified
676
-     */
677
-    public function set_modified($modified)
678
-    {
679
-        $this->set('MSG_modified', $modified);
680
-    }
681
-
682
-
683
-    /**
684
-     * Sets generation data for this message.
685
-     *
686
-     * @param mixed $data
687
-     */
688
-    public function set_generation_data($data)
689
-    {
690
-        $this->set_field_or_extra_meta('MSG_generation_data', $data);
691
-    }
692
-
693
-
694
-    /**
695
-     * Returns any set generation data for this message.
696
-     *
697
-     * @return mixed|null
698
-     */
699
-    public function get_generation_data()
700
-    {
701
-        return $this->get_field_or_extra_meta('MSG_generation_data');
702
-    }
703
-
704
-
705
-    /**
706
-     * Gets any error message.
707
-     *
708
-     * @return mixed|null
709
-     */
710
-    public function error_message()
711
-    {
712
-        return $this->get_field_or_extra_meta('MSG_error');
713
-    }
714
-
715
-
716
-    /**
717
-     * Sets an error message.
718
-     *
719
-     * @param $message
720
-     * @return bool|int
721
-     */
722
-    public function set_error_message($message)
723
-    {
724
-        return $this->set_field_or_extra_meta('MSG_error', $message);
725
-    }
726
-
727
-
728
-    /**
729
-     * This retrieves the associated template pack with this message.
730
-     *
731
-     * @return EE_Messages_Template_Pack | null
732
-     */
733
-    public function get_template_pack()
734
-    {
735
-        /**
736
-         * This is deprecated functionality that will be removed eventually but included here now for backward compat.
737
-         */
738
-        if (! empty($this->template_pack)) {
739
-            return $this->template_pack;
740
-        }
741
-        /** @type EE_Message_Template_Group $grp */
742
-        $grp = $this->get_first_related('Message_Template_Group');
743
-        // if no group then let's try to get the first related group by internal messenger and message type (will use global grp).
744
-        if (! $grp instanceof EE_Message_Template_Group) {
745
-            $grp = EEM_Message_Template_Group::instance()->get_one(
746
-                array(
747
-                    array(
748
-                        'MTP_messenger'    => $this->messenger(),
749
-                        'MTP_message_type' => $this->message_type(),
750
-                        'MTP_is_global'    => true,
751
-                    ),
752
-                )
753
-            );
754
-        }
755
-
756
-        return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack() : null;
757
-    }
758
-
759
-
760
-    /**
761
-     * Retrieves the variation used for generating this message.
762
-     *
763
-     * @return string
764
-     */
765
-    public function get_template_pack_variation()
766
-    {
767
-        /**
768
-         * This is deprecated functionality that will be removed eventually but included here now for backward compat.
769
-         */
770
-        if (! empty($this->template_variation)) {
771
-            return $this->template_variation;
772
-        }
773
-
774
-        /** @type EE_Message_Template_Group $grp */
775
-        $grp = $this->get_first_related('Message_Template_Group');
776
-
777
-        // if no group then let's try to get the first related group by internal messenger and message type (will use global grp).
778
-        if (! $grp instanceof EE_Message_Template_Group) {
779
-            $grp = EEM_Message_Template_Group::instance()->get_one(
780
-                array(
781
-                    array(
782
-                        'MTP_messenger'    => $this->messenger(),
783
-                        'MTP_message_type' => $this->message_type(),
784
-                        'MTP_is_global'    => true,
785
-                    ),
786
-                )
787
-            );
788
-        }
789
-
790
-        return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack_variation() : '';
791
-    }
792
-
793
-    /**
794
-     * Return the link to the admin details for the object.
795
-     *
796
-     * @return string
797
-     */
798
-    public function get_admin_details_link()
799
-    {
800
-        EE_Registry::instance()->load_helper('URL');
801
-        EE_Registry::instance()->load_helper('MSG_Template');
802
-        switch ($this->STS_ID()) {
803
-            case EEM_Message::status_failed:
804
-            case EEM_Message::status_debug_only:
805
-                return EEH_MSG_Template::generate_error_display_trigger($this);
806
-                break;
807
-
808
-            case EEM_Message::status_sent:
809
-                return EEH_MSG_Template::generate_browser_trigger($this);
810
-                break;
811
-
812
-            default:
813
-                return '';
814
-        }
815
-    }
816
-
817
-    /**
818
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
819
-     *
820
-     * @return string
821
-     */
822
-    public function get_admin_edit_link()
823
-    {
824
-        return $this->get_admin_details_link();
825
-    }
826
-
827
-    /**
828
-     * Returns the link to a settings page for the object.
829
-     *
830
-     * @return string
831
-     */
832
-    public function get_admin_settings_link()
833
-    {
834
-        EE_Registry::instance()->load_helper('URL');
835
-        return EEH_URL::add_query_args_and_nonce(
836
-            array(
837
-                'page'   => 'espresso_messages',
838
-                'action' => 'settings',
839
-            ),
840
-            admin_url('admin.php')
841
-        );
842
-    }
843
-
844
-    /**
845
-     * Returns the link to the "overview" for the object (typically the "list table" view).
846
-     *
847
-     * @return string
848
-     */
849
-    public function get_admin_overview_link()
850
-    {
851
-        EE_Registry::instance()->load_helper('URL');
852
-        return EEH_URL::add_query_args_and_nonce(
853
-            array(
854
-                'page'   => 'espresso_messages',
855
-                'action' => 'default',
856
-            ),
857
-            admin_url('admin.php')
858
-        );
859
-    }
860
-
861
-
862
-    /**
863
-     * This sets the EEM_Message::status_messenger_executing class on the message and the appropriate error message for
864
-     * it.
865
-     * Note this also SAVES the current message object to the db because it adds an error message to accompany the
866
-     * status.
867
-     *
868
-     */
869
-    public function set_messenger_is_executing()
870
-    {
871
-        $this->set_STS_ID(EEM_Message::status_messenger_executing);
872
-        if (EEM_Message::debug()) {
873
-            $this->set_error_message(
874
-                esc_html__(
875
-                    'A message with this status indicates that there was a problem that occurred while the message was being
12
+	/**
13
+	 * @deprecated 4.9.0  Added for backward compat with add-on's
14
+	 * @type null
15
+	 */
16
+	public $template_pack;
17
+
18
+	/**
19
+	 * @deprecated 4.9.0 Added for backward compat with add-on's
20
+	 * @type null
21
+	 */
22
+	public $template_variation;
23
+
24
+	/**
25
+	 * @deprecated 4.9.0 Added for backward compat with add-on's
26
+	 * @type string
27
+	 */
28
+	public $content = '';
29
+
30
+
31
+	/**
32
+	 * @type EE_messenger $_messenger
33
+	 */
34
+	protected $_messenger = null;
35
+
36
+	/**
37
+	 * @type EE_message_type $_message_type
38
+	 */
39
+	protected $_message_type = null;
40
+
41
+
42
+	/**
43
+	 * @param array  $props_n_values
44
+	 * @param string $timezone
45
+	 * @param array  $date_formats incoming date formats in an array.  First value is the date_format, second is time
46
+	 *                             format.
47
+	 * @return EE_Message
48
+	 */
49
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
50
+	{
51
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
52
+		// if object doesn't exist, let's generate a unique token on instantiation so that its available even before saving to db.
53
+		if (! $has_object) {
54
+			EE_Registry::instance()->load_helper('URL');
55
+			$props_n_values['MSG_token'] = EEH_URL::generate_unique_token();
56
+		}
57
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
58
+	}
59
+
60
+
61
+	/**
62
+	 * @param array  $props_n_values
63
+	 * @param string $timezone
64
+	 * @return EE_Message
65
+	 */
66
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
67
+	{
68
+		return new self($props_n_values, true, $timezone);
69
+	}
70
+
71
+
72
+	/**
73
+	 * Gets MSG_token
74
+	 *
75
+	 * @return int
76
+	 */
77
+	public function MSG_token()
78
+	{
79
+		return $this->get('MSG_token');
80
+	}
81
+
82
+
83
+	/**
84
+	 * Sets MSG_token
85
+	 *
86
+	 * @param int $MSG_token
87
+	 */
88
+	public function set_MSG_token($MSG_token)
89
+	{
90
+		$this->set('MSG_token', $MSG_token);
91
+	}
92
+
93
+
94
+	/**
95
+	 * Gets GRP_ID
96
+	 *
97
+	 * @return int
98
+	 */
99
+	public function GRP_ID()
100
+	{
101
+		return $this->get('GRP_ID');
102
+	}
103
+
104
+
105
+	/**
106
+	 * Sets GRP_ID
107
+	 *
108
+	 * @param int $GRP_ID
109
+	 */
110
+	public function set_GRP_ID($GRP_ID)
111
+	{
112
+		$this->set('GRP_ID', $GRP_ID);
113
+	}
114
+
115
+
116
+	/**
117
+	 * Gets TXN_ID
118
+	 *
119
+	 * @return int
120
+	 */
121
+	public function TXN_ID()
122
+	{
123
+		return $this->get('TXN_ID');
124
+	}
125
+
126
+
127
+	/**
128
+	 * Sets TXN_ID
129
+	 *
130
+	 * @param int $TXN_ID
131
+	 */
132
+	public function set_TXN_ID($TXN_ID)
133
+	{
134
+		$this->set('TXN_ID', $TXN_ID);
135
+	}
136
+
137
+
138
+	/**
139
+	 * Gets messenger
140
+	 *
141
+	 * @return string
142
+	 */
143
+	public function messenger()
144
+	{
145
+		return $this->get('MSG_messenger');
146
+	}
147
+
148
+
149
+	/**
150
+	 * Sets messenger
151
+	 *
152
+	 * @param string $messenger
153
+	 */
154
+	public function set_messenger($messenger)
155
+	{
156
+		$this->set('MSG_messenger', $messenger);
157
+	}
158
+
159
+
160
+	/**
161
+	 * Returns corresponding messenger object for the set messenger on this message
162
+	 *
163
+	 * @return EE_messenger | null
164
+	 */
165
+	public function messenger_object()
166
+	{
167
+		return $this->_messenger;
168
+	}
169
+
170
+
171
+	/**
172
+	 * Sets messenger
173
+	 *
174
+	 * @param EE_messenger $messenger
175
+	 */
176
+	public function set_messenger_object(EE_messenger $messenger)
177
+	{
178
+		$this->_messenger = $messenger;
179
+	}
180
+
181
+
182
+	/**
183
+	 * validates messenger
184
+	 *
185
+	 * @param bool $throw_exceptions
186
+	 * @return bool
187
+	 * @throws \EE_Error
188
+	 */
189
+	public function valid_messenger($throw_exceptions = false)
190
+	{
191
+		if ($this->_messenger instanceof EE_messenger) {
192
+			return true;
193
+		}
194
+		if ($throw_exceptions) {
195
+			throw new EE_Error(
196
+				sprintf(
197
+					esc_html__(
198
+						'The "%1$s" messenger set for this message is missing or invalid. Please double-check the spelling and verify that the correct files exist.',
199
+						'event_espresso'
200
+					),
201
+					$this->messenger()
202
+				)
203
+			);
204
+		}
205
+		return false;
206
+	}
207
+
208
+
209
+	/**
210
+	 * This returns the set localized label for the messenger on this message.
211
+	 * Note, if unable to retrieve the EE_messenger object then will just return the messenger slug saved
212
+	 * with this message.
213
+	 *
214
+	 * @param   bool $plural whether to return the plural label or not.
215
+	 * @return string
216
+	 */
217
+	public function messenger_label($plural = false)
218
+	{
219
+		$label_type = $plural ? 'plural' : 'singular';
220
+		$messenger = $this->messenger_object();
221
+		return $messenger instanceof EE_messenger ? $messenger->label[ $label_type ] : $this->messenger();
222
+	}
223
+
224
+
225
+	/**
226
+	 * Gets message_type
227
+	 *
228
+	 * @return string
229
+	 */
230
+	public function message_type()
231
+	{
232
+		return $this->get('MSG_message_type');
233
+	}
234
+
235
+
236
+	/**
237
+	 * Sets message_type
238
+	 *
239
+	 * @param string $message_type
240
+	 */
241
+	public function set_message_type($message_type)
242
+	{
243
+		$this->set('MSG_message_type', $message_type);
244
+	}
245
+
246
+
247
+	/**
248
+	 * Returns the message type object for the set message type on this message
249
+	 *
250
+	 * @return EE_message_type | null
251
+	 */
252
+	public function message_type_object()
253
+	{
254
+		return $this->_message_type;
255
+	}
256
+
257
+
258
+	/**
259
+	 * Sets message_type
260
+	 *
261
+	 * @param EE_message_type $message_type
262
+	 * @param bool            $set_priority   This indicates whether to set the priority to whatever the priority is on
263
+	 *                                        the message type or not.
264
+	 */
265
+	public function set_message_type_object(EE_message_type $message_type, $set_priority = false)
266
+	{
267
+		$this->_message_type = $message_type;
268
+		if ($set_priority) {
269
+			$this->set_priority($this->_message_type->get_priority());
270
+		}
271
+	}
272
+
273
+
274
+	/**
275
+	 * validates message_type
276
+	 *
277
+	 * @param bool $throw_exceptions
278
+	 * @return bool
279
+	 * @throws \EE_Error
280
+	 */
281
+	public function valid_message_type($throw_exceptions = false)
282
+	{
283
+		if ($this->_message_type instanceof EE_message_type) {
284
+			return true;
285
+		}
286
+		if ($throw_exceptions) {
287
+			throw new EE_Error(
288
+				sprintf(
289
+					esc_html__(
290
+						'The %1$s message type set for this message is missing or invalid. Please double-check the spelling and verify that the correct files exist.',
291
+						'event_espresso'
292
+					),
293
+					$this->message_type()
294
+				)
295
+			);
296
+		}
297
+		return false;
298
+	}
299
+
300
+
301
+	/**
302
+	 * validates messenger and message_type (that they are valid EE_messenger and EE_message_type objects).
303
+	 *
304
+	 * @param bool $throw_exceptions
305
+	 * @return bool
306
+	 * @throws \EE_Error
307
+	 */
308
+	public function is_valid($throw_exceptions = false)
309
+	{
310
+		if ($this->valid_messenger($throw_exceptions) && $this->valid_message_type($throw_exceptions)) {
311
+			return true;
312
+		}
313
+		return false;
314
+	}
315
+
316
+
317
+	/**
318
+	 * This validates whether the internal messenger and message type objects are valid for sending.
319
+	 * Three checks are done:
320
+	 * 1. There is a valid messenger object.
321
+	 * 2. There is a valid message type object.
322
+	 * 3. The message type object is active for the messenger.
323
+	 *
324
+	 * @throws EE_Error  But only if $throw_exceptions is set to true.
325
+	 * @param bool $throw_exceptions
326
+	 * @return bool
327
+	 */
328
+	public function is_valid_for_sending_or_generation($throw_exceptions = false)
329
+	{
330
+		$valid = false;
331
+		if ($this->is_valid($throw_exceptions)) {
332
+			/** @var EE_Message_Resource_Manager $message_resource_manager */
333
+			$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
334
+			$valid = $message_resource_manager->is_message_type_active_for_messenger(
335
+				$this->messenger(),
336
+				$this->message_type()
337
+			);
338
+			if (! $valid && $throw_exceptions) {
339
+				throw new EE_Error(
340
+					sprintf(
341
+						esc_html__(
342
+							'The %1$s message type is not a valid message type for the %2$s messenger so it will not be sent.',
343
+							'event_espresso'
344
+						),
345
+						$this->message_type(),
346
+						$this->messenger()
347
+					)
348
+				);
349
+			}
350
+		}
351
+		return $valid;
352
+	}
353
+
354
+
355
+	/**
356
+	 * This returns the set localized label for the message type on this message.
357
+	 * Note, if unable to retrieve the EE_message_type object then will just return the message type slug saved
358
+	 * with this message.
359
+	 *
360
+	 * @param   bool $plural whether to return the plural label or not.
361
+	 * @return string
362
+	 */
363
+	public function message_type_label($plural = false)
364
+	{
365
+		$label_type = $plural ? 'plural' : 'singular';
366
+		$message_type = $this->message_type_object();
367
+		return $message_type instanceof EE_message_type
368
+			? $message_type->label[ $label_type ]
369
+			: str_replace(
370
+				'_',
371
+				' ',
372
+				$this->message_type()
373
+			);
374
+	}
375
+
376
+
377
+	/**
378
+	 * Gets context
379
+	 *
380
+	 * @return string
381
+	 */
382
+	public function context()
383
+	{
384
+		return $this->get('MSG_context');
385
+	}
386
+
387
+
388
+	/**
389
+	 * This returns the corresponding localized label for the given context slug, if possible from installed message
390
+	 * types. Otherwise, this will just return the set context slug on this object.
391
+	 *
392
+	 * @return string
393
+	 */
394
+	public function context_label()
395
+	{
396
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
397
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
398
+		$contexts = $message_resource_manager->get_all_contexts();
399
+		return isset($contexts[ $this->context() ]) ? $contexts[ $this->context() ] : $this->context();
400
+	}
401
+
402
+
403
+	/**
404
+	 * Sets context
405
+	 *
406
+	 * @param string $context
407
+	 */
408
+	public function set_context($context)
409
+	{
410
+		$this->set('MSG_context', $context);
411
+	}
412
+
413
+
414
+	/**
415
+	 * Gets recipient_ID
416
+	 *
417
+	 * @return int
418
+	 */
419
+	public function recipient_ID()
420
+	{
421
+		return $this->get('MSG_recipient_ID');
422
+	}
423
+
424
+
425
+	/**
426
+	 * Sets recipient_ID
427
+	 *
428
+	 * @param string $recipient_ID
429
+	 */
430
+	public function set_recipient_ID($recipient_ID)
431
+	{
432
+		$this->set('MSG_recipient_ID', $recipient_ID);
433
+	}
434
+
435
+
436
+	/**
437
+	 * Gets recipient_type
438
+	 *
439
+	 * @return string
440
+	 */
441
+	public function recipient_type()
442
+	{
443
+		return $this->get('MSG_recipient_type');
444
+	}
445
+
446
+
447
+	/**
448
+	 * Return the related object matching the recipient type and ID.
449
+	 *
450
+	 * @return EE_Base_Class | null
451
+	 */
452
+	public function recipient_object()
453
+	{
454
+		if (! $this->recipient_type() || ! $this->recipient_ID()) {
455
+			return null;
456
+		}
457
+
458
+		return $this->get_first_related($this->recipient_type());
459
+	}
460
+
461
+
462
+	/**
463
+	 * Sets recipient_type
464
+	 *
465
+	 * @param string $recipient_type
466
+	 */
467
+	public function set_recipient_type($recipient_type)
468
+	{
469
+		$this->set('MSG_recipient_type', $recipient_type);
470
+	}
471
+
472
+
473
+	/**
474
+	 * Gets content
475
+	 *
476
+	 * @return string
477
+	 */
478
+	public function content()
479
+	{
480
+		return $this->get('MSG_content');
481
+	}
482
+
483
+
484
+	/**
485
+	 * Sets content
486
+	 *
487
+	 * @param string $content
488
+	 */
489
+	public function set_content($content)
490
+	{
491
+		$this->set('MSG_content', $content);
492
+	}
493
+
494
+
495
+	/**
496
+	 * Gets subject
497
+	 *
498
+	 * @return string
499
+	 */
500
+	public function subject()
501
+	{
502
+		return $this->get('MSG_subject');
503
+	}
504
+
505
+
506
+	/**
507
+	 * Sets subject
508
+	 *
509
+	 * @param string $subject
510
+	 */
511
+	public function set_subject($subject)
512
+	{
513
+		$this->set('MSG_subject', $subject);
514
+	}
515
+
516
+
517
+	/**
518
+	 * Gets to
519
+	 *
520
+	 * @return string
521
+	 */
522
+	public function to()
523
+	{
524
+		$to = $this->get('MSG_to');
525
+		return empty($to) ? esc_html__('No recipient', 'event_espresso') : $to;
526
+	}
527
+
528
+
529
+	/**
530
+	 * Sets to
531
+	 *
532
+	 * @param string $to
533
+	 */
534
+	public function set_to($to)
535
+	{
536
+		$this->set('MSG_to', $to);
537
+	}
538
+
539
+
540
+	/**
541
+	 * Gets from
542
+	 *
543
+	 * @return string
544
+	 */
545
+	public function from()
546
+	{
547
+		return $this->get('MSG_from');
548
+	}
549
+
550
+
551
+	/**
552
+	 * Sets from
553
+	 *
554
+	 * @param string $from
555
+	 */
556
+	public function set_from($from)
557
+	{
558
+		$this->set('MSG_from', $from);
559
+	}
560
+
561
+
562
+	/**
563
+	 * Gets priority
564
+	 *
565
+	 * @return int
566
+	 */
567
+	public function priority()
568
+	{
569
+		return $this->get('MSG_priority');
570
+	}
571
+
572
+
573
+	/**
574
+	 * Sets priority
575
+	 * Note.  Send Now Messengers always override any priority that may be set on a Message.  So
576
+	 * this method calls the send_now method to verify that.
577
+	 *
578
+	 * @param int $priority
579
+	 */
580
+	public function set_priority($priority)
581
+	{
582
+		$priority = $this->send_now() ? EEM_Message::priority_high : $priority;
583
+		parent::set('MSG_priority', $priority);
584
+	}
585
+
586
+
587
+	/**
588
+	 * Overrides parent::set method so we can capture any sets for priority.
589
+	 *
590
+	 * @see parent::set() for phpdocs
591
+	 * @param string $field_name
592
+	 * @param mixed  $field_value
593
+	 * @param bool   $use_default
594
+	 * @throws EE_Error
595
+	 */
596
+	public function set($field_name, $field_value, $use_default = false)
597
+	{
598
+		if ($field_name === 'MSG_priority') {
599
+			$this->set_priority($field_value);
600
+		}
601
+		parent::set($field_name, $field_value, $use_default);
602
+	}
603
+
604
+
605
+	/**
606
+	 * @return bool
607
+	 * @throws \EE_Error
608
+	 */
609
+	public function send_now()
610
+	{
611
+		$send_now = $this->valid_messenger() && $this->messenger_object()->send_now() ? EEM_Message::priority_high
612
+			: $this->priority();
613
+		return $send_now === EEM_Message::priority_high ? true : false;
614
+	}
615
+
616
+
617
+	/**
618
+	 * Gets STS_ID
619
+	 *
620
+	 * @return string
621
+	 */
622
+	public function STS_ID()
623
+	{
624
+		return $this->get('STS_ID');
625
+	}
626
+
627
+
628
+	/**
629
+	 * Sets STS_ID
630
+	 *
631
+	 * @param string $STS_ID
632
+	 */
633
+	public function set_STS_ID($STS_ID)
634
+	{
635
+		$this->set('STS_ID', $STS_ID);
636
+	}
637
+
638
+
639
+	/**
640
+	 * Gets created
641
+	 *
642
+	 * @return string
643
+	 */
644
+	public function created()
645
+	{
646
+		return $this->get('MSG_created');
647
+	}
648
+
649
+
650
+	/**
651
+	 * Sets created
652
+	 *
653
+	 * @param string $created
654
+	 */
655
+	public function set_created($created)
656
+	{
657
+		$this->set('MSG_created', $created);
658
+	}
659
+
660
+
661
+	/**
662
+	 * Gets modified
663
+	 *
664
+	 * @return string
665
+	 */
666
+	public function modified()
667
+	{
668
+		return $this->get('MSG_modified');
669
+	}
670
+
671
+
672
+	/**
673
+	 * Sets modified
674
+	 *
675
+	 * @param string $modified
676
+	 */
677
+	public function set_modified($modified)
678
+	{
679
+		$this->set('MSG_modified', $modified);
680
+	}
681
+
682
+
683
+	/**
684
+	 * Sets generation data for this message.
685
+	 *
686
+	 * @param mixed $data
687
+	 */
688
+	public function set_generation_data($data)
689
+	{
690
+		$this->set_field_or_extra_meta('MSG_generation_data', $data);
691
+	}
692
+
693
+
694
+	/**
695
+	 * Returns any set generation data for this message.
696
+	 *
697
+	 * @return mixed|null
698
+	 */
699
+	public function get_generation_data()
700
+	{
701
+		return $this->get_field_or_extra_meta('MSG_generation_data');
702
+	}
703
+
704
+
705
+	/**
706
+	 * Gets any error message.
707
+	 *
708
+	 * @return mixed|null
709
+	 */
710
+	public function error_message()
711
+	{
712
+		return $this->get_field_or_extra_meta('MSG_error');
713
+	}
714
+
715
+
716
+	/**
717
+	 * Sets an error message.
718
+	 *
719
+	 * @param $message
720
+	 * @return bool|int
721
+	 */
722
+	public function set_error_message($message)
723
+	{
724
+		return $this->set_field_or_extra_meta('MSG_error', $message);
725
+	}
726
+
727
+
728
+	/**
729
+	 * This retrieves the associated template pack with this message.
730
+	 *
731
+	 * @return EE_Messages_Template_Pack | null
732
+	 */
733
+	public function get_template_pack()
734
+	{
735
+		/**
736
+		 * This is deprecated functionality that will be removed eventually but included here now for backward compat.
737
+		 */
738
+		if (! empty($this->template_pack)) {
739
+			return $this->template_pack;
740
+		}
741
+		/** @type EE_Message_Template_Group $grp */
742
+		$grp = $this->get_first_related('Message_Template_Group');
743
+		// if no group then let's try to get the first related group by internal messenger and message type (will use global grp).
744
+		if (! $grp instanceof EE_Message_Template_Group) {
745
+			$grp = EEM_Message_Template_Group::instance()->get_one(
746
+				array(
747
+					array(
748
+						'MTP_messenger'    => $this->messenger(),
749
+						'MTP_message_type' => $this->message_type(),
750
+						'MTP_is_global'    => true,
751
+					),
752
+				)
753
+			);
754
+		}
755
+
756
+		return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack() : null;
757
+	}
758
+
759
+
760
+	/**
761
+	 * Retrieves the variation used for generating this message.
762
+	 *
763
+	 * @return string
764
+	 */
765
+	public function get_template_pack_variation()
766
+	{
767
+		/**
768
+		 * This is deprecated functionality that will be removed eventually but included here now for backward compat.
769
+		 */
770
+		if (! empty($this->template_variation)) {
771
+			return $this->template_variation;
772
+		}
773
+
774
+		/** @type EE_Message_Template_Group $grp */
775
+		$grp = $this->get_first_related('Message_Template_Group');
776
+
777
+		// if no group then let's try to get the first related group by internal messenger and message type (will use global grp).
778
+		if (! $grp instanceof EE_Message_Template_Group) {
779
+			$grp = EEM_Message_Template_Group::instance()->get_one(
780
+				array(
781
+					array(
782
+						'MTP_messenger'    => $this->messenger(),
783
+						'MTP_message_type' => $this->message_type(),
784
+						'MTP_is_global'    => true,
785
+					),
786
+				)
787
+			);
788
+		}
789
+
790
+		return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack_variation() : '';
791
+	}
792
+
793
+	/**
794
+	 * Return the link to the admin details for the object.
795
+	 *
796
+	 * @return string
797
+	 */
798
+	public function get_admin_details_link()
799
+	{
800
+		EE_Registry::instance()->load_helper('URL');
801
+		EE_Registry::instance()->load_helper('MSG_Template');
802
+		switch ($this->STS_ID()) {
803
+			case EEM_Message::status_failed:
804
+			case EEM_Message::status_debug_only:
805
+				return EEH_MSG_Template::generate_error_display_trigger($this);
806
+				break;
807
+
808
+			case EEM_Message::status_sent:
809
+				return EEH_MSG_Template::generate_browser_trigger($this);
810
+				break;
811
+
812
+			default:
813
+				return '';
814
+		}
815
+	}
816
+
817
+	/**
818
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
819
+	 *
820
+	 * @return string
821
+	 */
822
+	public function get_admin_edit_link()
823
+	{
824
+		return $this->get_admin_details_link();
825
+	}
826
+
827
+	/**
828
+	 * Returns the link to a settings page for the object.
829
+	 *
830
+	 * @return string
831
+	 */
832
+	public function get_admin_settings_link()
833
+	{
834
+		EE_Registry::instance()->load_helper('URL');
835
+		return EEH_URL::add_query_args_and_nonce(
836
+			array(
837
+				'page'   => 'espresso_messages',
838
+				'action' => 'settings',
839
+			),
840
+			admin_url('admin.php')
841
+		);
842
+	}
843
+
844
+	/**
845
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
846
+	 *
847
+	 * @return string
848
+	 */
849
+	public function get_admin_overview_link()
850
+	{
851
+		EE_Registry::instance()->load_helper('URL');
852
+		return EEH_URL::add_query_args_and_nonce(
853
+			array(
854
+				'page'   => 'espresso_messages',
855
+				'action' => 'default',
856
+			),
857
+			admin_url('admin.php')
858
+		);
859
+	}
860
+
861
+
862
+	/**
863
+	 * This sets the EEM_Message::status_messenger_executing class on the message and the appropriate error message for
864
+	 * it.
865
+	 * Note this also SAVES the current message object to the db because it adds an error message to accompany the
866
+	 * status.
867
+	 *
868
+	 */
869
+	public function set_messenger_is_executing()
870
+	{
871
+		$this->set_STS_ID(EEM_Message::status_messenger_executing);
872
+		if (EEM_Message::debug()) {
873
+			$this->set_error_message(
874
+				esc_html__(
875
+					'A message with this status indicates that there was a problem that occurred while the message was being
876 876
                     processed by the messenger.  It is still possible that the message was sent successfully, but at some
877 877
                     point during the processing there was a failure.  This usually is indicative of a timeout issue with PHP 
878 878
                     or memory limits being reached.  If you see this repeatedly you may want to consider upgrading the memory 
879 879
                     available to PHP on your server.',
880
-                    'event_espresso'
881
-                )
882
-            );
883
-        }
884
-    }
880
+					'event_espresso'
881
+				)
882
+			);
883
+		}
884
+	}
885 885
 }
Please login to merge, or discard this patch.