Completed
Branch master (d650b6)
by
unknown
28:49 queued 26:44
created
admin/new/pricing/templates/event_tickets_datetime_ticket_row.template.php 1 patch
Braces   +40 added lines, -16 removed lines patch added patch discarded remove patch
@@ -102,8 +102,11 @@  discard block
 block discarded – undo
102 102
                    name="archived_ticket[TKT_start_date]"
103 103
                    value="<?php echo esc_attr($TKT_start_date); ?>"
104 104
             />
105
-        <?php else : ?>
106
-            <label class='screen-reader-text' for="edit-ticket-TKT_start_date-<?php echo esc_attr($tkt_row); ?>">
105
+        <?php else {
106
+	: ?>
107
+            <label class='screen-reader-text' for="edit-ticket-TKT_start_date-<?php echo esc_attr($tkt_row);
108
+}
109
+?>">
107 110
                 <?php esc_html_e('Sale Starts', 'event_espresso') ?>
108 111
             </label>
109 112
             <input type='text'
@@ -136,8 +139,11 @@  discard block
 block discarded – undo
136 139
                    name="archived_ticket[<?php echo esc_attr($tkt_row); ?>][TKT_end_date]"
137 140
                    value="<?php echo esc_attr($TKT_end_date); ?>"
138 141
             />
139
-        <?php else : ?>
140
-            <label class='screen-reader-text' for='edit-ticket-TKT_end_date-<?php echo esc_attr($tkt_row); ?>'>
142
+        <?php else {
143
+	: ?>
144
+            <label class='screen-reader-text' for='edit-ticket-TKT_end_date-<?php echo esc_attr($tkt_row);
145
+}
146
+?>'>
141 147
                 <?php esc_html_e('Sell Until', 'event_espresso') ?>
142 148
             </label>
143 149
             <input type='text'
@@ -169,8 +175,11 @@  discard block
 block discarded – undo
169 175
                    name="archived_ticket[<?php echo esc_attr($tkt_row); ?>][TKT_base_price]"
170 176
                    value="<?php echo esc_attr($TKT_base_price); ?>"
171 177
             />
172
-        <?php else : ?>
173
-            <label class='screen-reader-text' for='edit-ticket-TKT_base_price-<?php echo esc_attr($tkt_row); ?>'>
178
+        <?php else {
179
+	: ?>
180
+            <label class='screen-reader-text' for='edit-ticket-TKT_base_price-<?php echo esc_attr($tkt_row);
181
+}
182
+?>'>
174 183
                 <?php esc_html_e('Price', 'event_espresso') ?>
175 184
             </label>
176 185
             <input id="edit-ticket-TKT_base_price-<?php echo esc_attr($tkt_row); ?>" type="text"
@@ -200,8 +209,11 @@  discard block
 block discarded – undo
200 209
                    name="archived_ticket[<?php echo esc_attr($tkt_row); ?>][TKT_qty]"
201 210
                    value="<?php echo esc_attr($TKT_qty_for_input); ?>"
202 211
             />
203
-        <?php else : ?>
204
-            <label class='screen-reader-text' for='edit-ticket-TKT_qty-<?php echo esc_attr($tkt_row); ?>'>
212
+        <?php else {
213
+	: ?>
214
+            <label class='screen-reader-text' for='edit-ticket-TKT_qty-<?php echo esc_attr($tkt_row);
215
+}
216
+?>'>
205 217
                 <?php esc_html_e('Qty', 'event_espresso') ?>
206 218
             </label>
207 219
             <input type="text"
@@ -321,9 +333,12 @@  discard block
 block discarded – undo
321 333
                                        name="archived_ticket[<?php echo esc_attr($tkt_row); ?>][TKT_uses]"
322 334
                                        value="<?php echo esc_attr($TKT_uses); ?>"
323 335
                                 />
324
-                            <?php else : ?>
336
+                            <?php else {
337
+	: ?>
325 338
                                 <label class='screen-reader-text'
326
-                                       for='edit-ticket-TKT_uses-<?php echo esc_attr($tkt_row); ?>'
339
+                                       for='edit-ticket-TKT_uses-<?php echo esc_attr($tkt_row);
340
+}
341
+?>'
327 342
                                 >
328 343
                                     <?php
329 344
                                     esc_html_e('Ticket Uses', 'event_espresso') ?>
@@ -353,8 +368,11 @@  discard block
 block discarded – undo
353 368
                                        name="archived_ticket[<?php echo esc_attr($tkt_row); ?>][TKT_min]"
354 369
                                        value="<?php echo esc_attr($TKT_min); ?>"
355 370
                                 />
356
-                            <?php else : ?>
357
-                                <label class='screen-reader-text' for='edit-ticket-TKT_min-<?php echo esc_attr($tkt_row);?>'>
371
+                            <?php else {
372
+	: ?>
373
+                                <label class='screen-reader-text' for='edit-ticket-TKT_min-<?php echo esc_attr($tkt_row);
374
+}
375
+?>'>
358 376
                                     <?php esc_html_e('Minimum Quantity', 'event_espresso') ?>
359 377
                                 </label>
360 378
                                 <input type="text"
@@ -380,8 +398,11 @@  discard block
 block discarded – undo
380 398
                                        name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_max]"
381 399
                                        value="<?php echo esc_attr($TKT_max); ?>"
382 400
                                 />
383
-                            <?php else : ?>
384
-                                <label class='screen-reader-text' for='edit-ticket-TKT_max-<?php echo esc_attr($tkt_row);?>'>
401
+                            <?php else {
402
+	: ?>
403
+                                <label class='screen-reader-text' for='edit-ticket-TKT_max-<?php echo esc_attr($tkt_row);
404
+}
405
+?>'>
385 406
                                     <?php esc_html_e('Maximum Quantity', 'event_espresso') ?>
386 407
                                 </label>
387 408
                                 <input type="text"
@@ -434,10 +455,13 @@  discard block
 block discarded – undo
434 455
                                value="1"
435 456
                                <?php echo esc_attr($TKT_taxable); ?>
436 457
                         />
437
-                        <?php else : ?>
458
+                        <?php else {
459
+	: ?>
438 460
                         <input type='checkbox'
439 461
                                class="TKT-taxable-checkbox"
440
-                               id="edit-ticket-TKT_taxable-<?php echo esc_attr($tkt_row); ?>"
462
+                               id="edit-ticket-TKT_taxable-<?php echo esc_attr($tkt_row);
463
+}
464
+?>"
441 465
                                name="<?php echo esc_attr($edit_tickets_name); ?>[<?php echo esc_attr($tkt_row); ?>][TKT_taxable]"
442 466
                                value="1"
443 467
                                <?php echo esc_attr($TKT_taxable); ?>
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 2 patches
Indentation   +2141 added lines, -2141 removed lines patch added patch discarded remove patch
@@ -15,2201 +15,2201 @@
 block discarded – undo
15 15
 class espresso_events_Pricing_Hooks extends EE_Admin_Hooks
16 16
 {
17 17
 
18
-    /**
19
-     * This property is just used to hold the status of whether an event is currently being
20
-     * created (true) or edited (false)
21
-     *
22
-     * @access protected
23
-     * @var bool
24
-     */
25
-    protected $_is_creating_event;
18
+	/**
19
+	 * This property is just used to hold the status of whether an event is currently being
20
+	 * created (true) or edited (false)
21
+	 *
22
+	 * @access protected
23
+	 * @var bool
24
+	 */
25
+	protected $_is_creating_event;
26 26
 
27
-    /**
28
-     * Used to contain the format strings for date and time that will be used for php date and
29
-     * time.
30
-     * Is set in the _set_hooks_properties() method.
31
-     *
32
-     * @var array
33
-     */
34
-    protected $_date_format_strings;
27
+	/**
28
+	 * Used to contain the format strings for date and time that will be used for php date and
29
+	 * time.
30
+	 * Is set in the _set_hooks_properties() method.
31
+	 *
32
+	 * @var array
33
+	 */
34
+	protected $_date_format_strings;
35 35
 
36
-    /**
37
-     * @var string $_date_time_format
38
-     */
39
-    protected $_date_time_format;
36
+	/**
37
+	 * @var string $_date_time_format
38
+	 */
39
+	protected $_date_time_format;
40 40
 
41 41
 
42
-    /**
43
-     * @throws InvalidArgumentException
44
-     * @throws InvalidInterfaceException
45
-     * @throws InvalidDataTypeException
46
-     */
47
-    protected function _set_hooks_properties()
48
-    {
49
-        $this->_name = 'pricing';
50
-        // capability check
51
-        if (
52
-            ! EE_Registry::instance()->CAP->current_user_can(
53
-                'ee_read_default_prices',
54
-                'advanced_ticket_datetime_metabox'
55
-            )
56
-        ) {
57
-            return;
58
-        }
59
-        $this->_setup_metaboxes();
60
-        $this->_set_date_time_formats();
61
-        $this->_validate_format_strings();
62
-        $this->_set_scripts_styles();
63
-        // commented out temporarily until logic is implemented in callback
64
-        // add_action(
65
-        //     'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
66
-        //     array($this, 'autosave_handling')
67
-        // );
68
-        add_filter(
69
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
70
-            array($this, 'caf_updates')
71
-        );
72
-    }
42
+	/**
43
+	 * @throws InvalidArgumentException
44
+	 * @throws InvalidInterfaceException
45
+	 * @throws InvalidDataTypeException
46
+	 */
47
+	protected function _set_hooks_properties()
48
+	{
49
+		$this->_name = 'pricing';
50
+		// capability check
51
+		if (
52
+			! EE_Registry::instance()->CAP->current_user_can(
53
+				'ee_read_default_prices',
54
+				'advanced_ticket_datetime_metabox'
55
+			)
56
+		) {
57
+			return;
58
+		}
59
+		$this->_setup_metaboxes();
60
+		$this->_set_date_time_formats();
61
+		$this->_validate_format_strings();
62
+		$this->_set_scripts_styles();
63
+		// commented out temporarily until logic is implemented in callback
64
+		// add_action(
65
+		//     'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
66
+		//     array($this, 'autosave_handling')
67
+		// );
68
+		add_filter(
69
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
70
+			array($this, 'caf_updates')
71
+		);
72
+	}
73 73
 
74 74
 
75
-    /**
76
-     * @return void
77
-     */
78
-    protected function _setup_metaboxes()
79
-    {
80
-        // if we were going to add our own metaboxes we'd use the below.
81
-        $this->_metaboxes = array(
82
-            0 => array(
83
-                'page_route' => array('edit', 'create_new'),
84
-                'func'       => 'pricing_metabox',
85
-                'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
86
-                'priority'   => 'high',
87
-                'context'    => 'normal',
88
-            ),
89
-        );
90
-        $this->_remove_metaboxes = array(
91
-            0 => array(
92
-                'page_route' => array('edit', 'create_new'),
93
-                'id'         => 'espresso_event_editor_tickets',
94
-                'context'    => 'normal',
95
-            ),
96
-        );
97
-    }
75
+	/**
76
+	 * @return void
77
+	 */
78
+	protected function _setup_metaboxes()
79
+	{
80
+		// if we were going to add our own metaboxes we'd use the below.
81
+		$this->_metaboxes = array(
82
+			0 => array(
83
+				'page_route' => array('edit', 'create_new'),
84
+				'func'       => 'pricing_metabox',
85
+				'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
86
+				'priority'   => 'high',
87
+				'context'    => 'normal',
88
+			),
89
+		);
90
+		$this->_remove_metaboxes = array(
91
+			0 => array(
92
+				'page_route' => array('edit', 'create_new'),
93
+				'id'         => 'espresso_event_editor_tickets',
94
+				'context'    => 'normal',
95
+			),
96
+		);
97
+	}
98 98
 
99 99
 
100
-    /**
101
-     * @return void
102
-     */
103
-    protected function _set_date_time_formats()
104
-    {
105
-        /**
106
-         * Format strings for date and time.  Defaults are existing behaviour from 4.1.
107
-         * Note, that if you return null as the value for 'date', and 'time' in the array, then
108
-         * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
109
-         *
110
-         * @since 4.6.7
111
-         * @var array  Expected an array returned with 'date' and 'time' keys.
112
-         */
113
-        $this->_date_format_strings = apply_filters(
114
-            'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
115
-            array(
116
-                'date' => 'Y-m-d',
117
-                'time' => 'h:i a',
118
-            )
119
-        );
120
-        // validate
121
-        $this->_date_format_strings['date'] = isset($this->_date_format_strings['date'])
122
-            ? $this->_date_format_strings['date']
123
-            : null;
124
-        $this->_date_format_strings['time'] = isset($this->_date_format_strings['time'])
125
-            ? $this->_date_format_strings['time']
126
-            : null;
127
-        $this->_date_time_format = $this->_date_format_strings['date']
128
-                                   . ' '
129
-                                   . $this->_date_format_strings['time'];
130
-    }
100
+	/**
101
+	 * @return void
102
+	 */
103
+	protected function _set_date_time_formats()
104
+	{
105
+		/**
106
+		 * Format strings for date and time.  Defaults are existing behaviour from 4.1.
107
+		 * Note, that if you return null as the value for 'date', and 'time' in the array, then
108
+		 * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
109
+		 *
110
+		 * @since 4.6.7
111
+		 * @var array  Expected an array returned with 'date' and 'time' keys.
112
+		 */
113
+		$this->_date_format_strings = apply_filters(
114
+			'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
115
+			array(
116
+				'date' => 'Y-m-d',
117
+				'time' => 'h:i a',
118
+			)
119
+		);
120
+		// validate
121
+		$this->_date_format_strings['date'] = isset($this->_date_format_strings['date'])
122
+			? $this->_date_format_strings['date']
123
+			: null;
124
+		$this->_date_format_strings['time'] = isset($this->_date_format_strings['time'])
125
+			? $this->_date_format_strings['time']
126
+			: null;
127
+		$this->_date_time_format = $this->_date_format_strings['date']
128
+								   . ' '
129
+								   . $this->_date_format_strings['time'];
130
+	}
131 131
 
132 132
 
133
-    /**
134
-     * @return void
135
-     */
136
-    protected function _validate_format_strings()
137
-    {
138
-        // validate format strings
139
-        $format_validation = EEH_DTT_Helper::validate_format_string(
140
-            $this->_date_time_format
141
-        );
142
-        if (is_array($format_validation)) {
143
-            $msg = '<p>';
144
-            $msg .= sprintf(
145
-                esc_html__(
146
-                    'The format "%s" was likely added via a filter and is invalid for the following reasons:',
147
-                    'event_espresso'
148
-                ),
149
-                $this->_date_time_format
150
-            );
151
-            $msg .= '</p><ul>';
152
-            foreach ($format_validation as $error) {
153
-                $msg .= '<li>' . $error . '</li>';
154
-            }
155
-            $msg .= '</ul><p>';
156
-            $msg .= sprintf(
157
-                esc_html__(
158
-                    '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
159
-                    'event_espresso'
160
-                ),
161
-                '<span style="color:#D54E21;">',
162
-                '</span>'
163
-            );
164
-            $msg .= '</p>';
165
-            EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
166
-            $this->_date_format_strings = array(
167
-                'date' => 'Y-m-d',
168
-                'time' => 'h:i a',
169
-            );
170
-        }
171
-    }
133
+	/**
134
+	 * @return void
135
+	 */
136
+	protected function _validate_format_strings()
137
+	{
138
+		// validate format strings
139
+		$format_validation = EEH_DTT_Helper::validate_format_string(
140
+			$this->_date_time_format
141
+		);
142
+		if (is_array($format_validation)) {
143
+			$msg = '<p>';
144
+			$msg .= sprintf(
145
+				esc_html__(
146
+					'The format "%s" was likely added via a filter and is invalid for the following reasons:',
147
+					'event_espresso'
148
+				),
149
+				$this->_date_time_format
150
+			);
151
+			$msg .= '</p><ul>';
152
+			foreach ($format_validation as $error) {
153
+				$msg .= '<li>' . $error . '</li>';
154
+			}
155
+			$msg .= '</ul><p>';
156
+			$msg .= sprintf(
157
+				esc_html__(
158
+					'%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
159
+					'event_espresso'
160
+				),
161
+				'<span style="color:#D54E21;">',
162
+				'</span>'
163
+			);
164
+			$msg .= '</p>';
165
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
166
+			$this->_date_format_strings = array(
167
+				'date' => 'Y-m-d',
168
+				'time' => 'h:i a',
169
+			);
170
+		}
171
+	}
172 172
 
173 173
 
174
-    /**
175
-     * @return void
176
-     */
177
-    protected function _set_scripts_styles()
178
-    {
179
-        $this->_scripts_styles = array(
180
-            'registers'   => array(
181
-                'ee-tickets-datetimes-css' => array(
182
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
183
-                    'type' => 'css',
184
-                ),
185
-                'ee-dtt-ticket-metabox'    => array(
186
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
187
-                    'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
188
-                ),
189
-            ),
190
-            'deregisters' => array(
191
-                'event-editor-css'       => array('type' => 'css'),
192
-                'event-datetime-metabox' => array('type' => 'js'),
193
-            ),
194
-            'enqueues'    => array(
195
-                'ee-tickets-datetimes-css' => array('edit', 'create_new'),
196
-                'ee-dtt-ticket-metabox'    => array('edit', 'create_new'),
197
-            ),
198
-            'localize'    => array(
199
-                'ee-dtt-ticket-metabox' => array(
200
-                    'DTT_TRASH_BLOCK'       => array(
201
-                        'main_warning'            => esc_html__(
202
-                            'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
203
-                            'event_espresso'
204
-                        ),
205
-                        'after_warning'           => esc_html__(
206
-                            'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
207
-                            'event_espresso'
208
-                        ),
209
-                        'cancel_button'           => '<button class="button-secondary ee-modal-cancel">'
210
-                                                     . esc_html__('Cancel', 'event_espresso') . '</button>',
211
-                        'close_button'            => '<button class="button-secondary ee-modal-cancel">'
212
-                                                     . esc_html__('Close', 'event_espresso') . '</button>',
213
-                        'single_warning_from_tkt' => esc_html__(
214
-                            'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
215
-                            'event_espresso'
216
-                        ),
217
-                        'single_warning_from_dtt' => esc_html__(
218
-                            'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
219
-                            'event_espresso'
220
-                        ),
221
-                        'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">'
222
-                                                     . esc_html__('Dismiss', 'event_espresso') . '</button>',
223
-                    ),
224
-                    'DTT_ERROR_MSG'         => array(
225
-                        'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
226
-                        'dismiss_button' => '<div class="save-cancel-button-container">'
227
-                                            . '<button class="button-secondary ee-modal-cancel">'
228
-                                            . esc_html__('Dismiss', 'event_espresso')
229
-                                            . '</button></div>',
230
-                    ),
231
-                    'DTT_OVERSELL_WARNING'  => array(
232
-                        'datetime_ticket' => esc_html__(
233
-                            'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
234
-                            'event_espresso'
235
-                        ),
236
-                        'ticket_datetime' => esc_html__(
237
-                            'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
238
-                            'event_espresso'
239
-                        ),
240
-                    ),
241
-                    'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
242
-                        $this->_date_format_strings['date'],
243
-                        $this->_date_format_strings['time']
244
-                    ),
245
-                    'DTT_START_OF_WEEK'     => array('dayValue' => (int) get_option('start_of_week')),
246
-                ),
247
-            ),
248
-        );
249
-    }
174
+	/**
175
+	 * @return void
176
+	 */
177
+	protected function _set_scripts_styles()
178
+	{
179
+		$this->_scripts_styles = array(
180
+			'registers'   => array(
181
+				'ee-tickets-datetimes-css' => array(
182
+					'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
183
+					'type' => 'css',
184
+				),
185
+				'ee-dtt-ticket-metabox'    => array(
186
+					'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
187
+					'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
188
+				),
189
+			),
190
+			'deregisters' => array(
191
+				'event-editor-css'       => array('type' => 'css'),
192
+				'event-datetime-metabox' => array('type' => 'js'),
193
+			),
194
+			'enqueues'    => array(
195
+				'ee-tickets-datetimes-css' => array('edit', 'create_new'),
196
+				'ee-dtt-ticket-metabox'    => array('edit', 'create_new'),
197
+			),
198
+			'localize'    => array(
199
+				'ee-dtt-ticket-metabox' => array(
200
+					'DTT_TRASH_BLOCK'       => array(
201
+						'main_warning'            => esc_html__(
202
+							'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
203
+							'event_espresso'
204
+						),
205
+						'after_warning'           => esc_html__(
206
+							'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
207
+							'event_espresso'
208
+						),
209
+						'cancel_button'           => '<button class="button-secondary ee-modal-cancel">'
210
+													 . esc_html__('Cancel', 'event_espresso') . '</button>',
211
+						'close_button'            => '<button class="button-secondary ee-modal-cancel">'
212
+													 . esc_html__('Close', 'event_espresso') . '</button>',
213
+						'single_warning_from_tkt' => esc_html__(
214
+							'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
215
+							'event_espresso'
216
+						),
217
+						'single_warning_from_dtt' => esc_html__(
218
+							'The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.',
219
+							'event_espresso'
220
+						),
221
+						'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">'
222
+													 . esc_html__('Dismiss', 'event_espresso') . '</button>',
223
+					),
224
+					'DTT_ERROR_MSG'         => array(
225
+						'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
226
+						'dismiss_button' => '<div class="save-cancel-button-container">'
227
+											. '<button class="button-secondary ee-modal-cancel">'
228
+											. esc_html__('Dismiss', 'event_espresso')
229
+											. '</button></div>',
230
+					),
231
+					'DTT_OVERSELL_WARNING'  => array(
232
+						'datetime_ticket' => esc_html__(
233
+							'You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.',
234
+							'event_espresso'
235
+						),
236
+						'ticket_datetime' => esc_html__(
237
+							'You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.',
238
+							'event_espresso'
239
+						),
240
+					),
241
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
242
+						$this->_date_format_strings['date'],
243
+						$this->_date_format_strings['time']
244
+					),
245
+					'DTT_START_OF_WEEK'     => array('dayValue' => (int) get_option('start_of_week')),
246
+				),
247
+			),
248
+		);
249
+	}
250 250
 
251 251
 
252
-    /**
253
-     * @param array $update_callbacks
254
-     * @return array
255
-     */
256
-    public function caf_updates(array $update_callbacks)
257
-    {
258
-        foreach ($update_callbacks as $key => $callback) {
259
-            if ($callback[1] === '_default_tickets_update') {
260
-                unset($update_callbacks[ $key ]);
261
-            }
262
-        }
263
-        $update_callbacks[] = array($this, 'datetime_and_tickets_caf_update');
264
-        return $update_callbacks;
265
-    }
252
+	/**
253
+	 * @param array $update_callbacks
254
+	 * @return array
255
+	 */
256
+	public function caf_updates(array $update_callbacks)
257
+	{
258
+		foreach ($update_callbacks as $key => $callback) {
259
+			if ($callback[1] === '_default_tickets_update') {
260
+				unset($update_callbacks[ $key ]);
261
+			}
262
+		}
263
+		$update_callbacks[] = array($this, 'datetime_and_tickets_caf_update');
264
+		return $update_callbacks;
265
+	}
266 266
 
267 267
 
268
-    /**
269
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
270
-     *
271
-     * @param  EE_Event $event The Event object we're attaching data to
272
-     * @param  array    $data  The request data from the form
273
-     * @throws ReflectionException
274
-     * @throws Exception
275
-     * @throws InvalidInterfaceException
276
-     * @throws InvalidDataTypeException
277
-     * @throws EE_Error
278
-     * @throws InvalidArgumentException
279
-     */
280
-    public function datetime_and_tickets_caf_update($event, $data)
281
-    {
282
-        // first we need to start with datetimes cause they are the "root" items attached to events.
283
-        $saved_datetimes = $this->_update_datetimes($event, $data);
284
-        // next tackle the tickets (and prices?)
285
-        $this->_update_tickets($event, $saved_datetimes, $data);
286
-    }
268
+	/**
269
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
270
+	 *
271
+	 * @param  EE_Event $event The Event object we're attaching data to
272
+	 * @param  array    $data  The request data from the form
273
+	 * @throws ReflectionException
274
+	 * @throws Exception
275
+	 * @throws InvalidInterfaceException
276
+	 * @throws InvalidDataTypeException
277
+	 * @throws EE_Error
278
+	 * @throws InvalidArgumentException
279
+	 */
280
+	public function datetime_and_tickets_caf_update($event, $data)
281
+	{
282
+		// first we need to start with datetimes cause they are the "root" items attached to events.
283
+		$saved_datetimes = $this->_update_datetimes($event, $data);
284
+		// next tackle the tickets (and prices?)
285
+		$this->_update_tickets($event, $saved_datetimes, $data);
286
+	}
287 287
 
288 288
 
289
-    /**
290
-     * update event_datetimes
291
-     *
292
-     * @param  EE_Event $event Event being updated
293
-     * @param  array    $data  the request data from the form
294
-     * @return EE_Datetime[]
295
-     * @throws Exception
296
-     * @throws ReflectionException
297
-     * @throws InvalidInterfaceException
298
-     * @throws InvalidDataTypeException
299
-     * @throws InvalidArgumentException
300
-     * @throws EE_Error
301
-     */
302
-    protected function _update_datetimes($event, $data)
303
-    {
304
-        $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
305
-        $saved_dtt_ids = array();
306
-        $saved_dtt_objs = array();
307
-        if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
308
-            throw new InvalidArgumentException(
309
-                esc_html__(
310
-                    'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
311
-                    'event_espresso'
312
-                )
313
-            );
314
-        }
315
-        foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
316
-            // trim all values to ensure any excess whitespace is removed.
317
-            $datetime_data = array_map(
318
-                function ($datetime_data) {
319
-                    return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
320
-                },
321
-                $datetime_data
322
-            );
323
-            $datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
324
-                                            && ! empty($datetime_data['DTT_EVT_end'])
325
-                ? $datetime_data['DTT_EVT_end']
326
-                : $datetime_data['DTT_EVT_start'];
327
-            $datetime_values = array(
328
-                'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
329
-                    ? $datetime_data['DTT_ID']
330
-                    : null,
331
-                'DTT_name'        => ! empty($datetime_data['DTT_name'])
332
-                    ? $datetime_data['DTT_name']
333
-                    : '',
334
-                'DTT_description' => ! empty($datetime_data['DTT_description'])
335
-                    ? $datetime_data['DTT_description']
336
-                    : '',
337
-                'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
338
-                'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
339
-                'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
340
-                    ? EE_INF
341
-                    : $datetime_data['DTT_reg_limit'],
342
-                'DTT_order'       => ! isset($datetime_data['DTT_order'])
343
-                    ? $row
344
-                    : $datetime_data['DTT_order'],
345
-            );
346
-            // if we have an id then let's get existing object first and then set the new values.
347
-            // Otherwise we instantiate a new object for save.
348
-            if (! empty($datetime_data['DTT_ID'])) {
349
-                $datetime = EE_Registry::instance()
350
-                                       ->load_model('Datetime', array($timezone))
351
-                                       ->get_one_by_ID($datetime_data['DTT_ID']);
352
-                // set date and time format according to what is set in this class.
353
-                $datetime->set_date_format($this->_date_format_strings['date']);
354
-                $datetime->set_time_format($this->_date_format_strings['time']);
355
-                foreach ($datetime_values as $field => $value) {
356
-                    $datetime->set($field, $value);
357
-                }
358
-                // make sure the $dtt_id here is saved just in case
359
-                // after the add_relation_to() the autosave replaces it.
360
-                // We need to do this so we dont' TRASH the parent DTT.
361
-                // (save the ID for both key and value to avoid duplications)
362
-                $saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
363
-            } else {
364
-                $datetime = EE_Registry::instance()->load_class(
365
-                    'Datetime',
366
-                    array(
367
-                        $datetime_values,
368
-                        $timezone,
369
-                        array($this->_date_format_strings['date'], $this->_date_format_strings['time']),
370
-                    ),
371
-                    false,
372
-                    false
373
-                );
374
-                foreach ($datetime_values as $field => $value) {
375
-                    $datetime->set($field, $value);
376
-                }
377
-            }
378
-            $datetime->save();
379
-            do_action(
380
-                'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save',
381
-                $datetime,
382
-                $row,
383
-                $datetime_data,
384
-                $data
385
-            );
386
-            $datetime = $event->_add_relation_to($datetime, 'Datetime');
387
-            // before going any further make sure our dates are setup correctly
388
-            // so that the end date is always equal or greater than the start date.
389
-            if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
390
-                $datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
391
-                $datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
392
-                $datetime->save();
393
-            }
394
-            // now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
395
-            // because it is possible there was a new one created for the autosave.
396
-            // (save the ID for both key and value to avoid duplications)
397
-            $DTT_ID = $datetime->ID();
398
-            $saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
399
-            $saved_dtt_objs[ $row ] = $datetime;
400
-            // @todo if ANY of these updates fail then we want the appropriate global error message.
401
-        }
402
-        $event->save();
403
-        // now we need to REMOVE any datetimes that got deleted.
404
-        // Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
405
-        // So its safe to permanently delete at this point.
406
-        $old_datetimes = explode(',', $data['datetime_IDs']);
407
-        $old_datetimes = $old_datetimes[0] === '' ? array() : $old_datetimes;
408
-        if (is_array($old_datetimes)) {
409
-            $datetimes_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
410
-            foreach ($datetimes_to_delete as $id) {
411
-                $id = absint($id);
412
-                if (empty($id)) {
413
-                    continue;
414
-                }
415
-                $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
416
-                // remove tkt relationships.
417
-                $related_tickets = $dtt_to_remove->get_many_related('Ticket');
418
-                foreach ($related_tickets as $tkt) {
419
-                    $dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
420
-                }
421
-                $event->_remove_relation_to($id, 'Datetime');
422
-                $dtt_to_remove->refresh_cache_of_related_objects();
423
-            }
424
-        }
425
-        return $saved_dtt_objs;
426
-    }
289
+	/**
290
+	 * update event_datetimes
291
+	 *
292
+	 * @param  EE_Event $event Event being updated
293
+	 * @param  array    $data  the request data from the form
294
+	 * @return EE_Datetime[]
295
+	 * @throws Exception
296
+	 * @throws ReflectionException
297
+	 * @throws InvalidInterfaceException
298
+	 * @throws InvalidDataTypeException
299
+	 * @throws InvalidArgumentException
300
+	 * @throws EE_Error
301
+	 */
302
+	protected function _update_datetimes($event, $data)
303
+	{
304
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
305
+		$saved_dtt_ids = array();
306
+		$saved_dtt_objs = array();
307
+		if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
308
+			throw new InvalidArgumentException(
309
+				esc_html__(
310
+					'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
311
+					'event_espresso'
312
+				)
313
+			);
314
+		}
315
+		foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
316
+			// trim all values to ensure any excess whitespace is removed.
317
+			$datetime_data = array_map(
318
+				function ($datetime_data) {
319
+					return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
320
+				},
321
+				$datetime_data
322
+			);
323
+			$datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
324
+											&& ! empty($datetime_data['DTT_EVT_end'])
325
+				? $datetime_data['DTT_EVT_end']
326
+				: $datetime_data['DTT_EVT_start'];
327
+			$datetime_values = array(
328
+				'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
329
+					? $datetime_data['DTT_ID']
330
+					: null,
331
+				'DTT_name'        => ! empty($datetime_data['DTT_name'])
332
+					? $datetime_data['DTT_name']
333
+					: '',
334
+				'DTT_description' => ! empty($datetime_data['DTT_description'])
335
+					? $datetime_data['DTT_description']
336
+					: '',
337
+				'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
338
+				'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
339
+				'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
340
+					? EE_INF
341
+					: $datetime_data['DTT_reg_limit'],
342
+				'DTT_order'       => ! isset($datetime_data['DTT_order'])
343
+					? $row
344
+					: $datetime_data['DTT_order'],
345
+			);
346
+			// if we have an id then let's get existing object first and then set the new values.
347
+			// Otherwise we instantiate a new object for save.
348
+			if (! empty($datetime_data['DTT_ID'])) {
349
+				$datetime = EE_Registry::instance()
350
+									   ->load_model('Datetime', array($timezone))
351
+									   ->get_one_by_ID($datetime_data['DTT_ID']);
352
+				// set date and time format according to what is set in this class.
353
+				$datetime->set_date_format($this->_date_format_strings['date']);
354
+				$datetime->set_time_format($this->_date_format_strings['time']);
355
+				foreach ($datetime_values as $field => $value) {
356
+					$datetime->set($field, $value);
357
+				}
358
+				// make sure the $dtt_id here is saved just in case
359
+				// after the add_relation_to() the autosave replaces it.
360
+				// We need to do this so we dont' TRASH the parent DTT.
361
+				// (save the ID for both key and value to avoid duplications)
362
+				$saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
363
+			} else {
364
+				$datetime = EE_Registry::instance()->load_class(
365
+					'Datetime',
366
+					array(
367
+						$datetime_values,
368
+						$timezone,
369
+						array($this->_date_format_strings['date'], $this->_date_format_strings['time']),
370
+					),
371
+					false,
372
+					false
373
+				);
374
+				foreach ($datetime_values as $field => $value) {
375
+					$datetime->set($field, $value);
376
+				}
377
+			}
378
+			$datetime->save();
379
+			do_action(
380
+				'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save',
381
+				$datetime,
382
+				$row,
383
+				$datetime_data,
384
+				$data
385
+			);
386
+			$datetime = $event->_add_relation_to($datetime, 'Datetime');
387
+			// before going any further make sure our dates are setup correctly
388
+			// so that the end date is always equal or greater than the start date.
389
+			if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
390
+				$datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
391
+				$datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
392
+				$datetime->save();
393
+			}
394
+			// now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
395
+			// because it is possible there was a new one created for the autosave.
396
+			// (save the ID for both key and value to avoid duplications)
397
+			$DTT_ID = $datetime->ID();
398
+			$saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
399
+			$saved_dtt_objs[ $row ] = $datetime;
400
+			// @todo if ANY of these updates fail then we want the appropriate global error message.
401
+		}
402
+		$event->save();
403
+		// now we need to REMOVE any datetimes that got deleted.
404
+		// Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
405
+		// So its safe to permanently delete at this point.
406
+		$old_datetimes = explode(',', $data['datetime_IDs']);
407
+		$old_datetimes = $old_datetimes[0] === '' ? array() : $old_datetimes;
408
+		if (is_array($old_datetimes)) {
409
+			$datetimes_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
410
+			foreach ($datetimes_to_delete as $id) {
411
+				$id = absint($id);
412
+				if (empty($id)) {
413
+					continue;
414
+				}
415
+				$dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
416
+				// remove tkt relationships.
417
+				$related_tickets = $dtt_to_remove->get_many_related('Ticket');
418
+				foreach ($related_tickets as $tkt) {
419
+					$dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
420
+				}
421
+				$event->_remove_relation_to($id, 'Datetime');
422
+				$dtt_to_remove->refresh_cache_of_related_objects();
423
+			}
424
+		}
425
+		return $saved_dtt_objs;
426
+	}
427 427
 
428 428
 
429
-    /**
430
-     * update tickets
431
-     *
432
-     * @param  EE_Event      $event           Event object being updated
433
-     * @param  EE_Datetime[] $saved_datetimes an array of datetime ids being updated
434
-     * @param  array         $data            incoming request data
435
-     * @return EE_Ticket[]
436
-     * @throws Exception
437
-     * @throws ReflectionException
438
-     * @throws InvalidInterfaceException
439
-     * @throws InvalidDataTypeException
440
-     * @throws InvalidArgumentException
441
-     * @throws EE_Error
442
-     */
443
-    protected function _update_tickets($event, $saved_datetimes, $data)
444
-    {
445
-        $new_tkt = null;
446
-        // stripslashes because WP filtered the $_POST ($data) array to add slashes
447
-        $data = stripslashes_deep($data);
448
-        $timezone = $data['timezone_string'] ?? null;
449
-        $saved_tickets = array();
450
-        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
451
-        if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
452
-            throw new InvalidArgumentException(
453
-                esc_html__(
454
-                    'The "edit_tickets" array is invalid therefore the event can not be updated.',
455
-                    'event_espresso'
456
-                )
457
-            );
458
-        }
459
-        foreach ($data['edit_tickets'] as $row => $tkt) {
460
-            $update_prices = $create_new_TKT = false;
461
-            // figure out what datetimes were added to the ticket
462
-            // and what datetimes were removed from the ticket in the session.
463
-            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
464
-            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
465
-            $datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
466
-            $datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
467
-            // trim inputs to ensure any excess whitespace is removed.
468
-            $tkt = array_map(
469
-                function ($ticket_data) {
470
-                    return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
471
-                },
472
-                $tkt
473
-            );
474
-            // note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
475
-            // because we're doing calculations prior to using the models.
476
-            // note incoming ['TKT_price'] value is already in standard notation (via js).
477
-            $ticket_price = isset($tkt['TKT_price'])
478
-                ? round((float) $tkt['TKT_price'], 3)
479
-                : 0;
480
-            // note incoming base price needs converted from localized value.
481
-            $base_price = isset($tkt['TKT_base_price'])
482
-                ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price'])
483
-                : 0;
484
-            // if ticket price == 0 and $base_price != 0 then ticket price == base_price
485
-            $ticket_price = $ticket_price === 0 && $base_price !== 0
486
-                ? $base_price
487
-                : $ticket_price;
488
-            $base_price_id = $tkt['TKT_base_price_ID'] ?? 0;
489
-            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
490
-                ? $data['edit_prices'][ $row ]
491
-                : array();
492
-            $now = null;
493
-            if (empty($tkt['TKT_start_date'])) {
494
-                // lets' use now in the set timezone.
495
-                $now = new DateTime('now', new DateTimeZone($event->get_timezone()));
496
-                $tkt['TKT_start_date'] = $now->format($this->_date_time_format);
497
-            }
498
-            if (empty($tkt['TKT_end_date'])) {
499
-                /**
500
-                 * set the TKT_end_date to the first datetime attached to the ticket.
501
-                 */
502
-                $first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
503
-                $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
504
-            }
505
-            $TKT_values = array(
506
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
507
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
508
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
509
-                'TKT_description' => ! empty($tkt['TKT_description'])
510
-                                     && $tkt['TKT_description'] !== esc_html__(
511
-                                         'You can modify this description',
512
-                                         'event_espresso'
513
-                                     )
514
-                    ? $tkt['TKT_description']
515
-                    : '',
516
-                'TKT_start_date'  => $tkt['TKT_start_date'],
517
-                'TKT_end_date'    => $tkt['TKT_end_date'],
518
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === ''
519
-                    ? EE_INF
520
-                    : $tkt['TKT_qty'],
521
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === ''
522
-                    ? EE_INF
523
-                    : $tkt['TKT_uses'],
524
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
525
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
526
-                'TKT_row'         => $row,
527
-                'TKT_order'       => $tkt['TKT_order'] ?? 0,
528
-                'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
529
-                'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
530
-                'TKT_price'       => $ticket_price,
531
-            );
532
-            // if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
533
-            // which means in turn that the prices will become new prices as well.
534
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
535
-                $TKT_values['TKT_ID'] = 0;
536
-                $TKT_values['TKT_is_default'] = 0;
537
-                $update_prices = true;
538
-            }
539
-            // if we have a TKT_ID then we need to get that existing TKT_obj and update it
540
-            // we actually do our saves ahead of doing any add_relations to
541
-            // because its entirely possible that this ticket wasn't removed or added to any datetime in the session
542
-            // but DID have it's items modified.
543
-            // keep in mind that if the TKT has been sold (and we have changed pricing information),
544
-            // then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
545
-            if (absint($TKT_values['TKT_ID'])) {
546
-                $ticket = EE_Registry::instance()
547
-                                     ->load_model('Ticket', array($timezone))
548
-                                     ->get_one_by_ID($tkt['TKT_ID']);
549
-                if ($ticket instanceof EE_Ticket) {
550
-                    $ticket = $this->_update_ticket_datetimes(
551
-                        $ticket,
552
-                        $saved_datetimes,
553
-                        $datetimes_added,
554
-                        $datetimes_removed
555
-                    );
556
-                    // are there any registrations using this ticket ?
557
-                    $tickets_sold = $ticket->count_related(
558
-                        'Registration',
559
-                        array(
560
-                            array(
561
-                                'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)),
562
-                            ),
563
-                        )
564
-                    );
565
-                    // set ticket formats
566
-                    $ticket->set_date_format($this->_date_format_strings['date']);
567
-                    $ticket->set_time_format($this->_date_format_strings['time']);
568
-                    // let's just check the total price for the existing ticket
569
-                    // and determine if it matches the new total price.
570
-                    // if they are different then we create a new ticket (if tickets sold)
571
-                    // if they aren't different then we go ahead and modify existing ticket.
572
-                    $create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
573
-                    // set new values
574
-                    foreach ($TKT_values as $field => $value) {
575
-                        if ($field === 'TKT_qty') {
576
-                            $ticket->set_qty($value);
577
-                        } else {
578
-                            $ticket->set($field, $value);
579
-                        }
580
-                    }
581
-                    // if $create_new_TKT is false then we can safely update the existing ticket.
582
-                    // Otherwise we have to create a new ticket.
583
-                    if ($create_new_TKT) {
584
-                        $new_tkt = $this->_duplicate_ticket(
585
-                            $ticket,
586
-                            $price_rows,
587
-                            $ticket_price,
588
-                            $base_price,
589
-                            $base_price_id
590
-                        );
591
-                    }
592
-                }
593
-            } else {
594
-                // no TKT_id so a new TKT
595
-                $ticket = EE_Ticket::new_instance(
596
-                    $TKT_values,
597
-                    $timezone,
598
-                    array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
599
-                );
600
-                if ($ticket instanceof EE_Ticket) {
601
-                    // make sure ticket has an ID of setting relations won't work
602
-                    $ticket->save();
603
-                    $ticket = $this->_update_ticket_datetimes(
604
-                        $ticket,
605
-                        $saved_datetimes,
606
-                        $datetimes_added,
607
-                        $datetimes_removed
608
-                    );
609
-                    $update_prices = true;
610
-                }
611
-            }
612
-            // make sure any current values have been saved.
613
-            // $ticket->save();
614
-            // before going any further make sure our dates are setup correctly
615
-            // so that the end date is always equal or greater than the start date.
616
-            if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
617
-                $ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
618
-                $ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
619
-            }
620
-            // let's make sure the base price is handled
621
-            $ticket = ! $create_new_TKT
622
-                ? $this->_add_prices_to_ticket(
623
-                    array(),
624
-                    $ticket,
625
-                    $update_prices,
626
-                    $base_price,
627
-                    $base_price_id
628
-                )
629
-                : $ticket;
630
-            // add/update price_modifiers
631
-            $ticket = ! $create_new_TKT
632
-                ? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
633
-                : $ticket;
634
-            // need to make sue that the TKT_price is accurate after saving the prices.
635
-            $ticket->ensure_TKT_Price_correct();
636
-            // handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
637
-            if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
638
-                $update_prices = true;
639
-                $new_default = clone $ticket;
640
-                $new_default->set('TKT_ID', 0);
641
-                $new_default->set('TKT_is_default', 1);
642
-                $new_default->set('TKT_row', 1);
643
-                $new_default->set('TKT_price', $ticket_price);
644
-                // remove any dtt relations cause we DON'T want dtt relations attached
645
-                // (note this is just removing the cached relations in the object)
646
-                $new_default->_remove_relations('Datetime');
647
-                // @todo we need to add the current attached prices as new prices to the new default ticket.
648
-                $new_default = $this->_add_prices_to_ticket(
649
-                    $price_rows,
650
-                    $new_default,
651
-                    $update_prices
652
-                );
653
-                // don't forget the base price!
654
-                $new_default = $this->_add_prices_to_ticket(
655
-                    array(),
656
-                    $new_default,
657
-                    $update_prices,
658
-                    $base_price,
659
-                    $base_price_id
660
-                );
661
-                $new_default->save();
662
-                do_action(
663
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
664
-                    $new_default,
665
-                    $row,
666
-                    $ticket,
667
-                    $data
668
-                );
669
-            }
670
-            // DO ALL dtt relationships for both current tickets and any archived tickets
671
-            // for the given dtt that are related to the current ticket.
672
-            // TODO... not sure exactly how we're going to do this considering we don't know
673
-            // what current ticket the archived tickets are related to
674
-            // (and TKT_parent is used for autosaves so that's not a field we can reliably use).
675
-            // let's assign any tickets that have been setup to the saved_tickets tracker
676
-            // save existing TKT
677
-            $ticket->save();
678
-            if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
679
-                // save new TKT
680
-                $new_tkt->save();
681
-                // add new ticket to array
682
-                $saved_tickets[ $new_tkt->ID() ] = $new_tkt;
683
-                do_action(
684
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
685
-                    $new_tkt,
686
-                    $row,
687
-                    $tkt,
688
-                    $data
689
-                );
690
-            } else {
691
-                // add tkt to saved tkts
692
-                $saved_tickets[ $ticket->ID() ] = $ticket;
693
-                do_action(
694
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
695
-                    $ticket,
696
-                    $row,
697
-                    $tkt,
698
-                    $data
699
-                );
700
-            }
701
-        }
702
-        // now we need to handle tickets actually "deleted permanently".
703
-        // There are cases where we'd want this to happen
704
-        // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
705
-        // Or a draft event was saved and in the process of editing a ticket is trashed.
706
-        // No sense in keeping all the related data in the db!
707
-        $old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
708
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
709
-        foreach ($tickets_removed as $id) {
710
-            $id = absint($id);
711
-            // get the ticket for this id
712
-            $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
713
-            // if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
714
-            if ($tkt_to_remove->get('TKT_is_default')) {
715
-                continue;
716
-            }
717
-            // if this tkt has any registrations attached so then we just ARCHIVE
718
-            // because we don't actually permanently delete these tickets.
719
-            if ($tkt_to_remove->count_related('Registration') > 0) {
720
-                $tkt_to_remove->delete();
721
-                continue;
722
-            }
723
-            // need to get all the related datetimes on this ticket and remove from every single one of them
724
-            // (remember this process can ONLY kick off if there are NO tkts_sold)
725
-            $datetimes = $tkt_to_remove->get_many_related('Datetime');
726
-            foreach ($datetimes as $datetime) {
727
-                $tkt_to_remove->_remove_relation_to($datetime, 'Datetime');
728
-            }
729
-            // need to do the same for prices (except these prices can also be deleted because again,
730
-            // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
731
-            $tkt_to_remove->delete_related_permanently('Price');
732
-            do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
733
-            // finally let's delete this ticket
734
-            // (which should not be blocked at this point b/c we've removed all our relationships)
735
-            $tkt_to_remove->delete_permanently();
736
-        }
737
-        return $saved_tickets;
738
-    }
429
+	/**
430
+	 * update tickets
431
+	 *
432
+	 * @param  EE_Event      $event           Event object being updated
433
+	 * @param  EE_Datetime[] $saved_datetimes an array of datetime ids being updated
434
+	 * @param  array         $data            incoming request data
435
+	 * @return EE_Ticket[]
436
+	 * @throws Exception
437
+	 * @throws ReflectionException
438
+	 * @throws InvalidInterfaceException
439
+	 * @throws InvalidDataTypeException
440
+	 * @throws InvalidArgumentException
441
+	 * @throws EE_Error
442
+	 */
443
+	protected function _update_tickets($event, $saved_datetimes, $data)
444
+	{
445
+		$new_tkt = null;
446
+		// stripslashes because WP filtered the $_POST ($data) array to add slashes
447
+		$data = stripslashes_deep($data);
448
+		$timezone = $data['timezone_string'] ?? null;
449
+		$saved_tickets = array();
450
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
451
+		if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
452
+			throw new InvalidArgumentException(
453
+				esc_html__(
454
+					'The "edit_tickets" array is invalid therefore the event can not be updated.',
455
+					'event_espresso'
456
+				)
457
+			);
458
+		}
459
+		foreach ($data['edit_tickets'] as $row => $tkt) {
460
+			$update_prices = $create_new_TKT = false;
461
+			// figure out what datetimes were added to the ticket
462
+			// and what datetimes were removed from the ticket in the session.
463
+			$starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
464
+			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
465
+			$datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
466
+			$datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
467
+			// trim inputs to ensure any excess whitespace is removed.
468
+			$tkt = array_map(
469
+				function ($ticket_data) {
470
+					return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
471
+				},
472
+				$tkt
473
+			);
474
+			// note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
475
+			// because we're doing calculations prior to using the models.
476
+			// note incoming ['TKT_price'] value is already in standard notation (via js).
477
+			$ticket_price = isset($tkt['TKT_price'])
478
+				? round((float) $tkt['TKT_price'], 3)
479
+				: 0;
480
+			// note incoming base price needs converted from localized value.
481
+			$base_price = isset($tkt['TKT_base_price'])
482
+				? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price'])
483
+				: 0;
484
+			// if ticket price == 0 and $base_price != 0 then ticket price == base_price
485
+			$ticket_price = $ticket_price === 0 && $base_price !== 0
486
+				? $base_price
487
+				: $ticket_price;
488
+			$base_price_id = $tkt['TKT_base_price_ID'] ?? 0;
489
+			$price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
490
+				? $data['edit_prices'][ $row ]
491
+				: array();
492
+			$now = null;
493
+			if (empty($tkt['TKT_start_date'])) {
494
+				// lets' use now in the set timezone.
495
+				$now = new DateTime('now', new DateTimeZone($event->get_timezone()));
496
+				$tkt['TKT_start_date'] = $now->format($this->_date_time_format);
497
+			}
498
+			if (empty($tkt['TKT_end_date'])) {
499
+				/**
500
+				 * set the TKT_end_date to the first datetime attached to the ticket.
501
+				 */
502
+				$first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
503
+				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
504
+			}
505
+			$TKT_values = array(
506
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
507
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
508
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
509
+				'TKT_description' => ! empty($tkt['TKT_description'])
510
+									 && $tkt['TKT_description'] !== esc_html__(
511
+										 'You can modify this description',
512
+										 'event_espresso'
513
+									 )
514
+					? $tkt['TKT_description']
515
+					: '',
516
+				'TKT_start_date'  => $tkt['TKT_start_date'],
517
+				'TKT_end_date'    => $tkt['TKT_end_date'],
518
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === ''
519
+					? EE_INF
520
+					: $tkt['TKT_qty'],
521
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === ''
522
+					? EE_INF
523
+					: $tkt['TKT_uses'],
524
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
525
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
526
+				'TKT_row'         => $row,
527
+				'TKT_order'       => $tkt['TKT_order'] ?? 0,
528
+				'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
529
+				'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
530
+				'TKT_price'       => $ticket_price,
531
+			);
532
+			// if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
533
+			// which means in turn that the prices will become new prices as well.
534
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
535
+				$TKT_values['TKT_ID'] = 0;
536
+				$TKT_values['TKT_is_default'] = 0;
537
+				$update_prices = true;
538
+			}
539
+			// if we have a TKT_ID then we need to get that existing TKT_obj and update it
540
+			// we actually do our saves ahead of doing any add_relations to
541
+			// because its entirely possible that this ticket wasn't removed or added to any datetime in the session
542
+			// but DID have it's items modified.
543
+			// keep in mind that if the TKT has been sold (and we have changed pricing information),
544
+			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
545
+			if (absint($TKT_values['TKT_ID'])) {
546
+				$ticket = EE_Registry::instance()
547
+									 ->load_model('Ticket', array($timezone))
548
+									 ->get_one_by_ID($tkt['TKT_ID']);
549
+				if ($ticket instanceof EE_Ticket) {
550
+					$ticket = $this->_update_ticket_datetimes(
551
+						$ticket,
552
+						$saved_datetimes,
553
+						$datetimes_added,
554
+						$datetimes_removed
555
+					);
556
+					// are there any registrations using this ticket ?
557
+					$tickets_sold = $ticket->count_related(
558
+						'Registration',
559
+						array(
560
+							array(
561
+								'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)),
562
+							),
563
+						)
564
+					);
565
+					// set ticket formats
566
+					$ticket->set_date_format($this->_date_format_strings['date']);
567
+					$ticket->set_time_format($this->_date_format_strings['time']);
568
+					// let's just check the total price for the existing ticket
569
+					// and determine if it matches the new total price.
570
+					// if they are different then we create a new ticket (if tickets sold)
571
+					// if they aren't different then we go ahead and modify existing ticket.
572
+					$create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
573
+					// set new values
574
+					foreach ($TKT_values as $field => $value) {
575
+						if ($field === 'TKT_qty') {
576
+							$ticket->set_qty($value);
577
+						} else {
578
+							$ticket->set($field, $value);
579
+						}
580
+					}
581
+					// if $create_new_TKT is false then we can safely update the existing ticket.
582
+					// Otherwise we have to create a new ticket.
583
+					if ($create_new_TKT) {
584
+						$new_tkt = $this->_duplicate_ticket(
585
+							$ticket,
586
+							$price_rows,
587
+							$ticket_price,
588
+							$base_price,
589
+							$base_price_id
590
+						);
591
+					}
592
+				}
593
+			} else {
594
+				// no TKT_id so a new TKT
595
+				$ticket = EE_Ticket::new_instance(
596
+					$TKT_values,
597
+					$timezone,
598
+					array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
599
+				);
600
+				if ($ticket instanceof EE_Ticket) {
601
+					// make sure ticket has an ID of setting relations won't work
602
+					$ticket->save();
603
+					$ticket = $this->_update_ticket_datetimes(
604
+						$ticket,
605
+						$saved_datetimes,
606
+						$datetimes_added,
607
+						$datetimes_removed
608
+					);
609
+					$update_prices = true;
610
+				}
611
+			}
612
+			// make sure any current values have been saved.
613
+			// $ticket->save();
614
+			// before going any further make sure our dates are setup correctly
615
+			// so that the end date is always equal or greater than the start date.
616
+			if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
617
+				$ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
618
+				$ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
619
+			}
620
+			// let's make sure the base price is handled
621
+			$ticket = ! $create_new_TKT
622
+				? $this->_add_prices_to_ticket(
623
+					array(),
624
+					$ticket,
625
+					$update_prices,
626
+					$base_price,
627
+					$base_price_id
628
+				)
629
+				: $ticket;
630
+			// add/update price_modifiers
631
+			$ticket = ! $create_new_TKT
632
+				? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
633
+				: $ticket;
634
+			// need to make sue that the TKT_price is accurate after saving the prices.
635
+			$ticket->ensure_TKT_Price_correct();
636
+			// handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
637
+			if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
638
+				$update_prices = true;
639
+				$new_default = clone $ticket;
640
+				$new_default->set('TKT_ID', 0);
641
+				$new_default->set('TKT_is_default', 1);
642
+				$new_default->set('TKT_row', 1);
643
+				$new_default->set('TKT_price', $ticket_price);
644
+				// remove any dtt relations cause we DON'T want dtt relations attached
645
+				// (note this is just removing the cached relations in the object)
646
+				$new_default->_remove_relations('Datetime');
647
+				// @todo we need to add the current attached prices as new prices to the new default ticket.
648
+				$new_default = $this->_add_prices_to_ticket(
649
+					$price_rows,
650
+					$new_default,
651
+					$update_prices
652
+				);
653
+				// don't forget the base price!
654
+				$new_default = $this->_add_prices_to_ticket(
655
+					array(),
656
+					$new_default,
657
+					$update_prices,
658
+					$base_price,
659
+					$base_price_id
660
+				);
661
+				$new_default->save();
662
+				do_action(
663
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
664
+					$new_default,
665
+					$row,
666
+					$ticket,
667
+					$data
668
+				);
669
+			}
670
+			// DO ALL dtt relationships for both current tickets and any archived tickets
671
+			// for the given dtt that are related to the current ticket.
672
+			// TODO... not sure exactly how we're going to do this considering we don't know
673
+			// what current ticket the archived tickets are related to
674
+			// (and TKT_parent is used for autosaves so that's not a field we can reliably use).
675
+			// let's assign any tickets that have been setup to the saved_tickets tracker
676
+			// save existing TKT
677
+			$ticket->save();
678
+			if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
679
+				// save new TKT
680
+				$new_tkt->save();
681
+				// add new ticket to array
682
+				$saved_tickets[ $new_tkt->ID() ] = $new_tkt;
683
+				do_action(
684
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
685
+					$new_tkt,
686
+					$row,
687
+					$tkt,
688
+					$data
689
+				);
690
+			} else {
691
+				// add tkt to saved tkts
692
+				$saved_tickets[ $ticket->ID() ] = $ticket;
693
+				do_action(
694
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
695
+					$ticket,
696
+					$row,
697
+					$tkt,
698
+					$data
699
+				);
700
+			}
701
+		}
702
+		// now we need to handle tickets actually "deleted permanently".
703
+		// There are cases where we'd want this to happen
704
+		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
705
+		// Or a draft event was saved and in the process of editing a ticket is trashed.
706
+		// No sense in keeping all the related data in the db!
707
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
708
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
709
+		foreach ($tickets_removed as $id) {
710
+			$id = absint($id);
711
+			// get the ticket for this id
712
+			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
713
+			// if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
714
+			if ($tkt_to_remove->get('TKT_is_default')) {
715
+				continue;
716
+			}
717
+			// if this tkt has any registrations attached so then we just ARCHIVE
718
+			// because we don't actually permanently delete these tickets.
719
+			if ($tkt_to_remove->count_related('Registration') > 0) {
720
+				$tkt_to_remove->delete();
721
+				continue;
722
+			}
723
+			// need to get all the related datetimes on this ticket and remove from every single one of them
724
+			// (remember this process can ONLY kick off if there are NO tkts_sold)
725
+			$datetimes = $tkt_to_remove->get_many_related('Datetime');
726
+			foreach ($datetimes as $datetime) {
727
+				$tkt_to_remove->_remove_relation_to($datetime, 'Datetime');
728
+			}
729
+			// need to do the same for prices (except these prices can also be deleted because again,
730
+			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
731
+			$tkt_to_remove->delete_related_permanently('Price');
732
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
733
+			// finally let's delete this ticket
734
+			// (which should not be blocked at this point b/c we've removed all our relationships)
735
+			$tkt_to_remove->delete_permanently();
736
+		}
737
+		return $saved_tickets;
738
+	}
739 739
 
740 740
 
741
-    /**
742
-     * @access  protected
743
-     * @param EE_Ticket      $ticket
744
-     * @param \EE_Datetime[] $saved_datetimes
745
-     * @param \EE_Datetime[] $added_datetimes
746
-     * @param \EE_Datetime[] $removed_datetimes
747
-     * @return EE_Ticket
748
-     * @throws EE_Error
749
-     */
750
-    protected function _update_ticket_datetimes(
751
-        EE_Ticket $ticket,
752
-        $saved_datetimes = array(),
753
-        $added_datetimes = array(),
754
-        $removed_datetimes = array()
755
-    ) {
756
-        // to start we have to add the ticket to all the datetimes its supposed to be with,
757
-        // and removing the ticket from datetimes it got removed from.
758
-        // first let's add datetimes
759
-        if (! empty($added_datetimes) && is_array($added_datetimes)) {
760
-            foreach ($added_datetimes as $row_id) {
761
-                $row_id = (int) $row_id;
762
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
763
-                    $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
764
-                    // Is this an existing ticket (has an ID) and does it have any sold?
765
-                    // If so, then we need to add that to the DTT sold because this DTT is getting added.
766
-                    if ($ticket->ID() && $ticket->sold() > 0) {
767
-                        $saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false);
768
-                    }
769
-                }
770
-            }
771
-        }
772
-        // then remove datetimes
773
-        if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
774
-            foreach ($removed_datetimes as $row_id) {
775
-                $row_id = (int) $row_id;
776
-                // its entirely possible that a datetime got deleted (instead of just removed from relationship.
777
-                // So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
778
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
779
-                    $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
780
-                    // Is this an existing ticket (has an ID) and does it have any sold?
781
-                    // If so, then we need to remove it's sold from the DTT_sold.
782
-                    if ($ticket->ID() && $ticket->sold() > 0) {
783
-                        $saved_datetimes[ $row_id ]->decreaseSold($ticket->sold());
784
-                    }
785
-                }
786
-            }
787
-        }
788
-        // cap ticket qty by datetime reg limits
789
-        $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
790
-        return $ticket;
791
-    }
741
+	/**
742
+	 * @access  protected
743
+	 * @param EE_Ticket      $ticket
744
+	 * @param \EE_Datetime[] $saved_datetimes
745
+	 * @param \EE_Datetime[] $added_datetimes
746
+	 * @param \EE_Datetime[] $removed_datetimes
747
+	 * @return EE_Ticket
748
+	 * @throws EE_Error
749
+	 */
750
+	protected function _update_ticket_datetimes(
751
+		EE_Ticket $ticket,
752
+		$saved_datetimes = array(),
753
+		$added_datetimes = array(),
754
+		$removed_datetimes = array()
755
+	) {
756
+		// to start we have to add the ticket to all the datetimes its supposed to be with,
757
+		// and removing the ticket from datetimes it got removed from.
758
+		// first let's add datetimes
759
+		if (! empty($added_datetimes) && is_array($added_datetimes)) {
760
+			foreach ($added_datetimes as $row_id) {
761
+				$row_id = (int) $row_id;
762
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
763
+					$ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
764
+					// Is this an existing ticket (has an ID) and does it have any sold?
765
+					// If so, then we need to add that to the DTT sold because this DTT is getting added.
766
+					if ($ticket->ID() && $ticket->sold() > 0) {
767
+						$saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false);
768
+					}
769
+				}
770
+			}
771
+		}
772
+		// then remove datetimes
773
+		if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
774
+			foreach ($removed_datetimes as $row_id) {
775
+				$row_id = (int) $row_id;
776
+				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
777
+				// So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
778
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
779
+					$ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
780
+					// Is this an existing ticket (has an ID) and does it have any sold?
781
+					// If so, then we need to remove it's sold from the DTT_sold.
782
+					if ($ticket->ID() && $ticket->sold() > 0) {
783
+						$saved_datetimes[ $row_id ]->decreaseSold($ticket->sold());
784
+					}
785
+				}
786
+			}
787
+		}
788
+		// cap ticket qty by datetime reg limits
789
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
790
+		return $ticket;
791
+	}
792 792
 
793 793
 
794
-    /**
795
-     * @access  protected
796
-     * @param EE_Ticket $ticket
797
-     * @param array     $price_rows
798
-     * @param int       $ticket_price
799
-     * @param int       $base_price
800
-     * @param int       $base_price_id
801
-     * @return EE_Ticket
802
-     * @throws ReflectionException
803
-     * @throws InvalidArgumentException
804
-     * @throws InvalidInterfaceException
805
-     * @throws InvalidDataTypeException
806
-     * @throws EE_Error
807
-     */
808
-    protected function _duplicate_ticket(
809
-        EE_Ticket $ticket,
810
-        $price_rows = array(),
811
-        $ticket_price = 0,
812
-        $base_price = 0,
813
-        $base_price_id = 0
814
-    ) {
815
-        // create new ticket that's a copy of the existing
816
-        // except a new id of course (and not archived)
817
-        // AND has the new TKT_price associated with it.
818
-        $new_ticket = clone $ticket;
819
-        $new_ticket->set('TKT_ID', 0);
820
-        $new_ticket->set_deleted(0);
821
-        $new_ticket->set_price($ticket_price);
822
-        $new_ticket->set_sold(0);
823
-        // let's get a new ID for this ticket
824
-        $new_ticket->save();
825
-        // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
826
-        $datetimes_on_existing = $ticket->datetimes();
827
-        $new_ticket = $this->_update_ticket_datetimes(
828
-            $new_ticket,
829
-            $datetimes_on_existing,
830
-            array_keys($datetimes_on_existing)
831
-        );
832
-        // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
833
-        // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
834
-        // available.
835
-        if ($ticket->sold() > 0) {
836
-            $new_qty = $ticket->qty() - $ticket->sold();
837
-            $new_ticket->set_qty($new_qty);
838
-        }
839
-        // now we update the prices just for this ticket
840
-        $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
841
-        // and we update the base price
842
-        $new_ticket = $this->_add_prices_to_ticket(
843
-            array(),
844
-            $new_ticket,
845
-            true,
846
-            $base_price,
847
-            $base_price_id
848
-        );
849
-        return $new_ticket;
850
-    }
794
+	/**
795
+	 * @access  protected
796
+	 * @param EE_Ticket $ticket
797
+	 * @param array     $price_rows
798
+	 * @param int       $ticket_price
799
+	 * @param int       $base_price
800
+	 * @param int       $base_price_id
801
+	 * @return EE_Ticket
802
+	 * @throws ReflectionException
803
+	 * @throws InvalidArgumentException
804
+	 * @throws InvalidInterfaceException
805
+	 * @throws InvalidDataTypeException
806
+	 * @throws EE_Error
807
+	 */
808
+	protected function _duplicate_ticket(
809
+		EE_Ticket $ticket,
810
+		$price_rows = array(),
811
+		$ticket_price = 0,
812
+		$base_price = 0,
813
+		$base_price_id = 0
814
+	) {
815
+		// create new ticket that's a copy of the existing
816
+		// except a new id of course (and not archived)
817
+		// AND has the new TKT_price associated with it.
818
+		$new_ticket = clone $ticket;
819
+		$new_ticket->set('TKT_ID', 0);
820
+		$new_ticket->set_deleted(0);
821
+		$new_ticket->set_price($ticket_price);
822
+		$new_ticket->set_sold(0);
823
+		// let's get a new ID for this ticket
824
+		$new_ticket->save();
825
+		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
826
+		$datetimes_on_existing = $ticket->datetimes();
827
+		$new_ticket = $this->_update_ticket_datetimes(
828
+			$new_ticket,
829
+			$datetimes_on_existing,
830
+			array_keys($datetimes_on_existing)
831
+		);
832
+		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
833
+		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
834
+		// available.
835
+		if ($ticket->sold() > 0) {
836
+			$new_qty = $ticket->qty() - $ticket->sold();
837
+			$new_ticket->set_qty($new_qty);
838
+		}
839
+		// now we update the prices just for this ticket
840
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
841
+		// and we update the base price
842
+		$new_ticket = $this->_add_prices_to_ticket(
843
+			array(),
844
+			$new_ticket,
845
+			true,
846
+			$base_price,
847
+			$base_price_id
848
+		);
849
+		return $new_ticket;
850
+	}
851 851
 
852 852
 
853
-    /**
854
-     * This attaches a list of given prices to a ticket.
855
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
856
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
857
-     * price info and prices are automatically "archived" via the ticket.
858
-     *
859
-     * @access  private
860
-     * @param array     $prices        Array of prices from the form.
861
-     * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
862
-     * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
863
-     * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
864
-     * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
865
-     * @return EE_Ticket
866
-     * @throws ReflectionException
867
-     * @throws InvalidArgumentException
868
-     * @throws InvalidInterfaceException
869
-     * @throws InvalidDataTypeException
870
-     * @throws EE_Error
871
-     */
872
-    protected function _add_prices_to_ticket(
873
-        $prices = array(),
874
-        EE_Ticket $ticket,
875
-        $new_prices = false,
876
-        $base_price = false,
877
-        $base_price_id = false
878
-    ) {
879
-        // let's just get any current prices that may exist on the given ticket
880
-        // so we can remove any prices that got trashed in this session.
881
-        $current_prices_on_ticket = $base_price !== false
882
-            ? $ticket->base_price(true)
883
-            : $ticket->price_modifiers();
884
-        $updated_prices = array();
885
-        // if $base_price ! FALSE then updating a base price.
886
-        if ($base_price !== false) {
887
-            $prices[1] = array(
888
-                'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
889
-                'PRT_ID'     => 1,
890
-                'PRC_amount' => $base_price,
891
-                'PRC_name'   => $ticket->get('TKT_name'),
892
-                'PRC_desc'   => $ticket->get('TKT_description'),
893
-            );
894
-        }
895
-        // possibly need to save tkt
896
-        if (! $ticket->ID()) {
897
-            $ticket->save();
898
-        }
899
-        foreach ($prices as $row => $prc) {
900
-            $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
901
-            if (empty($prt_id)) {
902
-                continue;
903
-            } //prices MUST have a price type id.
904
-            $PRC_values = array(
905
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
906
-                'PRT_ID'         => $prt_id,
907
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
908
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
909
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
910
-                'PRC_is_default' => false,
911
-                // make sure we set PRC_is_default to false for all ticket saves from event_editor
912
-                'PRC_order'      => $row,
913
-            );
914
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
915
-                $PRC_values['PRC_ID'] = 0;
916
-                $price = EE_Registry::instance()->load_class(
917
-                    'Price',
918
-                    array($PRC_values),
919
-                    false,
920
-                    false
921
-                );
922
-            } else {
923
-                $price = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
924
-                // update this price with new values
925
-                foreach ($PRC_values as $field => $value) {
926
-                    $price->set($field, $value);
927
-                }
928
-            }
929
-            $price->save();
930
-            $updated_prices[ $price->ID() ] = $price;
931
-            $ticket->_add_relation_to($price, 'Price');
932
-        }
933
-        // now let's remove any prices that got removed from the ticket
934
-        if (! empty($current_prices_on_ticket)) {
935
-            $current = array_keys($current_prices_on_ticket);
936
-            $updated = array_keys($updated_prices);
937
-            $prices_to_remove = array_diff($current, $updated);
938
-            if (! empty($prices_to_remove)) {
939
-                foreach ($prices_to_remove as $prc_id) {
940
-                    $p = $current_prices_on_ticket[ $prc_id ];
941
-                    $ticket->_remove_relation_to($p, 'Price');
942
-                    // delete permanently the price
943
-                    $p->delete_permanently();
944
-                }
945
-            }
946
-        }
947
-        return $ticket;
948
-    }
853
+	/**
854
+	 * This attaches a list of given prices to a ticket.
855
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
856
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
857
+	 * price info and prices are automatically "archived" via the ticket.
858
+	 *
859
+	 * @access  private
860
+	 * @param array     $prices        Array of prices from the form.
861
+	 * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
862
+	 * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
863
+	 * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
864
+	 * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
865
+	 * @return EE_Ticket
866
+	 * @throws ReflectionException
867
+	 * @throws InvalidArgumentException
868
+	 * @throws InvalidInterfaceException
869
+	 * @throws InvalidDataTypeException
870
+	 * @throws EE_Error
871
+	 */
872
+	protected function _add_prices_to_ticket(
873
+		$prices = array(),
874
+		EE_Ticket $ticket,
875
+		$new_prices = false,
876
+		$base_price = false,
877
+		$base_price_id = false
878
+	) {
879
+		// let's just get any current prices that may exist on the given ticket
880
+		// so we can remove any prices that got trashed in this session.
881
+		$current_prices_on_ticket = $base_price !== false
882
+			? $ticket->base_price(true)
883
+			: $ticket->price_modifiers();
884
+		$updated_prices = array();
885
+		// if $base_price ! FALSE then updating a base price.
886
+		if ($base_price !== false) {
887
+			$prices[1] = array(
888
+				'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
889
+				'PRT_ID'     => 1,
890
+				'PRC_amount' => $base_price,
891
+				'PRC_name'   => $ticket->get('TKT_name'),
892
+				'PRC_desc'   => $ticket->get('TKT_description'),
893
+			);
894
+		}
895
+		// possibly need to save tkt
896
+		if (! $ticket->ID()) {
897
+			$ticket->save();
898
+		}
899
+		foreach ($prices as $row => $prc) {
900
+			$prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
901
+			if (empty($prt_id)) {
902
+				continue;
903
+			} //prices MUST have a price type id.
904
+			$PRC_values = array(
905
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
906
+				'PRT_ID'         => $prt_id,
907
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
908
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
909
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
910
+				'PRC_is_default' => false,
911
+				// make sure we set PRC_is_default to false for all ticket saves from event_editor
912
+				'PRC_order'      => $row,
913
+			);
914
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
915
+				$PRC_values['PRC_ID'] = 0;
916
+				$price = EE_Registry::instance()->load_class(
917
+					'Price',
918
+					array($PRC_values),
919
+					false,
920
+					false
921
+				);
922
+			} else {
923
+				$price = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
924
+				// update this price with new values
925
+				foreach ($PRC_values as $field => $value) {
926
+					$price->set($field, $value);
927
+				}
928
+			}
929
+			$price->save();
930
+			$updated_prices[ $price->ID() ] = $price;
931
+			$ticket->_add_relation_to($price, 'Price');
932
+		}
933
+		// now let's remove any prices that got removed from the ticket
934
+		if (! empty($current_prices_on_ticket)) {
935
+			$current = array_keys($current_prices_on_ticket);
936
+			$updated = array_keys($updated_prices);
937
+			$prices_to_remove = array_diff($current, $updated);
938
+			if (! empty($prices_to_remove)) {
939
+				foreach ($prices_to_remove as $prc_id) {
940
+					$p = $current_prices_on_ticket[ $prc_id ];
941
+					$ticket->_remove_relation_to($p, 'Price');
942
+					// delete permanently the price
943
+					$p->delete_permanently();
944
+				}
945
+			}
946
+		}
947
+		return $ticket;
948
+	}
949 949
 
950 950
 
951
-    /**
952
-     * @param Events_Admin_Page $event_admin_obj
953
-     * @return Events_Admin_Page
954
-     */
955
-    public function autosave_handling(Events_Admin_Page $event_admin_obj)
956
-    {
957
-        return $event_admin_obj;
958
-        // doing nothing for the moment.
959
-        // todo when I get to this remember that I need to set the template args on the $event_admin_obj
960
-        // (use the set_template_args() method)
961
-        /**
962
-         * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
963
-         * 1. TKT_is_default_selector (visible)
964
-         * 2. TKT_is_default (hidden)
965
-         * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket
966
-         * (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want
967
-         * this ticket to be saved as a default.
968
-         * The tricky part is, on an initial display on create or edit (or after manually updating),
969
-         * the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true
970
-         * if this is a create.  However, after an autosave, users will want some sort of indicator that
971
-         * the TKT HAS been saved as a default..
972
-         * in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
973
-         * On Autosave:
974
-         * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements,
975
-         * then set the TKT_is_default to false.
976
-         * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).
977
-         *  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
978
-         * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
979
-         */
980
-    }
951
+	/**
952
+	 * @param Events_Admin_Page $event_admin_obj
953
+	 * @return Events_Admin_Page
954
+	 */
955
+	public function autosave_handling(Events_Admin_Page $event_admin_obj)
956
+	{
957
+		return $event_admin_obj;
958
+		// doing nothing for the moment.
959
+		// todo when I get to this remember that I need to set the template args on the $event_admin_obj
960
+		// (use the set_template_args() method)
961
+		/**
962
+		 * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
963
+		 * 1. TKT_is_default_selector (visible)
964
+		 * 2. TKT_is_default (hidden)
965
+		 * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket
966
+		 * (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want
967
+		 * this ticket to be saved as a default.
968
+		 * The tricky part is, on an initial display on create or edit (or after manually updating),
969
+		 * the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true
970
+		 * if this is a create.  However, after an autosave, users will want some sort of indicator that
971
+		 * the TKT HAS been saved as a default..
972
+		 * in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
973
+		 * On Autosave:
974
+		 * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements,
975
+		 * then set the TKT_is_default to false.
976
+		 * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).
977
+		 *  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
978
+		 * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
979
+		 */
980
+	}
981 981
 
982 982
 
983
-    /**
984
-     * @throws ReflectionException
985
-     * @throws InvalidArgumentException
986
-     * @throws InvalidInterfaceException
987
-     * @throws InvalidDataTypeException
988
-     * @throws DomainException
989
-     * @throws EE_Error
990
-     */
991
-    public function pricing_metabox()
992
-    {
993
-        $existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
994
-        $event = $this->_adminpage_obj->get_cpt_model_obj();
995
-        // set is_creating_event property.
996
-        $EVT_ID = $event->ID();
997
-        $this->_is_creating_event = empty($this->_req_data['post']);
998
-        // default main template args
999
-        $main_template_args = array(
1000
-            'event_datetime_help_link' => EEH_Template::get_help_tab_link(
1001
-                'event_editor_event_datetimes_help_tab',
1002
-                $this->_adminpage_obj->page_slug,
1003
-                $this->_adminpage_obj->get_req_action(),
1004
-                false,
1005
-                false
1006
-            ),
1007
-            // todo need to add a filter to the template for the help text
1008
-            // in the Events_Admin_Page core file so we can add further help
1009
-            'existing_datetime_ids'    => '',
1010
-            'total_dtt_rows'           => 1,
1011
-            'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1012
-                'add_new_dtt_info',
1013
-                $this->_adminpage_obj->page_slug,
1014
-                $this->_adminpage_obj->get_req_action(),
1015
-                false,
1016
-                false
1017
-            ),
1018
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1019
-            'datetime_rows'            => '',
1020
-            'show_tickets_container'   => '',
1021
-            // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
1022
-            'ticket_rows'              => '',
1023
-            'existing_ticket_ids'      => '',
1024
-            'total_ticket_rows'        => 1,
1025
-            'ticket_js_structure'      => '',
1026
-            'ee_collapsible_status'    => ' ee-collapsible-open'
1027
-            // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1028
-        );
1029
-        $timezone = $event instanceof EE_Event ? $event->timezone_string() : null;
1030
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1031
-        /**
1032
-         * 1. Start with retrieving Datetimes
1033
-         * 2. For each datetime get related tickets
1034
-         * 3. For each ticket get related prices
1035
-         */
1036
-        /** @var EEM_Datetime $datetime_model */
1037
-        $datetime_model = EE_Registry::instance()->load_model('Datetime', array($timezone));
1038
-        $datetimes = $datetime_model->get_all_event_dates($EVT_ID);
1039
-        $main_template_args['total_dtt_rows'] = count($datetimes);
1040
-        /**
1041
-         * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1042
-         * for why we are counting $datetime_row and then setting that on the Datetime object
1043
-         */
1044
-        $datetime_row = 1;
1045
-        foreach ($datetimes as $datetime) {
1046
-            $DTT_ID = $datetime->get('DTT_ID');
1047
-            $datetime->set('DTT_order', $datetime_row);
1048
-            $existing_datetime_ids[] = $DTT_ID;
1049
-            // tickets attached
1050
-            $related_tickets = $datetime->ID() > 0
1051
-                ? $datetime->get_many_related(
1052
-                    'Ticket',
1053
-                    array(
1054
-                        array(
1055
-                            'OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0),
1056
-                        ),
1057
-                        'default_where_conditions' => 'none',
1058
-                        'order_by'                 => array('TKT_order' => 'ASC'),
1059
-                    )
1060
-                )
1061
-                : array();
1062
-            // if there are no related tickets this is likely a new event OR autodraft
1063
-            // event so we need to generate the default tickets because datetimes
1064
-            // ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1065
-            // datetime on the event.
1066
-            if (empty($related_tickets) && count($datetimes) < 2) {
1067
-                /** @var EEM_Ticket $ticket_model */
1068
-                $ticket_model = EE_Registry::instance()->load_model('Ticket');
1069
-                $related_tickets = $ticket_model->get_all_default_tickets();
1070
-                // this should be ordered by TKT_ID, so let's grab the first default ticket
1071
-                // (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1072
-                $default_prices = EEM_Price::instance()->get_all_default_prices();
1073
-                $main_default_ticket = reset($related_tickets);
1074
-                if ($main_default_ticket instanceof EE_Ticket) {
1075
-                    foreach ($default_prices as $default_price) {
1076
-                        if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1077
-                            continue;
1078
-                        }
1079
-                        $main_default_ticket->cache('Price', $default_price);
1080
-                    }
1081
-                }
1082
-            }
1083
-            // we can't actually setup rows in this loop yet cause we don't know all
1084
-            // the unique tickets for this event yet (tickets are linked through all datetimes).
1085
-            // So we're going to temporarily cache some of that information.
1086
-            // loop through and setup the ticket rows and make sure the order is set.
1087
-            foreach ($related_tickets as $ticket) {
1088
-                $TKT_ID = $ticket->get('TKT_ID');
1089
-                $ticket_row = $ticket->get('TKT_row');
1090
-                // we only want unique tickets in our final display!!
1091
-                if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1092
-                    $existing_ticket_ids[] = $TKT_ID;
1093
-                    $all_tickets[] = $ticket;
1094
-                }
1095
-                // temporary cache of this ticket info for this datetime for later processing of datetime rows.
1096
-                $datetime_tickets[ $DTT_ID ][] = $ticket_row;
1097
-                // temporary cache of this datetime info for this ticket for later processing of ticket rows.
1098
-                if (
1099
-                    ! isset($ticket_datetimes[ $TKT_ID ])
1100
-                    || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1101
-                ) {
1102
-                    $ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1103
-                }
1104
-            }
1105
-            $datetime_row++;
1106
-        }
1107
-        $main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
1108
-        $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1109
-        $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1110
-        // sort $all_tickets by order
1111
-        usort(
1112
-            $all_tickets,
1113
-            function (EE_Ticket $a, EE_Ticket $b) {
1114
-                $a_order = (int) $a->get('TKT_order');
1115
-                $b_order = (int) $b->get('TKT_order');
1116
-                if ($a_order === $b_order) {
1117
-                    return 0;
1118
-                }
1119
-                return ($a_order < $b_order) ? -1 : 1;
1120
-            }
1121
-        );
1122
-        // k NOW we have all the data we need for setting up the dtt rows
1123
-        // and ticket rows so we start our dtt loop again.
1124
-        $datetime_row = 1;
1125
-        foreach ($datetimes as $datetime) {
1126
-            $main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1127
-                $datetime_row,
1128
-                $datetime,
1129
-                $datetime_tickets,
1130
-                $all_tickets,
1131
-                false,
1132
-                $datetimes
1133
-            );
1134
-            $datetime_row++;
1135
-        }
1136
-        // then loop through all tickets for the ticket rows.
1137
-        $ticket_row = 1;
1138
-        foreach ($all_tickets as $ticket) {
1139
-            $main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1140
-                $ticket_row,
1141
-                $ticket,
1142
-                $ticket_datetimes,
1143
-                $datetimes,
1144
-                false,
1145
-                $all_tickets
1146
-            );
1147
-            $ticket_row++;
1148
-        }
1149
-        $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
1150
-        EEH_Template::display_template(
1151
-            PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1152
-            $main_template_args
1153
-        );
1154
-    }
983
+	/**
984
+	 * @throws ReflectionException
985
+	 * @throws InvalidArgumentException
986
+	 * @throws InvalidInterfaceException
987
+	 * @throws InvalidDataTypeException
988
+	 * @throws DomainException
989
+	 * @throws EE_Error
990
+	 */
991
+	public function pricing_metabox()
992
+	{
993
+		$existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
994
+		$event = $this->_adminpage_obj->get_cpt_model_obj();
995
+		// set is_creating_event property.
996
+		$EVT_ID = $event->ID();
997
+		$this->_is_creating_event = empty($this->_req_data['post']);
998
+		// default main template args
999
+		$main_template_args = array(
1000
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link(
1001
+				'event_editor_event_datetimes_help_tab',
1002
+				$this->_adminpage_obj->page_slug,
1003
+				$this->_adminpage_obj->get_req_action(),
1004
+				false,
1005
+				false
1006
+			),
1007
+			// todo need to add a filter to the template for the help text
1008
+			// in the Events_Admin_Page core file so we can add further help
1009
+			'existing_datetime_ids'    => '',
1010
+			'total_dtt_rows'           => 1,
1011
+			'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1012
+				'add_new_dtt_info',
1013
+				$this->_adminpage_obj->page_slug,
1014
+				$this->_adminpage_obj->get_req_action(),
1015
+				false,
1016
+				false
1017
+			),
1018
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1019
+			'datetime_rows'            => '',
1020
+			'show_tickets_container'   => '',
1021
+			// $this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
1022
+			'ticket_rows'              => '',
1023
+			'existing_ticket_ids'      => '',
1024
+			'total_ticket_rows'        => 1,
1025
+			'ticket_js_structure'      => '',
1026
+			'ee_collapsible_status'    => ' ee-collapsible-open'
1027
+			// $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1028
+		);
1029
+		$timezone = $event instanceof EE_Event ? $event->timezone_string() : null;
1030
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1031
+		/**
1032
+		 * 1. Start with retrieving Datetimes
1033
+		 * 2. For each datetime get related tickets
1034
+		 * 3. For each ticket get related prices
1035
+		 */
1036
+		/** @var EEM_Datetime $datetime_model */
1037
+		$datetime_model = EE_Registry::instance()->load_model('Datetime', array($timezone));
1038
+		$datetimes = $datetime_model->get_all_event_dates($EVT_ID);
1039
+		$main_template_args['total_dtt_rows'] = count($datetimes);
1040
+		/**
1041
+		 * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1042
+		 * for why we are counting $datetime_row and then setting that on the Datetime object
1043
+		 */
1044
+		$datetime_row = 1;
1045
+		foreach ($datetimes as $datetime) {
1046
+			$DTT_ID = $datetime->get('DTT_ID');
1047
+			$datetime->set('DTT_order', $datetime_row);
1048
+			$existing_datetime_ids[] = $DTT_ID;
1049
+			// tickets attached
1050
+			$related_tickets = $datetime->ID() > 0
1051
+				? $datetime->get_many_related(
1052
+					'Ticket',
1053
+					array(
1054
+						array(
1055
+							'OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0),
1056
+						),
1057
+						'default_where_conditions' => 'none',
1058
+						'order_by'                 => array('TKT_order' => 'ASC'),
1059
+					)
1060
+				)
1061
+				: array();
1062
+			// if there are no related tickets this is likely a new event OR autodraft
1063
+			// event so we need to generate the default tickets because datetimes
1064
+			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1065
+			// datetime on the event.
1066
+			if (empty($related_tickets) && count($datetimes) < 2) {
1067
+				/** @var EEM_Ticket $ticket_model */
1068
+				$ticket_model = EE_Registry::instance()->load_model('Ticket');
1069
+				$related_tickets = $ticket_model->get_all_default_tickets();
1070
+				// this should be ordered by TKT_ID, so let's grab the first default ticket
1071
+				// (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1072
+				$default_prices = EEM_Price::instance()->get_all_default_prices();
1073
+				$main_default_ticket = reset($related_tickets);
1074
+				if ($main_default_ticket instanceof EE_Ticket) {
1075
+					foreach ($default_prices as $default_price) {
1076
+						if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1077
+							continue;
1078
+						}
1079
+						$main_default_ticket->cache('Price', $default_price);
1080
+					}
1081
+				}
1082
+			}
1083
+			// we can't actually setup rows in this loop yet cause we don't know all
1084
+			// the unique tickets for this event yet (tickets are linked through all datetimes).
1085
+			// So we're going to temporarily cache some of that information.
1086
+			// loop through and setup the ticket rows and make sure the order is set.
1087
+			foreach ($related_tickets as $ticket) {
1088
+				$TKT_ID = $ticket->get('TKT_ID');
1089
+				$ticket_row = $ticket->get('TKT_row');
1090
+				// we only want unique tickets in our final display!!
1091
+				if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1092
+					$existing_ticket_ids[] = $TKT_ID;
1093
+					$all_tickets[] = $ticket;
1094
+				}
1095
+				// temporary cache of this ticket info for this datetime for later processing of datetime rows.
1096
+				$datetime_tickets[ $DTT_ID ][] = $ticket_row;
1097
+				// temporary cache of this datetime info for this ticket for later processing of ticket rows.
1098
+				if (
1099
+					! isset($ticket_datetimes[ $TKT_ID ])
1100
+					|| ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1101
+				) {
1102
+					$ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1103
+				}
1104
+			}
1105
+			$datetime_row++;
1106
+		}
1107
+		$main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
1108
+		$main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1109
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1110
+		// sort $all_tickets by order
1111
+		usort(
1112
+			$all_tickets,
1113
+			function (EE_Ticket $a, EE_Ticket $b) {
1114
+				$a_order = (int) $a->get('TKT_order');
1115
+				$b_order = (int) $b->get('TKT_order');
1116
+				if ($a_order === $b_order) {
1117
+					return 0;
1118
+				}
1119
+				return ($a_order < $b_order) ? -1 : 1;
1120
+			}
1121
+		);
1122
+		// k NOW we have all the data we need for setting up the dtt rows
1123
+		// and ticket rows so we start our dtt loop again.
1124
+		$datetime_row = 1;
1125
+		foreach ($datetimes as $datetime) {
1126
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1127
+				$datetime_row,
1128
+				$datetime,
1129
+				$datetime_tickets,
1130
+				$all_tickets,
1131
+				false,
1132
+				$datetimes
1133
+			);
1134
+			$datetime_row++;
1135
+		}
1136
+		// then loop through all tickets for the ticket rows.
1137
+		$ticket_row = 1;
1138
+		foreach ($all_tickets as $ticket) {
1139
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1140
+				$ticket_row,
1141
+				$ticket,
1142
+				$ticket_datetimes,
1143
+				$datetimes,
1144
+				false,
1145
+				$all_tickets
1146
+			);
1147
+			$ticket_row++;
1148
+		}
1149
+		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
1150
+		EEH_Template::display_template(
1151
+			PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1152
+			$main_template_args
1153
+		);
1154
+	}
1155 1155
 
1156 1156
 
1157
-    /**
1158
-     * @param int         $datetime_row
1159
-     * @param EE_Datetime $datetime
1160
-     * @param array       $datetime_tickets
1161
-     * @param array       $all_tickets
1162
-     * @param bool        $default
1163
-     * @param array       $all_datetimes
1164
-     * @return mixed
1165
-     * @throws DomainException
1166
-     * @throws EE_Error
1167
-     */
1168
-    protected function _get_datetime_row(
1169
-        $datetime_row,
1170
-        EE_Datetime $datetime,
1171
-        $datetime_tickets = array(),
1172
-        $all_tickets = array(),
1173
-        $default = false,
1174
-        $all_datetimes = array()
1175
-    ) {
1176
-        $dtt_display_template_args = array(
1177
-            'dtt_edit_row'             => $this->_get_dtt_edit_row(
1178
-                $datetime_row,
1179
-                $datetime,
1180
-                $default,
1181
-                $all_datetimes
1182
-            ),
1183
-            'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1184
-                $datetime_row,
1185
-                $datetime,
1186
-                $datetime_tickets,
1187
-                $all_tickets,
1188
-                $default
1189
-            ),
1190
-            'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1191
-        );
1192
-        return EEH_Template::display_template(
1193
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1194
-            $dtt_display_template_args,
1195
-            true
1196
-        );
1197
-    }
1157
+	/**
1158
+	 * @param int         $datetime_row
1159
+	 * @param EE_Datetime $datetime
1160
+	 * @param array       $datetime_tickets
1161
+	 * @param array       $all_tickets
1162
+	 * @param bool        $default
1163
+	 * @param array       $all_datetimes
1164
+	 * @return mixed
1165
+	 * @throws DomainException
1166
+	 * @throws EE_Error
1167
+	 */
1168
+	protected function _get_datetime_row(
1169
+		$datetime_row,
1170
+		EE_Datetime $datetime,
1171
+		$datetime_tickets = array(),
1172
+		$all_tickets = array(),
1173
+		$default = false,
1174
+		$all_datetimes = array()
1175
+	) {
1176
+		$dtt_display_template_args = array(
1177
+			'dtt_edit_row'             => $this->_get_dtt_edit_row(
1178
+				$datetime_row,
1179
+				$datetime,
1180
+				$default,
1181
+				$all_datetimes
1182
+			),
1183
+			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1184
+				$datetime_row,
1185
+				$datetime,
1186
+				$datetime_tickets,
1187
+				$all_tickets,
1188
+				$default
1189
+			),
1190
+			'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1191
+		);
1192
+		return EEH_Template::display_template(
1193
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1194
+			$dtt_display_template_args,
1195
+			true
1196
+		);
1197
+	}
1198 1198
 
1199 1199
 
1200
-    /**
1201
-     * This method is used to generate a dtt fields  edit row.
1202
-     * The same row is used to generate a row with valid DTT objects
1203
-     * and the default row that is used as the skeleton by the js.
1204
-     *
1205
-     * @param int           $datetime_row  The row number for the row being generated.
1206
-     * @param EE_Datetime   $datetime
1207
-     * @param bool          $default       Whether a default row is being generated or not.
1208
-     * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor.
1209
-     * @return string
1210
-     * @throws DomainException
1211
-     * @throws EE_Error
1212
-     */
1213
-    protected function _get_dtt_edit_row($datetime_row, $datetime, $default, $all_datetimes)
1214
-    {
1215
-        // if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1216
-        $default = ! $datetime instanceof EE_Datetime ? true : $default;
1217
-        $template_args = array(
1218
-            'dtt_row'              => $default ? 'DTTNUM' : $datetime_row,
1219
-            'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1220
-            'edit_dtt_expanded'    => '',
1221
-            'DTT_ID'               => $default ? '' : $datetime->ID(),
1222
-            'DTT_name'             => $default ? '' : $datetime->get_f('DTT_name'),
1223
-            'DTT_description'      => $default ? '' : $datetime->get_f('DTT_description'),
1224
-            'DTT_EVT_start'        => $default ? '' : $datetime->start_date($this->_date_time_format),
1225
-            'DTT_EVT_end'          => $default ? '' : $datetime->end_date($this->_date_time_format),
1226
-            'DTT_reg_limit'        => $default
1227
-                ? ''
1228
-                : $datetime->get_pretty(
1229
-                    'DTT_reg_limit',
1230
-                    'input'
1231
-                ),
1232
-            'DTT_order'            => $default ? 'DTTNUM' : $datetime_row,
1233
-            'dtt_sold'             => $default ? '0' : $datetime->get('DTT_sold'),
1234
-            'dtt_reserved'         => $default ? '0' : $datetime->reserved(),
1235
-            'clone_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1236
-                ? ''
1237
-                : 'clone-icon ee-icon ee-icon-clone clickable',
1238
-            'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1239
-                ? 'ee-lock-icon'
1240
-                : 'trash-icon dashicons dashicons-post-trash clickable',
1241
-            'reg_list_url'         => $default || ! $datetime->event() instanceof \EE_Event
1242
-                ? ''
1243
-                : EE_Admin_Page::add_query_args_and_nonce(
1244
-                    array('event_id' => $datetime->event()->ID(), 'datetime_id' => $datetime->ID()),
1245
-                    REG_ADMIN_URL
1246
-                ),
1247
-        );
1248
-        $template_args['show_trash'] = count($all_datetimes) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1249
-            ? 'display:none'
1250
-            : '';
1251
-        // allow filtering of template args at this point.
1252
-        $template_args = apply_filters(
1253
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1254
-            $template_args,
1255
-            $datetime_row,
1256
-            $datetime,
1257
-            $default,
1258
-            $all_datetimes,
1259
-            $this->_is_creating_event
1260
-        );
1261
-        return EEH_Template::display_template(
1262
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1263
-            $template_args,
1264
-            true
1265
-        );
1266
-    }
1200
+	/**
1201
+	 * This method is used to generate a dtt fields  edit row.
1202
+	 * The same row is used to generate a row with valid DTT objects
1203
+	 * and the default row that is used as the skeleton by the js.
1204
+	 *
1205
+	 * @param int           $datetime_row  The row number for the row being generated.
1206
+	 * @param EE_Datetime   $datetime
1207
+	 * @param bool          $default       Whether a default row is being generated or not.
1208
+	 * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor.
1209
+	 * @return string
1210
+	 * @throws DomainException
1211
+	 * @throws EE_Error
1212
+	 */
1213
+	protected function _get_dtt_edit_row($datetime_row, $datetime, $default, $all_datetimes)
1214
+	{
1215
+		// if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1216
+		$default = ! $datetime instanceof EE_Datetime ? true : $default;
1217
+		$template_args = array(
1218
+			'dtt_row'              => $default ? 'DTTNUM' : $datetime_row,
1219
+			'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1220
+			'edit_dtt_expanded'    => '',
1221
+			'DTT_ID'               => $default ? '' : $datetime->ID(),
1222
+			'DTT_name'             => $default ? '' : $datetime->get_f('DTT_name'),
1223
+			'DTT_description'      => $default ? '' : $datetime->get_f('DTT_description'),
1224
+			'DTT_EVT_start'        => $default ? '' : $datetime->start_date($this->_date_time_format),
1225
+			'DTT_EVT_end'          => $default ? '' : $datetime->end_date($this->_date_time_format),
1226
+			'DTT_reg_limit'        => $default
1227
+				? ''
1228
+				: $datetime->get_pretty(
1229
+					'DTT_reg_limit',
1230
+					'input'
1231
+				),
1232
+			'DTT_order'            => $default ? 'DTTNUM' : $datetime_row,
1233
+			'dtt_sold'             => $default ? '0' : $datetime->get('DTT_sold'),
1234
+			'dtt_reserved'         => $default ? '0' : $datetime->reserved(),
1235
+			'clone_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1236
+				? ''
1237
+				: 'clone-icon ee-icon ee-icon-clone clickable',
1238
+			'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1239
+				? 'ee-lock-icon'
1240
+				: 'trash-icon dashicons dashicons-post-trash clickable',
1241
+			'reg_list_url'         => $default || ! $datetime->event() instanceof \EE_Event
1242
+				? ''
1243
+				: EE_Admin_Page::add_query_args_and_nonce(
1244
+					array('event_id' => $datetime->event()->ID(), 'datetime_id' => $datetime->ID()),
1245
+					REG_ADMIN_URL
1246
+				),
1247
+		);
1248
+		$template_args['show_trash'] = count($all_datetimes) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1249
+			? 'display:none'
1250
+			: '';
1251
+		// allow filtering of template args at this point.
1252
+		$template_args = apply_filters(
1253
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1254
+			$template_args,
1255
+			$datetime_row,
1256
+			$datetime,
1257
+			$default,
1258
+			$all_datetimes,
1259
+			$this->_is_creating_event
1260
+		);
1261
+		return EEH_Template::display_template(
1262
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1263
+			$template_args,
1264
+			true
1265
+		);
1266
+	}
1267 1267
 
1268 1268
 
1269
-    /**
1270
-     * @param int         $datetime_row
1271
-     * @param EE_Datetime $datetime
1272
-     * @param array       $datetime_tickets
1273
-     * @param array       $all_tickets
1274
-     * @param bool        $default
1275
-     * @return mixed
1276
-     * @throws DomainException
1277
-     * @throws EE_Error
1278
-     */
1279
-    protected function _get_dtt_attached_tickets_row(
1280
-        $datetime_row,
1281
-        $datetime,
1282
-        $datetime_tickets = array(),
1283
-        $all_tickets = array(),
1284
-        $default
1285
-    ) {
1286
-        $template_args = array(
1287
-            'dtt_row'                           => $default ? 'DTTNUM' : $datetime_row,
1288
-            'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1289
-            'DTT_description'                   => $default ? '' : $datetime->get_f('DTT_description'),
1290
-            'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1291
-            'show_tickets_row'                  => 'display:none;',
1292
-            'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1293
-                'add_new_ticket_via_datetime',
1294
-                $this->_adminpage_obj->page_slug,
1295
-                $this->_adminpage_obj->get_req_action(),
1296
-                false,
1297
-                false
1298
-            ),
1299
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1300
-            'DTT_ID'                            => $default ? '' : $datetime->ID(),
1301
-        );
1302
-        // need to setup the list items (but only if this isn't a default skeleton setup)
1303
-        if (! $default) {
1304
-            $ticket_row = 1;
1305
-            foreach ($all_tickets as $ticket) {
1306
-                $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1307
-                    $datetime_row,
1308
-                    $ticket_row,
1309
-                    $datetime,
1310
-                    $ticket,
1311
-                    $datetime_tickets,
1312
-                    $default
1313
-                );
1314
-                $ticket_row++;
1315
-            }
1316
-        }
1317
-        // filter template args at this point
1318
-        $template_args = apply_filters(
1319
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1320
-            $template_args,
1321
-            $datetime_row,
1322
-            $datetime,
1323
-            $datetime_tickets,
1324
-            $all_tickets,
1325
-            $default,
1326
-            $this->_is_creating_event
1327
-        );
1328
-        return EEH_Template::display_template(
1329
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1330
-            $template_args,
1331
-            true
1332
-        );
1333
-    }
1269
+	/**
1270
+	 * @param int         $datetime_row
1271
+	 * @param EE_Datetime $datetime
1272
+	 * @param array       $datetime_tickets
1273
+	 * @param array       $all_tickets
1274
+	 * @param bool        $default
1275
+	 * @return mixed
1276
+	 * @throws DomainException
1277
+	 * @throws EE_Error
1278
+	 */
1279
+	protected function _get_dtt_attached_tickets_row(
1280
+		$datetime_row,
1281
+		$datetime,
1282
+		$datetime_tickets = array(),
1283
+		$all_tickets = array(),
1284
+		$default
1285
+	) {
1286
+		$template_args = array(
1287
+			'dtt_row'                           => $default ? 'DTTNUM' : $datetime_row,
1288
+			'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1289
+			'DTT_description'                   => $default ? '' : $datetime->get_f('DTT_description'),
1290
+			'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1291
+			'show_tickets_row'                  => 'display:none;',
1292
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1293
+				'add_new_ticket_via_datetime',
1294
+				$this->_adminpage_obj->page_slug,
1295
+				$this->_adminpage_obj->get_req_action(),
1296
+				false,
1297
+				false
1298
+			),
1299
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1300
+			'DTT_ID'                            => $default ? '' : $datetime->ID(),
1301
+		);
1302
+		// need to setup the list items (but only if this isn't a default skeleton setup)
1303
+		if (! $default) {
1304
+			$ticket_row = 1;
1305
+			foreach ($all_tickets as $ticket) {
1306
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1307
+					$datetime_row,
1308
+					$ticket_row,
1309
+					$datetime,
1310
+					$ticket,
1311
+					$datetime_tickets,
1312
+					$default
1313
+				);
1314
+				$ticket_row++;
1315
+			}
1316
+		}
1317
+		// filter template args at this point
1318
+		$template_args = apply_filters(
1319
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1320
+			$template_args,
1321
+			$datetime_row,
1322
+			$datetime,
1323
+			$datetime_tickets,
1324
+			$all_tickets,
1325
+			$default,
1326
+			$this->_is_creating_event
1327
+		);
1328
+		return EEH_Template::display_template(
1329
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1330
+			$template_args,
1331
+			true
1332
+		);
1333
+	}
1334 1334
 
1335 1335
 
1336
-    /**
1337
-     * @param int         $datetime_row
1338
-     * @param int         $ticket_row
1339
-     * @param EE_Datetime $datetime
1340
-     * @param EE_Ticket   $ticket
1341
-     * @param array       $datetime_tickets
1342
-     * @param bool        $default
1343
-     * @return mixed
1344
-     * @throws DomainException
1345
-     * @throws EE_Error
1346
-     */
1347
-    protected function _get_datetime_tickets_list_item(
1348
-        $datetime_row,
1349
-        $ticket_row,
1350
-        $datetime,
1351
-        $ticket,
1352
-        $datetime_tickets = array(),
1353
-        $default
1354
-    ) {
1355
-        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1356
-            ? $datetime_tickets[ $datetime->ID() ]
1357
-            : array();
1358
-        $display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1359
-        $no_ticket = $default && empty($ticket);
1360
-        $template_args = array(
1361
-            'dtt_row'                 => $default
1362
-                ? 'DTTNUM'
1363
-                : $datetime_row,
1364
-            'tkt_row'                 => $no_ticket
1365
-                ? 'TICKETNUM'
1366
-                : $ticket_row,
1367
-            'datetime_ticket_checked' => in_array($display_row, $dtt_tkts, true)
1368
-                ? ' checked'
1369
-                : '',
1370
-            'ticket_selected'         => in_array($display_row, $dtt_tkts, true)
1371
-                ? ' ticket-selected'
1372
-                : '',
1373
-            'TKT_name'                => $no_ticket
1374
-                ? 'TKTNAME'
1375
-                : $ticket->get('TKT_name'),
1376
-            'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1377
-                ? ' tkt-status-' . EE_Ticket::onsale
1378
-                : ' tkt-status-' . $ticket->ticket_status(),
1379
-        );
1380
-        // filter template args
1381
-        $template_args = apply_filters(
1382
-            'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1383
-            $template_args,
1384
-            $datetime_row,
1385
-            $ticket_row,
1386
-            $datetime,
1387
-            $ticket,
1388
-            $datetime_tickets,
1389
-            $default,
1390
-            $this->_is_creating_event
1391
-        );
1392
-        return EEH_Template::display_template(
1393
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1394
-            $template_args,
1395
-            true
1396
-        );
1397
-    }
1336
+	/**
1337
+	 * @param int         $datetime_row
1338
+	 * @param int         $ticket_row
1339
+	 * @param EE_Datetime $datetime
1340
+	 * @param EE_Ticket   $ticket
1341
+	 * @param array       $datetime_tickets
1342
+	 * @param bool        $default
1343
+	 * @return mixed
1344
+	 * @throws DomainException
1345
+	 * @throws EE_Error
1346
+	 */
1347
+	protected function _get_datetime_tickets_list_item(
1348
+		$datetime_row,
1349
+		$ticket_row,
1350
+		$datetime,
1351
+		$ticket,
1352
+		$datetime_tickets = array(),
1353
+		$default
1354
+	) {
1355
+		$dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1356
+			? $datetime_tickets[ $datetime->ID() ]
1357
+			: array();
1358
+		$display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1359
+		$no_ticket = $default && empty($ticket);
1360
+		$template_args = array(
1361
+			'dtt_row'                 => $default
1362
+				? 'DTTNUM'
1363
+				: $datetime_row,
1364
+			'tkt_row'                 => $no_ticket
1365
+				? 'TICKETNUM'
1366
+				: $ticket_row,
1367
+			'datetime_ticket_checked' => in_array($display_row, $dtt_tkts, true)
1368
+				? ' checked'
1369
+				: '',
1370
+			'ticket_selected'         => in_array($display_row, $dtt_tkts, true)
1371
+				? ' ticket-selected'
1372
+				: '',
1373
+			'TKT_name'                => $no_ticket
1374
+				? 'TKTNAME'
1375
+				: $ticket->get('TKT_name'),
1376
+			'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1377
+				? ' tkt-status-' . EE_Ticket::onsale
1378
+				: ' tkt-status-' . $ticket->ticket_status(),
1379
+		);
1380
+		// filter template args
1381
+		$template_args = apply_filters(
1382
+			'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1383
+			$template_args,
1384
+			$datetime_row,
1385
+			$ticket_row,
1386
+			$datetime,
1387
+			$ticket,
1388
+			$datetime_tickets,
1389
+			$default,
1390
+			$this->_is_creating_event
1391
+		);
1392
+		return EEH_Template::display_template(
1393
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1394
+			$template_args,
1395
+			true
1396
+		);
1397
+	}
1398 1398
 
1399 1399
 
1400
-    /**
1401
-     * This generates the ticket row for tickets.
1402
-     * This same method is used to generate both the actual rows and the js skeleton row
1403
-     * (when default === true)
1404
-     *
1405
-     * @param int           $ticket_row       Represents the row number being generated.
1406
-     * @param               $ticket
1407
-     * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1408
-     *                                        or empty for default
1409
-     * @param EE_Datetime[] $all_datetimes    All Datetimes on the event or empty for default.
1410
-     * @param bool          $default          Whether default row being generated or not.
1411
-     * @param EE_Ticket[]   $all_tickets      This is an array of all tickets attached to the event
1412
-     *                                        (or empty in the case of defaults)
1413
-     * @return mixed
1414
-     * @throws InvalidArgumentException
1415
-     * @throws InvalidInterfaceException
1416
-     * @throws InvalidDataTypeException
1417
-     * @throws DomainException
1418
-     * @throws EE_Error
1419
-     * @throws ReflectionException
1420
-     */
1421
-    protected function _get_ticket_row(
1422
-        $ticket_row,
1423
-        $ticket,
1424
-        $ticket_datetimes,
1425
-        $all_datetimes,
1426
-        $default = false,
1427
-        $all_tickets = array()
1428
-    ) {
1429
-        // if $ticket is not an instance of EE_Ticket then force default to true.
1430
-        $default = ! $ticket instanceof EE_Ticket ? true : $default;
1431
-        $prices = ! empty($ticket) && ! $default
1432
-            ? $ticket->get_many_related(
1433
-                'Price',
1434
-                array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))
1435
-            )
1436
-            : array();
1437
-        // if there is only one price (which would be the base price)
1438
-        // or NO prices and this ticket is a default ticket,
1439
-        // let's just make sure there are no cached default prices on the object.
1440
-        // This is done by not including any query_params.
1441
-        if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1442
-            $prices = $ticket->prices();
1443
-        }
1444
-        // check if we're dealing with a default ticket in which case
1445
-        // we don't want any starting_ticket_datetime_row values set
1446
-        // (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1447
-        // This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1448
-        $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1449
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1450
-            ? $ticket_datetimes[ $ticket->ID() ]
1451
-            : array();
1452
-        $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1453
-        $base_price = $default ? null : $ticket->base_price();
1454
-        $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1455
-        // breaking out complicated condition for ticket_status
1456
-        if ($default) {
1457
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1458
-        } else {
1459
-            $ticket_status_class = $ticket->is_default()
1460
-                ? ' tkt-status-' . EE_Ticket::onsale
1461
-                : ' tkt-status-' . $ticket->ticket_status();
1462
-        }
1463
-        // breaking out complicated condition for TKT_taxable
1464
-        if ($default) {
1465
-            $TKT_taxable = '';
1466
-        } else {
1467
-            $TKT_taxable = $ticket->taxable()
1468
-                ? 'checked'
1469
-                : '';
1470
-        }
1471
-        if ($default) {
1472
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1473
-        } elseif ($ticket->is_default()) {
1474
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1475
-        } else {
1476
-            $TKT_status = $ticket->ticket_status(true);
1477
-        }
1478
-        if ($default) {
1479
-            $TKT_min = '';
1480
-        } else {
1481
-            $TKT_min = $ticket->min();
1482
-            if ($TKT_min === -1 || $TKT_min === 0) {
1483
-                $TKT_min = '';
1484
-            }
1485
-        }
1486
-        $template_args = array(
1487
-            'tkt_row'                       => $default ? 'TICKETNUM' : $ticket_row,
1488
-            'TKT_order'                     => $default ? 'TICKETNUM' : $ticket_row,
1489
-            // on initial page load this will always be the correct order.
1490
-            'tkt_status_class'              => $ticket_status_class,
1491
-            'display_edit_tkt_row'          => 'display:none;',
1492
-            'edit_tkt_expanded'             => '',
1493
-            'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1494
-            'TKT_name'                      => $default ? '' : $ticket->get_f('TKT_name'),
1495
-            'TKT_start_date'                => $default
1496
-                ? ''
1497
-                : $ticket->get_date('TKT_start_date', $this->_date_time_format),
1498
-            'TKT_end_date'                  => $default
1499
-                ? ''
1500
-                : $ticket->get_date('TKT_end_date', $this->_date_time_format),
1501
-            'TKT_status'                    => $TKT_status,
1502
-            'TKT_price'                     => $default
1503
-                ? ''
1504
-                : EEH_Template::format_currency(
1505
-                    $ticket->get_ticket_total_with_taxes(),
1506
-                    false,
1507
-                    false
1508
-                ),
1509
-            'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1510
-            'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1511
-            'TKT_qty'                       => $default
1512
-                ? ''
1513
-                : $ticket->get_pretty('TKT_qty', 'symbol'),
1514
-            'TKT_qty_for_input'             => $default
1515
-                ? ''
1516
-                : $ticket->get_pretty('TKT_qty', 'input'),
1517
-            'TKT_uses'                      => $default
1518
-                ? ''
1519
-                : $ticket->get_pretty('TKT_uses', 'input'),
1520
-            'TKT_min'                       => $TKT_min,
1521
-            'TKT_max'                       => $default
1522
-                ? ''
1523
-                : $ticket->get_pretty('TKT_max', 'input'),
1524
-            'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1525
-            'TKT_reserved'                  => $default ? 0 : $ticket->reserved(),
1526
-            'TKT_registrations'             => $default
1527
-                ? 0
1528
-                : $ticket->count_registrations(
1529
-                    array(
1530
-                        array(
1531
-                            'STS_ID' => array(
1532
-                                '!=',
1533
-                                EEM_Registration::status_id_incomplete,
1534
-                            ),
1535
-                        ),
1536
-                    )
1537
-                ),
1538
-            'TKT_ID'                        => $default ? 0 : $ticket->ID(),
1539
-            'TKT_description'               => $default ? '' : $ticket->get_f('TKT_description'),
1540
-            'TKT_is_default'                => $default ? 0 : $ticket->is_default(),
1541
-            'TKT_required'                  => $default ? 0 : $ticket->required(),
1542
-            'TKT_is_default_selector'       => '',
1543
-            'ticket_price_rows'             => '',
1544
-            'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1545
-                ? ''
1546
-                : $base_price->get_pretty('PRC_amount', 'localized_float'),
1547
-            'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1548
-            'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1549
-                ? ''
1550
-                : 'display:none;',
1551
-            'show_price_mod_button'         => count($prices) > 1
1552
-                                               || ($default && $count_price_mods > 0)
1553
-                                               || (! $default && $ticket->deleted())
1554
-                ? 'display:none;'
1555
-                : '',
1556
-            'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1557
-            'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1558
-            'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_datetimes),
1559
-            'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_datetimes),
1560
-            'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1561
-            'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1562
-            'TKT_taxable'                   => $TKT_taxable,
1563
-            'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1564
-                ? ''
1565
-                : 'display:none;',
1566
-            'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1567
-            'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1568
-                $ticket_subtotal,
1569
-                false,
1570
-                false
1571
-            ),
1572
-            'TKT_subtotal_amount'           => $ticket_subtotal,
1573
-            'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1574
-            'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1575
-            'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1576
-                ? ' ticket-archived'
1577
-                : '',
1578
-            'trash_icon'                    => $ticket instanceof EE_Ticket
1579
-                                               && $ticket->deleted()
1580
-                                               && ! $ticket->is_permanently_deleteable()
1581
-                ? 'ee-lock-icon '
1582
-                : 'trash-icon dashicons dashicons-post-trash clickable',
1583
-            'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->deleted()
1584
-                ? ''
1585
-                : 'clone-icon ee-icon ee-icon-clone clickable',
1586
-        );
1587
-        $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1588
-            ? 'display:none'
1589
-            : '';
1590
-        // handle rows that should NOT be empty
1591
-        if (empty($template_args['TKT_start_date'])) {
1592
-            // if empty then the start date will be now.
1593
-            $template_args['TKT_start_date'] = date(
1594
-                $this->_date_time_format,
1595
-                current_time('timestamp')
1596
-            );
1597
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1598
-        }
1599
-        if (empty($template_args['TKT_end_date'])) {
1600
-            // get the earliest datetime (if present);
1601
-            $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1602
-                ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1603
-                    'Datetime',
1604
-                    array('order_by' => array('DTT_EVT_start' => 'ASC'))
1605
-                )
1606
-                : null;
1607
-            if (! empty($earliest_dtt)) {
1608
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1609
-                    'DTT_EVT_start',
1610
-                    $this->_date_time_format
1611
-                );
1612
-            } else {
1613
-                // default so let's just use what's been set for the default date-time which is 30 days from now.
1614
-                $template_args['TKT_end_date'] = date(
1615
-                    $this->_date_time_format,
1616
-                    mktime(
1617
-                        24,
1618
-                        0,
1619
-                        0,
1620
-                        date('m'),
1621
-                        date('d') + 29,
1622
-                        date('Y')
1623
-                    )
1624
-                );
1625
-            }
1626
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1627
-        }
1628
-        // generate ticket_datetime items
1629
-        if (! $default) {
1630
-            $datetime_row = 1;
1631
-            foreach ($all_datetimes as $datetime) {
1632
-                $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1633
-                    $datetime_row,
1634
-                    $ticket_row,
1635
-                    $datetime,
1636
-                    $ticket,
1637
-                    $ticket_datetimes,
1638
-                    $default
1639
-                );
1640
-                $datetime_row++;
1641
-            }
1642
-        }
1643
-        $price_row = 1;
1644
-        foreach ($prices as $price) {
1645
-            if (! $price instanceof EE_Price) {
1646
-                continue;
1647
-            }
1648
-            if ($price->is_base_price()) {
1649
-                $price_row++;
1650
-                continue;
1651
-            }
1652
-            $show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1653
-            $show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1654
-            $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1655
-                $ticket_row,
1656
-                $price_row,
1657
-                $price,
1658
-                $default,
1659
-                $ticket,
1660
-                $show_trash,
1661
-                $show_create
1662
-            );
1663
-            $price_row++;
1664
-        }
1665
-        // filter $template_args
1666
-        $template_args = apply_filters(
1667
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1668
-            $template_args,
1669
-            $ticket_row,
1670
-            $ticket,
1671
-            $ticket_datetimes,
1672
-            $all_datetimes,
1673
-            $default,
1674
-            $all_tickets,
1675
-            $this->_is_creating_event
1676
-        );
1677
-        return EEH_Template::display_template(
1678
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1679
-            $template_args,
1680
-            true
1681
-        );
1682
-    }
1400
+	/**
1401
+	 * This generates the ticket row for tickets.
1402
+	 * This same method is used to generate both the actual rows and the js skeleton row
1403
+	 * (when default === true)
1404
+	 *
1405
+	 * @param int           $ticket_row       Represents the row number being generated.
1406
+	 * @param               $ticket
1407
+	 * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1408
+	 *                                        or empty for default
1409
+	 * @param EE_Datetime[] $all_datetimes    All Datetimes on the event or empty for default.
1410
+	 * @param bool          $default          Whether default row being generated or not.
1411
+	 * @param EE_Ticket[]   $all_tickets      This is an array of all tickets attached to the event
1412
+	 *                                        (or empty in the case of defaults)
1413
+	 * @return mixed
1414
+	 * @throws InvalidArgumentException
1415
+	 * @throws InvalidInterfaceException
1416
+	 * @throws InvalidDataTypeException
1417
+	 * @throws DomainException
1418
+	 * @throws EE_Error
1419
+	 * @throws ReflectionException
1420
+	 */
1421
+	protected function _get_ticket_row(
1422
+		$ticket_row,
1423
+		$ticket,
1424
+		$ticket_datetimes,
1425
+		$all_datetimes,
1426
+		$default = false,
1427
+		$all_tickets = array()
1428
+	) {
1429
+		// if $ticket is not an instance of EE_Ticket then force default to true.
1430
+		$default = ! $ticket instanceof EE_Ticket ? true : $default;
1431
+		$prices = ! empty($ticket) && ! $default
1432
+			? $ticket->get_many_related(
1433
+				'Price',
1434
+				array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))
1435
+			)
1436
+			: array();
1437
+		// if there is only one price (which would be the base price)
1438
+		// or NO prices and this ticket is a default ticket,
1439
+		// let's just make sure there are no cached default prices on the object.
1440
+		// This is done by not including any query_params.
1441
+		if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1442
+			$prices = $ticket->prices();
1443
+		}
1444
+		// check if we're dealing with a default ticket in which case
1445
+		// we don't want any starting_ticket_datetime_row values set
1446
+		// (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1447
+		// This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1448
+		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1449
+		$tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1450
+			? $ticket_datetimes[ $ticket->ID() ]
1451
+			: array();
1452
+		$ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1453
+		$base_price = $default ? null : $ticket->base_price();
1454
+		$count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1455
+		// breaking out complicated condition for ticket_status
1456
+		if ($default) {
1457
+			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1458
+		} else {
1459
+			$ticket_status_class = $ticket->is_default()
1460
+				? ' tkt-status-' . EE_Ticket::onsale
1461
+				: ' tkt-status-' . $ticket->ticket_status();
1462
+		}
1463
+		// breaking out complicated condition for TKT_taxable
1464
+		if ($default) {
1465
+			$TKT_taxable = '';
1466
+		} else {
1467
+			$TKT_taxable = $ticket->taxable()
1468
+				? 'checked'
1469
+				: '';
1470
+		}
1471
+		if ($default) {
1472
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1473
+		} elseif ($ticket->is_default()) {
1474
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1475
+		} else {
1476
+			$TKT_status = $ticket->ticket_status(true);
1477
+		}
1478
+		if ($default) {
1479
+			$TKT_min = '';
1480
+		} else {
1481
+			$TKT_min = $ticket->min();
1482
+			if ($TKT_min === -1 || $TKT_min === 0) {
1483
+				$TKT_min = '';
1484
+			}
1485
+		}
1486
+		$template_args = array(
1487
+			'tkt_row'                       => $default ? 'TICKETNUM' : $ticket_row,
1488
+			'TKT_order'                     => $default ? 'TICKETNUM' : $ticket_row,
1489
+			// on initial page load this will always be the correct order.
1490
+			'tkt_status_class'              => $ticket_status_class,
1491
+			'display_edit_tkt_row'          => 'display:none;',
1492
+			'edit_tkt_expanded'             => '',
1493
+			'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1494
+			'TKT_name'                      => $default ? '' : $ticket->get_f('TKT_name'),
1495
+			'TKT_start_date'                => $default
1496
+				? ''
1497
+				: $ticket->get_date('TKT_start_date', $this->_date_time_format),
1498
+			'TKT_end_date'                  => $default
1499
+				? ''
1500
+				: $ticket->get_date('TKT_end_date', $this->_date_time_format),
1501
+			'TKT_status'                    => $TKT_status,
1502
+			'TKT_price'                     => $default
1503
+				? ''
1504
+				: EEH_Template::format_currency(
1505
+					$ticket->get_ticket_total_with_taxes(),
1506
+					false,
1507
+					false
1508
+				),
1509
+			'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1510
+			'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1511
+			'TKT_qty'                       => $default
1512
+				? ''
1513
+				: $ticket->get_pretty('TKT_qty', 'symbol'),
1514
+			'TKT_qty_for_input'             => $default
1515
+				? ''
1516
+				: $ticket->get_pretty('TKT_qty', 'input'),
1517
+			'TKT_uses'                      => $default
1518
+				? ''
1519
+				: $ticket->get_pretty('TKT_uses', 'input'),
1520
+			'TKT_min'                       => $TKT_min,
1521
+			'TKT_max'                       => $default
1522
+				? ''
1523
+				: $ticket->get_pretty('TKT_max', 'input'),
1524
+			'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1525
+			'TKT_reserved'                  => $default ? 0 : $ticket->reserved(),
1526
+			'TKT_registrations'             => $default
1527
+				? 0
1528
+				: $ticket->count_registrations(
1529
+					array(
1530
+						array(
1531
+							'STS_ID' => array(
1532
+								'!=',
1533
+								EEM_Registration::status_id_incomplete,
1534
+							),
1535
+						),
1536
+					)
1537
+				),
1538
+			'TKT_ID'                        => $default ? 0 : $ticket->ID(),
1539
+			'TKT_description'               => $default ? '' : $ticket->get_f('TKT_description'),
1540
+			'TKT_is_default'                => $default ? 0 : $ticket->is_default(),
1541
+			'TKT_required'                  => $default ? 0 : $ticket->required(),
1542
+			'TKT_is_default_selector'       => '',
1543
+			'ticket_price_rows'             => '',
1544
+			'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1545
+				? ''
1546
+				: $base_price->get_pretty('PRC_amount', 'localized_float'),
1547
+			'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1548
+			'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1549
+				? ''
1550
+				: 'display:none;',
1551
+			'show_price_mod_button'         => count($prices) > 1
1552
+											   || ($default && $count_price_mods > 0)
1553
+											   || (! $default && $ticket->deleted())
1554
+				? 'display:none;'
1555
+				: '',
1556
+			'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1557
+			'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1558
+			'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_datetimes),
1559
+			'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_datetimes),
1560
+			'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1561
+			'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1562
+			'TKT_taxable'                   => $TKT_taxable,
1563
+			'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1564
+				? ''
1565
+				: 'display:none;',
1566
+			'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1567
+			'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1568
+				$ticket_subtotal,
1569
+				false,
1570
+				false
1571
+			),
1572
+			'TKT_subtotal_amount'           => $ticket_subtotal,
1573
+			'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1574
+			'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1575
+			'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1576
+				? ' ticket-archived'
1577
+				: '',
1578
+			'trash_icon'                    => $ticket instanceof EE_Ticket
1579
+											   && $ticket->deleted()
1580
+											   && ! $ticket->is_permanently_deleteable()
1581
+				? 'ee-lock-icon '
1582
+				: 'trash-icon dashicons dashicons-post-trash clickable',
1583
+			'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->deleted()
1584
+				? ''
1585
+				: 'clone-icon ee-icon ee-icon-clone clickable',
1586
+		);
1587
+		$template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1588
+			? 'display:none'
1589
+			: '';
1590
+		// handle rows that should NOT be empty
1591
+		if (empty($template_args['TKT_start_date'])) {
1592
+			// if empty then the start date will be now.
1593
+			$template_args['TKT_start_date'] = date(
1594
+				$this->_date_time_format,
1595
+				current_time('timestamp')
1596
+			);
1597
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1598
+		}
1599
+		if (empty($template_args['TKT_end_date'])) {
1600
+			// get the earliest datetime (if present);
1601
+			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1602
+				? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1603
+					'Datetime',
1604
+					array('order_by' => array('DTT_EVT_start' => 'ASC'))
1605
+				)
1606
+				: null;
1607
+			if (! empty($earliest_dtt)) {
1608
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1609
+					'DTT_EVT_start',
1610
+					$this->_date_time_format
1611
+				);
1612
+			} else {
1613
+				// default so let's just use what's been set for the default date-time which is 30 days from now.
1614
+				$template_args['TKT_end_date'] = date(
1615
+					$this->_date_time_format,
1616
+					mktime(
1617
+						24,
1618
+						0,
1619
+						0,
1620
+						date('m'),
1621
+						date('d') + 29,
1622
+						date('Y')
1623
+					)
1624
+				);
1625
+			}
1626
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1627
+		}
1628
+		// generate ticket_datetime items
1629
+		if (! $default) {
1630
+			$datetime_row = 1;
1631
+			foreach ($all_datetimes as $datetime) {
1632
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1633
+					$datetime_row,
1634
+					$ticket_row,
1635
+					$datetime,
1636
+					$ticket,
1637
+					$ticket_datetimes,
1638
+					$default
1639
+				);
1640
+				$datetime_row++;
1641
+			}
1642
+		}
1643
+		$price_row = 1;
1644
+		foreach ($prices as $price) {
1645
+			if (! $price instanceof EE_Price) {
1646
+				continue;
1647
+			}
1648
+			if ($price->is_base_price()) {
1649
+				$price_row++;
1650
+				continue;
1651
+			}
1652
+			$show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1653
+			$show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1654
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1655
+				$ticket_row,
1656
+				$price_row,
1657
+				$price,
1658
+				$default,
1659
+				$ticket,
1660
+				$show_trash,
1661
+				$show_create
1662
+			);
1663
+			$price_row++;
1664
+		}
1665
+		// filter $template_args
1666
+		$template_args = apply_filters(
1667
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1668
+			$template_args,
1669
+			$ticket_row,
1670
+			$ticket,
1671
+			$ticket_datetimes,
1672
+			$all_datetimes,
1673
+			$default,
1674
+			$all_tickets,
1675
+			$this->_is_creating_event
1676
+		);
1677
+		return EEH_Template::display_template(
1678
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1679
+			$template_args,
1680
+			true
1681
+		);
1682
+	}
1683 1683
 
1684 1684
 
1685
-    /**
1686
-     * @param int            $ticket_row
1687
-     * @param EE_Ticket|null $ticket
1688
-     * @return string
1689
-     * @throws DomainException
1690
-     * @throws EE_Error
1691
-     */
1692
-    protected function _get_tax_rows($ticket_row, $ticket)
1693
-    {
1694
-        $tax_rows = '';
1695
-        /** @var EE_Price[] $taxes */
1696
-        $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1697
-        foreach ($taxes as $tax) {
1698
-            $tax_added = $this->_get_tax_added($tax, $ticket);
1699
-            $template_args = array(
1700
-                'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1701
-                    ? ''
1702
-                    : 'display:none;',
1703
-                'tax_id'            => $tax->ID(),
1704
-                'tkt_row'           => $ticket_row,
1705
-                'tax_label'         => $tax->get('PRC_name'),
1706
-                'tax_added'         => $tax_added,
1707
-                'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1708
-                'tax_amount'        => $tax->get('PRC_amount'),
1709
-            );
1710
-            $template_args = apply_filters(
1711
-                'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1712
-                $template_args,
1713
-                $ticket_row,
1714
-                $ticket,
1715
-                $this->_is_creating_event
1716
-            );
1717
-            $tax_rows .= EEH_Template::display_template(
1718
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1719
-                $template_args,
1720
-                true
1721
-            );
1722
-        }
1723
-        return $tax_rows;
1724
-    }
1685
+	/**
1686
+	 * @param int            $ticket_row
1687
+	 * @param EE_Ticket|null $ticket
1688
+	 * @return string
1689
+	 * @throws DomainException
1690
+	 * @throws EE_Error
1691
+	 */
1692
+	protected function _get_tax_rows($ticket_row, $ticket)
1693
+	{
1694
+		$tax_rows = '';
1695
+		/** @var EE_Price[] $taxes */
1696
+		$taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1697
+		foreach ($taxes as $tax) {
1698
+			$tax_added = $this->_get_tax_added($tax, $ticket);
1699
+			$template_args = array(
1700
+				'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1701
+					? ''
1702
+					: 'display:none;',
1703
+				'tax_id'            => $tax->ID(),
1704
+				'tkt_row'           => $ticket_row,
1705
+				'tax_label'         => $tax->get('PRC_name'),
1706
+				'tax_added'         => $tax_added,
1707
+				'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1708
+				'tax_amount'        => $tax->get('PRC_amount'),
1709
+			);
1710
+			$template_args = apply_filters(
1711
+				'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1712
+				$template_args,
1713
+				$ticket_row,
1714
+				$ticket,
1715
+				$this->_is_creating_event
1716
+			);
1717
+			$tax_rows .= EEH_Template::display_template(
1718
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1719
+				$template_args,
1720
+				true
1721
+			);
1722
+		}
1723
+		return $tax_rows;
1724
+	}
1725 1725
 
1726 1726
 
1727
-    /**
1728
-     * @param EE_Price       $tax
1729
-     * @param EE_Ticket|null $ticket
1730
-     * @return float|int
1731
-     * @throws EE_Error
1732
-     */
1733
-    protected function _get_tax_added(EE_Price $tax, $ticket)
1734
-    {
1735
-        $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1736
-        return $subtotal * $tax->get('PRC_amount') / 100;
1737
-    }
1727
+	/**
1728
+	 * @param EE_Price       $tax
1729
+	 * @param EE_Ticket|null $ticket
1730
+	 * @return float|int
1731
+	 * @throws EE_Error
1732
+	 */
1733
+	protected function _get_tax_added(EE_Price $tax, $ticket)
1734
+	{
1735
+		$subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1736
+		return $subtotal * $tax->get('PRC_amount') / 100;
1737
+	}
1738 1738
 
1739 1739
 
1740
-    /**
1741
-     * @param int            $ticket_row
1742
-     * @param int            $price_row
1743
-     * @param EE_Price|null  $price
1744
-     * @param bool           $default
1745
-     * @param EE_Ticket|null $ticket
1746
-     * @param bool           $show_trash
1747
-     * @param bool           $show_create
1748
-     * @return mixed
1749
-     * @throws InvalidArgumentException
1750
-     * @throws InvalidInterfaceException
1751
-     * @throws InvalidDataTypeException
1752
-     * @throws DomainException
1753
-     * @throws EE_Error
1754
-     * @throws ReflectionException
1755
-     */
1756
-    protected function _get_ticket_price_row(
1757
-        $ticket_row,
1758
-        $price_row,
1759
-        $price,
1760
-        $default,
1761
-        $ticket,
1762
-        $show_trash = true,
1763
-        $show_create = true
1764
-    ) {
1765
-        $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1766
-        $template_args = array(
1767
-            'tkt_row'               => $default && empty($ticket)
1768
-                ? 'TICKETNUM'
1769
-                : $ticket_row,
1770
-            'PRC_order'             => $default && empty($price)
1771
-                ? 'PRICENUM'
1772
-                : $price_row,
1773
-            'edit_prices_name'      => $default && empty($price)
1774
-                ? 'PRICENAMEATTR'
1775
-                : 'edit_prices',
1776
-            'price_type_selector'   => $default && empty($price)
1777
-                ? $this->_get_base_price_template($ticket_row, $price_row, $price, $default)
1778
-                : $this->_get_price_type_selector(
1779
-                    $ticket_row,
1780
-                    $price_row,
1781
-                    $price,
1782
-                    $default,
1783
-                    $send_disabled
1784
-                ),
1785
-            'PRC_ID'                => $default && empty($price)
1786
-                ? 0
1787
-                : $price->ID(),
1788
-            'PRC_is_default'        => $default && empty($price)
1789
-                ? 0
1790
-                : $price->get('PRC_is_default'),
1791
-            'PRC_name'              => $default && empty($price)
1792
-                ? ''
1793
-                : $price->get('PRC_name'),
1794
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1795
-            'show_plus_or_minus'    => $default && empty($price)
1796
-                ? ''
1797
-                : 'display:none;',
1798
-            'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1799
-                ? 'display:none;'
1800
-                : '',
1801
-            'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1802
-                ? 'display:none;'
1803
-                : '',
1804
-            'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1805
-                ? 'display:none'
1806
-                : '',
1807
-            'PRC_amount'            => $default && empty($price)
1808
-                ? 0
1809
-                : $price->get_pretty('PRC_amount', 'localized_float'),
1810
-            'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1811
-                ? 'display:none;'
1812
-                : '',
1813
-            'show_trash_icon'       => $show_trash
1814
-                ? ''
1815
-                : ' style="display:none;"',
1816
-            'show_create_button'    => $show_create
1817
-                ? ''
1818
-                : ' style="display:none;"',
1819
-            'PRC_desc'              => $default && empty($price)
1820
-                ? ''
1821
-                : $price->get('PRC_desc'),
1822
-            'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1823
-        );
1824
-        $template_args = apply_filters(
1825
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1826
-            $template_args,
1827
-            $ticket_row,
1828
-            $price_row,
1829
-            $price,
1830
-            $default,
1831
-            $ticket,
1832
-            $show_trash,
1833
-            $show_create,
1834
-            $this->_is_creating_event
1835
-        );
1836
-        return EEH_Template::display_template(
1837
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1838
-            $template_args,
1839
-            true
1840
-        );
1841
-    }
1740
+	/**
1741
+	 * @param int            $ticket_row
1742
+	 * @param int            $price_row
1743
+	 * @param EE_Price|null  $price
1744
+	 * @param bool           $default
1745
+	 * @param EE_Ticket|null $ticket
1746
+	 * @param bool           $show_trash
1747
+	 * @param bool           $show_create
1748
+	 * @return mixed
1749
+	 * @throws InvalidArgumentException
1750
+	 * @throws InvalidInterfaceException
1751
+	 * @throws InvalidDataTypeException
1752
+	 * @throws DomainException
1753
+	 * @throws EE_Error
1754
+	 * @throws ReflectionException
1755
+	 */
1756
+	protected function _get_ticket_price_row(
1757
+		$ticket_row,
1758
+		$price_row,
1759
+		$price,
1760
+		$default,
1761
+		$ticket,
1762
+		$show_trash = true,
1763
+		$show_create = true
1764
+	) {
1765
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1766
+		$template_args = array(
1767
+			'tkt_row'               => $default && empty($ticket)
1768
+				? 'TICKETNUM'
1769
+				: $ticket_row,
1770
+			'PRC_order'             => $default && empty($price)
1771
+				? 'PRICENUM'
1772
+				: $price_row,
1773
+			'edit_prices_name'      => $default && empty($price)
1774
+				? 'PRICENAMEATTR'
1775
+				: 'edit_prices',
1776
+			'price_type_selector'   => $default && empty($price)
1777
+				? $this->_get_base_price_template($ticket_row, $price_row, $price, $default)
1778
+				: $this->_get_price_type_selector(
1779
+					$ticket_row,
1780
+					$price_row,
1781
+					$price,
1782
+					$default,
1783
+					$send_disabled
1784
+				),
1785
+			'PRC_ID'                => $default && empty($price)
1786
+				? 0
1787
+				: $price->ID(),
1788
+			'PRC_is_default'        => $default && empty($price)
1789
+				? 0
1790
+				: $price->get('PRC_is_default'),
1791
+			'PRC_name'              => $default && empty($price)
1792
+				? ''
1793
+				: $price->get('PRC_name'),
1794
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1795
+			'show_plus_or_minus'    => $default && empty($price)
1796
+				? ''
1797
+				: 'display:none;',
1798
+			'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1799
+				? 'display:none;'
1800
+				: '',
1801
+			'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1802
+				? 'display:none;'
1803
+				: '',
1804
+			'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1805
+				? 'display:none'
1806
+				: '',
1807
+			'PRC_amount'            => $default && empty($price)
1808
+				? 0
1809
+				: $price->get_pretty('PRC_amount', 'localized_float'),
1810
+			'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1811
+				? 'display:none;'
1812
+				: '',
1813
+			'show_trash_icon'       => $show_trash
1814
+				? ''
1815
+				: ' style="display:none;"',
1816
+			'show_create_button'    => $show_create
1817
+				? ''
1818
+				: ' style="display:none;"',
1819
+			'PRC_desc'              => $default && empty($price)
1820
+				? ''
1821
+				: $price->get('PRC_desc'),
1822
+			'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1823
+		);
1824
+		$template_args = apply_filters(
1825
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1826
+			$template_args,
1827
+			$ticket_row,
1828
+			$price_row,
1829
+			$price,
1830
+			$default,
1831
+			$ticket,
1832
+			$show_trash,
1833
+			$show_create,
1834
+			$this->_is_creating_event
1835
+		);
1836
+		return EEH_Template::display_template(
1837
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1838
+			$template_args,
1839
+			true
1840
+		);
1841
+	}
1842 1842
 
1843 1843
 
1844
-    /**
1845
-     * @param int      $ticket_row
1846
-     * @param int      $price_row
1847
-     * @param EE_Price $price
1848
-     * @param bool     $default
1849
-     * @param bool     $disabled
1850
-     * @return mixed
1851
-     * @throws ReflectionException
1852
-     * @throws InvalidArgumentException
1853
-     * @throws InvalidInterfaceException
1854
-     * @throws InvalidDataTypeException
1855
-     * @throws DomainException
1856
-     * @throws EE_Error
1857
-     */
1858
-    protected function _get_price_type_selector($ticket_row, $price_row, $price, $default, $disabled = false)
1859
-    {
1860
-        if ($price->is_base_price()) {
1861
-            return $this->_get_base_price_template(
1862
-                $ticket_row,
1863
-                $price_row,
1864
-                $price,
1865
-                $default
1866
-            );
1867
-        }
1868
-        return $this->_get_price_modifier_template(
1869
-            $ticket_row,
1870
-            $price_row,
1871
-            $price,
1872
-            $default,
1873
-            $disabled
1874
-        );
1875
-    }
1844
+	/**
1845
+	 * @param int      $ticket_row
1846
+	 * @param int      $price_row
1847
+	 * @param EE_Price $price
1848
+	 * @param bool     $default
1849
+	 * @param bool     $disabled
1850
+	 * @return mixed
1851
+	 * @throws ReflectionException
1852
+	 * @throws InvalidArgumentException
1853
+	 * @throws InvalidInterfaceException
1854
+	 * @throws InvalidDataTypeException
1855
+	 * @throws DomainException
1856
+	 * @throws EE_Error
1857
+	 */
1858
+	protected function _get_price_type_selector($ticket_row, $price_row, $price, $default, $disabled = false)
1859
+	{
1860
+		if ($price->is_base_price()) {
1861
+			return $this->_get_base_price_template(
1862
+				$ticket_row,
1863
+				$price_row,
1864
+				$price,
1865
+				$default
1866
+			);
1867
+		}
1868
+		return $this->_get_price_modifier_template(
1869
+			$ticket_row,
1870
+			$price_row,
1871
+			$price,
1872
+			$default,
1873
+			$disabled
1874
+		);
1875
+	}
1876 1876
 
1877 1877
 
1878
-    /**
1879
-     * @param int      $ticket_row
1880
-     * @param int      $price_row
1881
-     * @param EE_Price $price
1882
-     * @param bool     $default
1883
-     * @return mixed
1884
-     * @throws DomainException
1885
-     * @throws EE_Error
1886
-     */
1887
-    protected function _get_base_price_template($ticket_row, $price_row, $price, $default)
1888
-    {
1889
-        $template_args = array(
1890
-            'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1891
-            'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $price_row,
1892
-            'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1893
-            'PRT_name'                  => esc_html__('Price', 'event_espresso'),
1894
-            'price_selected_operator'   => '+',
1895
-            'price_selected_is_percent' => 0,
1896
-        );
1897
-        $template_args = apply_filters(
1898
-            'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1899
-            $template_args,
1900
-            $ticket_row,
1901
-            $price_row,
1902
-            $price,
1903
-            $default,
1904
-            $this->_is_creating_event
1905
-        );
1906
-        return EEH_Template::display_template(
1907
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1908
-            $template_args,
1909
-            true
1910
-        );
1911
-    }
1878
+	/**
1879
+	 * @param int      $ticket_row
1880
+	 * @param int      $price_row
1881
+	 * @param EE_Price $price
1882
+	 * @param bool     $default
1883
+	 * @return mixed
1884
+	 * @throws DomainException
1885
+	 * @throws EE_Error
1886
+	 */
1887
+	protected function _get_base_price_template($ticket_row, $price_row, $price, $default)
1888
+	{
1889
+		$template_args = array(
1890
+			'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1891
+			'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $price_row,
1892
+			'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1893
+			'PRT_name'                  => esc_html__('Price', 'event_espresso'),
1894
+			'price_selected_operator'   => '+',
1895
+			'price_selected_is_percent' => 0,
1896
+		);
1897
+		$template_args = apply_filters(
1898
+			'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1899
+			$template_args,
1900
+			$ticket_row,
1901
+			$price_row,
1902
+			$price,
1903
+			$default,
1904
+			$this->_is_creating_event
1905
+		);
1906
+		return EEH_Template::display_template(
1907
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1908
+			$template_args,
1909
+			true
1910
+		);
1911
+	}
1912 1912
 
1913 1913
 
1914
-    /**
1915
-     * @param int      $ticket_row
1916
-     * @param int      $price_row
1917
-     * @param EE_Price $price
1918
-     * @param bool     $default
1919
-     * @param bool     $disabled
1920
-     * @return mixed
1921
-     * @throws ReflectionException
1922
-     * @throws InvalidArgumentException
1923
-     * @throws InvalidInterfaceException
1924
-     * @throws InvalidDataTypeException
1925
-     * @throws DomainException
1926
-     * @throws EE_Error
1927
-     */
1928
-    protected function _get_price_modifier_template(
1929
-        $ticket_row,
1930
-        $price_row,
1931
-        $price,
1932
-        $default,
1933
-        $disabled = false
1934
-    ) {
1935
-        $select_name = $default && ! $price instanceof EE_Price
1936
-            ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1937
-            : 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
1938
-        /** @var EEM_Price_Type $price_type_model */
1939
-        $price_type_model = EE_Registry::instance()->load_model('Price_Type');
1940
-        $price_types = $price_type_model->get_all(array(
1941
-            array(
1942
-                'OR' => array(
1943
-                    'PBT_ID'  => '2',
1944
-                    'PBT_ID*' => '3',
1945
-                ),
1946
-            ),
1947
-        ));
1948
-        $all_price_types = $default && ! $price instanceof EE_Price
1949
-            ? array(esc_html__('Select Modifier', 'event_espresso'))
1950
-            : array();
1951
-        $selected_price_type_id = $default && ! $price instanceof EE_Price ? 0 : $price->type();
1952
-        $price_option_spans = '';
1953
-        // setup price types for selector
1954
-        foreach ($price_types as $price_type) {
1955
-            if (! $price_type instanceof EE_Price_Type) {
1956
-                continue;
1957
-            }
1958
-            $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1959
-            // while we're in the loop let's setup the option spans used by js
1960
-            $span_args = array(
1961
-                'PRT_ID'         => $price_type->ID(),
1962
-                'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1963
-                'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1964
-            );
1965
-            $price_option_spans .= EEH_Template::display_template(
1966
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1967
-                $span_args,
1968
-                true
1969
-            );
1970
-        }
1971
-        $select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1972
-            : $select_name;
1973
-        $select_input = new EE_Select_Input(
1974
-            $all_price_types,
1975
-            array(
1976
-                'default'               => $selected_price_type_id,
1977
-                'html_name'             => $select_name,
1978
-                'html_class'            => 'edit-price-PRT_ID',
1979
-                'other_html_attributes' => $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"',
1980
-            )
1981
-        );
1982
-        $price_selected_operator = $price instanceof EE_Price && $price->is_discount() ? '-' : '+';
1983
-        $price_selected_operator = $default && ! $price instanceof EE_Price ? '' : $price_selected_operator;
1984
-        $price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() ? 1 : 0;
1985
-        $price_selected_is_percent = $default && ! $price instanceof EE_Price ? '' : $price_selected_is_percent;
1986
-        $template_args = array(
1987
-            'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1988
-            'PRC_order'                 => $default && ! $price instanceof EE_Price ? 'PRICENUM' : $price_row,
1989
-            'price_modifier_selector'   => $select_input->get_html_for_input(),
1990
-            'main_name'                 => $select_name,
1991
-            'selected_price_type_id'    => $selected_price_type_id,
1992
-            'price_option_spans'        => $price_option_spans,
1993
-            'price_selected_operator'   => $price_selected_operator,
1994
-            'price_selected_is_percent' => $price_selected_is_percent,
1995
-            'disabled'                  => $disabled,
1996
-        );
1997
-        $template_args = apply_filters(
1998
-            'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
1999
-            $template_args,
2000
-            $ticket_row,
2001
-            $price_row,
2002
-            $price,
2003
-            $default,
2004
-            $disabled,
2005
-            $this->_is_creating_event
2006
-        );
2007
-        return EEH_Template::display_template(
2008
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2009
-            $template_args,
2010
-            true
2011
-        );
2012
-    }
1914
+	/**
1915
+	 * @param int      $ticket_row
1916
+	 * @param int      $price_row
1917
+	 * @param EE_Price $price
1918
+	 * @param bool     $default
1919
+	 * @param bool     $disabled
1920
+	 * @return mixed
1921
+	 * @throws ReflectionException
1922
+	 * @throws InvalidArgumentException
1923
+	 * @throws InvalidInterfaceException
1924
+	 * @throws InvalidDataTypeException
1925
+	 * @throws DomainException
1926
+	 * @throws EE_Error
1927
+	 */
1928
+	protected function _get_price_modifier_template(
1929
+		$ticket_row,
1930
+		$price_row,
1931
+		$price,
1932
+		$default,
1933
+		$disabled = false
1934
+	) {
1935
+		$select_name = $default && ! $price instanceof EE_Price
1936
+			? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1937
+			: 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
1938
+		/** @var EEM_Price_Type $price_type_model */
1939
+		$price_type_model = EE_Registry::instance()->load_model('Price_Type');
1940
+		$price_types = $price_type_model->get_all(array(
1941
+			array(
1942
+				'OR' => array(
1943
+					'PBT_ID'  => '2',
1944
+					'PBT_ID*' => '3',
1945
+				),
1946
+			),
1947
+		));
1948
+		$all_price_types = $default && ! $price instanceof EE_Price
1949
+			? array(esc_html__('Select Modifier', 'event_espresso'))
1950
+			: array();
1951
+		$selected_price_type_id = $default && ! $price instanceof EE_Price ? 0 : $price->type();
1952
+		$price_option_spans = '';
1953
+		// setup price types for selector
1954
+		foreach ($price_types as $price_type) {
1955
+			if (! $price_type instanceof EE_Price_Type) {
1956
+				continue;
1957
+			}
1958
+			$all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1959
+			// while we're in the loop let's setup the option spans used by js
1960
+			$span_args = array(
1961
+				'PRT_ID'         => $price_type->ID(),
1962
+				'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1963
+				'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1964
+			);
1965
+			$price_option_spans .= EEH_Template::display_template(
1966
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1967
+				$span_args,
1968
+				true
1969
+			);
1970
+		}
1971
+		$select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1972
+			: $select_name;
1973
+		$select_input = new EE_Select_Input(
1974
+			$all_price_types,
1975
+			array(
1976
+				'default'               => $selected_price_type_id,
1977
+				'html_name'             => $select_name,
1978
+				'html_class'            => 'edit-price-PRT_ID',
1979
+				'other_html_attributes' => $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"',
1980
+			)
1981
+		);
1982
+		$price_selected_operator = $price instanceof EE_Price && $price->is_discount() ? '-' : '+';
1983
+		$price_selected_operator = $default && ! $price instanceof EE_Price ? '' : $price_selected_operator;
1984
+		$price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() ? 1 : 0;
1985
+		$price_selected_is_percent = $default && ! $price instanceof EE_Price ? '' : $price_selected_is_percent;
1986
+		$template_args = array(
1987
+			'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1988
+			'PRC_order'                 => $default && ! $price instanceof EE_Price ? 'PRICENUM' : $price_row,
1989
+			'price_modifier_selector'   => $select_input->get_html_for_input(),
1990
+			'main_name'                 => $select_name,
1991
+			'selected_price_type_id'    => $selected_price_type_id,
1992
+			'price_option_spans'        => $price_option_spans,
1993
+			'price_selected_operator'   => $price_selected_operator,
1994
+			'price_selected_is_percent' => $price_selected_is_percent,
1995
+			'disabled'                  => $disabled,
1996
+		);
1997
+		$template_args = apply_filters(
1998
+			'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
1999
+			$template_args,
2000
+			$ticket_row,
2001
+			$price_row,
2002
+			$price,
2003
+			$default,
2004
+			$disabled,
2005
+			$this->_is_creating_event
2006
+		);
2007
+		return EEH_Template::display_template(
2008
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2009
+			$template_args,
2010
+			true
2011
+		);
2012
+	}
2013 2013
 
2014 2014
 
2015
-    /**
2016
-     * @param int              $datetime_row
2017
-     * @param int              $ticket_row
2018
-     * @param EE_Datetime|null $datetime
2019
-     * @param EE_Ticket|null   $ticket
2020
-     * @param array            $ticket_datetimes
2021
-     * @param bool             $default
2022
-     * @return mixed
2023
-     * @throws DomainException
2024
-     * @throws EE_Error
2025
-     */
2026
-    protected function _get_ticket_datetime_list_item(
2027
-        $datetime_row,
2028
-        $ticket_row,
2029
-        $datetime,
2030
-        $ticket,
2031
-        $ticket_datetimes = array(),
2032
-        $default
2033
-    ) {
2034
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2035
-            ? $ticket_datetimes[ $ticket->ID() ]
2036
-            : array();
2037
-        $template_args = array(
2038
-            'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2039
-                ? 'DTTNUM'
2040
-                : $datetime_row,
2041
-            'tkt_row'                  => $default
2042
-                ? 'TICKETNUM'
2043
-                : $ticket_row,
2044
-            'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2045
-                ? ' ticket-selected'
2046
-                : '',
2047
-            'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2048
-                ? ' checked'
2049
-                : '',
2050
-            'DTT_name'                 => $default && empty($datetime)
2051
-                ? 'DTTNAME'
2052
-                : $datetime->get_dtt_display_name(true),
2053
-            'tkt_status_class'         => '',
2054
-        );
2055
-        $template_args = apply_filters(
2056
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2057
-            $template_args,
2058
-            $datetime_row,
2059
-            $ticket_row,
2060
-            $datetime,
2061
-            $ticket,
2062
-            $ticket_datetimes,
2063
-            $default,
2064
-            $this->_is_creating_event
2065
-        );
2066
-        return EEH_Template::display_template(
2067
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2068
-            $template_args,
2069
-            true
2070
-        );
2071
-    }
2015
+	/**
2016
+	 * @param int              $datetime_row
2017
+	 * @param int              $ticket_row
2018
+	 * @param EE_Datetime|null $datetime
2019
+	 * @param EE_Ticket|null   $ticket
2020
+	 * @param array            $ticket_datetimes
2021
+	 * @param bool             $default
2022
+	 * @return mixed
2023
+	 * @throws DomainException
2024
+	 * @throws EE_Error
2025
+	 */
2026
+	protected function _get_ticket_datetime_list_item(
2027
+		$datetime_row,
2028
+		$ticket_row,
2029
+		$datetime,
2030
+		$ticket,
2031
+		$ticket_datetimes = array(),
2032
+		$default
2033
+	) {
2034
+		$tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2035
+			? $ticket_datetimes[ $ticket->ID() ]
2036
+			: array();
2037
+		$template_args = array(
2038
+			'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2039
+				? 'DTTNUM'
2040
+				: $datetime_row,
2041
+			'tkt_row'                  => $default
2042
+				? 'TICKETNUM'
2043
+				: $ticket_row,
2044
+			'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2045
+				? ' ticket-selected'
2046
+				: '',
2047
+			'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2048
+				? ' checked'
2049
+				: '',
2050
+			'DTT_name'                 => $default && empty($datetime)
2051
+				? 'DTTNAME'
2052
+				: $datetime->get_dtt_display_name(true),
2053
+			'tkt_status_class'         => '',
2054
+		);
2055
+		$template_args = apply_filters(
2056
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2057
+			$template_args,
2058
+			$datetime_row,
2059
+			$ticket_row,
2060
+			$datetime,
2061
+			$ticket,
2062
+			$ticket_datetimes,
2063
+			$default,
2064
+			$this->_is_creating_event
2065
+		);
2066
+		return EEH_Template::display_template(
2067
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2068
+			$template_args,
2069
+			true
2070
+		);
2071
+	}
2072 2072
 
2073 2073
 
2074
-    /**
2075
-     * @param array $all_datetimes
2076
-     * @param array $all_tickets
2077
-     * @return mixed
2078
-     * @throws ReflectionException
2079
-     * @throws InvalidArgumentException
2080
-     * @throws InvalidInterfaceException
2081
-     * @throws InvalidDataTypeException
2082
-     * @throws DomainException
2083
-     * @throws EE_Error
2084
-     */
2085
-    protected function _get_ticket_js_structure($all_datetimes = array(), $all_tickets = array())
2086
-    {
2087
-        $template_args = array(
2088
-            'default_datetime_edit_row'                => $this->_get_dtt_edit_row(
2089
-                'DTTNUM',
2090
-                null,
2091
-                true,
2092
-                $all_datetimes
2093
-            ),
2094
-            'default_ticket_row'                       => $this->_get_ticket_row(
2095
-                'TICKETNUM',
2096
-                null,
2097
-                array(),
2098
-                array(),
2099
-                true
2100
-            ),
2101
-            'default_price_row'                        => $this->_get_ticket_price_row(
2102
-                'TICKETNUM',
2103
-                'PRICENUM',
2104
-                null,
2105
-                true,
2106
-                null
2107
-            ),
2108
-            'default_price_rows'                       => '',
2109
-            'default_base_price_amount'                => 0,
2110
-            'default_base_price_name'                  => '',
2111
-            'default_base_price_description'           => '',
2112
-            'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2113
-                'TICKETNUM',
2114
-                'PRICENUM',
2115
-                null,
2116
-                true
2117
-            ),
2118
-            'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2119
-                'DTTNUM',
2120
-                null,
2121
-                array(),
2122
-                array(),
2123
-                true
2124
-            ),
2125
-            'existing_available_datetime_tickets_list' => '',
2126
-            'existing_available_ticket_datetimes_list' => '',
2127
-            'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2128
-                'DTTNUM',
2129
-                'TICKETNUM',
2130
-                null,
2131
-                null,
2132
-                array(),
2133
-                true
2134
-            ),
2135
-            'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2136
-                'DTTNUM',
2137
-                'TICKETNUM',
2138
-                null,
2139
-                null,
2140
-                array(),
2141
-                true
2142
-            ),
2143
-        );
2144
-        $ticket_row = 1;
2145
-        foreach ($all_tickets as $ticket) {
2146
-            $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2147
-                'DTTNUM',
2148
-                $ticket_row,
2149
-                null,
2150
-                $ticket,
2151
-                array(),
2152
-                true
2153
-            );
2154
-            $ticket_row++;
2155
-        }
2156
-        $datetime_row = 1;
2157
-        foreach ($all_datetimes as $datetime) {
2158
-            $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2159
-                $datetime_row,
2160
-                'TICKETNUM',
2161
-                $datetime,
2162
-                null,
2163
-                array(),
2164
-                true
2165
-            );
2166
-            $datetime_row++;
2167
-        }
2168
-        /** @var EEM_Price $price_model */
2169
-        $price_model = EE_Registry::instance()->load_model('Price');
2170
-        $default_prices = $price_model->get_all_default_prices();
2171
-        $price_row = 1;
2172
-        foreach ($default_prices as $price) {
2173
-            if (! $price instanceof EE_Price) {
2174
-                continue;
2175
-            }
2176
-            if ($price->is_base_price()) {
2177
-                $template_args['default_base_price_amount'] = $price->get_pretty(
2178
-                    'PRC_amount',
2179
-                    'localized_float'
2180
-                );
2181
-                $template_args['default_base_price_name'] = $price->get('PRC_name');
2182
-                $template_args['default_base_price_description'] = $price->get('PRC_desc');
2183
-                $price_row++;
2184
-                continue;
2185
-            }
2186
-            $show_trash = ! ((count($default_prices) > 1 && $price_row === 1)
2187
-                             || count($default_prices) === 1);
2188
-            $show_create = ! (count($default_prices) > 1
2189
-                              && count($default_prices)
2190
-                                 !== $price_row);
2191
-            $template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2192
-                'TICKETNUM',
2193
-                $price_row,
2194
-                $price,
2195
-                true,
2196
-                null,
2197
-                $show_trash,
2198
-                $show_create
2199
-            );
2200
-            $price_row++;
2201
-        }
2202
-        $template_args = apply_filters(
2203
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2204
-            $template_args,
2205
-            $all_datetimes,
2206
-            $all_tickets,
2207
-            $this->_is_creating_event
2208
-        );
2209
-        return EEH_Template::display_template(
2210
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2211
-            $template_args,
2212
-            true
2213
-        );
2214
-    }
2074
+	/**
2075
+	 * @param array $all_datetimes
2076
+	 * @param array $all_tickets
2077
+	 * @return mixed
2078
+	 * @throws ReflectionException
2079
+	 * @throws InvalidArgumentException
2080
+	 * @throws InvalidInterfaceException
2081
+	 * @throws InvalidDataTypeException
2082
+	 * @throws DomainException
2083
+	 * @throws EE_Error
2084
+	 */
2085
+	protected function _get_ticket_js_structure($all_datetimes = array(), $all_tickets = array())
2086
+	{
2087
+		$template_args = array(
2088
+			'default_datetime_edit_row'                => $this->_get_dtt_edit_row(
2089
+				'DTTNUM',
2090
+				null,
2091
+				true,
2092
+				$all_datetimes
2093
+			),
2094
+			'default_ticket_row'                       => $this->_get_ticket_row(
2095
+				'TICKETNUM',
2096
+				null,
2097
+				array(),
2098
+				array(),
2099
+				true
2100
+			),
2101
+			'default_price_row'                        => $this->_get_ticket_price_row(
2102
+				'TICKETNUM',
2103
+				'PRICENUM',
2104
+				null,
2105
+				true,
2106
+				null
2107
+			),
2108
+			'default_price_rows'                       => '',
2109
+			'default_base_price_amount'                => 0,
2110
+			'default_base_price_name'                  => '',
2111
+			'default_base_price_description'           => '',
2112
+			'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2113
+				'TICKETNUM',
2114
+				'PRICENUM',
2115
+				null,
2116
+				true
2117
+			),
2118
+			'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2119
+				'DTTNUM',
2120
+				null,
2121
+				array(),
2122
+				array(),
2123
+				true
2124
+			),
2125
+			'existing_available_datetime_tickets_list' => '',
2126
+			'existing_available_ticket_datetimes_list' => '',
2127
+			'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2128
+				'DTTNUM',
2129
+				'TICKETNUM',
2130
+				null,
2131
+				null,
2132
+				array(),
2133
+				true
2134
+			),
2135
+			'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2136
+				'DTTNUM',
2137
+				'TICKETNUM',
2138
+				null,
2139
+				null,
2140
+				array(),
2141
+				true
2142
+			),
2143
+		);
2144
+		$ticket_row = 1;
2145
+		foreach ($all_tickets as $ticket) {
2146
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2147
+				'DTTNUM',
2148
+				$ticket_row,
2149
+				null,
2150
+				$ticket,
2151
+				array(),
2152
+				true
2153
+			);
2154
+			$ticket_row++;
2155
+		}
2156
+		$datetime_row = 1;
2157
+		foreach ($all_datetimes as $datetime) {
2158
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2159
+				$datetime_row,
2160
+				'TICKETNUM',
2161
+				$datetime,
2162
+				null,
2163
+				array(),
2164
+				true
2165
+			);
2166
+			$datetime_row++;
2167
+		}
2168
+		/** @var EEM_Price $price_model */
2169
+		$price_model = EE_Registry::instance()->load_model('Price');
2170
+		$default_prices = $price_model->get_all_default_prices();
2171
+		$price_row = 1;
2172
+		foreach ($default_prices as $price) {
2173
+			if (! $price instanceof EE_Price) {
2174
+				continue;
2175
+			}
2176
+			if ($price->is_base_price()) {
2177
+				$template_args['default_base_price_amount'] = $price->get_pretty(
2178
+					'PRC_amount',
2179
+					'localized_float'
2180
+				);
2181
+				$template_args['default_base_price_name'] = $price->get('PRC_name');
2182
+				$template_args['default_base_price_description'] = $price->get('PRC_desc');
2183
+				$price_row++;
2184
+				continue;
2185
+			}
2186
+			$show_trash = ! ((count($default_prices) > 1 && $price_row === 1)
2187
+							 || count($default_prices) === 1);
2188
+			$show_create = ! (count($default_prices) > 1
2189
+							  && count($default_prices)
2190
+								 !== $price_row);
2191
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2192
+				'TICKETNUM',
2193
+				$price_row,
2194
+				$price,
2195
+				true,
2196
+				null,
2197
+				$show_trash,
2198
+				$show_create
2199
+			);
2200
+			$price_row++;
2201
+		}
2202
+		$template_args = apply_filters(
2203
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2204
+			$template_args,
2205
+			$all_datetimes,
2206
+			$all_tickets,
2207
+			$this->_is_creating_event
2208
+		);
2209
+		return EEH_Template::display_template(
2210
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2211
+			$template_args,
2212
+			true
2213
+		);
2214
+	}
2215 2215
 }
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
             );
151 151
             $msg .= '</p><ul>';
152 152
             foreach ($format_validation as $error) {
153
-                $msg .= '<li>' . $error . '</li>';
153
+                $msg .= '<li>'.$error.'</li>';
154 154
             }
155 155
             $msg .= '</ul><p>';
156 156
             $msg .= sprintf(
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
         $this->_scripts_styles = array(
180 180
             'registers'   => array(
181 181
                 'ee-tickets-datetimes-css' => array(
182
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
182
+                    'url'  => PRICING_ASSETS_URL.'event-tickets-datetimes.css',
183 183
                     'type' => 'css',
184 184
                 ),
185 185
                 'ee-dtt-ticket-metabox'    => array(
186
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
186
+                    'url'     => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js',
187 187
                     'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
188 188
                 ),
189 189
             ),
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
                             'event_espresso'
208 208
                         ),
209 209
                         'cancel_button'           => '<button class="button-secondary ee-modal-cancel">'
210
-                                                     . esc_html__('Cancel', 'event_espresso') . '</button>',
210
+                                                     . esc_html__('Cancel', 'event_espresso').'</button>',
211 211
                         'close_button'            => '<button class="button-secondary ee-modal-cancel">'
212
-                                                     . esc_html__('Close', 'event_espresso') . '</button>',
212
+                                                     . esc_html__('Close', 'event_espresso').'</button>',
213 213
                         'single_warning_from_tkt' => esc_html__(
214 214
                             'The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.',
215 215
                             'event_espresso'
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
                             'event_espresso'
220 220
                         ),
221 221
                         'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">'
222
-                                                     . esc_html__('Dismiss', 'event_espresso') . '</button>',
222
+                                                     . esc_html__('Dismiss', 'event_espresso').'</button>',
223 223
                     ),
224 224
                     'DTT_ERROR_MSG'         => array(
225 225
                         'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
     {
258 258
         foreach ($update_callbacks as $key => $callback) {
259 259
             if ($callback[1] === '_default_tickets_update') {
260
-                unset($update_callbacks[ $key ]);
260
+                unset($update_callbacks[$key]);
261 261
             }
262 262
         }
263 263
         $update_callbacks[] = array($this, 'datetime_and_tickets_caf_update');
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
         foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
316 316
             // trim all values to ensure any excess whitespace is removed.
317 317
             $datetime_data = array_map(
318
-                function ($datetime_data) {
318
+                function($datetime_data) {
319 319
                     return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
320 320
                 },
321 321
                 $datetime_data
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
             );
346 346
             // if we have an id then let's get existing object first and then set the new values.
347 347
             // Otherwise we instantiate a new object for save.
348
-            if (! empty($datetime_data['DTT_ID'])) {
348
+            if ( ! empty($datetime_data['DTT_ID'])) {
349 349
                 $datetime = EE_Registry::instance()
350 350
                                        ->load_model('Datetime', array($timezone))
351 351
                                        ->get_one_by_ID($datetime_data['DTT_ID']);
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
                 // after the add_relation_to() the autosave replaces it.
360 360
                 // We need to do this so we dont' TRASH the parent DTT.
361 361
                 // (save the ID for both key and value to avoid duplications)
362
-                $saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
362
+                $saved_dtt_ids[$datetime->ID()] = $datetime->ID();
363 363
             } else {
364 364
                 $datetime = EE_Registry::instance()->load_class(
365 365
                     'Datetime',
@@ -395,8 +395,8 @@  discard block
 block discarded – undo
395 395
             // because it is possible there was a new one created for the autosave.
396 396
             // (save the ID for both key and value to avoid duplications)
397 397
             $DTT_ID = $datetime->ID();
398
-            $saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
399
-            $saved_dtt_objs[ $row ] = $datetime;
398
+            $saved_dtt_ids[$DTT_ID] = $DTT_ID;
399
+            $saved_dtt_objs[$row] = $datetime;
400 400
             // @todo if ANY of these updates fail then we want the appropriate global error message.
401 401
         }
402 402
         $event->save();
@@ -460,13 +460,13 @@  discard block
 block discarded – undo
460 460
             $update_prices = $create_new_TKT = false;
461 461
             // figure out what datetimes were added to the ticket
462 462
             // and what datetimes were removed from the ticket in the session.
463
-            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
464
-            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
463
+            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
464
+            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]);
465 465
             $datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
466 466
             $datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
467 467
             // trim inputs to ensure any excess whitespace is removed.
468 468
             $tkt = array_map(
469
-                function ($ticket_data) {
469
+                function($ticket_data) {
470 470
                     return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
471 471
                 },
472 472
                 $tkt
@@ -486,8 +486,8 @@  discard block
 block discarded – undo
486 486
                 ? $base_price
487 487
                 : $ticket_price;
488 488
             $base_price_id = $tkt['TKT_base_price_ID'] ?? 0;
489
-            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
490
-                ? $data['edit_prices'][ $row ]
489
+            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row])
490
+                ? $data['edit_prices'][$row]
491 491
                 : array();
492 492
             $now = null;
493 493
             if (empty($tkt['TKT_start_date'])) {
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
                 /**
500 500
                  * set the TKT_end_date to the first datetime attached to the ticket.
501 501
                  */
502
-                $first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
502
+                $first_dtt = $saved_datetimes[reset($tkt_dtt_rows)];
503 503
                 $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
504 504
             }
505 505
             $TKT_values = array(
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
             // need to make sue that the TKT_price is accurate after saving the prices.
635 635
             $ticket->ensure_TKT_Price_correct();
636 636
             // handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
637
-            if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
637
+            if ( ! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
638 638
                 $update_prices = true;
639 639
                 $new_default = clone $ticket;
640 640
                 $new_default->set('TKT_ID', 0);
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
                 // save new TKT
680 680
                 $new_tkt->save();
681 681
                 // add new ticket to array
682
-                $saved_tickets[ $new_tkt->ID() ] = $new_tkt;
682
+                $saved_tickets[$new_tkt->ID()] = $new_tkt;
683 683
                 do_action(
684 684
                     'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
685 685
                     $new_tkt,
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
                 );
690 690
             } else {
691 691
                 // add tkt to saved tkts
692
-                $saved_tickets[ $ticket->ID() ] = $ticket;
692
+                $saved_tickets[$ticket->ID()] = $ticket;
693 693
                 do_action(
694 694
                     'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
695 695
                     $ticket,
@@ -756,31 +756,31 @@  discard block
 block discarded – undo
756 756
         // to start we have to add the ticket to all the datetimes its supposed to be with,
757 757
         // and removing the ticket from datetimes it got removed from.
758 758
         // first let's add datetimes
759
-        if (! empty($added_datetimes) && is_array($added_datetimes)) {
759
+        if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
760 760
             foreach ($added_datetimes as $row_id) {
761 761
                 $row_id = (int) $row_id;
762
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
763
-                    $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
762
+                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
763
+                    $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
764 764
                     // Is this an existing ticket (has an ID) and does it have any sold?
765 765
                     // If so, then we need to add that to the DTT sold because this DTT is getting added.
766 766
                     if ($ticket->ID() && $ticket->sold() > 0) {
767
-                        $saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false);
767
+                        $saved_datetimes[$row_id]->increaseSold($ticket->sold(), false);
768 768
                     }
769 769
                 }
770 770
             }
771 771
         }
772 772
         // then remove datetimes
773
-        if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
773
+        if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
774 774
             foreach ($removed_datetimes as $row_id) {
775 775
                 $row_id = (int) $row_id;
776 776
                 // its entirely possible that a datetime got deleted (instead of just removed from relationship.
777 777
                 // So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
778
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
779
-                    $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
778
+                if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
779
+                    $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
780 780
                     // Is this an existing ticket (has an ID) and does it have any sold?
781 781
                     // If so, then we need to remove it's sold from the DTT_sold.
782 782
                     if ($ticket->ID() && $ticket->sold() > 0) {
783
-                        $saved_datetimes[ $row_id ]->decreaseSold($ticket->sold());
783
+                        $saved_datetimes[$row_id]->decreaseSold($ticket->sold());
784 784
                     }
785 785
                 }
786 786
             }
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
             );
894 894
         }
895 895
         // possibly need to save tkt
896
-        if (! $ticket->ID()) {
896
+        if ( ! $ticket->ID()) {
897 897
             $ticket->save();
898 898
         }
899 899
         foreach ($prices as $row => $prc) {
@@ -927,17 +927,17 @@  discard block
 block discarded – undo
927 927
                 }
928 928
             }
929 929
             $price->save();
930
-            $updated_prices[ $price->ID() ] = $price;
930
+            $updated_prices[$price->ID()] = $price;
931 931
             $ticket->_add_relation_to($price, 'Price');
932 932
         }
933 933
         // now let's remove any prices that got removed from the ticket
934
-        if (! empty($current_prices_on_ticket)) {
934
+        if ( ! empty($current_prices_on_ticket)) {
935 935
             $current = array_keys($current_prices_on_ticket);
936 936
             $updated = array_keys($updated_prices);
937 937
             $prices_to_remove = array_diff($current, $updated);
938
-            if (! empty($prices_to_remove)) {
938
+            if ( ! empty($prices_to_remove)) {
939 939
                 foreach ($prices_to_remove as $prc_id) {
940
-                    $p = $current_prices_on_ticket[ $prc_id ];
940
+                    $p = $current_prices_on_ticket[$prc_id];
941 941
                     $ticket->_remove_relation_to($p, 'Price');
942 942
                     // delete permanently the price
943 943
                     $p->delete_permanently();
@@ -1088,18 +1088,18 @@  discard block
 block discarded – undo
1088 1088
                 $TKT_ID = $ticket->get('TKT_ID');
1089 1089
                 $ticket_row = $ticket->get('TKT_row');
1090 1090
                 // we only want unique tickets in our final display!!
1091
-                if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1091
+                if ( ! in_array($TKT_ID, $existing_ticket_ids, true)) {
1092 1092
                     $existing_ticket_ids[] = $TKT_ID;
1093 1093
                     $all_tickets[] = $ticket;
1094 1094
                 }
1095 1095
                 // temporary cache of this ticket info for this datetime for later processing of datetime rows.
1096
-                $datetime_tickets[ $DTT_ID ][] = $ticket_row;
1096
+                $datetime_tickets[$DTT_ID][] = $ticket_row;
1097 1097
                 // temporary cache of this datetime info for this ticket for later processing of ticket rows.
1098 1098
                 if (
1099
-                    ! isset($ticket_datetimes[ $TKT_ID ])
1100
-                    || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1099
+                    ! isset($ticket_datetimes[$TKT_ID])
1100
+                    || ! in_array($datetime_row, $ticket_datetimes[$TKT_ID], true)
1101 1101
                 ) {
1102
-                    $ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1102
+                    $ticket_datetimes[$TKT_ID][] = $datetime_row;
1103 1103
                 }
1104 1104
             }
1105 1105
             $datetime_row++;
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
         // sort $all_tickets by order
1111 1111
         usort(
1112 1112
             $all_tickets,
1113
-            function (EE_Ticket $a, EE_Ticket $b) {
1113
+            function(EE_Ticket $a, EE_Ticket $b) {
1114 1114
                 $a_order = (int) $a->get('TKT_order');
1115 1115
                 $b_order = (int) $b->get('TKT_order');
1116 1116
                 if ($a_order === $b_order) {
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
         }
1149 1149
         $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
1150 1150
         EEH_Template::display_template(
1151
-            PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1151
+            PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php',
1152 1152
             $main_template_args
1153 1153
         );
1154 1154
     }
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
             'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1191 1191
         );
1192 1192
         return EEH_Template::display_template(
1193
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1193
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php',
1194 1194
             $dtt_display_template_args,
1195 1195
             true
1196 1196
         );
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
             $this->_is_creating_event
1260 1260
         );
1261 1261
         return EEH_Template::display_template(
1262
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1262
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php',
1263 1263
             $template_args,
1264 1264
             true
1265 1265
         );
@@ -1300,7 +1300,7 @@  discard block
 block discarded – undo
1300 1300
             'DTT_ID'                            => $default ? '' : $datetime->ID(),
1301 1301
         );
1302 1302
         // need to setup the list items (but only if this isn't a default skeleton setup)
1303
-        if (! $default) {
1303
+        if ( ! $default) {
1304 1304
             $ticket_row = 1;
1305 1305
             foreach ($all_tickets as $ticket) {
1306 1306
                 $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
             $this->_is_creating_event
1327 1327
         );
1328 1328
         return EEH_Template::display_template(
1329
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1329
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php',
1330 1330
             $template_args,
1331 1331
             true
1332 1332
         );
@@ -1352,8 +1352,8 @@  discard block
 block discarded – undo
1352 1352
         $datetime_tickets = array(),
1353 1353
         $default
1354 1354
     ) {
1355
-        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1356
-            ? $datetime_tickets[ $datetime->ID() ]
1355
+        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[$datetime->ID()])
1356
+            ? $datetime_tickets[$datetime->ID()]
1357 1357
             : array();
1358 1358
         $display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1359 1359
         $no_ticket = $default && empty($ticket);
@@ -1374,8 +1374,8 @@  discard block
 block discarded – undo
1374 1374
                 ? 'TKTNAME'
1375 1375
                 : $ticket->get('TKT_name'),
1376 1376
             'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1377
-                ? ' tkt-status-' . EE_Ticket::onsale
1378
-                : ' tkt-status-' . $ticket->ticket_status(),
1377
+                ? ' tkt-status-'.EE_Ticket::onsale
1378
+                : ' tkt-status-'.$ticket->ticket_status(),
1379 1379
         );
1380 1380
         // filter template args
1381 1381
         $template_args = apply_filters(
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
             $this->_is_creating_event
1391 1391
         );
1392 1392
         return EEH_Template::display_template(
1393
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1393
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php',
1394 1394
             $template_args,
1395 1395
             true
1396 1396
         );
@@ -1446,19 +1446,19 @@  discard block
 block discarded – undo
1446 1446
         // (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1447 1447
         // This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1448 1448
         $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1449
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1450
-            ? $ticket_datetimes[ $ticket->ID() ]
1449
+        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()])
1450
+            ? $ticket_datetimes[$ticket->ID()]
1451 1451
             : array();
1452 1452
         $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1453 1453
         $base_price = $default ? null : $ticket->base_price();
1454 1454
         $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1455 1455
         // breaking out complicated condition for ticket_status
1456 1456
         if ($default) {
1457
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1457
+            $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale;
1458 1458
         } else {
1459 1459
             $ticket_status_class = $ticket->is_default()
1460
-                ? ' tkt-status-' . EE_Ticket::onsale
1461
-                : ' tkt-status-' . $ticket->ticket_status();
1460
+                ? ' tkt-status-'.EE_Ticket::onsale
1461
+                : ' tkt-status-'.$ticket->ticket_status();
1462 1462
         }
1463 1463
         // breaking out complicated condition for TKT_taxable
1464 1464
         if ($default) {
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
                 : 'display:none;',
1551 1551
             'show_price_mod_button'         => count($prices) > 1
1552 1552
                                                || ($default && $count_price_mods > 0)
1553
-                                               || (! $default && $ticket->deleted())
1553
+                                               || ( ! $default && $ticket->deleted())
1554 1554
                 ? 'display:none;'
1555 1555
                 : '',
1556 1556
             'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
                 $this->_date_time_format,
1595 1595
                 current_time('timestamp')
1596 1596
             );
1597
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1597
+            $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1598 1598
         }
1599 1599
         if (empty($template_args['TKT_end_date'])) {
1600 1600
             // get the earliest datetime (if present);
@@ -1604,7 +1604,7 @@  discard block
 block discarded – undo
1604 1604
                     array('order_by' => array('DTT_EVT_start' => 'ASC'))
1605 1605
                 )
1606 1606
                 : null;
1607
-            if (! empty($earliest_dtt)) {
1607
+            if ( ! empty($earliest_dtt)) {
1608 1608
                 $template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1609 1609
                     'DTT_EVT_start',
1610 1610
                     $this->_date_time_format
@@ -1623,10 +1623,10 @@  discard block
 block discarded – undo
1623 1623
                     )
1624 1624
                 );
1625 1625
             }
1626
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1626
+            $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1627 1627
         }
1628 1628
         // generate ticket_datetime items
1629
-        if (! $default) {
1629
+        if ( ! $default) {
1630 1630
             $datetime_row = 1;
1631 1631
             foreach ($all_datetimes as $datetime) {
1632 1632
                 $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
@@ -1642,7 +1642,7 @@  discard block
 block discarded – undo
1642 1642
         }
1643 1643
         $price_row = 1;
1644 1644
         foreach ($prices as $price) {
1645
-            if (! $price instanceof EE_Price) {
1645
+            if ( ! $price instanceof EE_Price) {
1646 1646
                 continue;
1647 1647
             }
1648 1648
             if ($price->is_base_price()) {
@@ -1675,7 +1675,7 @@  discard block
 block discarded – undo
1675 1675
             $this->_is_creating_event
1676 1676
         );
1677 1677
         return EEH_Template::display_template(
1678
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1678
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php',
1679 1679
             $template_args,
1680 1680
             true
1681 1681
         );
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
                 $this->_is_creating_event
1716 1716
             );
1717 1717
             $tax_rows .= EEH_Template::display_template(
1718
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1718
+                PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php',
1719 1719
                 $template_args,
1720 1720
                 true
1721 1721
             );
@@ -1834,7 +1834,7 @@  discard block
 block discarded – undo
1834 1834
             $this->_is_creating_event
1835 1835
         );
1836 1836
         return EEH_Template::display_template(
1837
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1837
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php',
1838 1838
             $template_args,
1839 1839
             true
1840 1840
         );
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
             $this->_is_creating_event
1905 1905
         );
1906 1906
         return EEH_Template::display_template(
1907
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1907
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php',
1908 1908
             $template_args,
1909 1909
             true
1910 1910
         );
@@ -1934,7 +1934,7 @@  discard block
 block discarded – undo
1934 1934
     ) {
1935 1935
         $select_name = $default && ! $price instanceof EE_Price
1936 1936
             ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1937
-            : 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
1937
+            : 'edit_prices['.esc_attr($ticket_row).']['.esc_attr($price_row).'][PRT_ID]';
1938 1938
         /** @var EEM_Price_Type $price_type_model */
1939 1939
         $price_type_model = EE_Registry::instance()->load_model('Price_Type');
1940 1940
         $price_types = $price_type_model->get_all(array(
@@ -1952,10 +1952,10 @@  discard block
 block discarded – undo
1952 1952
         $price_option_spans = '';
1953 1953
         // setup price types for selector
1954 1954
         foreach ($price_types as $price_type) {
1955
-            if (! $price_type instanceof EE_Price_Type) {
1955
+            if ( ! $price_type instanceof EE_Price_Type) {
1956 1956
                 continue;
1957 1957
             }
1958
-            $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1958
+            $all_price_types[$price_type->ID()] = $price_type->get('PRT_name');
1959 1959
             // while we're in the loop let's setup the option spans used by js
1960 1960
             $span_args = array(
1961 1961
                 'PRT_ID'         => $price_type->ID(),
@@ -1963,12 +1963,12 @@  discard block
 block discarded – undo
1963 1963
                 'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1964 1964
             );
1965 1965
             $price_option_spans .= EEH_Template::display_template(
1966
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1966
+                PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php',
1967 1967
                 $span_args,
1968 1968
                 true
1969 1969
             );
1970 1970
         }
1971
-        $select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1971
+        $select_name = $disabled ? 'archive_price['.$ticket_row.']['.$price_row.'][PRT_ID]'
1972 1972
             : $select_name;
1973 1973
         $select_input = new EE_Select_Input(
1974 1974
             $all_price_types,
@@ -2005,7 +2005,7 @@  discard block
 block discarded – undo
2005 2005
             $this->_is_creating_event
2006 2006
         );
2007 2007
         return EEH_Template::display_template(
2008
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2008
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php',
2009 2009
             $template_args,
2010 2010
             true
2011 2011
         );
@@ -2031,8 +2031,8 @@  discard block
 block discarded – undo
2031 2031
         $ticket_datetimes = array(),
2032 2032
         $default
2033 2033
     ) {
2034
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2035
-            ? $ticket_datetimes[ $ticket->ID() ]
2034
+        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()])
2035
+            ? $ticket_datetimes[$ticket->ID()]
2036 2036
             : array();
2037 2037
         $template_args = array(
2038 2038
             'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
@@ -2064,7 +2064,7 @@  discard block
 block discarded – undo
2064 2064
             $this->_is_creating_event
2065 2065
         );
2066 2066
         return EEH_Template::display_template(
2067
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2067
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2068 2068
             $template_args,
2069 2069
             true
2070 2070
         );
@@ -2170,7 +2170,7 @@  discard block
 block discarded – undo
2170 2170
         $default_prices = $price_model->get_all_default_prices();
2171 2171
         $price_row = 1;
2172 2172
         foreach ($default_prices as $price) {
2173
-            if (! $price instanceof EE_Price) {
2173
+            if ( ! $price instanceof EE_Price) {
2174 2174
                 continue;
2175 2175
             }
2176 2176
             if ($price->is_base_price()) {
@@ -2207,7 +2207,7 @@  discard block
 block discarded – undo
2207 2207
             $this->_is_creating_event
2208 2208
         );
2209 2209
         return EEH_Template::display_template(
2210
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2210
+            PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php',
2211 2211
             $template_args,
2212 2212
             true
2213 2213
         );
Please login to merge, or discard this patch.
core/libraries/iframe_display/IframeEmbedButton.php 1 patch
Indentation   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -15,274 +15,274 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * @var string $iframe_name
20
-     */
21
-    private $iframe_name;
18
+	/**
19
+	 * @var string $iframe_name
20
+	 */
21
+	private $iframe_name;
22 22
 
23
-    /**
24
-     * @var string $route_name
25
-     */
26
-    private $route_name;
23
+	/**
24
+	 * @var string $route_name
25
+	 */
26
+	private $route_name;
27 27
 
28
-    /**
29
-     * @var string $slug
30
-     */
31
-    private $slug;
28
+	/**
29
+	 * @var string $slug
30
+	 */
31
+	private $slug;
32 32
 
33
-    /**
34
-     * @var boolean $append_filterable_content
35
-     */
36
-    private $append_filterable_content;
33
+	/**
34
+	 * @var boolean $append_filterable_content
35
+	 */
36
+	private $append_filterable_content;
37 37
 
38 38
 
39
-    /**
40
-     * IframeEmbedButton constructor.
41
-     *
42
-     * @param string $iframe_name i18n name for the iframe. This will be used in HTML
43
-     * @param string $route_name  the name of the registered route
44
-     * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
45
-     *                            will most likely be "event" since that's the only usage atm
46
-     */
47
-    public function __construct($iframe_name, $route_name, $slug = 'event')
48
-    {
49
-        $this->iframe_name = $iframe_name;
50
-        $this->route_name = $route_name;
51
-        $this->slug = $slug;
52
-    }
39
+	/**
40
+	 * IframeEmbedButton constructor.
41
+	 *
42
+	 * @param string $iframe_name i18n name for the iframe. This will be used in HTML
43
+	 * @param string $route_name  the name of the registered route
44
+	 * @param string $slug        URL slug used for the thing the iframe button is being embedded in.
45
+	 *                            will most likely be "event" since that's the only usage atm
46
+	 */
47
+	public function __construct($iframe_name, $route_name, $slug = 'event')
48
+	{
49
+		$this->iframe_name = $iframe_name;
50
+		$this->route_name = $route_name;
51
+		$this->slug = $slug;
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Adds an iframe embed code button to the Event editor.
57
-     */
58
-    public function addEventEditorIframeEmbedButtonFilter()
59
-    {
60
-        // add button for iframe code to event editor.
61
-        add_filter(
62
-            'get_sample_permalink_html',
63
-            array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'),
64
-            10,
65
-            2
66
-        );
67
-        add_action(
68
-            'admin_enqueue_scripts',
69
-            array($this, 'embedButtonAssets'),
70
-            10
71
-        );
72
-    }
55
+	/**
56
+	 * Adds an iframe embed code button to the Event editor.
57
+	 */
58
+	public function addEventEditorIframeEmbedButtonFilter()
59
+	{
60
+		// add button for iframe code to event editor.
61
+		add_filter(
62
+			'get_sample_permalink_html',
63
+			array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'),
64
+			10,
65
+			2
66
+		);
67
+		add_action(
68
+			'admin_enqueue_scripts',
69
+			array($this, 'embedButtonAssets'),
70
+			10
71
+		);
72
+	}
73 73
 
74 74
 
75
-    /**
76
-     * @param $permalink_string
77
-     * @param $id
78
-     * @return string
79
-     */
80
-    public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id)
81
-    {
82
-        return $this->eventEditorIframeEmbedButton(
83
-            $permalink_string,
84
-            $id
85
-        );
86
-    }
75
+	/**
76
+	 * @param $permalink_string
77
+	 * @param $id
78
+	 * @return string
79
+	 */
80
+	public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id)
81
+	{
82
+		return $this->eventEditorIframeEmbedButton(
83
+			$permalink_string,
84
+			$id
85
+		);
86
+	}
87 87
 
88 88
 
89
-    /**
90
-     * iframe embed code button to the Event editor.
91
-     *
92
-     * @param string $permalink_string
93
-     * @param int    $id
94
-     * @return string
95
-     */
96
-    public function eventEditorIframeEmbedButton(
97
-        $permalink_string,
98
-        $id
99
-    ) {
100
-        // make sure this is ONLY when editing and the event id has been set.
101
-        if (! empty($id)) {
102
-            $post = get_post($id);
103
-            // if NOT event then let's get out.
104
-            if ($post->post_type !== 'espresso_events') {
105
-                return $permalink_string;
106
-            }
107
-            $permalink_string .= $this->embedButtonHtml(
108
-                array($this->slug => $id),
109
-                'button-small'
110
-            );
111
-        }
112
-        return $permalink_string;
113
-    }
89
+	/**
90
+	 * iframe embed code button to the Event editor.
91
+	 *
92
+	 * @param string $permalink_string
93
+	 * @param int    $id
94
+	 * @return string
95
+	 */
96
+	public function eventEditorIframeEmbedButton(
97
+		$permalink_string,
98
+		$id
99
+	) {
100
+		// make sure this is ONLY when editing and the event id has been set.
101
+		if (! empty($id)) {
102
+			$post = get_post($id);
103
+			// if NOT event then let's get out.
104
+			if ($post->post_type !== 'espresso_events') {
105
+				return $permalink_string;
106
+			}
107
+			$permalink_string .= $this->embedButtonHtml(
108
+				array($this->slug => $id),
109
+				'button-small'
110
+			);
111
+		}
112
+		return $permalink_string;
113
+	}
114 114
 
115 115
 
116
-    /**
117
-     * Adds an iframe embed code button via a WP do_action() as determined by the first parameter
118
-     *
119
-     * @param string $action name of the WP do_action() to hook into
120
-     */
121
-    public function addActionIframeEmbedButton($action)
122
-    {
123
-        // add button for iframe code to event editor.
124
-        add_action(
125
-            $action,
126
-            array($this, 'addActionIframeEmbedButtonCallback'),
127
-            10,
128
-            2
129
-        );
130
-    }
116
+	/**
117
+	 * Adds an iframe embed code button via a WP do_action() as determined by the first parameter
118
+	 *
119
+	 * @param string $action name of the WP do_action() to hook into
120
+	 */
121
+	public function addActionIframeEmbedButton($action)
122
+	{
123
+		// add button for iframe code to event editor.
124
+		add_action(
125
+			$action,
126
+			array($this, 'addActionIframeEmbedButtonCallback'),
127
+			10,
128
+			2
129
+		);
130
+	}
131 131
 
132 132
 
133
-    /**
134
-     * @return void
135
-     */
136
-    public function addActionIframeEmbedButtonCallback()
137
-    {
138
-        echo wp_kses($this->embedButtonHtml(), AllowedTags::getWithFormTags());
139
-    }
133
+	/**
134
+	 * @return void
135
+	 */
136
+	public function addActionIframeEmbedButtonCallback()
137
+	{
138
+		echo wp_kses($this->embedButtonHtml(), AllowedTags::getWithFormTags());
139
+	}
140 140
 
141 141
 
142
-    /**
143
-     * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter
144
-     *
145
-     * @param string $filter     name of the WP apply_filters() to hook into
146
-     * @param bool   $append     if true, will add iframe embed button to end of content,
147
-     *                           else if false, will add to the beginning of the content
148
-     */
149
-    public function addFilterIframeEmbedButton($filter, $append = true)
150
-    {
151
-        $this->append_filterable_content = $append;
152
-        // add button for iframe code to event editor.
153
-        add_filter(
154
-            $filter,
155
-            array($this, 'addFilterIframeEmbedButtonCallback'),
156
-            10
157
-        );
158
-    }
142
+	/**
143
+	 * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter
144
+	 *
145
+	 * @param string $filter     name of the WP apply_filters() to hook into
146
+	 * @param bool   $append     if true, will add iframe embed button to end of content,
147
+	 *                           else if false, will add to the beginning of the content
148
+	 */
149
+	public function addFilterIframeEmbedButton($filter, $append = true)
150
+	{
151
+		$this->append_filterable_content = $append;
152
+		// add button for iframe code to event editor.
153
+		add_filter(
154
+			$filter,
155
+			array($this, 'addFilterIframeEmbedButtonCallback'),
156
+			10
157
+		);
158
+	}
159 159
 
160 160
 
161
-    /**
162
-     * @param array|string $filterable_content
163
-     * @return array|string
164
-     */
165
-    public function addFilterIframeEmbedButtonCallback($filterable_content)
166
-    {
167
-        $embedButtonHtml = $this->embedButtonHtml();
168
-        if (is_array($filterable_content)) {
169
-            $filterable_content = $this->append_filterable_content
170
-                ? $filterable_content + array($this->route_name => $embedButtonHtml)
171
-                : array($this->route_name => $embedButtonHtml) + $filterable_content;
172
-        } else {
173
-            $filterable_content = $this->append_filterable_content
174
-                ? $filterable_content . $embedButtonHtml
175
-                : $embedButtonHtml . $filterable_content;
176
-        }
177
-        return $filterable_content;
178
-    }
161
+	/**
162
+	 * @param array|string $filterable_content
163
+	 * @return array|string
164
+	 */
165
+	public function addFilterIframeEmbedButtonCallback($filterable_content)
166
+	{
167
+		$embedButtonHtml = $this->embedButtonHtml();
168
+		if (is_array($filterable_content)) {
169
+			$filterable_content = $this->append_filterable_content
170
+				? $filterable_content + array($this->route_name => $embedButtonHtml)
171
+				: array($this->route_name => $embedButtonHtml) + $filterable_content;
172
+		} else {
173
+			$filterable_content = $this->append_filterable_content
174
+				? $filterable_content . $embedButtonHtml
175
+				: $embedButtonHtml . $filterable_content;
176
+		}
177
+		return $filterable_content;
178
+	}
179 179
 
180 180
 
181
-    /**
182
-     * iframe_embed_html
183
-     *
184
-     * @param array  $query_args
185
-     * @param string $button_class
186
-     * @return string
187
-     */
188
-    public function embedButtonHtml($query_args = array(), $button_class = '')
189
-    {
190
-        // incoming args will replace the defaults listed here in the second array (union preserves first array)
191
-        $query_args = (array) $query_args + array($this->route_name => 'iframe');
192
-        $query_args = (array) apply_filters(
193
-            'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
194
-            $query_args
195
-        );
196
-        // add this route to our localized vars
197
-        $iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes'])
198
-            ? \EE_Registry::$i18n_js_strings['iframe_module_routes']
199
-            : array();
200
-        $iframe_module_routes[ $this->route_name ] = $this->route_name;
201
-        \EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes;
202
-        $iframe_embed_html = \EEH_HTML::link(
203
-            '#',
204
-            sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name),
205
-            sprintf(
206
-                esc_html__(
207
-                    'click here to generate code for embedding %1$s iframe into another site.',
208
-                    'event_espresso'
209
-                ),
210
-                \EEH_Inflector::add_indefinite_article($this->iframe_name)
211
-            ),
212
-            esc_attr($this->route_name) . "-iframe-embed-trigger-js",
213
-            'iframe-embed-trigger-js button ' . esc_attr($button_class),
214
-            '',
215
-            ' data-iframe_embed_button="#' . esc_attr($this->route_name) . '-iframe-js" tabindex="-1"'
216
-        );
217
-        $iframe_embed_html .= \EEH_HTML::div(
218
-            '',
219
-            esc_attr($this->route_name) . "-iframe-js",
220
-            'iframe-embed-wrapper-js',
221
-            'display:none;'
222
-        );
223
-        $iframe_embed_html .= esc_html(
224
-            \EEH_HTML::div(
225
-                '<iframe src="' . esc_url_raw(add_query_arg($query_args, site_url())) . '" width="100%" height="100%"></iframe>',
226
-                '',
227
-                '',
228
-                'width:100%; height: 500px;'
229
-            )
230
-        );
231
-        $iframe_embed_html .= \EEH_HTML::divx();
232
-        return $iframe_embed_html;
233
-    }
181
+	/**
182
+	 * iframe_embed_html
183
+	 *
184
+	 * @param array  $query_args
185
+	 * @param string $button_class
186
+	 * @return string
187
+	 */
188
+	public function embedButtonHtml($query_args = array(), $button_class = '')
189
+	{
190
+		// incoming args will replace the defaults listed here in the second array (union preserves first array)
191
+		$query_args = (array) $query_args + array($this->route_name => 'iframe');
192
+		$query_args = (array) apply_filters(
193
+			'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args',
194
+			$query_args
195
+		);
196
+		// add this route to our localized vars
197
+		$iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes'])
198
+			? \EE_Registry::$i18n_js_strings['iframe_module_routes']
199
+			: array();
200
+		$iframe_module_routes[ $this->route_name ] = $this->route_name;
201
+		\EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes;
202
+		$iframe_embed_html = \EEH_HTML::link(
203
+			'#',
204
+			sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name),
205
+			sprintf(
206
+				esc_html__(
207
+					'click here to generate code for embedding %1$s iframe into another site.',
208
+					'event_espresso'
209
+				),
210
+				\EEH_Inflector::add_indefinite_article($this->iframe_name)
211
+			),
212
+			esc_attr($this->route_name) . "-iframe-embed-trigger-js",
213
+			'iframe-embed-trigger-js button ' . esc_attr($button_class),
214
+			'',
215
+			' data-iframe_embed_button="#' . esc_attr($this->route_name) . '-iframe-js" tabindex="-1"'
216
+		);
217
+		$iframe_embed_html .= \EEH_HTML::div(
218
+			'',
219
+			esc_attr($this->route_name) . "-iframe-js",
220
+			'iframe-embed-wrapper-js',
221
+			'display:none;'
222
+		);
223
+		$iframe_embed_html .= esc_html(
224
+			\EEH_HTML::div(
225
+				'<iframe src="' . esc_url_raw(add_query_arg($query_args, site_url())) . '" width="100%" height="100%"></iframe>',
226
+				'',
227
+				'',
228
+				'width:100%; height: 500px;'
229
+			)
230
+		);
231
+		$iframe_embed_html .= \EEH_HTML::divx();
232
+		return $iframe_embed_html;
233
+	}
234 234
 
235 235
 
236
-    /**
237
-     * enqueue iframe button js
238
-     */
239
-    public function embedButtonAssets()
240
-    {
241
-        \EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__(
242
-            'copy and paste the following into any other site\'s content to display this event:',
243
-            'event_espresso'
244
-        );
245
-        \EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__(
246
-            'click anywhere outside of this window to close it.',
247
-            'event_espresso'
248
-        );
249
-        wp_register_script(
250
-            'iframe_embed_button',
251
-            plugin_dir_url(__FILE__) . 'iframe-embed-button.js',
252
-            array('ee-dialog'),
253
-            EVENT_ESPRESSO_VERSION,
254
-            true
255
-        );
256
-        wp_enqueue_script('iframe_embed_button');
257
-    }
236
+	/**
237
+	 * enqueue iframe button js
238
+	 */
239
+	public function embedButtonAssets()
240
+	{
241
+		\EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__(
242
+			'copy and paste the following into any other site\'s content to display this event:',
243
+			'event_espresso'
244
+		);
245
+		\EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__(
246
+			'click anywhere outside of this window to close it.',
247
+			'event_espresso'
248
+		);
249
+		wp_register_script(
250
+			'iframe_embed_button',
251
+			plugin_dir_url(__FILE__) . 'iframe-embed-button.js',
252
+			array('ee-dialog'),
253
+			EVENT_ESPRESSO_VERSION,
254
+			true
255
+		);
256
+		wp_enqueue_script('iframe_embed_button');
257
+	}
258 258
 
259 259
 
260
-    /**
261
-     * generates embed button sections for admin pages
262
-     *
263
-     * @param array $embed_buttons
264
-     * @return string
265
-     */
266
-    public function addIframeEmbedButtonsSection(array $embed_buttons)
267
-    {
268
-        $embed_buttons = (array) apply_filters(
269
-            'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
270
-            $embed_buttons
271
-        );
272
-        if (empty($embed_buttons)) {
273
-            return '';
274
-        }
275
-        // add button for iframe code to event editor.
276
-        $html = \EEH_HTML::br(2);
277
-        $html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso'));
278
-        $html .= \EEH_HTML::p(
279
-            esc_html__(
280
-                'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
281
-                'event_espresso'
282
-            )
283
-        );
284
-        $html .= ' &nbsp; ' . implode(' &nbsp; ', $embed_buttons) . ' ';
285
-        $html .= \EEH_HTML::br(2);
286
-        return $html;
287
-    }
260
+	/**
261
+	 * generates embed button sections for admin pages
262
+	 *
263
+	 * @param array $embed_buttons
264
+	 * @return string
265
+	 */
266
+	public function addIframeEmbedButtonsSection(array $embed_buttons)
267
+	{
268
+		$embed_buttons = (array) apply_filters(
269
+			'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons',
270
+			$embed_buttons
271
+		);
272
+		if (empty($embed_buttons)) {
273
+			return '';
274
+		}
275
+		// add button for iframe code to event editor.
276
+		$html = \EEH_HTML::br(2);
277
+		$html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso'));
278
+		$html .= \EEH_HTML::p(
279
+			esc_html__(
280
+				'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.',
281
+				'event_espresso'
282
+			)
283
+		);
284
+		$html .= ' &nbsp; ' . implode(' &nbsp; ', $embed_buttons) . ' ';
285
+		$html .= \EEH_HTML::br(2);
286
+		return $html;
287
+	}
288 288
 }
Please login to merge, or discard this patch.
core/services/request/sanitizers/ServerSanitizer.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -11,60 +11,60 @@
 block discarded – undo
11 11
  */
12 12
 class ServerSanitizer
13 13
 {
14
-    /**
15
-     * @param string $key
16
-     * @param string $value
17
-     * @return mixed|string
18
-     */
19
-    public function clean($key, $value)
20
-    {
21
-        switch ($key) {
22
-            case 'AUTH_TYPE':
23
-                $valid_types = [
24
-                    'Basic',
25
-                    'Bearer',
26
-                    'Digest',
27
-                    'HOBA',
28
-                    'Mutual',
29
-                    'Negotiate',
30
-                    'OAuth',
31
-                    'SCRAM-SHA-1',
32
-                    'SCRAM-SHA-256',
33
-                    'vapid',
34
-                ];
35
-                return in_array($value, $valid_types, true) ? $value : 'Basic';
36
-            case 'argc':
37
-            case 'HTTP_DNT':
38
-            case 'HTTP_UPGRADE_INSECURE_REQUESTS':
39
-            case 'SERVER_PORT':
40
-            case 'REMOTE_PORT':
41
-            case 'REQUEST_TIME':
42
-                return (int) filter_var($value, FILTER_SANITIZE_NUMBER_INT);
43
-            case 'REQUEST_TIME_FLOAT':
44
-                return (float) filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
45
-            case 'REQUEST_METHOD':
46
-                $valid_types = [
47
-                    'CONNECT',
48
-                    'DELETE',
49
-                    'GET',
50
-                    'HEAD',
51
-                    'OPTIONS',
52
-                    'PATCH',
53
-                    'POST',
54
-                    'PUT',
55
-                    'TRACE',
56
-                ];
57
-                return in_array($value, $valid_types, true) ? $value : 'GET';
58
-            case 'HTTP_HOST':
59
-            case 'QUERY_STRING':
60
-            case 'REQUEST_URI':
61
-            case 'SCRIPT_NAME':
62
-            case 'SERVER_NAME':
63
-                return filter_var($value, FILTER_SANITIZE_URL);
64
-            case 'SERVER_ADMIN':
65
-                return filter_var($value, FILTER_SANITIZE_EMAIL);
66
-            default:
67
-                return filter_var($value, FILTER_SANITIZE_STRING);
68
-        }
69
-    }
14
+	/**
15
+	 * @param string $key
16
+	 * @param string $value
17
+	 * @return mixed|string
18
+	 */
19
+	public function clean($key, $value)
20
+	{
21
+		switch ($key) {
22
+			case 'AUTH_TYPE':
23
+				$valid_types = [
24
+					'Basic',
25
+					'Bearer',
26
+					'Digest',
27
+					'HOBA',
28
+					'Mutual',
29
+					'Negotiate',
30
+					'OAuth',
31
+					'SCRAM-SHA-1',
32
+					'SCRAM-SHA-256',
33
+					'vapid',
34
+				];
35
+				return in_array($value, $valid_types, true) ? $value : 'Basic';
36
+			case 'argc':
37
+			case 'HTTP_DNT':
38
+			case 'HTTP_UPGRADE_INSECURE_REQUESTS':
39
+			case 'SERVER_PORT':
40
+			case 'REMOTE_PORT':
41
+			case 'REQUEST_TIME':
42
+				return (int) filter_var($value, FILTER_SANITIZE_NUMBER_INT);
43
+			case 'REQUEST_TIME_FLOAT':
44
+				return (float) filter_var($value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
45
+			case 'REQUEST_METHOD':
46
+				$valid_types = [
47
+					'CONNECT',
48
+					'DELETE',
49
+					'GET',
50
+					'HEAD',
51
+					'OPTIONS',
52
+					'PATCH',
53
+					'POST',
54
+					'PUT',
55
+					'TRACE',
56
+				];
57
+				return in_array($value, $valid_types, true) ? $value : 'GET';
58
+			case 'HTTP_HOST':
59
+			case 'QUERY_STRING':
60
+			case 'REQUEST_URI':
61
+			case 'SCRIPT_NAME':
62
+			case 'SERVER_NAME':
63
+				return filter_var($value, FILTER_SANITIZE_URL);
64
+			case 'SERVER_ADMIN':
65
+				return filter_var($value, FILTER_SANITIZE_EMAIL);
66
+			default:
67
+				return filter_var($value, FILTER_SANITIZE_STRING);
68
+		}
69
+	}
70 70
 }
Please login to merge, or discard this patch.
core/services/request/sanitizers/AttributesSanitizer.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -11,25 +11,25 @@
 block discarded – undo
11 11
  */
12 12
 class AttributesSanitizer
13 13
 {
14
-    /**
15
-     * @param string $attributes
16
-     * @param array $allowed_tags
17
-     * @param string $tag
18
-     * @return mixed|string
19
-     */
20
-    public static function clean(string $attributes, array $allowed_tags, string $tag = 'div')
21
-    {
22
-        if (trim($attributes) === '') {
23
-            return '';
24
-        }
25
-        $html = '<' . $tag . ' ' . $attributes . '>';
26
-        $escaped = wp_kses($html, $allowed_tags);
27
-        $start = strpos($escaped, ' ');
28
-        $end = strpos($escaped, '>');
29
-        if ($start === false || $end === false) {
30
-            return '';
31
-        }
32
-        $length = $end - $start;
33
-        return trim(substr($escaped, $start, $length));
34
-    }
14
+	/**
15
+	 * @param string $attributes
16
+	 * @param array $allowed_tags
17
+	 * @param string $tag
18
+	 * @return mixed|string
19
+	 */
20
+	public static function clean(string $attributes, array $allowed_tags, string $tag = 'div')
21
+	{
22
+		if (trim($attributes) === '') {
23
+			return '';
24
+		}
25
+		$html = '<' . $tag . ' ' . $attributes . '>';
26
+		$escaped = wp_kses($html, $allowed_tags);
27
+		$start = strpos($escaped, ' ');
28
+		$end = strpos($escaped, '>');
29
+		if ($start === false || $end === false) {
30
+			return '';
31
+		}
32
+		$length = $end - $start;
33
+		return trim(substr($escaped, $start, $length));
34
+	}
35 35
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
         if (trim($attributes) === '') {
23 23
             return '';
24 24
         }
25
-        $html = '<' . $tag . ' ' . $attributes . '>';
25
+        $html = '<'.$tag.' '.$attributes.'>';
26 26
         $escaped = wp_kses($html, $allowed_tags);
27 27
         $start = strpos($escaped, ' ');
28 28
         $end = strpos($escaped, '>');
Please login to merge, or discard this patch.
admin/new/pricing/templates/event_tickets_metabox_main.template.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
               class="clickable ee-collapsible <?php echo sanitize_html_class($ee_collapsible_status); ?>">
28 28
             <span class="dashicons dashicons-clock ee-icon-size-20"></span>
29 29
             <?php
30
-                esc_html_e(
31
-                    'Event Datetimes',
32
-                    'event_espresso'
33
-                );
34
-                ?>
30
+				esc_html_e(
31
+					'Event Datetimes',
32
+					'event_espresso'
33
+				);
34
+				?>
35 35
         </span>
36 36
     </h3>
37 37
     <?php echo wp_kses($event_datetime_help_link, AllowedTags::getAllowedTags()); ?>
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
     </div> <!-- end .event-datetimes-container -->
69 69
     <div id="add-event-datetime" class="event-datetime-row add-dtt-row" style="display:none;">
70 70
         <h4 class="datetime-tickets-heading"><?php
71
-            esc_html_e(
72
-                'Add New Datetime',
73
-                'event_espresso'
74
-            ); ?></h4><?php echo wp_kses($add_new_dtt_help_link, AllowedTags::getAllowedTags()); ?>
71
+			esc_html_e(
72
+				'Add New Datetime',
73
+				'event_espresso'
74
+			); ?></h4><?php echo wp_kses($add_new_dtt_help_link, AllowedTags::getAllowedTags()); ?>
75 75
         <div>
76 76
             <table id="add-new-event-datetime-table" class="datetime-edit-table">
77 77
                 <tr>
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
                     <td class="event-datetime-column date-column">
86 86
                         <label class="add-new-event-datetime-DTT_EVT_start_label"
87 87
                                for="add-new-event-datetime-DTT_EVT_start"><?php
88
-                                esc_html_e(
89
-                                    'Event Start',
90
-                                    'event_espresso'
91
-                                ); ?></label>
88
+								esc_html_e(
89
+									'Event Start',
90
+									'event_espresso'
91
+								); ?></label>
92 92
                         <input type="text" name="add_new_datetime[DTT_EVT_start]"
93 93
                                id="add-new-event-datetime-DTT_EVT_start" class="ee-text-inp ee-datepicker"
94 94
                                data-context="start-dtt" data-date-field-context="#add-event-datetime"
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
                     <td class="event-datetime-column date-column">
99 99
                         <label class="add-new-event-datetime-DTT_EVT_end_label"
100 100
                                for="add-new-event-datetime-DTT_EVT_end"><?php
101
-                                esc_html_e(
102
-                                    'Event End',
103
-                                    'event_espresso'
104
-                                ); ?></label>
101
+								esc_html_e(
102
+									'Event End',
103
+									'event_espresso'
104
+								); ?></label>
105 105
                         <input type="text" name="add_new_datetime[DTT_EVT_end]" id="add-new-event-datetime-DTT_EVT_end"
106 106
                                class="ee-text-inp ee-datepicker" data-context="end-dtt"
107 107
                                data-date-field-context="#add-event-datetime"
@@ -111,10 +111,10 @@  discard block
 block discarded – undo
111 111
                     <td class="event-datetime-column reg-limit-column">
112 112
                         <label class="add-new-event-datetime-DTT_EVT_end_label"
113 113
                                for="add-new-event-datetime-DTT_reg_limit"><?php
114
-                                esc_html_e(
115
-                                    'Limit',
116
-                                    'event_espresso'
117
-                                ); ?></label>
114
+								esc_html_e(
115
+									'Limit',
116
+									'event_espresso'
117
+								); ?></label>
118 118
                         <input type="text" name="add_new_datetime[DTT_reg_limit]"
119 119
                                id="add-new-event-datetime-DTT_reg_limit" class="ee-numeric ee-small-text-inp">
120 120
                     </td>
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
         <h3 class="event-tickets-datetimes-title"><span data-target=".event-tickets-container"
138 138
                                                         class="clickable ee-collapsible <?php echo sanitize_html_class($ee_collapsible_status); ?>"><span
139 139
                     class="ee-icon ee-icon-tickets ee-icon-size-20"></span><?php
140
-                    esc_html_e(
141
-                        'Available Tickets',
142
-                        'event_espresso'
143
-                    ); ?></span></h3>
140
+					esc_html_e(
141
+						'Available Tickets',
142
+						'event_espresso'
143
+					); ?></span></h3>
144 144
         <div class="event-tickets-container ee-create-ticket-button" <?php echo AttributesSanitizer::clean($show_tickets_container, AllowedTags::getAllowedTags()); ?>>
145 145
             <button class="ee-create-ticket-button button-secondary ee-create-button" data-context="ticket"><?php
146
-                esc_html_e(
147
-                    'Create Ticket',
148
-                    'event_espresso'
149
-                ); ?></button>
146
+				esc_html_e(
147
+					'Create Ticket',
148
+					'event_espresso'
149
+				); ?></button>
150 150
         </div>
151 151
         <div style="clear:both"></div>
152 152
         <div class="event-tickets-container" <?php echo AttributesSanitizer::clean($show_tickets_container, AllowedTags::getAllowedTags()); ?>>
Please login to merge, or discard this patch.
core/libraries/iframe_display/iframe_wrapper.template.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
                 <?php echo $eei18n; ?>
37 37
             </script>
38 38
         <?php foreach ($header_js as $key => $url) :?>
39
-            <?php $header_attributes = isset($header_js_attributes[ $key ]) ? $header_js_attributes[ $key ] : ''; ?>
39
+            <?php $header_attributes = isset($header_js_attributes[$key]) ? $header_js_attributes[$key] : ''; ?>
40 40
         <script type="text/javascript" src="<?php echo esc_url_raw($url); ?>" <?php echo AttributesSanitizer::clean($header_attributes, AllowedTags::getAllowedTags(), 'script'); ?>></script>
41 41
         <?php endforeach; ?>
42 42
     <?php endif; ?>
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     <?php echo wp_kses($content, AllowedTags::getWithFormTags()); ?>
48 48
 </div>
49 49
 <?php foreach ($footer_js as $key => $url) : ?>
50
-    <?php $footer_attributes = isset($footer_js_attributes[ $key ]) ? $footer_js_attributes[ $key ] : ''; ?>
50
+    <?php $footer_attributes = isset($footer_js_attributes[$key]) ? $footer_js_attributes[$key] : ''; ?>
51 51
     <script type="text/javascript" src="<?php echo esc_url_raw($url); ?>" <?php echo AttributesSanitizer::clean($footer_attributes, AllowedTags::getAllowedTags(), 'script'); ?>></script>
52 52
 <?php endforeach; ?>
53 53
 <?php if ($enqueue_wp_assets) : ?>
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.31.rc.003');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.31.rc.003');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.