Completed
Branch FET-10416-autoload-b4-bootstra... (9a39f6)
by
unknown
119:38 queued 108:09
created
core/libraries/messages/EE_Messages_Data_Handler_Collection.lib.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION'))
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('No direct script access allowed');
4 4
 
5 5
 
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
 	 *                                                   classname to create an alternative index for retrieving data_handlers.
27 27
 	 * @return bool
28 28
 	 */
29
-	public function add( $data_handler, $data = null) {
29
+	public function add($data_handler, $data = null) {
30 30
 		$data = $data === null ? array() : (array) $data;
31
-		$info['key'] = $this->get_key( get_class( $data_handler ), $data );
32
-		return parent::add( $data_handler, $info );
31
+		$info['key'] = $this->get_key(get_class($data_handler), $data);
32
+		return parent::add($data_handler, $info);
33 33
 	}
34 34
 	
35 35
 
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	 *
45 45
 	 * @return  string      md5 hash using provided info.
46 46
 	 */
47
-	public function get_key( $classname, $data ) {
48
-		return md5( $classname . serialize( $data ) );
47
+	public function get_key($classname, $data) {
48
+		return md5($classname.serialize($data));
49 49
 	}
50 50
 
51 51
 
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @return null|EE_Messages_incoming_data
63 63
 	 */
64
-	public function get_by_key( $key ) {
64
+	public function get_by_key($key) {
65 65
 		$this->rewind();
66
-		while( $this->valid() ) {
66
+		while ($this->valid()) {
67 67
 			$data = $this->getInfo();
68
-			if ( isset( $data['key'] ) && $data['key'] === $key ) {
68
+			if (isset($data['key']) && $data['key'] === $key) {
69 69
 				$handler = $this->current();
70 70
 				$this->rewind();
71 71
 				return $handler;
Please login to merge, or discard this patch.
acceptance_tests/Page/MessagesAdmin.php 1 patch
Indentation   +242 added lines, -242 removed lines patch added patch discarded remove patch
@@ -14,254 +14,254 @@
 block discarded – undo
14 14
 class MessagesAdmin extends CoreAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * Context slug for the admin messages context.
19
-     * @var string
20
-     */
21
-    const ADMIN_CONTEXT_SLUG = 'admin';
17
+	/**
18
+	 * Context slug for the admin messages context.
19
+	 * @var string
20
+	 */
21
+	const ADMIN_CONTEXT_SLUG = 'admin';
22 22
 
23
-    /**
24
-     * Context slug for the primary attendee messages context
25
-     * @var string
26
-     */
27
-    const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee';
23
+	/**
24
+	 * Context slug for the primary attendee messages context
25
+	 * @var string
26
+	 */
27
+	const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee';
28 28
 
29 29
 
30
-    /**
31
-     * Status reference for the EEM_Message::status_sent status.
32
-     * @var string
33
-     */
34
-    const MESSAGE_STATUS_SENT = 'MSN';
30
+	/**
31
+	 * Status reference for the EEM_Message::status_sent status.
32
+	 * @var string
33
+	 */
34
+	const MESSAGE_STATUS_SENT = 'MSN';
35 35
 
36 36
 
37
-    /**
38
-     * Message type slug for the Payment Failed message type
39
-     */
40
-    const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed';
37
+	/**
38
+	 * Message type slug for the Payment Failed message type
39
+	 */
40
+	const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed';
41 41
 
42 42
 
43
-    /**
44
-     * Selector for the Global Messages "Send on same request" field in the Messages Settings tab.
45
-     * @var string
46
-     */
47
-    const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR =
48
-        '#global_messages_settings-do-messages-on-same-request';
49
-
43
+	/**
44
+	 * Selector for the Global Messages "Send on same request" field in the Messages Settings tab.
45
+	 * @var string
46
+	 */
47
+	const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR =
48
+		'#global_messages_settings-do-messages-on-same-request';
49
+
50 50
 
51
-    /**
52
-     * Selector for the Global Messages Settings submit button in the Messages Settings tab.
53
-     * @var string
54
-     */
55
-    const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit';
56
-
57
-
58
-    /**
59
-     * This is the container where active message types for a messenger are found/dragged to.
60
-     * @var string
61
-     */
62
-    const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types';
63
-
64
-
65
-    /**
66
-     * Locator for the context switcher selector on the Message Template Editor page.
67
-     * @var string
68
-     */
69
-    const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select";
70
-
71
-
72
-    /**
73
-     * Locator for the context switcher submit button in the Message Template Editor page.
74
-     * @var string
75
-     */
76
-    const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt";
77
-
78
-
79
-    /**
80
-     * Locator for the dialog container used for housing viewed messages in the message activity list table.
81
-     * @var string
82
-     */
83
-    const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content';
84
-
85
-
86
-
87
-    /**
88
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
89
-     *                                  a string.
90
-     * @return string
91
-     */
92
-    public static function messageActivityListTableUrl($additional_params = '')
93
-    {
94
-        return self::adminUrl('espresso_messages', 'default', $additional_params);
95
-    }
96
-
97
-
98
-    /**
99
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
100
-     *                                  a string.
101
-     * @return string
102
-     */
103
-    public static function defaultMessageTemplateListTableUrl($additional_params = '')
104
-    {
105
-        return self::adminUrl('espresso_messages', 'global_mtps', $additional_params);
106
-    }
107
-
108
-
109
-    /**
110
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
111
-     *                                  a string.
112
-     * @return string
113
-     */
114
-    public static function customMessageTemplateListTableUrl($additional_params = '')
115
-    {
116
-        return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params);
117
-    }
118
-
119
-
120
-    /**
121
-     * @return string
122
-     */
123
-    public static function messageSettingsUrl()
124
-    {
125
-        return self::adminUrl('espresso_messages', 'settings');
126
-    }
127
-
128
-
129
-
130
-    public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger(
131
-        $message_type_slug,
132
-        $messenger_slug = 'email'
133
-    ) {
134
-        return "#$message_type_slug-messagetype-$messenger_slug";
135
-    }
136
-
137
-
138
-    /**
139
-     * @param string $message_type_slug
140
-     * @param string $context
141
-     * @return string
142
-     */
143
-    public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
144
-    {
145
-        return $context
146
-            ? '.' . $message_type_slug . '-' . $context . '-edit-link'
147
-            : '.' . $message_type_slug . '-edit-link';
148
-    }
149
-
150
-
151
-    /**
152
-     * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters.
153
-     *
154
-     * @param        $field
155
-     * @param        $message_type_label
156
-     * @param string $message_status
157
-     * @param string $messenger
158
-     * @param string $context
159
-     * @param string $table_cell_content_for_field
160
-     * @param int    $number_in_set   It's possible that the given parameters could match multiple items in the view.
161
-     *                                This allows you to indicate which item from the set to match.  If this is set to 0
162
-     *                                then all matches for the locator will be returned.
163
-     * @return string
164
-     */
165
-    public static function messagesActivityListTableCellSelectorFor(
166
-        $field,
167
-        $message_type_label,
168
-        $message_status = self::MESSAGE_STATUS_SENT,
169
-        $messenger = 'Email',
170
-        $context = 'Event Admin',
171
-        $table_cell_content_for_field = '',
172
-        $number_in_set = 1
173
-    ) {
174
-        $selector = "//tbody[@id='the-list']";
175
-        $selector .= "//tr[contains(@class, 'msg-status-$message_status')]"
176
-                     . "//td[contains(@class, 'message_type') and text()='$message_type_label']";
177
-        if ($messenger) {
178
-            $selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']";
179
-        }
180
-        $selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']";
181
-        $selector .= $table_cell_content_for_field
182
-            ? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']"
183
-            : "/ancestor::tr/td[contains(@class, 'column-$field')]";
184
-        return $number_in_set > 0 ? Locator::elementAt($selector, $number_in_set) : $selector;
185
-    }
186
-
187
-
188
-    /**
189
-     * Selector for the Create Custom button found in the message template list table.
190
-     * @param string $message_type_label
191
-     * @param string $messenger_label
192
-     * @return string
193
-     */
194
-    public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label)
195
-    {
196
-        $selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']"
197
-                    . "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]"
198
-                    . "//ancestor::tr/td/a[@class='button button-small']";
199
-        return $selector;
200
-    }
201
-
202
-
203
-    /**
204
-     * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to
205
-     * the FIRST match (which will be the latest message sent if the table is default sorted).
206
-     *
207
-     * @param string $message_type_label    The visible message type label for the row you want to match
208
-     * @param string $message_status        The status of the message for the row you want to match.
209
-     * @param string $messenger             The visible messenger label for the row you want to match.
210
-     * @param string $context               The visible context label for the row you want to match.
211
-     * @param int    $number_in_set         It's possible that the given parameters could match multiple items in the
212
-     *                                      view. This allows you to indicate which item from the set to match.
213
-     * @return string
214
-     */
215
-    public static function messagesActivityListTableViewButtonSelectorFor(
216
-        $message_type_label,
217
-        $message_status = self::MESSAGE_STATUS_SENT,
218
-        $messenger = 'Email',
219
-        $context = 'Event Admin',
220
-        $number_in_set = 1
221
-    ) {
222
-        $selector = self::messagesActivityListTableCellSelectorFor(
223
-            'action',
224
-            $message_type_label,
225
-            $message_status,
226
-            $messenger,
227
-            $context,
228
-            '',
229
-            $number_in_set
230
-        );
231
-        $selector .= "/a/span[contains(@class, 'ee-message-action-link-view')"
232
-                     . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]";
233
-        return $selector;
234
-    }
235
-
236
-
237
-
238
-    /**
239
-     * Locator for the delete action link for a message item in the message activity list table.
240
-     * Note: The link is not visible by default, so the column would need hovered over for the link to appear.
241
-     * @param        $message_type_label
242
-     * @param string $message_status
243
-     * @param string $messenger
244
-     * @param string $context
245
-     * @param int    $number_in_set
246
-     * @return string
247
-     */
248
-    public static function messagesActivityListTableDeleteActionSelectorFor(
249
-        $message_type_label,
250
-        $message_status = self::MESSAGE_STATUS_SENT,
251
-        $messenger = 'Email',
252
-        $context = 'Event Admin',
253
-        $number_in_set = 1
254
-    ) {
255
-        $selector = self::messagesActivityListTableCellSelectorFor(
256
-            'to',
257
-            $message_type_label,
258
-            $message_status,
259
-            $messenger,
260
-            $context,
261
-            '',
262
-            $number_in_set
263
-        );
264
-        $selector .= "/div/span[@class='delete']/a";
265
-        return $selector;
266
-    }
51
+	/**
52
+	 * Selector for the Global Messages Settings submit button in the Messages Settings tab.
53
+	 * @var string
54
+	 */
55
+	const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit';
56
+
57
+
58
+	/**
59
+	 * This is the container where active message types for a messenger are found/dragged to.
60
+	 * @var string
61
+	 */
62
+	const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types';
63
+
64
+
65
+	/**
66
+	 * Locator for the context switcher selector on the Message Template Editor page.
67
+	 * @var string
68
+	 */
69
+	const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select";
70
+
71
+
72
+	/**
73
+	 * Locator for the context switcher submit button in the Message Template Editor page.
74
+	 * @var string
75
+	 */
76
+	const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt";
77
+
78
+
79
+	/**
80
+	 * Locator for the dialog container used for housing viewed messages in the message activity list table.
81
+	 * @var string
82
+	 */
83
+	const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content';
84
+
85
+
86
+
87
+	/**
88
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
89
+	 *                                  a string.
90
+	 * @return string
91
+	 */
92
+	public static function messageActivityListTableUrl($additional_params = '')
93
+	{
94
+		return self::adminUrl('espresso_messages', 'default', $additional_params);
95
+	}
96
+
97
+
98
+	/**
99
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
100
+	 *                                  a string.
101
+	 * @return string
102
+	 */
103
+	public static function defaultMessageTemplateListTableUrl($additional_params = '')
104
+	{
105
+		return self::adminUrl('espresso_messages', 'global_mtps', $additional_params);
106
+	}
107
+
108
+
109
+	/**
110
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
111
+	 *                                  a string.
112
+	 * @return string
113
+	 */
114
+	public static function customMessageTemplateListTableUrl($additional_params = '')
115
+	{
116
+		return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params);
117
+	}
118
+
119
+
120
+	/**
121
+	 * @return string
122
+	 */
123
+	public static function messageSettingsUrl()
124
+	{
125
+		return self::adminUrl('espresso_messages', 'settings');
126
+	}
127
+
128
+
129
+
130
+	public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger(
131
+		$message_type_slug,
132
+		$messenger_slug = 'email'
133
+	) {
134
+		return "#$message_type_slug-messagetype-$messenger_slug";
135
+	}
136
+
137
+
138
+	/**
139
+	 * @param string $message_type_slug
140
+	 * @param string $context
141
+	 * @return string
142
+	 */
143
+	public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '')
144
+	{
145
+		return $context
146
+			? '.' . $message_type_slug . '-' . $context . '-edit-link'
147
+			: '.' . $message_type_slug . '-edit-link';
148
+	}
149
+
150
+
151
+	/**
152
+	 * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters.
153
+	 *
154
+	 * @param        $field
155
+	 * @param        $message_type_label
156
+	 * @param string $message_status
157
+	 * @param string $messenger
158
+	 * @param string $context
159
+	 * @param string $table_cell_content_for_field
160
+	 * @param int    $number_in_set   It's possible that the given parameters could match multiple items in the view.
161
+	 *                                This allows you to indicate which item from the set to match.  If this is set to 0
162
+	 *                                then all matches for the locator will be returned.
163
+	 * @return string
164
+	 */
165
+	public static function messagesActivityListTableCellSelectorFor(
166
+		$field,
167
+		$message_type_label,
168
+		$message_status = self::MESSAGE_STATUS_SENT,
169
+		$messenger = 'Email',
170
+		$context = 'Event Admin',
171
+		$table_cell_content_for_field = '',
172
+		$number_in_set = 1
173
+	) {
174
+		$selector = "//tbody[@id='the-list']";
175
+		$selector .= "//tr[contains(@class, 'msg-status-$message_status')]"
176
+					 . "//td[contains(@class, 'message_type') and text()='$message_type_label']";
177
+		if ($messenger) {
178
+			$selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']";
179
+		}
180
+		$selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']";
181
+		$selector .= $table_cell_content_for_field
182
+			? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']"
183
+			: "/ancestor::tr/td[contains(@class, 'column-$field')]";
184
+		return $number_in_set > 0 ? Locator::elementAt($selector, $number_in_set) : $selector;
185
+	}
186
+
187
+
188
+	/**
189
+	 * Selector for the Create Custom button found in the message template list table.
190
+	 * @param string $message_type_label
191
+	 * @param string $messenger_label
192
+	 * @return string
193
+	 */
194
+	public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label)
195
+	{
196
+		$selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']"
197
+					. "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]"
198
+					. "//ancestor::tr/td/a[@class='button button-small']";
199
+		return $selector;
200
+	}
201
+
202
+
203
+	/**
204
+	 * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to
205
+	 * the FIRST match (which will be the latest message sent if the table is default sorted).
206
+	 *
207
+	 * @param string $message_type_label    The visible message type label for the row you want to match
208
+	 * @param string $message_status        The status of the message for the row you want to match.
209
+	 * @param string $messenger             The visible messenger label for the row you want to match.
210
+	 * @param string $context               The visible context label for the row you want to match.
211
+	 * @param int    $number_in_set         It's possible that the given parameters could match multiple items in the
212
+	 *                                      view. This allows you to indicate which item from the set to match.
213
+	 * @return string
214
+	 */
215
+	public static function messagesActivityListTableViewButtonSelectorFor(
216
+		$message_type_label,
217
+		$message_status = self::MESSAGE_STATUS_SENT,
218
+		$messenger = 'Email',
219
+		$context = 'Event Admin',
220
+		$number_in_set = 1
221
+	) {
222
+		$selector = self::messagesActivityListTableCellSelectorFor(
223
+			'action',
224
+			$message_type_label,
225
+			$message_status,
226
+			$messenger,
227
+			$context,
228
+			'',
229
+			$number_in_set
230
+		);
231
+		$selector .= "/a/span[contains(@class, 'ee-message-action-link-view')"
232
+					 . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]";
233
+		return $selector;
234
+	}
235
+
236
+
237
+
238
+	/**
239
+	 * Locator for the delete action link for a message item in the message activity list table.
240
+	 * Note: The link is not visible by default, so the column would need hovered over for the link to appear.
241
+	 * @param        $message_type_label
242
+	 * @param string $message_status
243
+	 * @param string $messenger
244
+	 * @param string $context
245
+	 * @param int    $number_in_set
246
+	 * @return string
247
+	 */
248
+	public static function messagesActivityListTableDeleteActionSelectorFor(
249
+		$message_type_label,
250
+		$message_status = self::MESSAGE_STATUS_SENT,
251
+		$messenger = 'Email',
252
+		$context = 'Event Admin',
253
+		$number_in_set = 1
254
+	) {
255
+		$selector = self::messagesActivityListTableCellSelectorFor(
256
+			'to',
257
+			$message_type_label,
258
+			$message_status,
259
+			$messenger,
260
+			$context,
261
+			'',
262
+			$number_in_set
263
+		);
264
+		$selector .= "/div/span[@class='delete']/a";
265
+		return $selector;
266
+	}
267 267
 }
268 268
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/tests/c-TestCustomMessageTemplateCept.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@  discard block
 block discarded – undo
18 18
 $event_one_link = $event_two_link = $event_three_link = '';
19 19
 
20 20
 $I->wantTo(
21
-    'Test that when registrations for multiple events are completed, and those events share the same custom'
22
-    . 'template, that that custom template will be used.'
21
+	'Test that when registrations for multiple events are completed, and those events share the same custom'
22
+	. 'template, that that custom template will be used.'
23 23
 );
24 24
 
25 25
 //need the MER plugin active for this test (we'll deactivate it after).
26 26
 $I->ensurePluginActive(
27
-    'event-espresso-mer-multi-event-registration',
28
-    'activated'
27
+	'event-espresso-mer-multi-event-registration',
28
+	'activated'
29 29
 );
30 30
 
31 31
 $I->loginAsAdmin();
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 
84 84
 
85 85
 $test_registration_details = array(
86
-    'fname' => 'CTGuy',
87
-    'lname' => 'Dude',
88
-    'email' => '[email protected]'
86
+	'fname' => 'CTGuy',
87
+	'lname' => 'Dude',
88
+	'email' => '[email protected]'
89 89
 );
90 90
 
91 91
 $I->amGoingTo('Register for Event One and Event Two and verify Custom Template A was used.');
@@ -111,23 +111,23 @@  discard block
 block discarded – undo
111 111
 $I->loginAsAdmin();
112 112
 $I->amOnMessagesActivityListTablePage();
113 113
 $I->viewMessageInMessagesListTableFor(
114
-    'Registration Approved',
115
-    MessagesAdmin::MESSAGE_STATUS_SENT,
116
-    'Email',
117
-    'Registrant'
114
+	'Registration Approved',
115
+	MessagesAdmin::MESSAGE_STATUS_SENT,
116
+	'Email',
117
+	'Registrant'
118 118
 );
119 119
 $I->seeTextInViewMessageModal($custom_template_a_label);
120 120
 $I->dismissMessageModal();
121 121
 $I->deleteMessageInMessagesListTableFor(
122
-    'Registration Approved',
123
-    MessagesAdmin::MESSAGE_STATUS_SENT,
124
-    'Email',
125
-    'Registrant'
122
+	'Registration Approved',
123
+	MessagesAdmin::MESSAGE_STATUS_SENT,
124
+	'Email',
125
+	'Registrant'
126 126
 );
127 127
 
128 128
 //verify admin context
129 129
 $I->viewMessageInMessagesListTableFor(
130
-    'Registration Approved'
130
+	'Registration Approved'
131 131
 );
132 132
 $I->seeTextInViewMessageModal($custom_template_a_label);
133 133
 $I->dismissMessageModal();
@@ -156,25 +156,25 @@  discard block
 block discarded – undo
156 156
 $I->loginAsAdmin();
157 157
 $I->amOnMessagesActivityListTablePage();
158 158
 $I->viewMessageInMessagesListTableFor(
159
-    'Registration Approved',
160
-    MessagesAdmin::MESSAGE_STATUS_SENT,
161
-    'Email',
162
-    'Registrant'
159
+	'Registration Approved',
160
+	MessagesAdmin::MESSAGE_STATUS_SENT,
161
+	'Email',
162
+	'Registrant'
163 163
 );
164 164
 $I->waitForElementVisible(MessagesAdmin::MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR);
165 165
 $I->dontSeeTextInViewMessageModal($custom_template_a_label);
166 166
 $I->dontSeeTextInViewMessageModal($custom_template_b_label);
167 167
 $I->dismissMessageModal();
168 168
 $I->deleteMessageInMessagesListTableFor(
169
-    'Registration Approved',
170
-    MessagesAdmin::MESSAGE_STATUS_SENT,
171
-    'Email',
172
-    'Registrant'
169
+	'Registration Approved',
170
+	MessagesAdmin::MESSAGE_STATUS_SENT,
171
+	'Email',
172
+	'Registrant'
173 173
 );
174 174
 
175 175
 //verify admin context
176 176
 $I->viewMessageInMessagesListTableFor(
177
-    'Registration Approved'
177
+	'Registration Approved'
178 178
 );
179 179
 $I->waitForElementVisible(MessagesAdmin::MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR);
180 180
 $I->dontSee($custom_template_a_label);
@@ -186,6 +186,6 @@  discard block
 block discarded – undo
186 186
 
187 187
 //deactivate MER plugin so its not active for future tests
188 188
 $I->ensurePluginDeactivated(
189
-    'event-espresso-mer-multi-event-registration',
190
-    'Plugin deactivated'
189
+	'event-espresso-mer-multi-event-registration',
190
+	'Plugin deactivated'
191 191
 );
192 192
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/MessagesAdmin.php 1 patch
Indentation   +238 added lines, -238 removed lines patch added patch discarded remove patch
@@ -10,242 +10,242 @@
 block discarded – undo
10 10
  */
11 11
 trait MessagesAdmin
12 12
 {
13
-    /**
14
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
15
-     *                                  a string.
16
-     */
17
-    public function amOnMessagesActivityListTablePage($additional_params = '')
18
-    {
19
-        $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params));
20
-    }
21
-
22
-    /**
23
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
24
-     *                                  a string.
25
-     */
26
-    public function amOnDefaultMessageTemplateListTablePage($additional_params = '')
27
-    {
28
-        $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params));
29
-    }
30
-
31
-
32
-    /**
33
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
34
-     *                                  a string.
35
-     */
36
-    public function amOnCustomMessageTemplateListTablePage($additional_params = '')
37
-    {
38
-        $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params));
39
-    }
40
-
41
-
42
-    /**
43
-     * Directs to message settings page
44
-     */
45
-    public function amOnMessageSettingsPage()
46
-    {
47
-        $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl());
48
-    }
49
-
50
-
51
-    public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email')
52
-    {
53
-        $this->actor()->dragAndDrop(
54
-            MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug),
55
-            MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR
56
-        );
57
-    }
58
-
59
-
60
-    /**
61
-     * Assumes you are already on the list table page that has the ui for editing the template.
62
-     * @param string $message_type_slug
63
-     * @param string $context [optional] if you want to click directly to the given context in the editor
64
-     */
65
-    public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '')
66
-    {
67
-        $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context));
68
-    }
69
-
70
-
71
-    /**
72
-     * Use this action to verify that the count for the given text in the specified field is as expected.  For example
73
-     * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column.
74
-     *
75
-     * @param int    $expected_occurence_count
76
-     * @param string $text_to_check_for
77
-     * @param string $field
78
-     * @param string $message_type_label
79
-     * @param string $message_status
80
-     * @param string $messenger
81
-     * @param string $context
82
-     */
83
-    public function verifyMatchingCountofTextInMessageActivityListTableFor(
84
-        $expected_occurence_count,
85
-        $text_to_check_for,
86
-        $field,
87
-        $message_type_label,
88
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
89
-        $messenger = 'Email',
90
-        $context = 'Event Admin'
91
-    ) {
92
-        $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor(
93
-            $field,
94
-            $message_type_label,
95
-            $message_status,
96
-            $messenger,
97
-            $context,
98
-            $text_to_check_for,
99
-            0
100
-        ));
101
-        $actual_count = count($elements);
102
-        $this->actor()->assertEquals(
103
-            $expected_occurence_count,
104
-            $actual_count,
105
-            sprintf(
106
-                'Expected %s of the %s text for the %s field but there were actually %s counted.',
107
-                $expected_occurence_count,
108
-                $text_to_check_for,
109
-                $field,
110
-                $actual_count
111
-            )
112
-        );
113
-    }
114
-
115
-
116
-    /**
117
-     * This will create a custom message template for the given messenger and message type from the context of the
118
-     * default (global) message template list table.
119
-     * Also takes care of verifying the template was created.
120
-     * @param string $message_type_label
121
-     * @param string $messenger_label
122
-     */
123
-    public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label)
124
-    {
125
-        $this->amOnDefaultMessageTemplateListTablePage();
126
-        $this->actor()->click(
127
-            MessagesPage::createCustomButtonForMessageTypeAndMessenger(
128
-                $message_type_label,
129
-                $messenger_label
130
-            )
131
-        );
132
-        $this->actor()->seeInField('#title', 'New Custom Template');
133
-    }
134
-
135
-
136
-    /**
137
-     * This switches the context of the current messages template to the given reference.
138
-     * @param string $context_reference  This should be the visible label for the option.
139
-     */
140
-    public function switchContextTo($context_reference)
141
-    {
142
-        $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference);
143
-        $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR);
144
-        $this->actor()->waitForText($context_reference, 10, 'h1');
145
-    }
146
-
147
-
148
-    /**
149
-     * This takes care of clicking the View Message icon for the given parameters.
150
-     * Assumes you are already viewing the messages activity list table.
151
-     * @param        $message_type_label
152
-     * @param        $message_status
153
-     * @param string $messenger
154
-     * @param string $context
155
-     * @param int    $number_in_set
156
-     */
157
-    public function viewMessageInMessagesListTableFor(
158
-        $message_type_label,
159
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
160
-        $messenger = 'Email',
161
-        $context = 'Event Admin',
162
-        $number_in_set = 1
163
-    ) {
164
-        $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor(
165
-            $message_type_label,
166
-            $message_status,
167
-            $messenger,
168
-            $context,
169
-            $number_in_set
170
-        ));
171
-    }
172
-
173
-
174
-    /**
175
-     * Takes care of deleting a message matching the given parameters via the message activity list table.
176
-     * Assumes you are already viewing the messages activity list table.
177
-     * @param        $message_type_label
178
-     * @param        $message_status
179
-     * @param string $messenger
180
-     * @param string $context
181
-     * @param int    $number_in_set
182
-     */
183
-    public function deleteMessageInMessagesListTableFor(
184
-        $message_type_label,
185
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
186
-        $messenger = 'Email',
187
-        $context = 'Event Admin',
188
-        $number_in_set = 1
189
-    ) {
190
-        $delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor(
191
-            $message_type_label,
192
-            $message_status,
193
-            $messenger,
194
-            $context,
195
-            $number_in_set
196
-        );
197
-        $this->actor()->moveMouseOver(
198
-            MessagesPage::messagesActivityListTableCellSelectorFor(
199
-                'to',
200
-                $message_type_label,
201
-                $message_status,
202
-                $messenger,
203
-                $context,
204
-                '',
205
-                $number_in_set
206
-            ),
207
-            5,
208
-            5
209
-        );
210
-        $this->actor()->waitForElementVisible(
211
-            $delete_action_selector
212
-        );
213
-        $this->actor()->click(
214
-            $delete_action_selector
215
-        );
216
-        $this->actor()->waitForText('successfully deleted');
217
-    }
218
-
219
-
220
-    /**
221
-     * Assuming you have already triggered the view modal for a single message from the context of the message activity
222
-     * list table, this will take care of validating the given text is in that window.
223
-     * @param string $text_to_view
224
-     */
225
-    public function seeTextInViewMessageModal($text_to_view, $should_not_see = false)
226
-    {
227
-        $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content');
228
-        $this->actor()->switchToIframe('message-view-window');
229
-        $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view);
230
-        $this->actor()->switchToIframe();
231
-    }
232
-
233
-
234
-    /**
235
-     * Assuming you have already triggered the view modal for a single message from the context of the message activity
236
-     * list table, this will take care of validating the given text is NOT that window.
237
-     * @param string $text_to_view
238
-     */
239
-    public function dontSeeTextInViewMessageModal($text_to_view)
240
-    {
241
-        $this->seeTextInViewMessageModal($text_to_view, true);
242
-    }
243
-
244
-
245
-    public function dismissMessageModal()
246
-    {
247
-        $this->actor()->click('#espresso-admin-page-overlay-dv');
248
-        //this is needed otherwise phantom js gets stuck in the wrong context and any future element events will fail.
249
-        $this->actor()->click('form#EE_Message_List_Table-table-frm');
250
-    }
13
+	/**
14
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
15
+	 *                                  a string.
16
+	 */
17
+	public function amOnMessagesActivityListTablePage($additional_params = '')
18
+	{
19
+		$this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params));
20
+	}
21
+
22
+	/**
23
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
24
+	 *                                  a string.
25
+	 */
26
+	public function amOnDefaultMessageTemplateListTablePage($additional_params = '')
27
+	{
28
+		$this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params));
29
+	}
30
+
31
+
32
+	/**
33
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
34
+	 *                                  a string.
35
+	 */
36
+	public function amOnCustomMessageTemplateListTablePage($additional_params = '')
37
+	{
38
+		$this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params));
39
+	}
40
+
41
+
42
+	/**
43
+	 * Directs to message settings page
44
+	 */
45
+	public function amOnMessageSettingsPage()
46
+	{
47
+		$this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl());
48
+	}
49
+
50
+
51
+	public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email')
52
+	{
53
+		$this->actor()->dragAndDrop(
54
+			MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug),
55
+			MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR
56
+		);
57
+	}
58
+
59
+
60
+	/**
61
+	 * Assumes you are already on the list table page that has the ui for editing the template.
62
+	 * @param string $message_type_slug
63
+	 * @param string $context [optional] if you want to click directly to the given context in the editor
64
+	 */
65
+	public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '')
66
+	{
67
+		$this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context));
68
+	}
69
+
70
+
71
+	/**
72
+	 * Use this action to verify that the count for the given text in the specified field is as expected.  For example
73
+	 * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column.
74
+	 *
75
+	 * @param int    $expected_occurence_count
76
+	 * @param string $text_to_check_for
77
+	 * @param string $field
78
+	 * @param string $message_type_label
79
+	 * @param string $message_status
80
+	 * @param string $messenger
81
+	 * @param string $context
82
+	 */
83
+	public function verifyMatchingCountofTextInMessageActivityListTableFor(
84
+		$expected_occurence_count,
85
+		$text_to_check_for,
86
+		$field,
87
+		$message_type_label,
88
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
89
+		$messenger = 'Email',
90
+		$context = 'Event Admin'
91
+	) {
92
+		$elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor(
93
+			$field,
94
+			$message_type_label,
95
+			$message_status,
96
+			$messenger,
97
+			$context,
98
+			$text_to_check_for,
99
+			0
100
+		));
101
+		$actual_count = count($elements);
102
+		$this->actor()->assertEquals(
103
+			$expected_occurence_count,
104
+			$actual_count,
105
+			sprintf(
106
+				'Expected %s of the %s text for the %s field but there were actually %s counted.',
107
+				$expected_occurence_count,
108
+				$text_to_check_for,
109
+				$field,
110
+				$actual_count
111
+			)
112
+		);
113
+	}
114
+
115
+
116
+	/**
117
+	 * This will create a custom message template for the given messenger and message type from the context of the
118
+	 * default (global) message template list table.
119
+	 * Also takes care of verifying the template was created.
120
+	 * @param string $message_type_label
121
+	 * @param string $messenger_label
122
+	 */
123
+	public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label)
124
+	{
125
+		$this->amOnDefaultMessageTemplateListTablePage();
126
+		$this->actor()->click(
127
+			MessagesPage::createCustomButtonForMessageTypeAndMessenger(
128
+				$message_type_label,
129
+				$messenger_label
130
+			)
131
+		);
132
+		$this->actor()->seeInField('#title', 'New Custom Template');
133
+	}
134
+
135
+
136
+	/**
137
+	 * This switches the context of the current messages template to the given reference.
138
+	 * @param string $context_reference  This should be the visible label for the option.
139
+	 */
140
+	public function switchContextTo($context_reference)
141
+	{
142
+		$this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference);
143
+		$this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR);
144
+		$this->actor()->waitForText($context_reference, 10, 'h1');
145
+	}
146
+
147
+
148
+	/**
149
+	 * This takes care of clicking the View Message icon for the given parameters.
150
+	 * Assumes you are already viewing the messages activity list table.
151
+	 * @param        $message_type_label
152
+	 * @param        $message_status
153
+	 * @param string $messenger
154
+	 * @param string $context
155
+	 * @param int    $number_in_set
156
+	 */
157
+	public function viewMessageInMessagesListTableFor(
158
+		$message_type_label,
159
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
160
+		$messenger = 'Email',
161
+		$context = 'Event Admin',
162
+		$number_in_set = 1
163
+	) {
164
+		$this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor(
165
+			$message_type_label,
166
+			$message_status,
167
+			$messenger,
168
+			$context,
169
+			$number_in_set
170
+		));
171
+	}
172
+
173
+
174
+	/**
175
+	 * Takes care of deleting a message matching the given parameters via the message activity list table.
176
+	 * Assumes you are already viewing the messages activity list table.
177
+	 * @param        $message_type_label
178
+	 * @param        $message_status
179
+	 * @param string $messenger
180
+	 * @param string $context
181
+	 * @param int    $number_in_set
182
+	 */
183
+	public function deleteMessageInMessagesListTableFor(
184
+		$message_type_label,
185
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
186
+		$messenger = 'Email',
187
+		$context = 'Event Admin',
188
+		$number_in_set = 1
189
+	) {
190
+		$delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor(
191
+			$message_type_label,
192
+			$message_status,
193
+			$messenger,
194
+			$context,
195
+			$number_in_set
196
+		);
197
+		$this->actor()->moveMouseOver(
198
+			MessagesPage::messagesActivityListTableCellSelectorFor(
199
+				'to',
200
+				$message_type_label,
201
+				$message_status,
202
+				$messenger,
203
+				$context,
204
+				'',
205
+				$number_in_set
206
+			),
207
+			5,
208
+			5
209
+		);
210
+		$this->actor()->waitForElementVisible(
211
+			$delete_action_selector
212
+		);
213
+		$this->actor()->click(
214
+			$delete_action_selector
215
+		);
216
+		$this->actor()->waitForText('successfully deleted');
217
+	}
218
+
219
+
220
+	/**
221
+	 * Assuming you have already triggered the view modal for a single message from the context of the message activity
222
+	 * list table, this will take care of validating the given text is in that window.
223
+	 * @param string $text_to_view
224
+	 */
225
+	public function seeTextInViewMessageModal($text_to_view, $should_not_see = false)
226
+	{
227
+		$this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content');
228
+		$this->actor()->switchToIframe('message-view-window');
229
+		$should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view);
230
+		$this->actor()->switchToIframe();
231
+	}
232
+
233
+
234
+	/**
235
+	 * Assuming you have already triggered the view modal for a single message from the context of the message activity
236
+	 * list table, this will take care of validating the given text is NOT that window.
237
+	 * @param string $text_to_view
238
+	 */
239
+	public function dontSeeTextInViewMessageModal($text_to_view)
240
+	{
241
+		$this->seeTextInViewMessageModal($text_to_view, true);
242
+	}
243
+
244
+
245
+	public function dismissMessageModal()
246
+	{
247
+		$this->actor()->click('#espresso-admin-page-overlay-dv');
248
+		//this is needed otherwise phantom js gets stuck in the wrong context and any future element events will fail.
249
+		$this->actor()->click('form#EE_Message_List_Table-table-frm');
250
+	}
251 251
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 1 patch
Spacing   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
         $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
477 477
         $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
478 478
         global $ee_menu_slugs;
479
-        $ee_menu_slugs = (array)$ee_menu_slugs;
479
+        $ee_menu_slugs = (array) $ee_menu_slugs;
480 480
         if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
481 481
             return;
482 482
         }
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
         //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
492 492
         $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
493 493
         $this->_current_view = $this->_req_action;
494
-        $this->_req_nonce = $this->_req_action . '_nonce';
494
+        $this->_req_nonce = $this->_req_action.'_nonce';
495 495
         $this->_define_page_props();
496 496
         $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
497 497
         //default things
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
             $this->_extend_page_config_for_cpt();
513 513
         }
514 514
         //filter routes and page_config so addons can add their stuff. Filtering done per class
515
-        $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
516
-        $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
515
+        $this->_page_routes = apply_filters('FHEE__'.get_class($this).'__page_setup__page_routes', $this->_page_routes, $this);
516
+        $this->_page_config = apply_filters('FHEE__'.get_class($this).'__page_setup__page_config', $this->_page_config, $this);
517 517
         //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
518
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
519
-            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
518
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
519
+            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view), 10, 2);
520 520
         }
521 521
         //next route only if routing enabled
522 522
         if ($this->_routing && ! defined('DOING_AJAX')) {
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
             if ($this->_is_UI_request) {
527 527
                 //admin_init stuff - global, all views for this page class, specific view
528 528
                 add_action('admin_init', array($this, 'admin_init'), 10);
529
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
530
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
529
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
530
+                    add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15);
531 531
                 }
532 532
             } else {
533 533
                 //hijack regular WP loading and route admin request immediately
@@ -547,17 +547,17 @@  discard block
 block discarded – undo
547 547
      */
548 548
     private function _do_other_page_hooks()
549 549
     {
550
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
550
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array());
551 551
         foreach ($registered_pages as $page) {
552 552
             //now let's setup the file name and class that should be present
553 553
             $classname = str_replace('.class.php', '', $page);
554 554
             //autoloaders should take care of loading file
555 555
             if ( ! class_exists($classname)) {
556
-                $error_msg[] = sprintf( esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
556
+                $error_msg[] = sprintf(esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
557 557
                 $error_msg[] = $error_msg[0]
558 558
                                . "\r\n"
559
-                               . sprintf( esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
560
-                                'event_espresso'), $page, '<br />', '<strong>' . $classname . '</strong>');
559
+                               . sprintf(esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
560
+                                'event_espresso'), $page, '<br />', '<strong>'.$classname.'</strong>');
561 561
                 throw new EE_Error(implode('||', $error_msg));
562 562
             }
563 563
             $a = new ReflectionClass($classname);
@@ -593,13 +593,13 @@  discard block
 block discarded – undo
593 593
         //load admin_notices - global, page class, and view specific
594 594
         add_action('admin_notices', array($this, 'admin_notices_global'), 5);
595 595
         add_action('admin_notices', array($this, 'admin_notices'), 10);
596
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
597
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
596
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
597
+            add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15);
598 598
         }
599 599
         //load network admin_notices - global, page class, and view specific
600 600
         add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
601
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
602
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
601
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
602
+            add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view));
603 603
         }
604 604
         //this will save any per_page screen options if they are present
605 605
         $this->_set_per_page_screen_options();
@@ -611,8 +611,8 @@  discard block
 block discarded – undo
611 611
         //add screen options - global, page child class, and view specific
612 612
         $this->_add_global_screen_options();
613 613
         $this->_add_screen_options();
614
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
615
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
614
+        if (method_exists($this, '_add_screen_options_'.$this->_current_view)) {
615
+            call_user_func(array($this, '_add_screen_options_'.$this->_current_view));
616 616
         }
617 617
         //add help tab(s) and tours- set via page_config and qtips.
618 618
         $this->_add_help_tour();
@@ -621,31 +621,31 @@  discard block
 block discarded – undo
621 621
         //add feature_pointers - global, page child class, and view specific
622 622
         $this->_add_feature_pointers();
623 623
         $this->_add_global_feature_pointers();
624
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
625
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
624
+        if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) {
625
+            call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view));
626 626
         }
627 627
         //enqueue scripts/styles - global, page class, and view specific
628 628
         add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
629 629
         add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
630
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
631
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
630
+        if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) {
631
+            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15);
632 632
         }
633 633
         add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
634 634
         //admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
635 635
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
636 636
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
637
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
638
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
637
+        if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) {
638
+            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101);
639 639
         }
640 640
         //admin footer scripts
641 641
         add_action('admin_footer', array($this, 'admin_footer_global'), 99);
642 642
         add_action('admin_footer', array($this, 'admin_footer'), 100);
643
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
644
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
643
+        if (method_exists($this, 'admin_footer_'.$this->_current_view)) {
644
+            add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101);
645 645
         }
646 646
         do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
647 647
         //targeted hook
648
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
648
+        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action);
649 649
     }
650 650
 
651 651
 
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
             // user error msg
722 722
             $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
723 723
             // developer error msg
724
-            $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
724
+            $error_msg .= '||'.$error_msg.__(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
725 725
             throw new EE_Error($error_msg);
726 726
         }
727 727
         // and that the requested page route exists
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
             // user error msg
733 733
             $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
734 734
             // developer error msg
735
-            $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
735
+            $error_msg .= '||'.$error_msg.sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
736 736
             throw new EE_Error($error_msg);
737 737
         }
738 738
         // and that a default route exists
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
             // user error msg
741 741
             $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
742 742
             // developer error msg
743
-            $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
743
+            $error_msg .= '||'.$error_msg.__(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
744 744
             throw new EE_Error($error_msg);
745 745
         }
746 746
         //first lets' catch if the UI request has EVER been set.
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
             // user error msg
770 770
             $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
771 771
             // developer error msg
772
-            $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
772
+            $error_msg .= '||'.$error_msg.sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
773 773
             throw new EE_Error($error_msg);
774 774
         }
775 775
     }
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
             // these are not the droids you are looking for !!!
792 792
             $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
793 793
             if (WP_DEBUG) {
794
-                $msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
794
+                $msg .= "\n  ".sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
795 795
             }
796 796
             if ( ! defined('DOING_AJAX')) {
797 797
                 wp_die($msg);
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
                 if (strpos($key, 'nonce') !== false) {
970 970
                     continue;
971 971
                 }
972
-                $args['wp_referer[' . $key . ']'] = $value;
972
+                $args['wp_referer['.$key.']'] = $value;
973 973
             }
974 974
         }
975 975
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
                     if ($tour instanceof EE_Help_Tour_final_stop) {
1016 1016
                         continue;
1017 1017
                     }
1018
-                    $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1018
+                    $tb[] = '<button id="trigger-tour-'.$tour->get_slug().'" class="button-primary trigger-ee-help-tour">'.$tour->get_label().'</button>';
1019 1019
                 }
1020 1020
                 $tour_buttons .= implode('<br />', $tb);
1021 1021
                 $tour_buttons .= '</div></div>';
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
                     throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1028 1028
                             'event_espresso'), $config['help_sidebar'], get_class($this)));
1029 1029
                 }
1030
-                $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1030
+                $content = apply_filters('FHEE__'.get_class($this).'__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1031 1031
                 $content .= $tour_buttons; //add help tour buttons.
1032 1032
                 //do we have any help tours setup?  Cause if we do we want to add the buttons
1033 1033
                 $this->_current_screen->set_help_sidebar($content);
@@ -1040,13 +1040,13 @@  discard block
 block discarded – undo
1040 1040
             if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1041 1041
                 $_ht['id'] = $this->page_slug;
1042 1042
                 $_ht['title'] = __('Help Tours', 'event_espresso');
1043
-                $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1043
+                $_ht['content'] = '<p>'.__('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso').'</p>';
1044 1044
                 $this->_current_screen->add_help_tab($_ht);
1045 1045
             }/**/
1046 1046
             if ( ! isset($config['help_tabs'])) {
1047 1047
                 return;
1048 1048
             } //no help tabs for this route
1049
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1049
+            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1050 1050
                 //we're here so there ARE help tabs!
1051 1051
                 //make sure we've got what we need
1052 1052
                 if ( ! isset($cfg['title'])) {
@@ -1061,9 +1061,9 @@  discard block
 block discarded – undo
1061 1061
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1062 1062
                     //second priority goes to filename
1063 1063
                 } else if ( ! empty($cfg['filename'])) {
1064
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1064
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1065 1065
                     //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1066
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1066
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()).'/help_tabs/'.$cfg['filename'].'.help_tab.php' : $file_path;
1067 1067
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1068 1068
                     if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1069 1069
                         EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
                     return;
1083 1083
                 }
1084 1084
                 //setup config array for help tab method
1085
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1085
+                $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1086 1086
                 $_ht = array(
1087 1087
                         'id'       => $id,
1088 1088
                         'title'    => $cfg['title'],
@@ -1120,9 +1120,9 @@  discard block
 block discarded – undo
1120 1120
             }
1121 1121
             if (isset($config['help_tour'])) {
1122 1122
                 foreach ($config['help_tour'] as $tour) {
1123
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1123
+                    $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php';
1124 1124
                     //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1125
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1125
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()).'/help_tours/'.$tour.'.class.php' : $file_path;
1126 1126
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1127 1127
                     if ( ! is_readable($file_path)) {
1128 1128
                         EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'),
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
                     require_once $file_path;
1133 1133
                     if ( ! class_exists($tour)) {
1134 1134
                         $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1135
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1135
+                        $error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1136 1136
                                         'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1137 1137
                         throw new EE_Error(implode('||', $error_msg));
1138 1138
                     }
@@ -1164,11 +1164,11 @@  discard block
 block discarded – undo
1164 1164
     protected function _add_qtips()
1165 1165
     {
1166 1166
         if (isset($this->_route_config['qtips'])) {
1167
-            $qtips = (array)$this->_route_config['qtips'];
1167
+            $qtips = (array) $this->_route_config['qtips'];
1168 1168
             //load qtip loader
1169 1169
             $path = array(
1170
-                    $this->_get_dir() . '/qtips/',
1171
-                    EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1170
+                    $this->_get_dir().'/qtips/',
1171
+                    EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1172 1172
             );
1173 1173
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1174 1174
         }
@@ -1198,11 +1198,11 @@  discard block
 block discarded – undo
1198 1198
             if ( ! $this->check_user_access($slug, true)) {
1199 1199
                 continue;
1200 1200
             } //no nav tab becasue current user does not have access.
1201
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1201
+            $css_class = isset($config['css_class']) ? $config['css_class'].' ' : '';
1202 1202
             $this->_nav_tabs[$slug] = array(
1203 1203
                     'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1204 1204
                     'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1205
-                    'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1205
+                    'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class,
1206 1206
                     'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1207 1207
             );
1208 1208
             $i++;
@@ -1265,11 +1265,11 @@  discard block
 block discarded – undo
1265 1265
             $capability = empty($capability) ? 'manage_options' : $capability;
1266 1266
         }
1267 1267
         $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1268
-        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1268
+        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug.'_'.$route_to_check, $id)) && ! defined('DOING_AJAX')) {
1269 1269
             if ($verify_only) {
1270 1270
                 return false;
1271 1271
             } else {
1272
-                if ( is_user_logged_in() ) {
1272
+                if (is_user_logged_in()) {
1273 1273
                     wp_die(__('You do not have access to this route.', 'event_espresso'));
1274 1274
                 } else {
1275 1275
                     return false;
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
     public function admin_footer_global()
1362 1362
     {
1363 1363
         //dialog container for dialog helper
1364
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1364
+        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n";
1365 1365
         $d_cont .= '<div class="ee-notices"></div>';
1366 1366
         $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1367 1367
         $d_cont .= '</div>';
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
             echo implode('<br />', $this->_help_tour[$this->_req_action]);
1372 1372
         }
1373 1373
         //current set timezone for timezone js
1374
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1374
+        echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>';
1375 1375
     }
1376 1376
 
1377 1377
 
@@ -1396,7 +1396,7 @@  discard block
 block discarded – undo
1396 1396
     {
1397 1397
         $content = '';
1398 1398
         $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1399
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1399
+        $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php';
1400 1400
         //loop through the array and setup content
1401 1401
         foreach ($help_array as $trigger => $help) {
1402 1402
             //make sure the array is setup properly
@@ -1430,7 +1430,7 @@  discard block
 block discarded – undo
1430 1430
     private function _get_help_content()
1431 1431
     {
1432 1432
         //what is the method we're looking for?
1433
-        $method_name = '_help_popup_content_' . $this->_req_action;
1433
+        $method_name = '_help_popup_content_'.$this->_req_action;
1434 1434
         //if method doesn't exist let's get out.
1435 1435
         if ( ! method_exists($this, $method_name)) {
1436 1436
             return array();
@@ -1474,8 +1474,8 @@  discard block
 block discarded – undo
1474 1474
             $help_content = $this->_set_help_popup_content($help_array, false);
1475 1475
         }
1476 1476
         //let's setup the trigger
1477
-        $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1478
-        $content = $content . $help_content;
1477
+        $content = '<a class="ee-dialog" href="?height='.$dimensions[0].'&width='.$dimensions[1].'&inlineId='.$trigger_id.'" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1478
+        $content = $content.$help_content;
1479 1479
         if ($display) {
1480 1480
             echo $content;
1481 1481
         } else {
@@ -1535,27 +1535,27 @@  discard block
 block discarded – undo
1535 1535
             add_action('admin_head', array($this, 'add_xdebug_style'));
1536 1536
         }
1537 1537
         // register all styles
1538
-        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1539
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1538
+        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1539
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1540 1540
         //helpers styles
1541
-        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1541
+        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1542 1542
         /** SCRIPTS **/
1543 1543
         //register all scripts
1544
-        wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1545
-        wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1546
-        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1544
+        wp_register_script('ee-dialog', EE_ADMIN_URL.'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1545
+        wp_register_script('ee_admin_js', EE_ADMIN_URL.'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1546
+        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1547 1547
         add_filter('FHEE_load_joyride', '__return_true');
1548 1548
         //script for sorting tables
1549
-        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1549
+        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1550 1550
         //script for parsing uri's
1551
-        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1551
+        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1552 1552
         //and parsing associative serialized form elements
1553
-        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1553
+        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1554 1554
         //helpers scripts
1555
-        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1556
-        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1557
-        wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1558
-        wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1555
+        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1556
+        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1557
+        wp_register_script('ee-moment', EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1558
+        wp_register_script('ee-datepicker', EE_ADMIN_URL.'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1559 1559
         //google charts
1560 1560
         wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1561 1561
         // ENQUEUE ALL BASICS BY DEFAULT
@@ -1579,7 +1579,7 @@  discard block
 block discarded – undo
1579 1579
          */
1580 1580
         if ( ! empty($this->_help_tour)) {
1581 1581
             //register the js for kicking things off
1582
-            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1582
+            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL.'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1583 1583
             //setup tours for the js tour object
1584 1584
             foreach ($this->_help_tour['tours'] as $tour) {
1585 1585
                 $tours[] = array(
@@ -1674,17 +1674,17 @@  discard block
 block discarded – undo
1674 1674
             return;
1675 1675
         } //not a list_table view so get out.
1676 1676
         //list table functions are per view specific (because some admin pages might have more than one listtable!)
1677
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1677
+        if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === false) {
1678 1678
             //user error msg
1679 1679
             $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1680 1680
             //developer error msg
1681
-            $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1682
-                            $this->_req_action, '_set_list_table_views_' . $this->_req_action);
1681
+            $error_msg .= '||'.sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1682
+                            $this->_req_action, '_set_list_table_views_'.$this->_req_action);
1683 1683
             throw new EE_Error($error_msg);
1684 1684
         }
1685 1685
         //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1686
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1687
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1686
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action, $this->_views);
1687
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1688 1688
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1689 1689
         $this->_set_list_table_view();
1690 1690
         $this->_set_list_table_object();
@@ -1759,7 +1759,7 @@  discard block
 block discarded – undo
1759 1759
             // check for current view
1760 1760
             $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1761 1761
             $query_args['action'] = $this->_req_action;
1762
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1762
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
1763 1763
             $query_args['status'] = $view['slug'];
1764 1764
             //merge any other arguments sent in.
1765 1765
             if (isset($extra_query_args[$view['slug']])) {
@@ -1797,14 +1797,14 @@  discard block
 block discarded – undo
1797 1797
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1798 1798
         foreach ($values as $value) {
1799 1799
             if ($value < $max_entries) {
1800
-                $selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1800
+                $selected = $value == $per_page ? ' selected="'.$per_page.'"' : '';
1801 1801
                 $entries_per_page_dropdown .= '
1802
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
1802
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
1803 1803
             }
1804 1804
         }
1805
-        $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1805
+        $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : '';
1806 1806
         $entries_per_page_dropdown .= '
1807
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
1807
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
1808 1808
         $entries_per_page_dropdown .= '
1809 1809
 					</select>
1810 1810
 					entries
@@ -1826,7 +1826,7 @@  discard block
 block discarded – undo
1826 1826
     public function _set_search_attributes()
1827 1827
     {
1828 1828
         $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1829
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1829
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
1830 1830
     }
1831 1831
 
1832 1832
     /*** END LIST TABLE METHODS **/
@@ -1864,7 +1864,7 @@  discard block
 block discarded – undo
1864 1864
                     // user error msg
1865 1865
                     $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1866 1866
                     // developer error msg
1867
-                    $error_msg .= '||' . sprintf(
1867
+                    $error_msg .= '||'.sprintf(
1868 1868
                                     __(
1869 1869
                                             'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
1870 1870
                                             'event_espresso'
@@ -1894,15 +1894,15 @@  discard block
 block discarded – undo
1894 1894
                 && is_array($this->_route_config['columns'])
1895 1895
                 && count($this->_route_config['columns']) === 2
1896 1896
         ) {
1897
-            add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1897
+            add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1]));
1898 1898
             $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1899 1899
             $screen_id = $this->_current_screen->id;
1900
-            $screen_columns = (int)get_user_option("screen_layout_$screen_id");
1900
+            $screen_columns = (int) get_user_option("screen_layout_$screen_id");
1901 1901
             $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1902
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1902
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
1903 1903
             $this->_template_args['current_page'] = $this->_wp_page_slug;
1904 1904
             $this->_template_args['screen'] = $this->_current_screen;
1905
-            $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1905
+            $this->_column_template_path = EE_ADMIN_TEMPLATE.'admin_details_metabox_column_wrapper.template.php';
1906 1906
             //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
1907 1907
             $this->_route_config['has_metaboxes'] = true;
1908 1908
         }
@@ -1949,7 +1949,7 @@  discard block
 block discarded – undo
1949 1949
      */
1950 1950
     public function espresso_ratings_request()
1951 1951
     {
1952
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1952
+        $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php';
1953 1953
         EEH_Template::display_template($template_path, array());
1954 1954
     }
1955 1955
 
@@ -1957,18 +1957,18 @@  discard block
 block discarded – undo
1957 1957
 
1958 1958
     public static function cached_rss_display($rss_id, $url)
1959 1959
     {
1960
-        $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1960
+        $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading&#8230;').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>';
1961 1961
         $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1962
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
1963
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1964
-        $post = '</div>' . "\n";
1965
-        $cache_key = 'ee_rss_' . md5($rss_id);
1962
+        $pre = '<div class="espresso-rss-display">'."\n\t";
1963
+        $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>';
1964
+        $post = '</div>'."\n";
1965
+        $cache_key = 'ee_rss_'.md5($rss_id);
1966 1966
         if (false != ($output = get_transient($cache_key))) {
1967
-            echo $pre . $output . $post;
1967
+            echo $pre.$output.$post;
1968 1968
             return true;
1969 1969
         }
1970 1970
         if ( ! $doing_ajax) {
1971
-            echo $pre . $loading . $post;
1971
+            echo $pre.$loading.$post;
1972 1972
             return false;
1973 1973
         }
1974 1974
         ob_start();
@@ -2027,7 +2027,7 @@  discard block
 block discarded – undo
2027 2027
 
2028 2028
     public function espresso_sponsors_post_box()
2029 2029
     {
2030
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2030
+        $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php';
2031 2031
         EEH_Template::display_template($templatepath);
2032 2032
     }
2033 2033
 
@@ -2035,7 +2035,7 @@  discard block
 block discarded – undo
2035 2035
 
2036 2036
     private function _publish_post_box()
2037 2037
     {
2038
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2038
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2039 2039
         //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2040 2040
         if ( ! empty($this->_labels['publishbox'])) {
2041 2041
             $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
@@ -2052,7 +2052,7 @@  discard block
 block discarded – undo
2052 2052
     {
2053 2053
         //if we have extra content set let's add it in if not make sure its empty
2054 2054
         $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2055
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2055
+        $template_path = EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php';
2056 2056
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2057 2057
     }
2058 2058
 
@@ -2221,7 +2221,7 @@  discard block
 block discarded – undo
2221 2221
         //if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2222 2222
         $call_back_func = $create_func ? create_function('$post, $metabox',
2223 2223
                 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2224
-        add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2224
+        add_meta_box(str_replace('_', '-', $action).'-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2225 2225
     }
2226 2226
 
2227 2227
 
@@ -2302,9 +2302,9 @@  discard block
 block discarded – undo
2302 2302
                 : 'espresso-default-admin';
2303 2303
         $template_path = $sidebar
2304 2304
                 ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2305
-                : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2305
+                : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2306 2306
         if (defined('DOING_AJAX') && DOING_AJAX) {
2307
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2307
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2308 2308
         }
2309 2309
         $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2310 2310
         $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
@@ -2350,7 +2350,7 @@  discard block
 block discarded – undo
2350 2350
                         true
2351 2351
                 )
2352 2352
                 : $this->_template_args['preview_action_button'];
2353
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2353
+        $template_path = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php';
2354 2354
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2355 2355
                 $template_path,
2356 2356
                 $this->_template_args,
@@ -2401,7 +2401,7 @@  discard block
 block discarded – undo
2401 2401
         //setup search attributes
2402 2402
         $this->_set_search_attributes();
2403 2403
         $this->_template_args['current_page'] = $this->_wp_page_slug;
2404
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2404
+        $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2405 2405
         $this->_template_args['table_url'] = defined('DOING_AJAX')
2406 2406
                 ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2407 2407
                 : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
@@ -2411,29 +2411,29 @@  discard block
 block discarded – undo
2411 2411
         $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2412 2412
         if ( ! empty($ajax_sorting_callback)) {
2413 2413
             $sortable_list_table_form_fields = wp_nonce_field(
2414
-                    $ajax_sorting_callback . '_nonce',
2415
-                    $ajax_sorting_callback . '_nonce',
2414
+                    $ajax_sorting_callback.'_nonce',
2415
+                    $ajax_sorting_callback.'_nonce',
2416 2416
                     false,
2417 2417
                     false
2418 2418
             );
2419 2419
             //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2420 2420
             //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2421
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2422
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2421
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'.$this->page_slug.'" />';
2422
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'.$ajax_sorting_callback.'" />';
2423 2423
         } else {
2424 2424
             $sortable_list_table_form_fields = '';
2425 2425
         }
2426 2426
         $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2427 2427
         $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2428
-        $nonce_ref = $this->_req_action . '_nonce';
2429
-        $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2428
+        $nonce_ref = $this->_req_action.'_nonce';
2429
+        $hidden_form_fields .= '<input type="hidden" name="'.$nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">';
2430 2430
         $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2431 2431
         //display message about search results?
2432 2432
         $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2433
-                ? '<p class="ee-search-results">' . sprintf(
2433
+                ? '<p class="ee-search-results">'.sprintf(
2434 2434
                         esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2435 2435
                         trim($this->_req_data['s'], '%')
2436
-                ) . '</p>'
2436
+                ).'</p>'
2437 2437
                 : '';
2438 2438
         // filter before_list_table template arg
2439 2439
         $this->_template_args['before_list_table'] = apply_filters(
@@ -2507,8 +2507,8 @@  discard block
 block discarded – undo
2507 2507
      */
2508 2508
     protected function _display_legend($items)
2509 2509
     {
2510
-        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2511
-        $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2510
+        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this);
2511
+        $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php';
2512 2512
         return EEH_Template::display_template($legend_template, $this->_template_args, true);
2513 2513
     }
2514 2514
 
@@ -2600,13 +2600,13 @@  discard block
 block discarded – undo
2600 2600
         $this->_nav_tabs = $this->_get_main_nav_tabs();
2601 2601
         $this->_template_args['nav_tabs'] = $this->_nav_tabs;
2602 2602
         $this->_template_args['admin_page_title'] = $this->_admin_page_title;
2603
-        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2603
+        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view,
2604 2604
                 isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2605
-        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2605
+        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view,
2606 2606
                 isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2607 2607
         $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2608 2608
         // load settings page wrapper template
2609
-        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2609
+        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php';
2610 2610
         //about page?
2611 2611
         $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2612 2612
         if (defined('DOING_AJAX')) {
@@ -2680,20 +2680,20 @@  discard block
 block discarded – undo
2680 2680
     protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2681 2681
     {
2682 2682
         //make sure $text and $actions are in an array
2683
-        $text = (array)$text;
2684
-        $actions = (array)$actions;
2683
+        $text = (array) $text;
2684
+        $actions = (array) $actions;
2685 2685
         $referrer_url = empty($referrer) ? '' : $referrer;
2686
-        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2687
-                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2686
+        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$_SERVER['REQUEST_URI'].'" />'
2687
+                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$referrer.'" />';
2688 2688
         $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2689 2689
         $default_names = array('save', 'save_and_close');
2690 2690
         //add in a hidden index for the current page (so save and close redirects properly)
2691 2691
         $this->_template_args['save_buttons'] = $referrer_url;
2692 2692
         foreach ($button_text as $key => $button) {
2693 2693
             $ref = $default_names[$key];
2694
-            $id = $this->_current_view . '_' . $ref;
2694
+            $id = $this->_current_view.'_'.$ref;
2695 2695
             $name = ! empty($actions) ? $actions[$key] : $ref;
2696
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2696
+            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '.$ref.'" value="'.$button.'" name="'.$name.'" id="'.$id.'" />';
2697 2697
             if ( ! $both) {
2698 2698
                 break;
2699 2699
             }
@@ -2729,15 +2729,15 @@  discard block
 block discarded – undo
2729 2729
     {
2730 2730
         if (empty($route)) {
2731 2731
             $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2732
-            $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2733
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2732
+            $dev_msg = $user_msg."\n".sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2733
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
2734 2734
         }
2735 2735
         // open form
2736
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2736
+        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'.$this->_admin_base_url.'" id="'.$route.'_event_form" >';
2737 2737
         // add nonce
2738
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2738
+        $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
2739 2739
         //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2740
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2740
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
2741 2741
         // add REQUIRED form action
2742 2742
         $hidden_fields = array(
2743 2743
                 'action' => array('type' => 'hidden', 'value' => $route),
@@ -2747,8 +2747,8 @@  discard block
 block discarded – undo
2747 2747
         // generate form fields
2748 2748
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2749 2749
         // add fields to form
2750
-        foreach ((array)$form_fields as $field_name => $form_field) {
2751
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2750
+        foreach ((array) $form_fields as $field_name => $form_field) {
2751
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
2752 2752
         }
2753 2753
         // close form
2754 2754
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -2829,7 +2829,7 @@  discard block
 block discarded – undo
2829 2829
          * @param array $query_args       The original query_args array coming into the
2830 2830
          *                                method.
2831 2831
          */
2832
-        do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2832
+        do_action('AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action, $query_args);
2833 2833
         //calculate where we're going (if we have a "save and close" button pushed)
2834 2834
         if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2835 2835
             // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
@@ -2845,7 +2845,7 @@  discard block
 block discarded – undo
2845 2845
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
2846 2846
                 //is there a wp_referer array in our _default_route_query_args property?
2847 2847
                 if ($query_param == 'wp_referer') {
2848
-                    $query_value = (array)$query_value;
2848
+                    $query_value = (array) $query_value;
2849 2849
                     foreach ($query_value as $reference => $value) {
2850 2850
                         if (strpos($reference, 'nonce') !== false) {
2851 2851
                             continue;
@@ -2871,11 +2871,11 @@  discard block
 block discarded – undo
2871 2871
         // if redirecting to anything other than the main page, add a nonce
2872 2872
         if (isset($query_args['action'])) {
2873 2873
             // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2874
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2874
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
2875 2875
         }
2876 2876
         //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2877
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2878
-        $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2877
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
2878
+        $redirect_url = apply_filters('FHEE_redirect_'.$classname.$this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2879 2879
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2880 2880
         if (defined('DOING_AJAX')) {
2881 2881
             $default_data = array(
@@ -3005,7 +3005,7 @@  discard block
 block discarded – undo
3005 3005
         $args = array(
3006 3006
                 'label'   => $this->_admin_page_title,
3007 3007
                 'default' => 10,
3008
-                'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3008
+                'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3009 3009
         );
3010 3010
         //ONLY add the screen option if the user has access to it.
3011 3011
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3038,8 +3038,8 @@  discard block
 block discarded – undo
3038 3038
             $map_option = $option;
3039 3039
             $option = str_replace('-', '_', $option);
3040 3040
             switch ($map_option) {
3041
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3042
-                    $value = (int)$value;
3041
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3042
+                    $value = (int) $value;
3043 3043
                     if ($value < 1 || $value > 999) {
3044 3044
                         return;
3045 3045
                     }
@@ -3066,7 +3066,7 @@  discard block
 block discarded – undo
3066 3066
      */
3067 3067
     public function set_template_args($data)
3068 3068
     {
3069
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3069
+        $this->_template_args = array_merge($this->_template_args, (array) $data);
3070 3070
     }
3071 3071
 
3072 3072
 
@@ -3088,12 +3088,12 @@  discard block
 block discarded – undo
3088 3088
             $this->_verify_route($route);
3089 3089
         }
3090 3090
         //now let's set the string for what kind of transient we're setting
3091
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3091
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3092 3092
         $data = $notices ? array('notices' => $data) : $data;
3093 3093
         //is there already a transient for this route?  If there is then let's ADD to that transient
3094 3094
         $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3095 3095
         if ($existing) {
3096
-            $data = array_merge((array)$data, (array)$existing);
3096
+            $data = array_merge((array) $data, (array) $existing);
3097 3097
         }
3098 3098
         if (is_multisite() && is_network_admin()) {
3099 3099
             set_site_transient($transient, $data, 8);
@@ -3114,7 +3114,7 @@  discard block
 block discarded – undo
3114 3114
     {
3115 3115
         $user_id = get_current_user_id();
3116 3116
         $route = ! $route ? $this->_req_action : $route;
3117
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3117
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3118 3118
         $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3119 3119
         //delete transient after retrieval (just in case it hasn't expired);
3120 3120
         if (is_multisite() && is_network_admin()) {
@@ -3355,7 +3355,7 @@  discard block
 block discarded – undo
3355 3355
      */
3356 3356
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3357 3357
     {
3358
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3358
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3359 3359
     }
3360 3360
 
3361 3361
 
@@ -3369,7 +3369,7 @@  discard block
 block discarded – undo
3369 3369
      */
3370 3370
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3371 3371
     {
3372
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3372
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3373 3373
     }
3374 3374
 
3375 3375
 
Please login to merge, or discard this patch.
core/db_classes/EE_Line_Item.class.php 2 patches
Indentation   +1490 added lines, -1490 removed lines patch added patch discarded remove patch
@@ -18,1496 +18,1496 @@
 block discarded – undo
18 18
 class EE_Line_Item extends EE_Base_Class implements EEI_Line_Item
19 19
 {
20 20
 
21
-    /**
22
-     * for children line items (currently not a normal relation)
23
-     *
24
-     * @type EE_Line_Item[]
25
-     */
26
-    protected $_children = array();
27
-
28
-    /**
29
-     * for the parent line item
30
-     *
31
-     * @var EE_Line_Item
32
-     */
33
-    protected $_parent;
34
-
35
-
36
-
37
-    /**
38
-     *
39
-     * @param array  $props_n_values          incoming values
40
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
41
-     *                                        used.)
42
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
43
-     *                                        date_format and the second value is the time format
44
-     * @return EE_Line_Item
45
-     * @throws EE_Error
46
-     */
47
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
48
-    {
49
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
50
-        return $has_object
51
-            ? $has_object
52
-            : new self($props_n_values, false, $timezone);
53
-    }
54
-
55
-
56
-
57
-    /**
58
-     * @param array  $props_n_values  incoming values from the database
59
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
60
-     *                                the website will be used.
61
-     * @return EE_Line_Item
62
-     * @throws EE_Error
63
-     */
64
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
65
-    {
66
-        return new self($props_n_values, true, $timezone);
67
-    }
68
-
69
-
70
-
71
-    /**
72
-     * Adds some defaults if they're not specified
73
-     *
74
-     * @param array  $fieldValues
75
-     * @param bool   $bydb
76
-     * @param string $timezone
77
-     * @throws EE_Error
78
-     */
79
-    protected function __construct($fieldValues = array(), $bydb = false, $timezone = '')
80
-    {
81
-        parent::__construct($fieldValues, $bydb, $timezone);
82
-        if (! $this->get('LIN_code')) {
83
-            $this->set_code($this->generate_code());
84
-        }
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     * Gets ID
91
-     *
92
-     * @return int
93
-     * @throws EE_Error
94
-     */
95
-    public function ID()
96
-    {
97
-        return $this->get('LIN_ID');
98
-    }
99
-
100
-
101
-
102
-    /**
103
-     * Gets TXN_ID
104
-     *
105
-     * @return int
106
-     * @throws EE_Error
107
-     */
108
-    public function TXN_ID()
109
-    {
110
-        return $this->get('TXN_ID');
111
-    }
112
-
113
-
114
-
115
-    /**
116
-     * Sets TXN_ID
117
-     *
118
-     * @param int $TXN_ID
119
-     * @throws EE_Error
120
-     */
121
-    public function set_TXN_ID($TXN_ID)
122
-    {
123
-        $this->set('TXN_ID', $TXN_ID);
124
-    }
125
-
126
-
127
-
128
-    /**
129
-     * Gets name
130
-     *
131
-     * @return string
132
-     * @throws EE_Error
133
-     */
134
-    public function name()
135
-    {
136
-        $name = $this->get('LIN_name');
137
-        if (! $name) {
138
-            $name = ucwords(str_replace('-', ' ', $this->type()));
139
-        }
140
-        return $name;
141
-    }
142
-
143
-
144
-
145
-    /**
146
-     * Sets name
147
-     *
148
-     * @param string $name
149
-     * @throws EE_Error
150
-     */
151
-    public function set_name($name)
152
-    {
153
-        $this->set('LIN_name', $name);
154
-    }
155
-
156
-
157
-
158
-    /**
159
-     * Gets desc
160
-     *
161
-     * @return string
162
-     * @throws EE_Error
163
-     */
164
-    public function desc()
165
-    {
166
-        return $this->get('LIN_desc');
167
-    }
168
-
169
-
170
-
171
-    /**
172
-     * Sets desc
173
-     *
174
-     * @param string $desc
175
-     * @throws EE_Error
176
-     */
177
-    public function set_desc($desc)
178
-    {
179
-        $this->set('LIN_desc', $desc);
180
-    }
181
-
182
-
183
-
184
-    /**
185
-     * Gets quantity
186
-     *
187
-     * @return int
188
-     * @throws EE_Error
189
-     */
190
-    public function quantity()
191
-    {
192
-        return $this->get('LIN_quantity');
193
-    }
194
-
195
-
196
-
197
-    /**
198
-     * Sets quantity
199
-     *
200
-     * @param int $quantity
201
-     * @throws EE_Error
202
-     */
203
-    public function set_quantity($quantity)
204
-    {
205
-        $this->set('LIN_quantity', max($quantity, 0));
206
-    }
207
-
208
-
209
-
210
-    /**
211
-     * Gets item_id
212
-     *
213
-     * @return string
214
-     * @throws EE_Error
215
-     */
216
-    public function OBJ_ID()
217
-    {
218
-        return $this->get('OBJ_ID');
219
-    }
220
-
221
-
222
-
223
-    /**
224
-     * Sets item_id
225
-     *
226
-     * @param string $item_id
227
-     * @throws EE_Error
228
-     */
229
-    public function set_OBJ_ID($item_id)
230
-    {
231
-        $this->set('OBJ_ID', $item_id);
232
-    }
233
-
234
-
235
-
236
-    /**
237
-     * Gets item_type
238
-     *
239
-     * @return string
240
-     * @throws EE_Error
241
-     */
242
-    public function OBJ_type()
243
-    {
244
-        return $this->get('OBJ_type');
245
-    }
246
-
247
-
248
-
249
-    /**
250
-     * Gets item_type
251
-     *
252
-     * @return string
253
-     * @throws EE_Error
254
-     */
255
-    public function OBJ_type_i18n()
256
-    {
257
-        $obj_type = $this->OBJ_type();
258
-        switch ($obj_type) {
259
-            case 'Event':
260
-                $obj_type = __('Event', 'event_espresso');
261
-                break;
262
-            case 'Price':
263
-                $obj_type = __('Price', 'event_espresso');
264
-                break;
265
-            case 'Promotion':
266
-                $obj_type = __('Promotion', 'event_espresso');
267
-                break;
268
-            case 'Ticket':
269
-                $obj_type = __('Ticket', 'event_espresso');
270
-                break;
271
-            case 'Transaction':
272
-                $obj_type = __('Transaction', 'event_espresso');
273
-                break;
274
-        }
275
-        return apply_filters('FHEE__EE_Line_Item__OBJ_type_i18n', $obj_type, $this);
276
-    }
277
-
278
-
279
-
280
-    /**
281
-     * Sets item_type
282
-     *
283
-     * @param string $OBJ_type
284
-     * @throws EE_Error
285
-     */
286
-    public function set_OBJ_type($OBJ_type)
287
-    {
288
-        $this->set('OBJ_type', $OBJ_type);
289
-    }
290
-
291
-
292
-
293
-    /**
294
-     * Gets unit_price
295
-     *
296
-     * @return float
297
-     * @throws EE_Error
298
-     */
299
-    public function unit_price()
300
-    {
301
-        return $this->get('LIN_unit_price');
302
-    }
303
-
304
-
305
-
306
-    /**
307
-     * Sets unit_price
308
-     *
309
-     * @param float $unit_price
310
-     * @throws EE_Error
311
-     */
312
-    public function set_unit_price($unit_price)
313
-    {
314
-        $this->set('LIN_unit_price', $unit_price);
315
-    }
316
-
317
-
318
-
319
-    /**
320
-     * Checks if this item is a percentage modifier or not
321
-     *
322
-     * @return boolean
323
-     * @throws EE_Error
324
-     */
325
-    public function is_percent()
326
-    {
327
-        if ($this->is_tax_sub_total()) {
328
-            //tax subtotals HAVE a percent on them, that percentage only applies
329
-            //to taxable items, so its' an exception. Treat it like a flat line item
330
-            return false;
331
-        }
332
-        $unit_price = abs($this->get('LIN_unit_price'));
333
-        $percent = abs($this->get('LIN_percent'));
334
-        if ($unit_price < .001 && $percent) {
335
-            return true;
336
-        }
337
-        if ($unit_price >= .001 && ! $percent) {
338
-            return false;
339
-        }
340
-        if ($unit_price >= .001 && $percent) {
341
-            throw new EE_Error(
342
-                sprintf(
343
-                    esc_html__('A Line Item can not have a unit price of (%s) AND a percent (%s)!', 'event_espresso'),
344
-                    $unit_price, $percent
345
-                )
346
-            );
347
-        }
348
-        // if they're both 0, assume its not a percent item
349
-        return false;
350
-    }
351
-
352
-
353
-
354
-    /**
355
-     * Gets percent (between 100-.001)
356
-     *
357
-     * @return float
358
-     * @throws EE_Error
359
-     */
360
-    public function percent()
361
-    {
362
-        return $this->get('LIN_percent');
363
-    }
364
-
365
-
366
-
367
-    /**
368
-     * Sets percent (between 100-0.01)
369
-     *
370
-     * @param float $percent
371
-     * @throws EE_Error
372
-     */
373
-    public function set_percent($percent)
374
-    {
375
-        $this->set('LIN_percent', $percent);
376
-    }
377
-
378
-
379
-
380
-    /**
381
-     * Gets total
382
-     *
383
-     * @return float
384
-     * @throws EE_Error
385
-     */
386
-    public function total()
387
-    {
388
-        return $this->get('LIN_total');
389
-    }
390
-
391
-
392
-
393
-    /**
394
-     * Sets total
395
-     *
396
-     * @param float $total
397
-     * @throws EE_Error
398
-     */
399
-    public function set_total($total)
400
-    {
401
-        $this->set('LIN_total', $total);
402
-    }
403
-
404
-
405
-
406
-    /**
407
-     * Gets order
408
-     *
409
-     * @return int
410
-     * @throws EE_Error
411
-     */
412
-    public function order()
413
-    {
414
-        return $this->get('LIN_order');
415
-    }
416
-
417
-
418
-
419
-    /**
420
-     * Sets order
421
-     *
422
-     * @param int $order
423
-     * @throws EE_Error
424
-     */
425
-    public function set_order($order)
426
-    {
427
-        $this->set('LIN_order', $order);
428
-    }
429
-
430
-
431
-
432
-    /**
433
-     * Gets parent
434
-     *
435
-     * @return int
436
-     * @throws EE_Error
437
-     */
438
-    public function parent_ID()
439
-    {
440
-        return $this->get('LIN_parent');
441
-    }
442
-
443
-
444
-
445
-    /**
446
-     * Sets parent
447
-     *
448
-     * @param int $parent
449
-     * @throws EE_Error
450
-     */
451
-    public function set_parent_ID($parent)
452
-    {
453
-        $this->set('LIN_parent', $parent);
454
-    }
455
-
456
-
457
-
458
-    /**
459
-     * Gets type
460
-     *
461
-     * @return string
462
-     * @throws EE_Error
463
-     */
464
-    public function type()
465
-    {
466
-        return $this->get('LIN_type');
467
-    }
468
-
469
-
470
-
471
-    /**
472
-     * Sets type
473
-     *
474
-     * @param string $type
475
-     * @throws EE_Error
476
-     */
477
-    public function set_type($type)
478
-    {
479
-        $this->set('LIN_type', $type);
480
-    }
481
-
482
-
483
-
484
-    /**
485
-     * Gets the line item of which this item is a composite. Eg, if this is a subtotal, the parent might be a total\
486
-     * If this line item is saved to the DB, fetches the parent from the DB. However, if this line item isn't in the DB
487
-     * it uses its cached reference to its parent line item (which would have been set by `EE_Line_Item::set_parent()`
488
-     * or indirectly by `EE_Line_item::add_child_line_item()`)
489
-     *
490
-     * @return EE_Base_Class|EE_Line_Item
491
-     * @throws EE_Error
492
-     */
493
-    public function parent()
494
-    {
495
-        return $this->ID()
496
-            ? $this->get_model()->get_one_by_ID($this->parent_ID())
497
-            : $this->_parent;
498
-    }
499
-
500
-
501
-
502
-    /**
503
-     * Gets ALL the children of this line item (ie, all the parts that contribute towards this total).
504
-     *
505
-     * @return EE_Base_Class[]|EE_Line_Item[]
506
-     * @throws EE_Error
507
-     */
508
-    public function children()
509
-    {
510
-        if ($this->ID()) {
511
-            return $this->get_model()->get_all(
512
-                array(
513
-                    array('LIN_parent' => $this->ID()),
514
-                    'order_by' => array('LIN_order' => 'ASC'),
515
-                )
516
-            );
517
-        }
518
-        if (! is_array($this->_children)) {
519
-            $this->_children = array();
520
-        }
521
-        return $this->_children;
522
-    }
523
-
524
-
525
-
526
-    /**
527
-     * Gets code
528
-     *
529
-     * @return string
530
-     * @throws EE_Error
531
-     */
532
-    public function code()
533
-    {
534
-        return $this->get('LIN_code');
535
-    }
536
-
537
-
538
-
539
-    /**
540
-     * Sets code
541
-     *
542
-     * @param string $code
543
-     * @throws EE_Error
544
-     */
545
-    public function set_code($code)
546
-    {
547
-        $this->set('LIN_code', $code);
548
-    }
549
-
550
-
551
-
552
-    /**
553
-     * Gets is_taxable
554
-     *
555
-     * @return boolean
556
-     * @throws EE_Error
557
-     */
558
-    public function is_taxable()
559
-    {
560
-        return $this->get('LIN_is_taxable');
561
-    }
562
-
563
-
564
-
565
-    /**
566
-     * Sets is_taxable
567
-     *
568
-     * @param boolean $is_taxable
569
-     * @throws EE_Error
570
-     */
571
-    public function set_is_taxable($is_taxable)
572
-    {
573
-        $this->set('LIN_is_taxable', $is_taxable);
574
-    }
575
-
576
-
577
-
578
-    /**
579
-     * Gets the object that this model-joins-to.
580
-     * returns one of the model objects that the field OBJ_ID can point to... see the 'OBJ_ID' field on
581
-     * EEM_Promotion_Object
582
-     *
583
-     *        Eg, if this line item join model object is for a ticket, this will return the EE_Ticket object
584
-     *
585
-     * @return EE_Base_Class | NULL
586
-     * @throws EE_Error
587
-     */
588
-    public function get_object()
589
-    {
590
-        $model_name_of_related_obj = $this->OBJ_type();
591
-        return $this->get_model()->has_relation($model_name_of_related_obj)
592
-            ? $this->get_first_related($model_name_of_related_obj)
593
-            : null;
594
-    }
595
-
596
-
597
-
598
-    /**
599
-     * Like EE_Line_Item::get_object(), but can only ever actually return an EE_Ticket.
600
-     * (IE, if this line item is for a price or something else, will return NULL)
601
-     *
602
-     * @param array $query_params
603
-     * @return EE_Base_Class|EE_Ticket
604
-     * @throws EE_Error
605
-     */
606
-    public function ticket($query_params = array())
607
-    {
608
-        //we're going to assume that when this method is called we always want to receive the attached ticket EVEN if that ticket is archived.  This can be overridden via the incoming $query_params argument
609
-        $remove_defaults = array('default_where_conditions' => 'none');
610
-        $query_params = array_merge($remove_defaults, $query_params);
611
-        return $this->get_first_related('Ticket', $query_params);
612
-    }
613
-
614
-
615
-
616
-    /**
617
-     * Gets the EE_Datetime that's related to the ticket, IF this is for a ticket
618
-     *
619
-     * @return EE_Datetime | NULL
620
-     * @throws EE_Error
621
-     */
622
-    public function get_ticket_datetime()
623
-    {
624
-        if ($this->OBJ_type() === 'Ticket') {
625
-            $ticket = $this->ticket();
626
-            if ($ticket instanceof EE_Ticket) {
627
-                $datetime = $ticket->first_datetime();
628
-                if ($datetime instanceof EE_Datetime) {
629
-                    return $datetime;
630
-                }
631
-            }
632
-        }
633
-        return null;
634
-    }
635
-
636
-
637
-
638
-    /**
639
-     * Gets the event's name that's related to the ticket, if this is for
640
-     * a ticket
641
-     *
642
-     * @return string
643
-     * @throws EE_Error
644
-     */
645
-    public function ticket_event_name()
646
-    {
647
-        $event_name = esc_html__('Unknown', 'event_espresso');
648
-        $event = $this->ticket_event();
649
-        if ($event instanceof EE_Event) {
650
-            $event_name = $event->name();
651
-        }
652
-        return $event_name;
653
-    }
654
-
655
-
656
-    /**
657
-     * Gets the event that's related to the ticket, if this line item represents a ticket.
658
-     *
659
-     * @return EE_Event|null
660
-     * @throws EE_Error
661
-     */
662
-    public function ticket_event()
663
-    {
664
-        $event = null;
665
-        $ticket = $this->ticket();
666
-        if ($ticket instanceof EE_Ticket) {
667
-            $datetime = $ticket->first_datetime();
668
-            if ($datetime instanceof EE_Datetime) {
669
-                $event = $datetime->event();
670
-            }
671
-        }
672
-        return $event;
673
-    }
674
-
675
-
676
-
677
-    /**
678
-     * Gets the first datetime for this lien item, assuming it's for a ticket
679
-     *
680
-     * @param string $date_format
681
-     * @param string $time_format
682
-     * @return string
683
-     * @throws EE_Error
684
-     */
685
-    public function ticket_datetime_start($date_format = '', $time_format = '')
686
-    {
687
-        $first_datetime_string = esc_html__('Unknown', 'event_espresso');
688
-        $datetime = $this->get_ticket_datetime();
689
-        if ($datetime) {
690
-            $first_datetime_string = $datetime->start_date_and_time($date_format, $time_format);
691
-        }
692
-        return $first_datetime_string;
693
-    }
694
-
695
-
696
-
697
-    /**
698
-     * Adds the line item as a child to this line item. If there is another child line
699
-     * item with the same LIN_code, it is overwritten by this new one
700
-     *
701
-     * @param EEI_Line_Item $line_item
702
-     * @param bool          $set_order
703
-     * @return bool success
704
-     * @throws EE_Error
705
-     */
706
-    public function add_child_line_item(EEI_Line_Item $line_item, $set_order = true)
707
-    {
708
-        // should we calculate the LIN_order for this line item ?
709
-        if ($set_order || $line_item->order() === null) {
710
-            $line_item->set_order(count($this->children()));
711
-        }
712
-        if ($this->ID()) {
713
-            //check for any duplicate line items (with the same code), if so, this replaces it
714
-            $line_item_with_same_code = $this->get_child_line_item($line_item->code());
715
-            if ($line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item) {
716
-                $this->delete_child_line_item($line_item_with_same_code->code());
717
-            }
718
-            $line_item->set_parent_ID($this->ID());
719
-            if ($this->TXN_ID()) {
720
-                $line_item->set_TXN_ID($this->TXN_ID());
721
-            }
722
-            return $line_item->save();
723
-        }
724
-        $this->_children[$line_item->code()] = $line_item;
725
-        if ($line_item->parent() !== $this) {
726
-            $line_item->set_parent($this);
727
-        }
728
-        return true;
729
-    }
730
-
731
-
732
-    /**
733
-     * Similar to EE_Base_Class::_add_relation_to, except this isn't a normal relation.
734
-     * If this line item is saved to the DB, this is just a wrapper for set_parent_ID() and save()
735
-     * However, if this line item is NOT saved to the DB, this just caches the parent on
736
-     * the EE_Line_Item::_parent property.
737
-     *
738
-     * @param EE_Line_Item $line_item
739
-     * @throws EE_Error
740
-     */
741
-    public function set_parent($line_item)
742
-    {
743
-        if ($this->ID()) {
744
-            if (! $line_item->ID()) {
745
-                $line_item->save();
746
-            }
747
-            $this->set_parent_ID($line_item->ID());
748
-            $this->save();
749
-        } else {
750
-            $this->_parent = $line_item;
751
-            $this->set_parent_ID($line_item->ID());
752
-        }
753
-    }
754
-
755
-
756
-
757
-    /**
758
-     * Gets the child line item as specified by its code. Because this returns an object (by reference)
759
-     * you can modify this child line item and the parent (this object) can know about them
760
-     * because it also has a reference to that line item
761
-     *
762
-     * @param string $code
763
-     * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL
764
-     * @throws EE_Error
765
-     */
766
-    public function get_child_line_item($code)
767
-    {
768
-        if ($this->ID()) {
769
-            return $this->get_model()->get_one(
770
-                array(array('LIN_parent' => $this->ID(), 'LIN_code' => $code))
771
-            );
772
-        }
773
-        return isset($this->_children[$code])
774
-            ? $this->_children[$code]
775
-            : null;
776
-    }
777
-
778
-
779
-
780
-    /**
781
-     * Returns how many items are deleted (or, if this item has not been saved ot the DB yet, just how many it HAD
782
-     * cached on it)
783
-     *
784
-     * @return int
785
-     * @throws EE_Error
786
-     */
787
-    public function delete_children_line_items()
788
-    {
789
-        if ($this->ID()) {
790
-            return $this->get_model()->delete(array(array('LIN_parent' => $this->ID())));
791
-        }
792
-        $count = count($this->_children);
793
-        $this->_children = array();
794
-        return $count;
795
-    }
796
-
797
-
798
-
799
-    /**
800
-     * If this line item has been saved to the DB, deletes its child with LIN_code == $code. If this line
801
-     * HAS NOT been saved to the DB, removes the child line item with index $code.
802
-     * Also searches through the child's children for a matching line item. However, once a line item has been found
803
-     * and deleted, stops searching (so if there are line items with duplicate codes, only the first one found will be
804
-     * deleted)
805
-     *
806
-     * @param string $code
807
-     * @param bool   $stop_search_once_found
808
-     * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to
809
-     *             the DB yet)
810
-     * @throws EE_Error
811
-     */
812
-    public function delete_child_line_item($code, $stop_search_once_found = true)
813
-    {
814
-        if ($this->ID()) {
815
-            $items_deleted = 0;
816
-            if ($this->code() === $code) {
817
-                $items_deleted += EEH_Line_Item::delete_all_child_items($this);
818
-                $items_deleted += (int)$this->delete();
819
-                if ($stop_search_once_found) {
820
-                    return $items_deleted;
821
-                }
822
-            }
823
-            foreach ($this->children() as $child_line_item) {
824
-                $items_deleted += $child_line_item->delete_child_line_item($code, $stop_search_once_found);
825
-            }
826
-            return $items_deleted;
827
-        }
828
-        if (isset($this->_children[$code])) {
829
-            unset($this->_children[$code]);
830
-            return 1;
831
-        }
832
-        return 0;
833
-    }
834
-
835
-
836
-    /**
837
-     * If this line item is in the database, is of the type subtotal, and
838
-     * has no children, why do we have it? It should be deleted so this function
839
-     * does that
840
-     *
841
-     * @return boolean
842
-     * @throws EE_Error
843
-     */
844
-    public function delete_if_childless_subtotal()
845
-    {
846
-        if ($this->ID() && $this->type() === EEM_Line_Item::type_sub_total && ! $this->children()) {
847
-            return $this->delete();
848
-        }
849
-        return false;
850
-    }
851
-
852
-
853
-
854
-    /**
855
-     * Creates a code and returns a string. doesn't assign the code to this model object
856
-     *
857
-     * @return string
858
-     * @throws EE_Error
859
-     */
860
-    public function generate_code()
861
-    {
862
-        // each line item in the cart requires a unique identifier
863
-        return md5($this->get('OBJ_type') . $this->get('OBJ_ID') . microtime());
864
-    }
865
-
866
-
867
-
868
-    /**
869
-     * @return bool
870
-     * @throws EE_Error
871
-     */
872
-    public function is_tax()
873
-    {
874
-        return $this->type() === EEM_Line_Item::type_tax;
875
-    }
876
-
877
-
878
-
879
-    /**
880
-     * @return bool
881
-     * @throws EE_Error
882
-     */
883
-    public function is_tax_sub_total()
884
-    {
885
-        return $this->type() === EEM_Line_Item::type_tax_sub_total;
886
-    }
887
-
888
-
889
-
890
-    /**
891
-     * @return bool
892
-     * @throws EE_Error
893
-     */
894
-    public function is_line_item()
895
-    {
896
-        return $this->type() === EEM_Line_Item::type_line_item;
897
-    }
898
-
899
-
900
-
901
-    /**
902
-     * @return bool
903
-     * @throws EE_Error
904
-     */
905
-    public function is_sub_line_item()
906
-    {
907
-        return $this->type() === EEM_Line_Item::type_sub_line_item;
908
-    }
909
-
910
-
911
-
912
-    /**
913
-     * @return bool
914
-     * @throws EE_Error
915
-     */
916
-    public function is_sub_total()
917
-    {
918
-        return $this->type() === EEM_Line_Item::type_sub_total;
919
-    }
920
-
921
-
922
-
923
-    /**
924
-     * Whether or not this line item is a cancellation line item
925
-     *
926
-     * @return boolean
927
-     * @throws EE_Error
928
-     */
929
-    public function is_cancellation()
930
-    {
931
-        return EEM_Line_Item::type_cancellation === $this->type();
932
-    }
933
-
934
-
935
-
936
-    /**
937
-     * @return bool
938
-     * @throws EE_Error
939
-     */
940
-    public function is_total()
941
-    {
942
-        return $this->type() === EEM_Line_Item::type_total;
943
-    }
944
-
945
-
946
-
947
-    /**
948
-     * @return bool
949
-     * @throws EE_Error
950
-     */
951
-    public function is_cancelled()
952
-    {
953
-        return $this->type() === EEM_Line_Item::type_cancellation;
954
-    }
955
-
956
-
957
-
958
-    /**
959
-     * @return string like '2, 004.00', formatted according to the localized currency
960
-     * @throws EE_Error
961
-     */
962
-    public function unit_price_no_code()
963
-    {
964
-        return $this->get_pretty('LIN_unit_price', 'no_currency_code');
965
-    }
966
-
967
-
968
-
969
-    /**
970
-     * @return string like '2, 004.00', formatted according to the localized currency
971
-     * @throws EE_Error
972
-     */
973
-    public function total_no_code()
974
-    {
975
-        return $this->get_pretty('LIN_total', 'no_currency_code');
976
-    }
977
-
978
-
979
-
980
-    /**
981
-     * Gets the final total on this item, taking taxes into account.
982
-     * Has the side-effect of setting the sub-total as it was just calculated.
983
-     * If this is used on a grand-total line item, also updates the transaction's
984
-     * TXN_total (provided this line item is allowed to persist, otherwise we don't
985
-     * want to change a persistable transaction with info from a non-persistent line item)
986
-     *
987
-     * @return float
988
-     * @throws EE_Error
989
-     * @throws InvalidArgumentException
990
-     * @throws InvalidInterfaceException
991
-     * @throws InvalidDataTypeException
992
-     */
993
-    public function recalculate_total_including_taxes()
994
-    {
995
-        $pre_tax_total = $this->recalculate_pre_tax_total();
996
-        $tax_total = $this->recalculate_taxes_and_tax_total();
997
-        $total = $pre_tax_total + $tax_total;
998
-        // no negative totals plz
999
-        $total = max($total, 0);
1000
-        $this->set_total($total);
1001
-        //only update the related transaction's total
1002
-        //if we intend to save this line item and its a grand total
1003
-        if (
1004
-            $this->allow_persist() && $this->type() === EEM_Line_Item::type_total
1005
-            && $this->transaction()
1006
-               instanceof
1007
-               EE_Transaction
1008
-        ) {
1009
-            $this->transaction()->set_total($total);
1010
-            if ($this->transaction()->ID()) {
1011
-                $this->transaction()->save();
1012
-            }
1013
-        }
1014
-        $this->maybe_save();
1015
-        return $total;
1016
-    }
1017
-
1018
-
1019
-    /**
1020
-     * Recursively goes through all the children and recalculates sub-totals EXCEPT for
1021
-     * tax-sub-totals (they're a an odd beast). Updates the 'total' on each line item according to either its
1022
-     * unit price * quantity or the total of all its children EXCEPT when we're only calculating the taxable total and
1023
-     * when this is called on the grand total
1024
-     *
1025
-     * @return float
1026
-     * @throws InvalidArgumentException
1027
-     * @throws InvalidInterfaceException
1028
-     * @throws InvalidDataTypeException
1029
-     * @throws EE_Error
1030
-     */
1031
-    public function recalculate_pre_tax_total()
1032
-    {
1033
-        $total = 0;
1034
-        $my_children = $this->children();
1035
-        $has_children = ! empty($my_children);
1036
-        if ($has_children && $this->is_line_item()) {
1037
-            $total = $this->_recalculate_pretax_total_for_line_item($total, $my_children);
1038
-        } elseif (! $has_children && ($this->is_sub_line_item() || $this->is_line_item())) {
1039
-            $total = $this->unit_price() * $this->quantity();
1040
-        } elseif ($this->is_sub_total() || $this->is_total()) {
1041
-            $total = $this->_recalculate_pretax_total_for_subtotal($total, $my_children);
1042
-        } elseif ($this->is_tax_sub_total() || $this->is_tax() || $this->is_cancelled()) {
1043
-            // completely ignore tax totals, tax sub-totals, and cancelled line items, when calculating the pre-tax-total
1044
-            return 0;
1045
-        }
1046
-        // ensure all non-line items and non-sub-line-items have a quantity of 1 (except for Events)
1047
-        if (
1048
-            ! $this->is_line_item() && ! $this->is_sub_line_item() && ! $this->is_cancellation()
1049
-        ) {
1050
-            if ($this->OBJ_type() !== 'Event') {
1051
-                $this->set_quantity(1);
1052
-            }
1053
-            if (! $this->is_percent()) {
1054
-                $this->set_unit_price($total);
1055
-            }
1056
-        }
1057
-        //we don't want to bother saving grand totals, because that needs to factor in taxes anyways
1058
-        //so it ought to be
1059
-        if (! $this->is_total()) {
1060
-            $this->set_total($total);
1061
-            //if not a percent line item, make sure we keep the unit price in sync
1062
-            if (
1063
-                $has_children
1064
-                && $this->is_line_item()
1065
-                && ! $this->is_percent()
1066
-            ) {
1067
-                if ($this->quantity() === 0) {
1068
-                    $new_unit_price = 0;
1069
-                } else {
1070
-                    $new_unit_price = $this->total() / $this->quantity();
1071
-                }
1072
-                $this->set_unit_price($new_unit_price);
1073
-            }
1074
-            $this->maybe_save();
1075
-        }
1076
-        return $total;
1077
-    }
1078
-
1079
-
1080
-
1081
-    /**
1082
-     * Calculates the pretax total when this line item is a subtotal or total line item.
1083
-     * Basically does a sum-then-round approach (ie, any percent line item that are children
1084
-     * will calculate their total based on the un-rounded total we're working with so far, and
1085
-     * THEN round the result; instead of rounding as we go like with sub-line-items)
1086
-     *
1087
-     * @param float          $calculated_total_so_far
1088
-     * @param EE_Line_Item[] $my_children
1089
-     * @return float
1090
-     * @throws InvalidArgumentException
1091
-     * @throws InvalidInterfaceException
1092
-     * @throws InvalidDataTypeException
1093
-     * @throws EE_Error
1094
-     */
1095
-    protected function _recalculate_pretax_total_for_subtotal($calculated_total_so_far, $my_children = null)
1096
-    {
1097
-        if ($my_children === null) {
1098
-            $my_children = $this->children();
1099
-        }
1100
-        //get the total of all its children
1101
-        foreach ($my_children as $child_line_item) {
1102
-            if ($child_line_item instanceof EE_Line_Item && ! $child_line_item->is_cancellation()) {
1103
-                // percentage line items are based on total so far
1104
-                if ($child_line_item->is_percent()) {
1105
-                    //round as we go so that the line items add up ok
1106
-                    $percent_total = round(
1107
-                        $calculated_total_so_far * $child_line_item->percent() / 100,
1108
-                        EE_Registry::instance()->CFG->currency->dec_plc
1109
-                    );
1110
-                    $child_line_item->set_total($percent_total);
1111
-                    //so far all percent line items should have a quantity of 1
1112
-                    //(ie, no double percent discounts. Although that might be requested someday)
1113
-                    $child_line_item->set_quantity(1);
1114
-                    $child_line_item->maybe_save();
1115
-                    $calculated_total_so_far += $percent_total;
1116
-                } else {
1117
-                    //verify flat sub-line-item quantities match their parent
1118
-                    if ($child_line_item->is_sub_line_item()) {
1119
-                        $child_line_item->set_quantity($this->quantity());
1120
-                    }
1121
-                    $calculated_total_so_far += $child_line_item->recalculate_pre_tax_total();
1122
-                }
1123
-            }
1124
-        }
1125
-        if ($this->is_sub_total()) {
1126
-            // no negative totals plz
1127
-            $calculated_total_so_far = max($calculated_total_so_far, 0);
1128
-        }
1129
-        return $calculated_total_so_far;
1130
-    }
1131
-
1132
-
1133
-
1134
-    /**
1135
-     * Calculates the pretax total for a normal line item, in a round-then-sum approach
1136
-     * (where each sub-line-item is applied to the base price for the line item
1137
-     * and the result is immediately rounded, rather than summing all the sub-line-items
1138
-     * then rounding, like we do when recalculating pretax totals on totals and subtotals).
1139
-     *
1140
-     * @param float          $calculated_total_so_far
1141
-     * @param EE_Line_Item[] $my_children
1142
-     * @return float
1143
-     * @throws InvalidArgumentException
1144
-     * @throws InvalidInterfaceException
1145
-     * @throws InvalidDataTypeException
1146
-     * @throws EE_Error
1147
-     */
1148
-    protected function _recalculate_pretax_total_for_line_item($calculated_total_so_far, $my_children = null)
1149
-    {
1150
-        if ($my_children === null) {
1151
-            $my_children = $this->children();
1152
-        }
1153
-        //we need to keep track of the running total for a single item,
1154
-        //because we need to round as we go
1155
-        $unit_price_for_total = 0;
1156
-        $quantity_for_total = 1;
1157
-        //get the total of all its children
1158
-        foreach ($my_children as $child_line_item) {
1159
-            if ($child_line_item instanceof EE_Line_Item && ! $child_line_item->is_cancellation()) {
1160
-                if ($child_line_item->is_percent()) {
1161
-                    //it should be the unit-price-so-far multiplied by teh percent multiplied by the quantity
1162
-                    //not total multiplied by percent, because that ignores rounding along-the-way
1163
-                    $percent_unit_price = round(
1164
-                        $unit_price_for_total * $child_line_item->percent() / 100,
1165
-                        EE_Registry::instance()->CFG->currency->dec_plc
1166
-                    );
1167
-                    $percent_total = $percent_unit_price * $quantity_for_total;
1168
-                    $child_line_item->set_total($percent_total);
1169
-                    //so far all percent line items should have a quantity of 1
1170
-                    //(ie, no double percent discounts. Although that might be requested someday)
1171
-                    $child_line_item->set_quantity(1);
1172
-                    $child_line_item->maybe_save();
1173
-                    $calculated_total_so_far += $percent_total;
1174
-                    $unit_price_for_total += $percent_unit_price;
1175
-                } else {
1176
-                    //verify flat sub-line-item quantities match their parent
1177
-                    if ($child_line_item->is_sub_line_item()) {
1178
-                        $child_line_item->set_quantity($this->quantity());
1179
-                    }
1180
-                    $quantity_for_total = $child_line_item->quantity();
1181
-                    $calculated_total_so_far += $child_line_item->recalculate_pre_tax_total();
1182
-                    $unit_price_for_total += $child_line_item->unit_price();
1183
-                }
1184
-            }
1185
-        }
1186
-        return $calculated_total_so_far;
1187
-    }
1188
-
1189
-
1190
-
1191
-    /**
1192
-     * Recalculates the total on each individual tax (based on a recalculation of the pre-tax total), sets
1193
-     * the totals on each tax calculated, and returns the final tax total
1194
-     *
1195
-     * @return float
1196
-     * @throws EE_Error
1197
-     */
1198
-    public function recalculate_taxes_and_tax_total()
1199
-    {
1200
-        //get all taxes
1201
-        $taxes = $this->tax_descendants();
1202
-        //calculate the pretax total
1203
-        $taxable_total = $this->taxable_total();
1204
-        $tax_total = 0;
1205
-        foreach ($taxes as $tax) {
1206
-            $total_on_this_tax = $taxable_total * $tax->percent() / 100;
1207
-            //remember the total on this line item
1208
-            $tax->set_total($total_on_this_tax);
1209
-            $tax_total += $tax->total();
1210
-        }
1211
-        $this->_recalculate_tax_sub_total();
1212
-        return $tax_total;
1213
-    }
1214
-
1215
-
1216
-
1217
-    /**
1218
-     * Simply forces all the tax-sub-totals to recalculate. Assumes the taxes have been calculated
1219
-     *
1220
-     * @return void
1221
-     * @throws EE_Error
1222
-     */
1223
-    private function _recalculate_tax_sub_total()
1224
-    {
1225
-        if ($this->is_tax_sub_total()) {
1226
-            $total = 0;
1227
-            $total_percent = 0;
1228
-            //simply loop through all its children (which should be taxes) and sum their total
1229
-            foreach ($this->children() as $child_tax) {
1230
-                if ($child_tax instanceof EE_Line_Item) {
1231
-                    $total += $child_tax->total();
1232
-                    $total_percent += $child_tax->percent();
1233
-                }
1234
-            }
1235
-            $this->set_total($total);
1236
-            $this->set_percent($total_percent);
1237
-        } elseif ($this->is_total()) {
1238
-            foreach ($this->children() as $maybe_tax_subtotal) {
1239
-                if ($maybe_tax_subtotal instanceof EE_Line_Item) {
1240
-                    $maybe_tax_subtotal->_recalculate_tax_sub_total();
1241
-                }
1242
-            }
1243
-        }
1244
-    }
1245
-
1246
-
1247
-
1248
-    /**
1249
-     * Gets the total tax on this line item. Assumes taxes have already been calculated using
1250
-     * recalculate_taxes_and_total
1251
-     *
1252
-     * @return float
1253
-     * @throws EE_Error
1254
-     */
1255
-    public function get_total_tax()
1256
-    {
1257
-        $this->_recalculate_tax_sub_total();
1258
-        $total = 0;
1259
-        foreach ($this->tax_descendants() as $tax_line_item) {
1260
-            if ($tax_line_item instanceof EE_Line_Item) {
1261
-                $total += $tax_line_item->total();
1262
-            }
1263
-        }
1264
-        return $total;
1265
-    }
1266
-
1267
-
1268
-    /**
1269
-     * Gets the total for all the items purchased only
1270
-     *
1271
-     * @return float
1272
-     * @throws EE_Error
1273
-     */
1274
-    public function get_items_total()
1275
-    {
1276
-        //by default, let's make sure we're consistent with the existing line item
1277
-        if ($this->is_total()) {
1278
-            $pretax_subtotal_li = EEH_Line_Item::get_pre_tax_subtotal($this);
1279
-            if ($pretax_subtotal_li instanceof EE_Line_Item) {
1280
-                return $pretax_subtotal_li->total();
1281
-            }
1282
-        }
1283
-        $total = 0;
1284
-        foreach ($this->get_items() as $item) {
1285
-            if ($item instanceof EE_Line_Item) {
1286
-                $total += $item->total();
1287
-            }
1288
-        }
1289
-        return $total;
1290
-    }
1291
-
1292
-
1293
-
1294
-    /**
1295
-     * Gets all the descendants (ie, children or children of children etc) that
1296
-     * are of the type 'tax'
1297
-     *
1298
-     * @return EE_Line_Item[]
1299
-     */
1300
-    public function tax_descendants()
1301
-    {
1302
-        return EEH_Line_Item::get_tax_descendants($this);
1303
-    }
1304
-
1305
-
1306
-
1307
-    /**
1308
-     * Gets all the real items purchased which are children of this item
1309
-     *
1310
-     * @return EE_Line_Item[]
1311
-     */
1312
-    public function get_items()
1313
-    {
1314
-        return EEH_Line_Item::get_line_item_descendants($this);
1315
-    }
1316
-
1317
-
1318
-
1319
-    /**
1320
-     * Returns the amount taxable among this line item's children (or if it has no children,
1321
-     * how much of it is taxable). Does not recalculate totals or subtotals.
1322
-     * If the taxable total is negative, (eg, if none of the tickets were taxable,
1323
-     * but there is a "Taxable" discount), returns 0.
1324
-     *
1325
-     * @return float
1326
-     * @throws EE_Error
1327
-     */
1328
-    public function taxable_total()
1329
-    {
1330
-        $total = 0;
1331
-        if ($this->children()) {
1332
-            foreach ($this->children() as $child_line_item) {
1333
-                if ($child_line_item->type() === EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) {
1334
-                    //if it's a percent item, only take into account the percent
1335
-                    //that's taxable too (the taxable total so far)
1336
-                    if ($child_line_item->is_percent()) {
1337
-                        $total += ($total * $child_line_item->percent() / 100);
1338
-                    } else {
1339
-                        $total += $child_line_item->total();
1340
-                    }
1341
-                } elseif ($child_line_item->type() === EEM_Line_Item::type_sub_total) {
1342
-                    $total += $child_line_item->taxable_total();
1343
-                }
1344
-            }
1345
-        }
1346
-        return max($total, 0);
1347
-    }
1348
-
1349
-
1350
-
1351
-    /**
1352
-     * Gets the transaction for this line item
1353
-     *
1354
-     * @return EE_Base_Class|EE_Transaction
1355
-     * @throws EE_Error
1356
-     */
1357
-    public function transaction()
1358
-    {
1359
-        return $this->get_first_related('Transaction');
1360
-    }
1361
-
1362
-
1363
-
1364
-    /**
1365
-     * Saves this line item to the DB, and recursively saves its descendants.
1366
-     * Because there currently is no proper parent-child relation on the model,
1367
-     * save_this_and_cached() will NOT save the descendants.
1368
-     * Also sets the transaction on this line item and all its descendants before saving
1369
-     *
1370
-     * @param int $txn_id if none is provided, assumes $this->TXN_ID()
1371
-     * @return int count of items saved
1372
-     * @throws EE_Error
1373
-     */
1374
-    public function save_this_and_descendants_to_txn($txn_id = null)
1375
-    {
1376
-        $count = 0;
1377
-        if (! $txn_id) {
1378
-            $txn_id = $this->TXN_ID();
1379
-        }
1380
-        $this->set_TXN_ID($txn_id);
1381
-        $children = $this->children();
1382
-        $count += $this->save()
1383
-            ? 1
1384
-            : 0;
1385
-        foreach ($children as $child_line_item) {
1386
-            if ($child_line_item instanceof EE_Line_Item) {
1387
-                $child_line_item->set_parent_ID($this->ID());
1388
-                $count += $child_line_item->save_this_and_descendants_to_txn($txn_id);
1389
-            }
1390
-        }
1391
-        return $count;
1392
-    }
1393
-
1394
-
1395
-
1396
-    /**
1397
-     * Saves this line item to the DB, and recursively saves its descendants.
1398
-     *
1399
-     * @return int count of items saved
1400
-     * @throws EE_Error
1401
-     */
1402
-    public function save_this_and_descendants()
1403
-    {
1404
-        $count = 0;
1405
-        $children = $this->children();
1406
-        $count += $this->save()
1407
-            ? 1
1408
-            : 0;
1409
-        foreach ($children as $child_line_item) {
1410
-            if ($child_line_item instanceof EE_Line_Item) {
1411
-                $child_line_item->set_parent_ID($this->ID());
1412
-                $count += $child_line_item->save_this_and_descendants();
1413
-            }
1414
-        }
1415
-        return $count;
1416
-    }
1417
-
1418
-
1419
-
1420
-    /**
1421
-     * returns the cancellation line item if this item was cancelled
1422
-     *
1423
-     * @return EE_Line_Item[]
1424
-     * @throws InvalidArgumentException
1425
-     * @throws InvalidInterfaceException
1426
-     * @throws InvalidDataTypeException
1427
-     * @throws ReflectionException
1428
-     * @throws EE_Error
1429
-     */
1430
-    public function get_cancellations()
1431
-    {
1432
-        EE_Registry::instance()->load_helper('Line_Item');
1433
-        return EEH_Line_Item::get_descendants_of_type($this, EEM_Line_Item::type_cancellation);
1434
-    }
1435
-
1436
-
1437
-
1438
-    /**
1439
-     * If this item has an ID, then this saves it again to update the db
1440
-     *
1441
-     * @return int count of items saved
1442
-     * @throws EE_Error
1443
-     */
1444
-    public function maybe_save()
1445
-    {
1446
-        if ($this->ID()) {
1447
-            return $this->save();
1448
-        }
1449
-        return false;
1450
-    }
1451
-
1452
-
1453
-    /**
1454
-     * clears the cached children and parent from the line item
1455
-     *
1456
-     * @return void
1457
-     */
1458
-    public function clear_related_line_item_cache()
1459
-    {
1460
-        $this->_children = array();
1461
-        $this->_parent = null;
1462
-    }
1463
-
1464
-
1465
-
1466
-    /**
1467
-     * @param bool $raw
1468
-     * @return int
1469
-     * @throws EE_Error
1470
-     */
1471
-    public function timestamp($raw = false)
1472
-    {
1473
-        return $raw
1474
-            ? $this->get_raw('LIN_timestamp')
1475
-            : $this->get('LIN_timestamp');
1476
-    }
1477
-
1478
-
1479
-
1480
-
1481
-    /************************* DEPRECATED *************************/
1482
-    /**
1483
-     * @deprecated 4.6.0
1484
-     * @param string $type one of the constants on EEM_Line_Item
1485
-     * @return EE_Line_Item[]
1486
-     */
1487
-    protected function _get_descendants_of_type($type)
1488
-    {
1489
-        EE_Error::doing_it_wrong(
1490
-            'EE_Line_Item::_get_descendants_of_type()',
1491
-            __('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0'
1492
-        );
1493
-        return EEH_Line_Item::get_descendants_of_type($this, $type);
1494
-    }
1495
-
1496
-
1497
-
1498
-    /**
1499
-     * @deprecated 4.6.0
1500
-     * @param string $type like one of the EEM_Line_Item::type_*
1501
-     * @return EE_Line_Item
1502
-     */
1503
-    public function get_nearest_descendant_of_type($type)
1504
-    {
1505
-        EE_Error::doing_it_wrong(
1506
-            'EE_Line_Item::get_nearest_descendant_of_type()',
1507
-            __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0'
1508
-        );
1509
-        return EEH_Line_Item::get_nearest_descendant_of_type($this, $type);
1510
-    }
21
+	/**
22
+	 * for children line items (currently not a normal relation)
23
+	 *
24
+	 * @type EE_Line_Item[]
25
+	 */
26
+	protected $_children = array();
27
+
28
+	/**
29
+	 * for the parent line item
30
+	 *
31
+	 * @var EE_Line_Item
32
+	 */
33
+	protected $_parent;
34
+
35
+
36
+
37
+	/**
38
+	 *
39
+	 * @param array  $props_n_values          incoming values
40
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
41
+	 *                                        used.)
42
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
43
+	 *                                        date_format and the second value is the time format
44
+	 * @return EE_Line_Item
45
+	 * @throws EE_Error
46
+	 */
47
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
48
+	{
49
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
50
+		return $has_object
51
+			? $has_object
52
+			: new self($props_n_values, false, $timezone);
53
+	}
54
+
55
+
56
+
57
+	/**
58
+	 * @param array  $props_n_values  incoming values from the database
59
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
60
+	 *                                the website will be used.
61
+	 * @return EE_Line_Item
62
+	 * @throws EE_Error
63
+	 */
64
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
65
+	{
66
+		return new self($props_n_values, true, $timezone);
67
+	}
68
+
69
+
70
+
71
+	/**
72
+	 * Adds some defaults if they're not specified
73
+	 *
74
+	 * @param array  $fieldValues
75
+	 * @param bool   $bydb
76
+	 * @param string $timezone
77
+	 * @throws EE_Error
78
+	 */
79
+	protected function __construct($fieldValues = array(), $bydb = false, $timezone = '')
80
+	{
81
+		parent::__construct($fieldValues, $bydb, $timezone);
82
+		if (! $this->get('LIN_code')) {
83
+			$this->set_code($this->generate_code());
84
+		}
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 * Gets ID
91
+	 *
92
+	 * @return int
93
+	 * @throws EE_Error
94
+	 */
95
+	public function ID()
96
+	{
97
+		return $this->get('LIN_ID');
98
+	}
99
+
100
+
101
+
102
+	/**
103
+	 * Gets TXN_ID
104
+	 *
105
+	 * @return int
106
+	 * @throws EE_Error
107
+	 */
108
+	public function TXN_ID()
109
+	{
110
+		return $this->get('TXN_ID');
111
+	}
112
+
113
+
114
+
115
+	/**
116
+	 * Sets TXN_ID
117
+	 *
118
+	 * @param int $TXN_ID
119
+	 * @throws EE_Error
120
+	 */
121
+	public function set_TXN_ID($TXN_ID)
122
+	{
123
+		$this->set('TXN_ID', $TXN_ID);
124
+	}
125
+
126
+
127
+
128
+	/**
129
+	 * Gets name
130
+	 *
131
+	 * @return string
132
+	 * @throws EE_Error
133
+	 */
134
+	public function name()
135
+	{
136
+		$name = $this->get('LIN_name');
137
+		if (! $name) {
138
+			$name = ucwords(str_replace('-', ' ', $this->type()));
139
+		}
140
+		return $name;
141
+	}
142
+
143
+
144
+
145
+	/**
146
+	 * Sets name
147
+	 *
148
+	 * @param string $name
149
+	 * @throws EE_Error
150
+	 */
151
+	public function set_name($name)
152
+	{
153
+		$this->set('LIN_name', $name);
154
+	}
155
+
156
+
157
+
158
+	/**
159
+	 * Gets desc
160
+	 *
161
+	 * @return string
162
+	 * @throws EE_Error
163
+	 */
164
+	public function desc()
165
+	{
166
+		return $this->get('LIN_desc');
167
+	}
168
+
169
+
170
+
171
+	/**
172
+	 * Sets desc
173
+	 *
174
+	 * @param string $desc
175
+	 * @throws EE_Error
176
+	 */
177
+	public function set_desc($desc)
178
+	{
179
+		$this->set('LIN_desc', $desc);
180
+	}
181
+
182
+
183
+
184
+	/**
185
+	 * Gets quantity
186
+	 *
187
+	 * @return int
188
+	 * @throws EE_Error
189
+	 */
190
+	public function quantity()
191
+	{
192
+		return $this->get('LIN_quantity');
193
+	}
194
+
195
+
196
+
197
+	/**
198
+	 * Sets quantity
199
+	 *
200
+	 * @param int $quantity
201
+	 * @throws EE_Error
202
+	 */
203
+	public function set_quantity($quantity)
204
+	{
205
+		$this->set('LIN_quantity', max($quantity, 0));
206
+	}
207
+
208
+
209
+
210
+	/**
211
+	 * Gets item_id
212
+	 *
213
+	 * @return string
214
+	 * @throws EE_Error
215
+	 */
216
+	public function OBJ_ID()
217
+	{
218
+		return $this->get('OBJ_ID');
219
+	}
220
+
221
+
222
+
223
+	/**
224
+	 * Sets item_id
225
+	 *
226
+	 * @param string $item_id
227
+	 * @throws EE_Error
228
+	 */
229
+	public function set_OBJ_ID($item_id)
230
+	{
231
+		$this->set('OBJ_ID', $item_id);
232
+	}
233
+
234
+
235
+
236
+	/**
237
+	 * Gets item_type
238
+	 *
239
+	 * @return string
240
+	 * @throws EE_Error
241
+	 */
242
+	public function OBJ_type()
243
+	{
244
+		return $this->get('OBJ_type');
245
+	}
246
+
247
+
248
+
249
+	/**
250
+	 * Gets item_type
251
+	 *
252
+	 * @return string
253
+	 * @throws EE_Error
254
+	 */
255
+	public function OBJ_type_i18n()
256
+	{
257
+		$obj_type = $this->OBJ_type();
258
+		switch ($obj_type) {
259
+			case 'Event':
260
+				$obj_type = __('Event', 'event_espresso');
261
+				break;
262
+			case 'Price':
263
+				$obj_type = __('Price', 'event_espresso');
264
+				break;
265
+			case 'Promotion':
266
+				$obj_type = __('Promotion', 'event_espresso');
267
+				break;
268
+			case 'Ticket':
269
+				$obj_type = __('Ticket', 'event_espresso');
270
+				break;
271
+			case 'Transaction':
272
+				$obj_type = __('Transaction', 'event_espresso');
273
+				break;
274
+		}
275
+		return apply_filters('FHEE__EE_Line_Item__OBJ_type_i18n', $obj_type, $this);
276
+	}
277
+
278
+
279
+
280
+	/**
281
+	 * Sets item_type
282
+	 *
283
+	 * @param string $OBJ_type
284
+	 * @throws EE_Error
285
+	 */
286
+	public function set_OBJ_type($OBJ_type)
287
+	{
288
+		$this->set('OBJ_type', $OBJ_type);
289
+	}
290
+
291
+
292
+
293
+	/**
294
+	 * Gets unit_price
295
+	 *
296
+	 * @return float
297
+	 * @throws EE_Error
298
+	 */
299
+	public function unit_price()
300
+	{
301
+		return $this->get('LIN_unit_price');
302
+	}
303
+
304
+
305
+
306
+	/**
307
+	 * Sets unit_price
308
+	 *
309
+	 * @param float $unit_price
310
+	 * @throws EE_Error
311
+	 */
312
+	public function set_unit_price($unit_price)
313
+	{
314
+		$this->set('LIN_unit_price', $unit_price);
315
+	}
316
+
317
+
318
+
319
+	/**
320
+	 * Checks if this item is a percentage modifier or not
321
+	 *
322
+	 * @return boolean
323
+	 * @throws EE_Error
324
+	 */
325
+	public function is_percent()
326
+	{
327
+		if ($this->is_tax_sub_total()) {
328
+			//tax subtotals HAVE a percent on them, that percentage only applies
329
+			//to taxable items, so its' an exception. Treat it like a flat line item
330
+			return false;
331
+		}
332
+		$unit_price = abs($this->get('LIN_unit_price'));
333
+		$percent = abs($this->get('LIN_percent'));
334
+		if ($unit_price < .001 && $percent) {
335
+			return true;
336
+		}
337
+		if ($unit_price >= .001 && ! $percent) {
338
+			return false;
339
+		}
340
+		if ($unit_price >= .001 && $percent) {
341
+			throw new EE_Error(
342
+				sprintf(
343
+					esc_html__('A Line Item can not have a unit price of (%s) AND a percent (%s)!', 'event_espresso'),
344
+					$unit_price, $percent
345
+				)
346
+			);
347
+		}
348
+		// if they're both 0, assume its not a percent item
349
+		return false;
350
+	}
351
+
352
+
353
+
354
+	/**
355
+	 * Gets percent (between 100-.001)
356
+	 *
357
+	 * @return float
358
+	 * @throws EE_Error
359
+	 */
360
+	public function percent()
361
+	{
362
+		return $this->get('LIN_percent');
363
+	}
364
+
365
+
366
+
367
+	/**
368
+	 * Sets percent (between 100-0.01)
369
+	 *
370
+	 * @param float $percent
371
+	 * @throws EE_Error
372
+	 */
373
+	public function set_percent($percent)
374
+	{
375
+		$this->set('LIN_percent', $percent);
376
+	}
377
+
378
+
379
+
380
+	/**
381
+	 * Gets total
382
+	 *
383
+	 * @return float
384
+	 * @throws EE_Error
385
+	 */
386
+	public function total()
387
+	{
388
+		return $this->get('LIN_total');
389
+	}
390
+
391
+
392
+
393
+	/**
394
+	 * Sets total
395
+	 *
396
+	 * @param float $total
397
+	 * @throws EE_Error
398
+	 */
399
+	public function set_total($total)
400
+	{
401
+		$this->set('LIN_total', $total);
402
+	}
403
+
404
+
405
+
406
+	/**
407
+	 * Gets order
408
+	 *
409
+	 * @return int
410
+	 * @throws EE_Error
411
+	 */
412
+	public function order()
413
+	{
414
+		return $this->get('LIN_order');
415
+	}
416
+
417
+
418
+
419
+	/**
420
+	 * Sets order
421
+	 *
422
+	 * @param int $order
423
+	 * @throws EE_Error
424
+	 */
425
+	public function set_order($order)
426
+	{
427
+		$this->set('LIN_order', $order);
428
+	}
429
+
430
+
431
+
432
+	/**
433
+	 * Gets parent
434
+	 *
435
+	 * @return int
436
+	 * @throws EE_Error
437
+	 */
438
+	public function parent_ID()
439
+	{
440
+		return $this->get('LIN_parent');
441
+	}
442
+
443
+
444
+
445
+	/**
446
+	 * Sets parent
447
+	 *
448
+	 * @param int $parent
449
+	 * @throws EE_Error
450
+	 */
451
+	public function set_parent_ID($parent)
452
+	{
453
+		$this->set('LIN_parent', $parent);
454
+	}
455
+
456
+
457
+
458
+	/**
459
+	 * Gets type
460
+	 *
461
+	 * @return string
462
+	 * @throws EE_Error
463
+	 */
464
+	public function type()
465
+	{
466
+		return $this->get('LIN_type');
467
+	}
468
+
469
+
470
+
471
+	/**
472
+	 * Sets type
473
+	 *
474
+	 * @param string $type
475
+	 * @throws EE_Error
476
+	 */
477
+	public function set_type($type)
478
+	{
479
+		$this->set('LIN_type', $type);
480
+	}
481
+
482
+
483
+
484
+	/**
485
+	 * Gets the line item of which this item is a composite. Eg, if this is a subtotal, the parent might be a total\
486
+	 * If this line item is saved to the DB, fetches the parent from the DB. However, if this line item isn't in the DB
487
+	 * it uses its cached reference to its parent line item (which would have been set by `EE_Line_Item::set_parent()`
488
+	 * or indirectly by `EE_Line_item::add_child_line_item()`)
489
+	 *
490
+	 * @return EE_Base_Class|EE_Line_Item
491
+	 * @throws EE_Error
492
+	 */
493
+	public function parent()
494
+	{
495
+		return $this->ID()
496
+			? $this->get_model()->get_one_by_ID($this->parent_ID())
497
+			: $this->_parent;
498
+	}
499
+
500
+
501
+
502
+	/**
503
+	 * Gets ALL the children of this line item (ie, all the parts that contribute towards this total).
504
+	 *
505
+	 * @return EE_Base_Class[]|EE_Line_Item[]
506
+	 * @throws EE_Error
507
+	 */
508
+	public function children()
509
+	{
510
+		if ($this->ID()) {
511
+			return $this->get_model()->get_all(
512
+				array(
513
+					array('LIN_parent' => $this->ID()),
514
+					'order_by' => array('LIN_order' => 'ASC'),
515
+				)
516
+			);
517
+		}
518
+		if (! is_array($this->_children)) {
519
+			$this->_children = array();
520
+		}
521
+		return $this->_children;
522
+	}
523
+
524
+
525
+
526
+	/**
527
+	 * Gets code
528
+	 *
529
+	 * @return string
530
+	 * @throws EE_Error
531
+	 */
532
+	public function code()
533
+	{
534
+		return $this->get('LIN_code');
535
+	}
536
+
537
+
538
+
539
+	/**
540
+	 * Sets code
541
+	 *
542
+	 * @param string $code
543
+	 * @throws EE_Error
544
+	 */
545
+	public function set_code($code)
546
+	{
547
+		$this->set('LIN_code', $code);
548
+	}
549
+
550
+
551
+
552
+	/**
553
+	 * Gets is_taxable
554
+	 *
555
+	 * @return boolean
556
+	 * @throws EE_Error
557
+	 */
558
+	public function is_taxable()
559
+	{
560
+		return $this->get('LIN_is_taxable');
561
+	}
562
+
563
+
564
+
565
+	/**
566
+	 * Sets is_taxable
567
+	 *
568
+	 * @param boolean $is_taxable
569
+	 * @throws EE_Error
570
+	 */
571
+	public function set_is_taxable($is_taxable)
572
+	{
573
+		$this->set('LIN_is_taxable', $is_taxable);
574
+	}
575
+
576
+
577
+
578
+	/**
579
+	 * Gets the object that this model-joins-to.
580
+	 * returns one of the model objects that the field OBJ_ID can point to... see the 'OBJ_ID' field on
581
+	 * EEM_Promotion_Object
582
+	 *
583
+	 *        Eg, if this line item join model object is for a ticket, this will return the EE_Ticket object
584
+	 *
585
+	 * @return EE_Base_Class | NULL
586
+	 * @throws EE_Error
587
+	 */
588
+	public function get_object()
589
+	{
590
+		$model_name_of_related_obj = $this->OBJ_type();
591
+		return $this->get_model()->has_relation($model_name_of_related_obj)
592
+			? $this->get_first_related($model_name_of_related_obj)
593
+			: null;
594
+	}
595
+
596
+
597
+
598
+	/**
599
+	 * Like EE_Line_Item::get_object(), but can only ever actually return an EE_Ticket.
600
+	 * (IE, if this line item is for a price or something else, will return NULL)
601
+	 *
602
+	 * @param array $query_params
603
+	 * @return EE_Base_Class|EE_Ticket
604
+	 * @throws EE_Error
605
+	 */
606
+	public function ticket($query_params = array())
607
+	{
608
+		//we're going to assume that when this method is called we always want to receive the attached ticket EVEN if that ticket is archived.  This can be overridden via the incoming $query_params argument
609
+		$remove_defaults = array('default_where_conditions' => 'none');
610
+		$query_params = array_merge($remove_defaults, $query_params);
611
+		return $this->get_first_related('Ticket', $query_params);
612
+	}
613
+
614
+
615
+
616
+	/**
617
+	 * Gets the EE_Datetime that's related to the ticket, IF this is for a ticket
618
+	 *
619
+	 * @return EE_Datetime | NULL
620
+	 * @throws EE_Error
621
+	 */
622
+	public function get_ticket_datetime()
623
+	{
624
+		if ($this->OBJ_type() === 'Ticket') {
625
+			$ticket = $this->ticket();
626
+			if ($ticket instanceof EE_Ticket) {
627
+				$datetime = $ticket->first_datetime();
628
+				if ($datetime instanceof EE_Datetime) {
629
+					return $datetime;
630
+				}
631
+			}
632
+		}
633
+		return null;
634
+	}
635
+
636
+
637
+
638
+	/**
639
+	 * Gets the event's name that's related to the ticket, if this is for
640
+	 * a ticket
641
+	 *
642
+	 * @return string
643
+	 * @throws EE_Error
644
+	 */
645
+	public function ticket_event_name()
646
+	{
647
+		$event_name = esc_html__('Unknown', 'event_espresso');
648
+		$event = $this->ticket_event();
649
+		if ($event instanceof EE_Event) {
650
+			$event_name = $event->name();
651
+		}
652
+		return $event_name;
653
+	}
654
+
655
+
656
+	/**
657
+	 * Gets the event that's related to the ticket, if this line item represents a ticket.
658
+	 *
659
+	 * @return EE_Event|null
660
+	 * @throws EE_Error
661
+	 */
662
+	public function ticket_event()
663
+	{
664
+		$event = null;
665
+		$ticket = $this->ticket();
666
+		if ($ticket instanceof EE_Ticket) {
667
+			$datetime = $ticket->first_datetime();
668
+			if ($datetime instanceof EE_Datetime) {
669
+				$event = $datetime->event();
670
+			}
671
+		}
672
+		return $event;
673
+	}
674
+
675
+
676
+
677
+	/**
678
+	 * Gets the first datetime for this lien item, assuming it's for a ticket
679
+	 *
680
+	 * @param string $date_format
681
+	 * @param string $time_format
682
+	 * @return string
683
+	 * @throws EE_Error
684
+	 */
685
+	public function ticket_datetime_start($date_format = '', $time_format = '')
686
+	{
687
+		$first_datetime_string = esc_html__('Unknown', 'event_espresso');
688
+		$datetime = $this->get_ticket_datetime();
689
+		if ($datetime) {
690
+			$first_datetime_string = $datetime->start_date_and_time($date_format, $time_format);
691
+		}
692
+		return $first_datetime_string;
693
+	}
694
+
695
+
696
+
697
+	/**
698
+	 * Adds the line item as a child to this line item. If there is another child line
699
+	 * item with the same LIN_code, it is overwritten by this new one
700
+	 *
701
+	 * @param EEI_Line_Item $line_item
702
+	 * @param bool          $set_order
703
+	 * @return bool success
704
+	 * @throws EE_Error
705
+	 */
706
+	public function add_child_line_item(EEI_Line_Item $line_item, $set_order = true)
707
+	{
708
+		// should we calculate the LIN_order for this line item ?
709
+		if ($set_order || $line_item->order() === null) {
710
+			$line_item->set_order(count($this->children()));
711
+		}
712
+		if ($this->ID()) {
713
+			//check for any duplicate line items (with the same code), if so, this replaces it
714
+			$line_item_with_same_code = $this->get_child_line_item($line_item->code());
715
+			if ($line_item_with_same_code instanceof EE_Line_Item && $line_item_with_same_code !== $line_item) {
716
+				$this->delete_child_line_item($line_item_with_same_code->code());
717
+			}
718
+			$line_item->set_parent_ID($this->ID());
719
+			if ($this->TXN_ID()) {
720
+				$line_item->set_TXN_ID($this->TXN_ID());
721
+			}
722
+			return $line_item->save();
723
+		}
724
+		$this->_children[$line_item->code()] = $line_item;
725
+		if ($line_item->parent() !== $this) {
726
+			$line_item->set_parent($this);
727
+		}
728
+		return true;
729
+	}
730
+
731
+
732
+	/**
733
+	 * Similar to EE_Base_Class::_add_relation_to, except this isn't a normal relation.
734
+	 * If this line item is saved to the DB, this is just a wrapper for set_parent_ID() and save()
735
+	 * However, if this line item is NOT saved to the DB, this just caches the parent on
736
+	 * the EE_Line_Item::_parent property.
737
+	 *
738
+	 * @param EE_Line_Item $line_item
739
+	 * @throws EE_Error
740
+	 */
741
+	public function set_parent($line_item)
742
+	{
743
+		if ($this->ID()) {
744
+			if (! $line_item->ID()) {
745
+				$line_item->save();
746
+			}
747
+			$this->set_parent_ID($line_item->ID());
748
+			$this->save();
749
+		} else {
750
+			$this->_parent = $line_item;
751
+			$this->set_parent_ID($line_item->ID());
752
+		}
753
+	}
754
+
755
+
756
+
757
+	/**
758
+	 * Gets the child line item as specified by its code. Because this returns an object (by reference)
759
+	 * you can modify this child line item and the parent (this object) can know about them
760
+	 * because it also has a reference to that line item
761
+	 *
762
+	 * @param string $code
763
+	 * @return EE_Base_Class|EE_Line_Item|EE_Soft_Delete_Base_Class|NULL
764
+	 * @throws EE_Error
765
+	 */
766
+	public function get_child_line_item($code)
767
+	{
768
+		if ($this->ID()) {
769
+			return $this->get_model()->get_one(
770
+				array(array('LIN_parent' => $this->ID(), 'LIN_code' => $code))
771
+			);
772
+		}
773
+		return isset($this->_children[$code])
774
+			? $this->_children[$code]
775
+			: null;
776
+	}
777
+
778
+
779
+
780
+	/**
781
+	 * Returns how many items are deleted (or, if this item has not been saved ot the DB yet, just how many it HAD
782
+	 * cached on it)
783
+	 *
784
+	 * @return int
785
+	 * @throws EE_Error
786
+	 */
787
+	public function delete_children_line_items()
788
+	{
789
+		if ($this->ID()) {
790
+			return $this->get_model()->delete(array(array('LIN_parent' => $this->ID())));
791
+		}
792
+		$count = count($this->_children);
793
+		$this->_children = array();
794
+		return $count;
795
+	}
796
+
797
+
798
+
799
+	/**
800
+	 * If this line item has been saved to the DB, deletes its child with LIN_code == $code. If this line
801
+	 * HAS NOT been saved to the DB, removes the child line item with index $code.
802
+	 * Also searches through the child's children for a matching line item. However, once a line item has been found
803
+	 * and deleted, stops searching (so if there are line items with duplicate codes, only the first one found will be
804
+	 * deleted)
805
+	 *
806
+	 * @param string $code
807
+	 * @param bool   $stop_search_once_found
808
+	 * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to
809
+	 *             the DB yet)
810
+	 * @throws EE_Error
811
+	 */
812
+	public function delete_child_line_item($code, $stop_search_once_found = true)
813
+	{
814
+		if ($this->ID()) {
815
+			$items_deleted = 0;
816
+			if ($this->code() === $code) {
817
+				$items_deleted += EEH_Line_Item::delete_all_child_items($this);
818
+				$items_deleted += (int)$this->delete();
819
+				if ($stop_search_once_found) {
820
+					return $items_deleted;
821
+				}
822
+			}
823
+			foreach ($this->children() as $child_line_item) {
824
+				$items_deleted += $child_line_item->delete_child_line_item($code, $stop_search_once_found);
825
+			}
826
+			return $items_deleted;
827
+		}
828
+		if (isset($this->_children[$code])) {
829
+			unset($this->_children[$code]);
830
+			return 1;
831
+		}
832
+		return 0;
833
+	}
834
+
835
+
836
+	/**
837
+	 * If this line item is in the database, is of the type subtotal, and
838
+	 * has no children, why do we have it? It should be deleted so this function
839
+	 * does that
840
+	 *
841
+	 * @return boolean
842
+	 * @throws EE_Error
843
+	 */
844
+	public function delete_if_childless_subtotal()
845
+	{
846
+		if ($this->ID() && $this->type() === EEM_Line_Item::type_sub_total && ! $this->children()) {
847
+			return $this->delete();
848
+		}
849
+		return false;
850
+	}
851
+
852
+
853
+
854
+	/**
855
+	 * Creates a code and returns a string. doesn't assign the code to this model object
856
+	 *
857
+	 * @return string
858
+	 * @throws EE_Error
859
+	 */
860
+	public function generate_code()
861
+	{
862
+		// each line item in the cart requires a unique identifier
863
+		return md5($this->get('OBJ_type') . $this->get('OBJ_ID') . microtime());
864
+	}
865
+
866
+
867
+
868
+	/**
869
+	 * @return bool
870
+	 * @throws EE_Error
871
+	 */
872
+	public function is_tax()
873
+	{
874
+		return $this->type() === EEM_Line_Item::type_tax;
875
+	}
876
+
877
+
878
+
879
+	/**
880
+	 * @return bool
881
+	 * @throws EE_Error
882
+	 */
883
+	public function is_tax_sub_total()
884
+	{
885
+		return $this->type() === EEM_Line_Item::type_tax_sub_total;
886
+	}
887
+
888
+
889
+
890
+	/**
891
+	 * @return bool
892
+	 * @throws EE_Error
893
+	 */
894
+	public function is_line_item()
895
+	{
896
+		return $this->type() === EEM_Line_Item::type_line_item;
897
+	}
898
+
899
+
900
+
901
+	/**
902
+	 * @return bool
903
+	 * @throws EE_Error
904
+	 */
905
+	public function is_sub_line_item()
906
+	{
907
+		return $this->type() === EEM_Line_Item::type_sub_line_item;
908
+	}
909
+
910
+
911
+
912
+	/**
913
+	 * @return bool
914
+	 * @throws EE_Error
915
+	 */
916
+	public function is_sub_total()
917
+	{
918
+		return $this->type() === EEM_Line_Item::type_sub_total;
919
+	}
920
+
921
+
922
+
923
+	/**
924
+	 * Whether or not this line item is a cancellation line item
925
+	 *
926
+	 * @return boolean
927
+	 * @throws EE_Error
928
+	 */
929
+	public function is_cancellation()
930
+	{
931
+		return EEM_Line_Item::type_cancellation === $this->type();
932
+	}
933
+
934
+
935
+
936
+	/**
937
+	 * @return bool
938
+	 * @throws EE_Error
939
+	 */
940
+	public function is_total()
941
+	{
942
+		return $this->type() === EEM_Line_Item::type_total;
943
+	}
944
+
945
+
946
+
947
+	/**
948
+	 * @return bool
949
+	 * @throws EE_Error
950
+	 */
951
+	public function is_cancelled()
952
+	{
953
+		return $this->type() === EEM_Line_Item::type_cancellation;
954
+	}
955
+
956
+
957
+
958
+	/**
959
+	 * @return string like '2, 004.00', formatted according to the localized currency
960
+	 * @throws EE_Error
961
+	 */
962
+	public function unit_price_no_code()
963
+	{
964
+		return $this->get_pretty('LIN_unit_price', 'no_currency_code');
965
+	}
966
+
967
+
968
+
969
+	/**
970
+	 * @return string like '2, 004.00', formatted according to the localized currency
971
+	 * @throws EE_Error
972
+	 */
973
+	public function total_no_code()
974
+	{
975
+		return $this->get_pretty('LIN_total', 'no_currency_code');
976
+	}
977
+
978
+
979
+
980
+	/**
981
+	 * Gets the final total on this item, taking taxes into account.
982
+	 * Has the side-effect of setting the sub-total as it was just calculated.
983
+	 * If this is used on a grand-total line item, also updates the transaction's
984
+	 * TXN_total (provided this line item is allowed to persist, otherwise we don't
985
+	 * want to change a persistable transaction with info from a non-persistent line item)
986
+	 *
987
+	 * @return float
988
+	 * @throws EE_Error
989
+	 * @throws InvalidArgumentException
990
+	 * @throws InvalidInterfaceException
991
+	 * @throws InvalidDataTypeException
992
+	 */
993
+	public function recalculate_total_including_taxes()
994
+	{
995
+		$pre_tax_total = $this->recalculate_pre_tax_total();
996
+		$tax_total = $this->recalculate_taxes_and_tax_total();
997
+		$total = $pre_tax_total + $tax_total;
998
+		// no negative totals plz
999
+		$total = max($total, 0);
1000
+		$this->set_total($total);
1001
+		//only update the related transaction's total
1002
+		//if we intend to save this line item and its a grand total
1003
+		if (
1004
+			$this->allow_persist() && $this->type() === EEM_Line_Item::type_total
1005
+			&& $this->transaction()
1006
+			   instanceof
1007
+			   EE_Transaction
1008
+		) {
1009
+			$this->transaction()->set_total($total);
1010
+			if ($this->transaction()->ID()) {
1011
+				$this->transaction()->save();
1012
+			}
1013
+		}
1014
+		$this->maybe_save();
1015
+		return $total;
1016
+	}
1017
+
1018
+
1019
+	/**
1020
+	 * Recursively goes through all the children and recalculates sub-totals EXCEPT for
1021
+	 * tax-sub-totals (they're a an odd beast). Updates the 'total' on each line item according to either its
1022
+	 * unit price * quantity or the total of all its children EXCEPT when we're only calculating the taxable total and
1023
+	 * when this is called on the grand total
1024
+	 *
1025
+	 * @return float
1026
+	 * @throws InvalidArgumentException
1027
+	 * @throws InvalidInterfaceException
1028
+	 * @throws InvalidDataTypeException
1029
+	 * @throws EE_Error
1030
+	 */
1031
+	public function recalculate_pre_tax_total()
1032
+	{
1033
+		$total = 0;
1034
+		$my_children = $this->children();
1035
+		$has_children = ! empty($my_children);
1036
+		if ($has_children && $this->is_line_item()) {
1037
+			$total = $this->_recalculate_pretax_total_for_line_item($total, $my_children);
1038
+		} elseif (! $has_children && ($this->is_sub_line_item() || $this->is_line_item())) {
1039
+			$total = $this->unit_price() * $this->quantity();
1040
+		} elseif ($this->is_sub_total() || $this->is_total()) {
1041
+			$total = $this->_recalculate_pretax_total_for_subtotal($total, $my_children);
1042
+		} elseif ($this->is_tax_sub_total() || $this->is_tax() || $this->is_cancelled()) {
1043
+			// completely ignore tax totals, tax sub-totals, and cancelled line items, when calculating the pre-tax-total
1044
+			return 0;
1045
+		}
1046
+		// ensure all non-line items and non-sub-line-items have a quantity of 1 (except for Events)
1047
+		if (
1048
+			! $this->is_line_item() && ! $this->is_sub_line_item() && ! $this->is_cancellation()
1049
+		) {
1050
+			if ($this->OBJ_type() !== 'Event') {
1051
+				$this->set_quantity(1);
1052
+			}
1053
+			if (! $this->is_percent()) {
1054
+				$this->set_unit_price($total);
1055
+			}
1056
+		}
1057
+		//we don't want to bother saving grand totals, because that needs to factor in taxes anyways
1058
+		//so it ought to be
1059
+		if (! $this->is_total()) {
1060
+			$this->set_total($total);
1061
+			//if not a percent line item, make sure we keep the unit price in sync
1062
+			if (
1063
+				$has_children
1064
+				&& $this->is_line_item()
1065
+				&& ! $this->is_percent()
1066
+			) {
1067
+				if ($this->quantity() === 0) {
1068
+					$new_unit_price = 0;
1069
+				} else {
1070
+					$new_unit_price = $this->total() / $this->quantity();
1071
+				}
1072
+				$this->set_unit_price($new_unit_price);
1073
+			}
1074
+			$this->maybe_save();
1075
+		}
1076
+		return $total;
1077
+	}
1078
+
1079
+
1080
+
1081
+	/**
1082
+	 * Calculates the pretax total when this line item is a subtotal or total line item.
1083
+	 * Basically does a sum-then-round approach (ie, any percent line item that are children
1084
+	 * will calculate their total based on the un-rounded total we're working with so far, and
1085
+	 * THEN round the result; instead of rounding as we go like with sub-line-items)
1086
+	 *
1087
+	 * @param float          $calculated_total_so_far
1088
+	 * @param EE_Line_Item[] $my_children
1089
+	 * @return float
1090
+	 * @throws InvalidArgumentException
1091
+	 * @throws InvalidInterfaceException
1092
+	 * @throws InvalidDataTypeException
1093
+	 * @throws EE_Error
1094
+	 */
1095
+	protected function _recalculate_pretax_total_for_subtotal($calculated_total_so_far, $my_children = null)
1096
+	{
1097
+		if ($my_children === null) {
1098
+			$my_children = $this->children();
1099
+		}
1100
+		//get the total of all its children
1101
+		foreach ($my_children as $child_line_item) {
1102
+			if ($child_line_item instanceof EE_Line_Item && ! $child_line_item->is_cancellation()) {
1103
+				// percentage line items are based on total so far
1104
+				if ($child_line_item->is_percent()) {
1105
+					//round as we go so that the line items add up ok
1106
+					$percent_total = round(
1107
+						$calculated_total_so_far * $child_line_item->percent() / 100,
1108
+						EE_Registry::instance()->CFG->currency->dec_plc
1109
+					);
1110
+					$child_line_item->set_total($percent_total);
1111
+					//so far all percent line items should have a quantity of 1
1112
+					//(ie, no double percent discounts. Although that might be requested someday)
1113
+					$child_line_item->set_quantity(1);
1114
+					$child_line_item->maybe_save();
1115
+					$calculated_total_so_far += $percent_total;
1116
+				} else {
1117
+					//verify flat sub-line-item quantities match their parent
1118
+					if ($child_line_item->is_sub_line_item()) {
1119
+						$child_line_item->set_quantity($this->quantity());
1120
+					}
1121
+					$calculated_total_so_far += $child_line_item->recalculate_pre_tax_total();
1122
+				}
1123
+			}
1124
+		}
1125
+		if ($this->is_sub_total()) {
1126
+			// no negative totals plz
1127
+			$calculated_total_so_far = max($calculated_total_so_far, 0);
1128
+		}
1129
+		return $calculated_total_so_far;
1130
+	}
1131
+
1132
+
1133
+
1134
+	/**
1135
+	 * Calculates the pretax total for a normal line item, in a round-then-sum approach
1136
+	 * (where each sub-line-item is applied to the base price for the line item
1137
+	 * and the result is immediately rounded, rather than summing all the sub-line-items
1138
+	 * then rounding, like we do when recalculating pretax totals on totals and subtotals).
1139
+	 *
1140
+	 * @param float          $calculated_total_so_far
1141
+	 * @param EE_Line_Item[] $my_children
1142
+	 * @return float
1143
+	 * @throws InvalidArgumentException
1144
+	 * @throws InvalidInterfaceException
1145
+	 * @throws InvalidDataTypeException
1146
+	 * @throws EE_Error
1147
+	 */
1148
+	protected function _recalculate_pretax_total_for_line_item($calculated_total_so_far, $my_children = null)
1149
+	{
1150
+		if ($my_children === null) {
1151
+			$my_children = $this->children();
1152
+		}
1153
+		//we need to keep track of the running total for a single item,
1154
+		//because we need to round as we go
1155
+		$unit_price_for_total = 0;
1156
+		$quantity_for_total = 1;
1157
+		//get the total of all its children
1158
+		foreach ($my_children as $child_line_item) {
1159
+			if ($child_line_item instanceof EE_Line_Item && ! $child_line_item->is_cancellation()) {
1160
+				if ($child_line_item->is_percent()) {
1161
+					//it should be the unit-price-so-far multiplied by teh percent multiplied by the quantity
1162
+					//not total multiplied by percent, because that ignores rounding along-the-way
1163
+					$percent_unit_price = round(
1164
+						$unit_price_for_total * $child_line_item->percent() / 100,
1165
+						EE_Registry::instance()->CFG->currency->dec_plc
1166
+					);
1167
+					$percent_total = $percent_unit_price * $quantity_for_total;
1168
+					$child_line_item->set_total($percent_total);
1169
+					//so far all percent line items should have a quantity of 1
1170
+					//(ie, no double percent discounts. Although that might be requested someday)
1171
+					$child_line_item->set_quantity(1);
1172
+					$child_line_item->maybe_save();
1173
+					$calculated_total_so_far += $percent_total;
1174
+					$unit_price_for_total += $percent_unit_price;
1175
+				} else {
1176
+					//verify flat sub-line-item quantities match their parent
1177
+					if ($child_line_item->is_sub_line_item()) {
1178
+						$child_line_item->set_quantity($this->quantity());
1179
+					}
1180
+					$quantity_for_total = $child_line_item->quantity();
1181
+					$calculated_total_so_far += $child_line_item->recalculate_pre_tax_total();
1182
+					$unit_price_for_total += $child_line_item->unit_price();
1183
+				}
1184
+			}
1185
+		}
1186
+		return $calculated_total_so_far;
1187
+	}
1188
+
1189
+
1190
+
1191
+	/**
1192
+	 * Recalculates the total on each individual tax (based on a recalculation of the pre-tax total), sets
1193
+	 * the totals on each tax calculated, and returns the final tax total
1194
+	 *
1195
+	 * @return float
1196
+	 * @throws EE_Error
1197
+	 */
1198
+	public function recalculate_taxes_and_tax_total()
1199
+	{
1200
+		//get all taxes
1201
+		$taxes = $this->tax_descendants();
1202
+		//calculate the pretax total
1203
+		$taxable_total = $this->taxable_total();
1204
+		$tax_total = 0;
1205
+		foreach ($taxes as $tax) {
1206
+			$total_on_this_tax = $taxable_total * $tax->percent() / 100;
1207
+			//remember the total on this line item
1208
+			$tax->set_total($total_on_this_tax);
1209
+			$tax_total += $tax->total();
1210
+		}
1211
+		$this->_recalculate_tax_sub_total();
1212
+		return $tax_total;
1213
+	}
1214
+
1215
+
1216
+
1217
+	/**
1218
+	 * Simply forces all the tax-sub-totals to recalculate. Assumes the taxes have been calculated
1219
+	 *
1220
+	 * @return void
1221
+	 * @throws EE_Error
1222
+	 */
1223
+	private function _recalculate_tax_sub_total()
1224
+	{
1225
+		if ($this->is_tax_sub_total()) {
1226
+			$total = 0;
1227
+			$total_percent = 0;
1228
+			//simply loop through all its children (which should be taxes) and sum their total
1229
+			foreach ($this->children() as $child_tax) {
1230
+				if ($child_tax instanceof EE_Line_Item) {
1231
+					$total += $child_tax->total();
1232
+					$total_percent += $child_tax->percent();
1233
+				}
1234
+			}
1235
+			$this->set_total($total);
1236
+			$this->set_percent($total_percent);
1237
+		} elseif ($this->is_total()) {
1238
+			foreach ($this->children() as $maybe_tax_subtotal) {
1239
+				if ($maybe_tax_subtotal instanceof EE_Line_Item) {
1240
+					$maybe_tax_subtotal->_recalculate_tax_sub_total();
1241
+				}
1242
+			}
1243
+		}
1244
+	}
1245
+
1246
+
1247
+
1248
+	/**
1249
+	 * Gets the total tax on this line item. Assumes taxes have already been calculated using
1250
+	 * recalculate_taxes_and_total
1251
+	 *
1252
+	 * @return float
1253
+	 * @throws EE_Error
1254
+	 */
1255
+	public function get_total_tax()
1256
+	{
1257
+		$this->_recalculate_tax_sub_total();
1258
+		$total = 0;
1259
+		foreach ($this->tax_descendants() as $tax_line_item) {
1260
+			if ($tax_line_item instanceof EE_Line_Item) {
1261
+				$total += $tax_line_item->total();
1262
+			}
1263
+		}
1264
+		return $total;
1265
+	}
1266
+
1267
+
1268
+	/**
1269
+	 * Gets the total for all the items purchased only
1270
+	 *
1271
+	 * @return float
1272
+	 * @throws EE_Error
1273
+	 */
1274
+	public function get_items_total()
1275
+	{
1276
+		//by default, let's make sure we're consistent with the existing line item
1277
+		if ($this->is_total()) {
1278
+			$pretax_subtotal_li = EEH_Line_Item::get_pre_tax_subtotal($this);
1279
+			if ($pretax_subtotal_li instanceof EE_Line_Item) {
1280
+				return $pretax_subtotal_li->total();
1281
+			}
1282
+		}
1283
+		$total = 0;
1284
+		foreach ($this->get_items() as $item) {
1285
+			if ($item instanceof EE_Line_Item) {
1286
+				$total += $item->total();
1287
+			}
1288
+		}
1289
+		return $total;
1290
+	}
1291
+
1292
+
1293
+
1294
+	/**
1295
+	 * Gets all the descendants (ie, children or children of children etc) that
1296
+	 * are of the type 'tax'
1297
+	 *
1298
+	 * @return EE_Line_Item[]
1299
+	 */
1300
+	public function tax_descendants()
1301
+	{
1302
+		return EEH_Line_Item::get_tax_descendants($this);
1303
+	}
1304
+
1305
+
1306
+
1307
+	/**
1308
+	 * Gets all the real items purchased which are children of this item
1309
+	 *
1310
+	 * @return EE_Line_Item[]
1311
+	 */
1312
+	public function get_items()
1313
+	{
1314
+		return EEH_Line_Item::get_line_item_descendants($this);
1315
+	}
1316
+
1317
+
1318
+
1319
+	/**
1320
+	 * Returns the amount taxable among this line item's children (or if it has no children,
1321
+	 * how much of it is taxable). Does not recalculate totals or subtotals.
1322
+	 * If the taxable total is negative, (eg, if none of the tickets were taxable,
1323
+	 * but there is a "Taxable" discount), returns 0.
1324
+	 *
1325
+	 * @return float
1326
+	 * @throws EE_Error
1327
+	 */
1328
+	public function taxable_total()
1329
+	{
1330
+		$total = 0;
1331
+		if ($this->children()) {
1332
+			foreach ($this->children() as $child_line_item) {
1333
+				if ($child_line_item->type() === EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) {
1334
+					//if it's a percent item, only take into account the percent
1335
+					//that's taxable too (the taxable total so far)
1336
+					if ($child_line_item->is_percent()) {
1337
+						$total += ($total * $child_line_item->percent() / 100);
1338
+					} else {
1339
+						$total += $child_line_item->total();
1340
+					}
1341
+				} elseif ($child_line_item->type() === EEM_Line_Item::type_sub_total) {
1342
+					$total += $child_line_item->taxable_total();
1343
+				}
1344
+			}
1345
+		}
1346
+		return max($total, 0);
1347
+	}
1348
+
1349
+
1350
+
1351
+	/**
1352
+	 * Gets the transaction for this line item
1353
+	 *
1354
+	 * @return EE_Base_Class|EE_Transaction
1355
+	 * @throws EE_Error
1356
+	 */
1357
+	public function transaction()
1358
+	{
1359
+		return $this->get_first_related('Transaction');
1360
+	}
1361
+
1362
+
1363
+
1364
+	/**
1365
+	 * Saves this line item to the DB, and recursively saves its descendants.
1366
+	 * Because there currently is no proper parent-child relation on the model,
1367
+	 * save_this_and_cached() will NOT save the descendants.
1368
+	 * Also sets the transaction on this line item and all its descendants before saving
1369
+	 *
1370
+	 * @param int $txn_id if none is provided, assumes $this->TXN_ID()
1371
+	 * @return int count of items saved
1372
+	 * @throws EE_Error
1373
+	 */
1374
+	public function save_this_and_descendants_to_txn($txn_id = null)
1375
+	{
1376
+		$count = 0;
1377
+		if (! $txn_id) {
1378
+			$txn_id = $this->TXN_ID();
1379
+		}
1380
+		$this->set_TXN_ID($txn_id);
1381
+		$children = $this->children();
1382
+		$count += $this->save()
1383
+			? 1
1384
+			: 0;
1385
+		foreach ($children as $child_line_item) {
1386
+			if ($child_line_item instanceof EE_Line_Item) {
1387
+				$child_line_item->set_parent_ID($this->ID());
1388
+				$count += $child_line_item->save_this_and_descendants_to_txn($txn_id);
1389
+			}
1390
+		}
1391
+		return $count;
1392
+	}
1393
+
1394
+
1395
+
1396
+	/**
1397
+	 * Saves this line item to the DB, and recursively saves its descendants.
1398
+	 *
1399
+	 * @return int count of items saved
1400
+	 * @throws EE_Error
1401
+	 */
1402
+	public function save_this_and_descendants()
1403
+	{
1404
+		$count = 0;
1405
+		$children = $this->children();
1406
+		$count += $this->save()
1407
+			? 1
1408
+			: 0;
1409
+		foreach ($children as $child_line_item) {
1410
+			if ($child_line_item instanceof EE_Line_Item) {
1411
+				$child_line_item->set_parent_ID($this->ID());
1412
+				$count += $child_line_item->save_this_and_descendants();
1413
+			}
1414
+		}
1415
+		return $count;
1416
+	}
1417
+
1418
+
1419
+
1420
+	/**
1421
+	 * returns the cancellation line item if this item was cancelled
1422
+	 *
1423
+	 * @return EE_Line_Item[]
1424
+	 * @throws InvalidArgumentException
1425
+	 * @throws InvalidInterfaceException
1426
+	 * @throws InvalidDataTypeException
1427
+	 * @throws ReflectionException
1428
+	 * @throws EE_Error
1429
+	 */
1430
+	public function get_cancellations()
1431
+	{
1432
+		EE_Registry::instance()->load_helper('Line_Item');
1433
+		return EEH_Line_Item::get_descendants_of_type($this, EEM_Line_Item::type_cancellation);
1434
+	}
1435
+
1436
+
1437
+
1438
+	/**
1439
+	 * If this item has an ID, then this saves it again to update the db
1440
+	 *
1441
+	 * @return int count of items saved
1442
+	 * @throws EE_Error
1443
+	 */
1444
+	public function maybe_save()
1445
+	{
1446
+		if ($this->ID()) {
1447
+			return $this->save();
1448
+		}
1449
+		return false;
1450
+	}
1451
+
1452
+
1453
+	/**
1454
+	 * clears the cached children and parent from the line item
1455
+	 *
1456
+	 * @return void
1457
+	 */
1458
+	public function clear_related_line_item_cache()
1459
+	{
1460
+		$this->_children = array();
1461
+		$this->_parent = null;
1462
+	}
1463
+
1464
+
1465
+
1466
+	/**
1467
+	 * @param bool $raw
1468
+	 * @return int
1469
+	 * @throws EE_Error
1470
+	 */
1471
+	public function timestamp($raw = false)
1472
+	{
1473
+		return $raw
1474
+			? $this->get_raw('LIN_timestamp')
1475
+			: $this->get('LIN_timestamp');
1476
+	}
1477
+
1478
+
1479
+
1480
+
1481
+	/************************* DEPRECATED *************************/
1482
+	/**
1483
+	 * @deprecated 4.6.0
1484
+	 * @param string $type one of the constants on EEM_Line_Item
1485
+	 * @return EE_Line_Item[]
1486
+	 */
1487
+	protected function _get_descendants_of_type($type)
1488
+	{
1489
+		EE_Error::doing_it_wrong(
1490
+			'EE_Line_Item::_get_descendants_of_type()',
1491
+			__('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0'
1492
+		);
1493
+		return EEH_Line_Item::get_descendants_of_type($this, $type);
1494
+	}
1495
+
1496
+
1497
+
1498
+	/**
1499
+	 * @deprecated 4.6.0
1500
+	 * @param string $type like one of the EEM_Line_Item::type_*
1501
+	 * @return EE_Line_Item
1502
+	 */
1503
+	public function get_nearest_descendant_of_type($type)
1504
+	{
1505
+		EE_Error::doing_it_wrong(
1506
+			'EE_Line_Item::get_nearest_descendant_of_type()',
1507
+			__('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0'
1508
+		);
1509
+		return EEH_Line_Item::get_nearest_descendant_of_type($this, $type);
1510
+	}
1511 1511
 
1512 1512
 
1513 1513
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     protected function __construct($fieldValues = array(), $bydb = false, $timezone = '')
80 80
     {
81 81
         parent::__construct($fieldValues, $bydb, $timezone);
82
-        if (! $this->get('LIN_code')) {
82
+        if ( ! $this->get('LIN_code')) {
83 83
             $this->set_code($this->generate_code());
84 84
         }
85 85
     }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     public function name()
135 135
     {
136 136
         $name = $this->get('LIN_name');
137
-        if (! $name) {
137
+        if ( ! $name) {
138 138
             $name = ucwords(str_replace('-', ' ', $this->type()));
139 139
         }
140 140
         return $name;
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
                 )
516 516
             );
517 517
         }
518
-        if (! is_array($this->_children)) {
518
+        if ( ! is_array($this->_children)) {
519 519
             $this->_children = array();
520 520
         }
521 521
         return $this->_children;
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
     public function set_parent($line_item)
742 742
     {
743 743
         if ($this->ID()) {
744
-            if (! $line_item->ID()) {
744
+            if ( ! $line_item->ID()) {
745 745
                 $line_item->save();
746 746
             }
747 747
             $this->set_parent_ID($line_item->ID());
@@ -815,7 +815,7 @@  discard block
 block discarded – undo
815 815
             $items_deleted = 0;
816 816
             if ($this->code() === $code) {
817 817
                 $items_deleted += EEH_Line_Item::delete_all_child_items($this);
818
-                $items_deleted += (int)$this->delete();
818
+                $items_deleted += (int) $this->delete();
819 819
                 if ($stop_search_once_found) {
820 820
                     return $items_deleted;
821 821
                 }
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
     public function generate_code()
861 861
     {
862 862
         // each line item in the cart requires a unique identifier
863
-        return md5($this->get('OBJ_type') . $this->get('OBJ_ID') . microtime());
863
+        return md5($this->get('OBJ_type').$this->get('OBJ_ID').microtime());
864 864
     }
865 865
 
866 866
 
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
         $has_children = ! empty($my_children);
1036 1036
         if ($has_children && $this->is_line_item()) {
1037 1037
             $total = $this->_recalculate_pretax_total_for_line_item($total, $my_children);
1038
-        } elseif (! $has_children && ($this->is_sub_line_item() || $this->is_line_item())) {
1038
+        } elseif ( ! $has_children && ($this->is_sub_line_item() || $this->is_line_item())) {
1039 1039
             $total = $this->unit_price() * $this->quantity();
1040 1040
         } elseif ($this->is_sub_total() || $this->is_total()) {
1041 1041
             $total = $this->_recalculate_pretax_total_for_subtotal($total, $my_children);
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
             if ($this->OBJ_type() !== 'Event') {
1051 1051
                 $this->set_quantity(1);
1052 1052
             }
1053
-            if (! $this->is_percent()) {
1053
+            if ( ! $this->is_percent()) {
1054 1054
                 $this->set_unit_price($total);
1055 1055
             }
1056 1056
         }
1057 1057
         //we don't want to bother saving grand totals, because that needs to factor in taxes anyways
1058 1058
         //so it ought to be
1059
-        if (! $this->is_total()) {
1059
+        if ( ! $this->is_total()) {
1060 1060
             $this->set_total($total);
1061 1061
             //if not a percent line item, make sure we keep the unit price in sync
1062 1062
             if (
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
     public function save_this_and_descendants_to_txn($txn_id = null)
1375 1375
     {
1376 1376
         $count = 0;
1377
-        if (! $txn_id) {
1377
+        if ( ! $txn_id) {
1378 1378
             $txn_id = $this->TXN_ID();
1379 1379
         }
1380 1380
         $this->set_TXN_ID($txn_id);
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -38,217 +38,217 @@
 block discarded – undo
38 38
  * @since       4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 
64 64
 } else {
65
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
66
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
-        /**
68
-         * espresso_minimum_php_version_error
69
-         *
70
-         * @return void
71
-         */
72
-        function espresso_minimum_php_version_error()
73
-        {
74
-            ?>
65
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
66
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
+		/**
68
+		 * espresso_minimum_php_version_error
69
+		 *
70
+		 * @return void
71
+		 */
72
+		function espresso_minimum_php_version_error()
73
+		{
74
+			?>
75 75
             <div class="error">
76 76
                 <p>
77 77
                     <?php
78
-                    printf(
79
-                        esc_html__(
80
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
81
-                            'event_espresso'
82
-                        ),
83
-                        EE_MIN_PHP_VER_REQUIRED,
84
-                        PHP_VERSION,
85
-                        '<br/>',
86
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
87
-                    );
88
-                    ?>
78
+					printf(
79
+						esc_html__(
80
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
81
+							'event_espresso'
82
+						),
83
+						EE_MIN_PHP_VER_REQUIRED,
84
+						PHP_VERSION,
85
+						'<br/>',
86
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
87
+					);
88
+					?>
89 89
                 </p>
90 90
             </div>
91 91
             <?php
92
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
93
-        }
92
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
93
+		}
94 94
 
95
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
96
-    } else {
97
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
98
-        /**
99
-         * espresso_version
100
-         * Returns the plugin version
101
-         *
102
-         * @return string
103
-         */
104
-        function espresso_version()
105
-        {
106
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.46.rc.048');
107
-        }
95
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
96
+	} else {
97
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
98
+		/**
99
+		 * espresso_version
100
+		 * Returns the plugin version
101
+		 *
102
+		 * @return string
103
+		 */
104
+		function espresso_version()
105
+		{
106
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.46.rc.048');
107
+		}
108 108
 
109
-        /**
110
-         * espresso_plugin_activation
111
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
112
-         */
113
-        function espresso_plugin_activation()
114
-        {
115
-            update_option('ee_espresso_activation', true);
116
-        }
109
+		/**
110
+		 * espresso_plugin_activation
111
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
112
+		 */
113
+		function espresso_plugin_activation()
114
+		{
115
+			update_option('ee_espresso_activation', true);
116
+		}
117 117
 
118
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
119
-        /**
120
-         *    espresso_load_error_handling
121
-         *    this function loads EE's class for handling exceptions and errors
122
-         */
123
-        function espresso_load_error_handling()
124
-        {
125
-            static $error_handling_loaded = false;
126
-            if ($error_handling_loaded) {
127
-                return;
128
-            }
129
-            // load debugging tools
130
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
132
-                \EEH_Debug_Tools::instance();
133
-            }
134
-            // load error handling
135
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
-                require_once(EE_CORE . 'EE_Error.core.php');
137
-            } else {
138
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139
-            }
140
-            $error_handling_loaded = true;
141
-        }
118
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
119
+		/**
120
+		 *    espresso_load_error_handling
121
+		 *    this function loads EE's class for handling exceptions and errors
122
+		 */
123
+		function espresso_load_error_handling()
124
+		{
125
+			static $error_handling_loaded = false;
126
+			if ($error_handling_loaded) {
127
+				return;
128
+			}
129
+			// load debugging tools
130
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
132
+				\EEH_Debug_Tools::instance();
133
+			}
134
+			// load error handling
135
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
+				require_once(EE_CORE . 'EE_Error.core.php');
137
+			} else {
138
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139
+			}
140
+			$error_handling_loaded = true;
141
+		}
142 142
 
143
-        /**
144
-         *    espresso_load_required
145
-         *    given a class name and path, this function will load that file or throw an exception
146
-         *
147
-         * @param    string $classname
148
-         * @param    string $full_path_to_file
149
-         * @throws    EE_Error
150
-         */
151
-        function espresso_load_required($classname, $full_path_to_file)
152
-        {
153
-            if (is_readable($full_path_to_file)) {
154
-                require_once($full_path_to_file);
155
-            } else {
156
-                throw new \EE_Error (
157
-                    sprintf(
158
-                        esc_html__(
159
-                            'The %s class file could not be located or is not readable due to file permissions.',
160
-                            'event_espresso'
161
-                        ),
162
-                        $classname
163
-                    )
164
-                );
165
-            }
166
-        }
143
+		/**
144
+		 *    espresso_load_required
145
+		 *    given a class name and path, this function will load that file or throw an exception
146
+		 *
147
+		 * @param    string $classname
148
+		 * @param    string $full_path_to_file
149
+		 * @throws    EE_Error
150
+		 */
151
+		function espresso_load_required($classname, $full_path_to_file)
152
+		{
153
+			if (is_readable($full_path_to_file)) {
154
+				require_once($full_path_to_file);
155
+			} else {
156
+				throw new \EE_Error (
157
+					sprintf(
158
+						esc_html__(
159
+							'The %s class file could not be located or is not readable due to file permissions.',
160
+							'event_espresso'
161
+						),
162
+						$classname
163
+					)
164
+				);
165
+			}
166
+		}
167 167
 
168
-        /**
169
-         * @since 4.9.27
170
-         * @throws \EE_Error
171
-         * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
172
-         * @throws \EventEspresso\core\exceptions\InvalidEntityException
173
-         * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
174
-         * @throws \EventEspresso\core\exceptions\InvalidClassException
175
-         * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
176
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
177
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
178
-         * @throws \OutOfBoundsException
179
-         */
180
-        function bootstrap_espresso()
181
-        {
182
-            require_once(plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE) . 'core/espresso_definitions.php');
183
-            try {
184
-                espresso_load_error_handling();
185
-                espresso_load_required(
186
-                    'EEH_Base',
187
-                    EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
188
-                );
189
-                espresso_load_required(
190
-                    'EEH_File',
191
-                    EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
192
-                );
193
-                espresso_load_required(
194
-                    'EEH_File',
195
-                    EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
196
-                );
197
-                espresso_load_required(
198
-                    'EEH_Array',
199
-                    EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
200
-                );
201
-                // instantiate and configure PSR4 autoloader
202
-                espresso_load_required(
203
-                    'Psr4Autoloader',
204
-                    EE_CORE . 'Psr4Autoloader.php'
205
-                );
206
-                espresso_load_required(
207
-                    'EE_Psr4AutoloaderInit',
208
-                    EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
209
-                );
210
-                $AutoloaderInit = new EE_Psr4AutoloaderInit();
211
-                $AutoloaderInit->initializeAutoloader();
212
-                espresso_load_required(
213
-                    'EE_Request',
214
-                    EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
215
-                );
216
-                espresso_load_required(
217
-                    'EE_Response',
218
-                    EE_CORE . 'request_stack' . DS . 'EE_Response.core.php'
219
-                );
220
-                espresso_load_required(
221
-                    'EE_Bootstrap',
222
-                    EE_CORE . 'EE_Bootstrap.core.php'
223
-                );
224
-                // bootstrap EE and the request stack
225
-                new EE_Bootstrap(
226
-                    new EE_Request($_GET, $_POST, $_COOKIE),
227
-                    new EE_Response()
228
-                );
229
-            } catch (Exception $e) {
230
-                require_once EE_CORE . 'exceptions.' . DS . 'ExceptionStackTraceDisplay.php';
231
-                new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
232
-            }
233
-        }
234
-        bootstrap_espresso();
235
-    }
168
+		/**
169
+		 * @since 4.9.27
170
+		 * @throws \EE_Error
171
+		 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
172
+		 * @throws \EventEspresso\core\exceptions\InvalidEntityException
173
+		 * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
174
+		 * @throws \EventEspresso\core\exceptions\InvalidClassException
175
+		 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
176
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
177
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
178
+		 * @throws \OutOfBoundsException
179
+		 */
180
+		function bootstrap_espresso()
181
+		{
182
+			require_once(plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE) . 'core/espresso_definitions.php');
183
+			try {
184
+				espresso_load_error_handling();
185
+				espresso_load_required(
186
+					'EEH_Base',
187
+					EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
188
+				);
189
+				espresso_load_required(
190
+					'EEH_File',
191
+					EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
192
+				);
193
+				espresso_load_required(
194
+					'EEH_File',
195
+					EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
196
+				);
197
+				espresso_load_required(
198
+					'EEH_Array',
199
+					EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
200
+				);
201
+				// instantiate and configure PSR4 autoloader
202
+				espresso_load_required(
203
+					'Psr4Autoloader',
204
+					EE_CORE . 'Psr4Autoloader.php'
205
+				);
206
+				espresso_load_required(
207
+					'EE_Psr4AutoloaderInit',
208
+					EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
209
+				);
210
+				$AutoloaderInit = new EE_Psr4AutoloaderInit();
211
+				$AutoloaderInit->initializeAutoloader();
212
+				espresso_load_required(
213
+					'EE_Request',
214
+					EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
215
+				);
216
+				espresso_load_required(
217
+					'EE_Response',
218
+					EE_CORE . 'request_stack' . DS . 'EE_Response.core.php'
219
+				);
220
+				espresso_load_required(
221
+					'EE_Bootstrap',
222
+					EE_CORE . 'EE_Bootstrap.core.php'
223
+				);
224
+				// bootstrap EE and the request stack
225
+				new EE_Bootstrap(
226
+					new EE_Request($_GET, $_POST, $_COOKIE),
227
+					new EE_Response()
228
+				);
229
+			} catch (Exception $e) {
230
+				require_once EE_CORE . 'exceptions.' . DS . 'ExceptionStackTraceDisplay.php';
231
+				new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
232
+			}
233
+		}
234
+		bootstrap_espresso();
235
+	}
236 236
 }
237 237
 if (! function_exists('espresso_deactivate_plugin')) {
238
-    /**
239
-     *    deactivate_plugin
240
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
241
-     *
242
-     * @access public
243
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
244
-     * @return    void
245
-     */
246
-    function espresso_deactivate_plugin($plugin_basename = '')
247
-    {
248
-        if (! function_exists('deactivate_plugins')) {
249
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
250
-        }
251
-        unset($_GET['activate'], $_REQUEST['activate']);
252
-        deactivate_plugins($plugin_basename);
253
-    }
238
+	/**
239
+	 *    deactivate_plugin
240
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
241
+	 *
242
+	 * @access public
243
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
244
+	 * @return    void
245
+	 */
246
+	function espresso_deactivate_plugin($plugin_basename = '')
247
+	{
248
+		if (! function_exists('deactivate_plugins')) {
249
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
250
+		}
251
+		unset($_GET['activate'], $_REQUEST['activate']);
252
+		deactivate_plugins($plugin_basename);
253
+	}
254 254
 }
Please login to merge, or discard this patch.
core/EE_Load_Espresso_Core.core.php 2 patches
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -23,204 +23,204 @@
 block discarded – undo
23 23
 class EE_Load_Espresso_Core implements EEI_Request_Decorator, EEI_Request_Stack_Core_App
24 24
 {
25 25
 
26
-    /**
27
-     * @var EE_Request $request
28
-     */
29
-    protected $request;
26
+	/**
27
+	 * @var EE_Request $request
28
+	 */
29
+	protected $request;
30 30
 
31
-    /**
32
-     * @var EE_Response $response
33
-     */
34
-    protected $response;
31
+	/**
32
+	 * @var EE_Response $response
33
+	 */
34
+	protected $response;
35 35
 
36
-    /**
37
-     * @var EE_Dependency_Map $dependency_map
38
-     */
39
-    protected $dependency_map;
36
+	/**
37
+	 * @var EE_Dependency_Map $dependency_map
38
+	 */
39
+	protected $dependency_map;
40 40
 
41
-    /**
42
-     * @var EE_Registry $registry
43
-     */
44
-    protected $registry;
41
+	/**
42
+	 * @var EE_Registry $registry
43
+	 */
44
+	protected $registry;
45 45
 
46 46
 
47 47
 
48
-    /**
49
-     * EE_Load_Espresso_Core constructor
50
-     */
48
+	/**
49
+	 * EE_Load_Espresso_Core constructor
50
+	 */
51 51
 	public function __construct() {
52
-        // deprecated functions
53
-        espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php');
54
-        espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
55
-    }
56
-
57
-
58
-
59
-    /**
60
-     * handle
61
-     * sets hooks for running rest of system
62
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
63
-     * starting EE Addons from any other point may lead to problems
64
-     *
65
-     * @param EE_Request  $request
66
-     * @param EE_Response $response
67
-     * @return EE_Response
68
-     * @throws EE_Error
69
-     * @throws InvalidDataTypeException
70
-     * @throws InvalidInterfaceException
71
-     * @throws InvalidArgumentException
72
-     */
73
-    public function handle_request(EE_Request $request, EE_Response $response)
74
-    {
75
-        $this->request = $request;
76
-        $this->response = $response;
77
-        // info about how to load classes required by other classes
78
-        $this->dependency_map = $this->_load_dependency_map();
79
-        // central repository for classes
80
-        $this->registry = $this->_load_registry();
81
-        do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading');
82
-        $loader = LoaderFactory::getLoader($this->registry);
83
-        $this->dependency_map->setLoader($loader);
84
-        // build DI container
85
-        // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop();
86
-        // $OpenCoffeeShop->addRecipes();
87
-        // $CoffeeShop = $OpenCoffeeShop->CoffeeShop();
88
-        // workarounds for PHP < 5.3
89
-        $this->_load_class_tools();
90
-        // deprecated functions
91
-        espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
92
-        // WP cron jobs
93
-        $loader->getShared('EE_Cron_Tasks');
94
-        $loader->getShared('EE_Request_Handler');
95
-        $loader->getShared('EE_System');
96
-        return $this->response;
97
-    }
98
-
99
-
100
-
101
-    /**
102
-     * @return EE_Request
103
-     */
104
-    public function request()
105
-    {
106
-        return $this->request;
107
-    }
108
-
109
-
110
-
111
-    /**
112
-     * @return EE_Response
113
-     */
114
-    public function response()
115
-    {
116
-        return $this->response;
117
-    }
118
-
119
-
120
-
121
-    /**
122
-     * @return EE_Dependency_Map
123
-     * @throws EE_Error
124
-     */
125
-    public function dependency_map()
126
-    {
127
-        if (! $this->dependency_map instanceof EE_Dependency_Map) {
128
-            throw new EE_Error(
129
-                sprintf(
130
-                    __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'),
131
-                    print_r($this->dependency_map, true)
132
-                )
133
-            );
134
-        }
135
-        return $this->dependency_map;
136
-    }
137
-
138
-
139
-
140
-    /**
141
-     * @return EE_Registry
142
-     * @throws EE_Error
143
-     */
144
-    public function registry()
145
-    {
146
-        if (! $this->registry instanceof EE_Registry) {
147
-            throw new EE_Error(
148
-                sprintf(
149
-                    __('Invalid EE_Registry: "%1$s"', 'event_espresso'),
150
-                    print_r($this->registry, true)
151
-                )
152
-            );
153
-        }
154
-        return $this->registry;
155
-    }
156
-
157
-
158
-
159
-    /**
160
-     * @return EE_Dependency_Map
161
-     */
162
-    private function _load_dependency_map()
163
-    {
164
-        if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) {
165
-            EE_Error::add_error(
166
-                __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'),
167
-                __FILE__, __FUNCTION__, __LINE__
168
-            );
169
-            wp_die(EE_Error::get_notices());
170
-        }
171
-        require_once(EE_CORE . 'EE_Dependency_Map.core.php');
172
-        return EE_Dependency_Map::instance($this->request, $this->response);
173
-    }
174
-
175
-
176
-
177
-    /**
178
-     * @return EE_Registry
179
-     */
180
-    private function _load_registry()
181
-    {
182
-        if (! is_readable(EE_CORE . 'EE_Registry.core.php')) {
183
-            EE_Error::add_error(
184
-                __('The EE_Registry core class could not be loaded.', 'event_espresso'),
185
-                __FILE__, __FUNCTION__, __LINE__
186
-            );
187
-            wp_die(EE_Error::get_notices());
188
-        }
189
-        require_once(EE_CORE . 'EE_Registry.core.php');
190
-        return EE_Registry::instance($this->dependency_map);
191
-    }
192
-
193
-
194
-
195
-    /**
196
-     * @return void
197
-     */
198
-    private function _load_class_tools()
199
-    {
200
-        if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) {
201
-            EE_Error::add_error(
202
-                __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'),
203
-                __FILE__, __FUNCTION__, __LINE__
204
-            );
205
-        }
206
-        require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php');
207
-    }
208
-
209
-
210
-
211
-    /**
212
-     * called after the request stack has been fully processed
213
-     * if any of the middleware apps has requested the plugin be deactivated, then we do that now
214
-     *
215
-     * @param EE_Request  $request
216
-     * @param EE_Response $response
217
-     */
218
-    public function handle_response(EE_Request $request, EE_Response $response)
219
-    {
220
-        if ($response->plugin_deactivated()) {
221
-            espresso_deactivate_plugin(EE_PLUGIN_BASENAME);
222
-        }
223
-    }
52
+		// deprecated functions
53
+		espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php');
54
+		espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
55
+	}
56
+
57
+
58
+
59
+	/**
60
+	 * handle
61
+	 * sets hooks for running rest of system
62
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
63
+	 * starting EE Addons from any other point may lead to problems
64
+	 *
65
+	 * @param EE_Request  $request
66
+	 * @param EE_Response $response
67
+	 * @return EE_Response
68
+	 * @throws EE_Error
69
+	 * @throws InvalidDataTypeException
70
+	 * @throws InvalidInterfaceException
71
+	 * @throws InvalidArgumentException
72
+	 */
73
+	public function handle_request(EE_Request $request, EE_Response $response)
74
+	{
75
+		$this->request = $request;
76
+		$this->response = $response;
77
+		// info about how to load classes required by other classes
78
+		$this->dependency_map = $this->_load_dependency_map();
79
+		// central repository for classes
80
+		$this->registry = $this->_load_registry();
81
+		do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading');
82
+		$loader = LoaderFactory::getLoader($this->registry);
83
+		$this->dependency_map->setLoader($loader);
84
+		// build DI container
85
+		// $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop();
86
+		// $OpenCoffeeShop->addRecipes();
87
+		// $CoffeeShop = $OpenCoffeeShop->CoffeeShop();
88
+		// workarounds for PHP < 5.3
89
+		$this->_load_class_tools();
90
+		// deprecated functions
91
+		espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
92
+		// WP cron jobs
93
+		$loader->getShared('EE_Cron_Tasks');
94
+		$loader->getShared('EE_Request_Handler');
95
+		$loader->getShared('EE_System');
96
+		return $this->response;
97
+	}
98
+
99
+
100
+
101
+	/**
102
+	 * @return EE_Request
103
+	 */
104
+	public function request()
105
+	{
106
+		return $this->request;
107
+	}
108
+
109
+
110
+
111
+	/**
112
+	 * @return EE_Response
113
+	 */
114
+	public function response()
115
+	{
116
+		return $this->response;
117
+	}
118
+
119
+
120
+
121
+	/**
122
+	 * @return EE_Dependency_Map
123
+	 * @throws EE_Error
124
+	 */
125
+	public function dependency_map()
126
+	{
127
+		if (! $this->dependency_map instanceof EE_Dependency_Map) {
128
+			throw new EE_Error(
129
+				sprintf(
130
+					__('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'),
131
+					print_r($this->dependency_map, true)
132
+				)
133
+			);
134
+		}
135
+		return $this->dependency_map;
136
+	}
137
+
138
+
139
+
140
+	/**
141
+	 * @return EE_Registry
142
+	 * @throws EE_Error
143
+	 */
144
+	public function registry()
145
+	{
146
+		if (! $this->registry instanceof EE_Registry) {
147
+			throw new EE_Error(
148
+				sprintf(
149
+					__('Invalid EE_Registry: "%1$s"', 'event_espresso'),
150
+					print_r($this->registry, true)
151
+				)
152
+			);
153
+		}
154
+		return $this->registry;
155
+	}
156
+
157
+
158
+
159
+	/**
160
+	 * @return EE_Dependency_Map
161
+	 */
162
+	private function _load_dependency_map()
163
+	{
164
+		if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) {
165
+			EE_Error::add_error(
166
+				__('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'),
167
+				__FILE__, __FUNCTION__, __LINE__
168
+			);
169
+			wp_die(EE_Error::get_notices());
170
+		}
171
+		require_once(EE_CORE . 'EE_Dependency_Map.core.php');
172
+		return EE_Dependency_Map::instance($this->request, $this->response);
173
+	}
174
+
175
+
176
+
177
+	/**
178
+	 * @return EE_Registry
179
+	 */
180
+	private function _load_registry()
181
+	{
182
+		if (! is_readable(EE_CORE . 'EE_Registry.core.php')) {
183
+			EE_Error::add_error(
184
+				__('The EE_Registry core class could not be loaded.', 'event_espresso'),
185
+				__FILE__, __FUNCTION__, __LINE__
186
+			);
187
+			wp_die(EE_Error::get_notices());
188
+		}
189
+		require_once(EE_CORE . 'EE_Registry.core.php');
190
+		return EE_Registry::instance($this->dependency_map);
191
+	}
192
+
193
+
194
+
195
+	/**
196
+	 * @return void
197
+	 */
198
+	private function _load_class_tools()
199
+	{
200
+		if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) {
201
+			EE_Error::add_error(
202
+				__('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'),
203
+				__FILE__, __FUNCTION__, __LINE__
204
+			);
205
+		}
206
+		require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php');
207
+	}
208
+
209
+
210
+
211
+	/**
212
+	 * called after the request stack has been fully processed
213
+	 * if any of the middleware apps has requested the plugin be deactivated, then we do that now
214
+	 *
215
+	 * @param EE_Request  $request
216
+	 * @param EE_Response $response
217
+	 */
218
+	public function handle_response(EE_Request $request, EE_Response $response)
219
+	{
220
+		if ($response->plugin_deactivated()) {
221
+			espresso_deactivate_plugin(EE_PLUGIN_BASENAME);
222
+		}
223
+	}
224 224
 
225 225
 
226 226
 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
      */
51 51
 	public function __construct() {
52 52
         // deprecated functions
53
-        espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php');
54
-        espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
53
+        espresso_load_required('EE_Base', EE_CORE.'EE_Base.core.php');
54
+        espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php');
55 55
     }
56 56
 
57 57
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
         // workarounds for PHP < 5.3
89 89
         $this->_load_class_tools();
90 90
         // deprecated functions
91
-        espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
91
+        espresso_load_required('EE_Deprecated', EE_CORE.'EE_Deprecated.core.php');
92 92
         // WP cron jobs
93 93
         $loader->getShared('EE_Cron_Tasks');
94 94
         $loader->getShared('EE_Request_Handler');
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public function dependency_map()
126 126
     {
127
-        if (! $this->dependency_map instanceof EE_Dependency_Map) {
127
+        if ( ! $this->dependency_map instanceof EE_Dependency_Map) {
128 128
             throw new EE_Error(
129 129
                 sprintf(
130 130
                     __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'),
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function registry()
145 145
     {
146
-        if (! $this->registry instanceof EE_Registry) {
146
+        if ( ! $this->registry instanceof EE_Registry) {
147 147
             throw new EE_Error(
148 148
                 sprintf(
149 149
                     __('Invalid EE_Registry: "%1$s"', 'event_espresso'),
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
      */
162 162
     private function _load_dependency_map()
163 163
     {
164
-        if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) {
164
+        if ( ! is_readable(EE_CORE.'EE_Dependency_Map.core.php')) {
165 165
             EE_Error::add_error(
166 166
                 __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'),
167 167
                 __FILE__, __FUNCTION__, __LINE__
168 168
             );
169 169
             wp_die(EE_Error::get_notices());
170 170
         }
171
-        require_once(EE_CORE . 'EE_Dependency_Map.core.php');
171
+        require_once(EE_CORE.'EE_Dependency_Map.core.php');
172 172
         return EE_Dependency_Map::instance($this->request, $this->response);
173 173
     }
174 174
 
@@ -179,14 +179,14 @@  discard block
 block discarded – undo
179 179
      */
180 180
     private function _load_registry()
181 181
     {
182
-        if (! is_readable(EE_CORE . 'EE_Registry.core.php')) {
182
+        if ( ! is_readable(EE_CORE.'EE_Registry.core.php')) {
183 183
             EE_Error::add_error(
184 184
                 __('The EE_Registry core class could not be loaded.', 'event_espresso'),
185 185
                 __FILE__, __FUNCTION__, __LINE__
186 186
             );
187 187
             wp_die(EE_Error::get_notices());
188 188
         }
189
-        require_once(EE_CORE . 'EE_Registry.core.php');
189
+        require_once(EE_CORE.'EE_Registry.core.php');
190 190
         return EE_Registry::instance($this->dependency_map);
191 191
     }
192 192
 
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
      */
198 198
     private function _load_class_tools()
199 199
     {
200
-        if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) {
200
+        if ( ! is_readable(EE_HELPERS.'EEH_Class_Tools.helper.php')) {
201 201
             EE_Error::add_error(
202 202
                 __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'),
203 203
                 __FILE__, __FUNCTION__, __LINE__
204 204
             );
205 205
         }
206
-        require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php');
206
+        require_once(EE_HELPERS.'EEH_Class_Tools.helper.php');
207 207
     }
208 208
 
209 209
 
Please login to merge, or discard this patch.