Completed
Branch updates-from-cafe (85364e)
by
unknown
10:08 queued 02:37
created
registration_form/templates/questions_main_meta_box.template.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         EEH_HTML::h4(
48 48
             '<span class="dashicons dashicons-info"></span>'
49 49
             . esc_html__('Did you know...', 'event_espresso')
50
-        ) .
50
+        ).
51 51
         EEH_HTML::p(
52 52
             esc_html__(
53 53
                 'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.',
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                                type="hidden"
109 109
                                value="<?php echo esc_attr($question->get('QST_order')); ?>"
110 110
                         />
111
-                        <?php if (! empty($QST_system)) { ?>
111
+                        <?php if ( ! empty($QST_system)) { ?>
112 112
                             <input id='QST_admin_label'
113 113
                                    name="QST_admin_label"
114 114
                                    type="hidden"
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
                         <?php } ?>
118 118
                         <br />
119 119
                         <p class="description">
120
-                            <?php if (! empty($QST_system)) { ?>
120
+                            <?php if ( ! empty($QST_system)) { ?>
121 121
                                 <span class="description" style="color:#D54E21;">
122 122
                                 <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso') ?>
123 123
                         </span>
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
                         <br />
155 155
                         <p class="description">
156 156
                             <?php
157
-                            if (! empty($QST_system)) { ?>
157
+                            if ( ! empty($QST_system)) { ?>
158 158
                                 <span class="description" style="color:#D54E21;">
159 159
                                     <?php esc_html_e(
160 160
                                         'System question! This field cannot be changed.',
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 
187 187
                         // Only display Confirm email for
188 188
                         if (empty($QST_system) || $QST_system !== EEM_Attendee::system_question_email_confirm) {
189
-                            unset($question_types[ EEM_Question::QST_type_email_confirm ]);
189
+                            unset($question_types[EEM_Question::QST_type_email_confirm]);
190 190
                         }
191 191
 
192 192
                         echo wp_kses(
193 193
                             EEH_Form_Fields::select_input(
194
-                                'QST_type' . $id,
194
+                                'QST_type'.$id,
195 195
                                 $question_types,
196 196
                                 $question->type(),
197
-                                'id="QST_type' . $id . '"' . $disabled_attr
197
+                                'id="QST_type'.$id.'"'.$disabled_attr
198 198
                             ),
199 199
                             AllowedTags::getWithFormTags()
200 200
                         );
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
                         <input id="QST_max"
238 238
                             class="ee-input-width--small"
239 239
                         <?php if ($max_max !== EE_INF) :?>
240
-                            max="<?php echo esc_attr($max_max);?>"
240
+                            max="<?php echo esc_attr($max_max); ?>"
241 241
                         <?php  endif; ?>
242 242
                             min="1"
243 243
                             name="QST_max"
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
                                 <?php
323 323
                                 $count            = 0;
324 324
                                 $question_options = $question->options();
325
-                                if (! empty($question_options)) {
325
+                                if ( ! empty($question_options)) {
326 326
                                     foreach ($question_options as $option_id => $option) {
327 327
                                         $disabled_attr = $has_answers || $option->get('QSO_system')
328 328
                                             ? 'disabled'
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
                                                 />
357 357
                                             </td>
358 358
                                             <td>
359
-                                                <?php if (! $option->system()) { ?>
359
+                                                <?php if ( ! $option->system()) { ?>
360 360
                                                     <span class="dashicons clickable dashicons-post-trash ee-icon-size-18 remove-option remove-item">
361 361
                                         </span>
362 362
                                                 <?php } ?>
@@ -478,10 +478,10 @@  discard block
 block discarded – undo
478 478
                         ];
479 479
                         echo wp_kses(
480 480
                             EEH_Form_Fields::select_input(
481
-                                'QST_required' . $id,
481
+                                'QST_required'.$id,
482 482
                                 $requiredOptions,
483 483
                                 $question->required(),
484
-                                'id="QST_required' . $id . '"' . $disabled_attr
484
+                                'id="QST_required'.$id.'"'.$disabled_attr
485 485
                             ),
486 486
                             AllowedTags::getWithFormTags()
487 487
                         );
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
                                 ) ?>
505 505
                             </span>
506 506
                         </p>
507
-                        <?php if (! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?>
507
+                        <?php if ( ! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?>
508 508
                             <input type="hidden" id="QST_required" name="QST_required" value="1" />
509 509
                             <p>
510 510
                             <span class="description" style="color:#D54E21;">
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 1 patch
Indentation   +2147 added lines, -2147 removed lines patch added patch discarded remove patch
@@ -14,2207 +14,2207 @@
 block discarded – undo
14 14
  */
15 15
 class espresso_events_Pricing_Hooks extends EE_Admin_Hooks
16 16
 {
17
-    /**
18
-     * This property is just used to hold the status of whether an event is currently being
19
-     * created (true) or edited (false)
20
-     *
21
-     * @access protected
22
-     * @var bool
23
-     */
24
-    protected $_is_creating_event;
17
+	/**
18
+	 * This property is just used to hold the status of whether an event is currently being
19
+	 * created (true) or edited (false)
20
+	 *
21
+	 * @access protected
22
+	 * @var bool
23
+	 */
24
+	protected $_is_creating_event;
25 25
 
26
-    /**
27
-     * Used to contain the format strings for date and time that will be used for php date and
28
-     * time.
29
-     * Is set in the _set_hooks_properties() method.
30
-     *
31
-     * @var array
32
-     */
33
-    protected $_date_format_strings;
26
+	/**
27
+	 * Used to contain the format strings for date and time that will be used for php date and
28
+	 * time.
29
+	 * Is set in the _set_hooks_properties() method.
30
+	 *
31
+	 * @var array
32
+	 */
33
+	protected $_date_format_strings;
34 34
 
35
-    /**
36
-     * @var string $_date_time_format
37
-     */
38
-    protected $_date_time_format;
35
+	/**
36
+	 * @var string $_date_time_format
37
+	 */
38
+	protected $_date_time_format;
39 39
 
40 40
 
41
-    /**
42
-     * @throws InvalidArgumentException
43
-     * @throws InvalidInterfaceException
44
-     * @throws InvalidDataTypeException
45
-     */
46
-    protected function _set_hooks_properties()
47
-    {
48
-        $this->_name = 'pricing';
49
-        // capability check
50
-        if (
51
-            ! EE_Registry::instance()->CAP->current_user_can(
52
-                'ee_read_default_prices',
53
-                'advanced_ticket_datetime_metabox'
54
-            )
55
-        ) {
56
-            return;
57
-        }
58
-        $this->_setup_metaboxes();
59
-        $this->_set_date_time_formats();
60
-        $this->_validate_format_strings();
61
-        $this->_set_scripts_styles();
62
-        // commented out temporarily until logic is implemented in callback
63
-        // add_action(
64
-        //     'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
65
-        //     array($this, 'autosave_handling')
66
-        // );
67
-        add_filter(
68
-            'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
69
-            array($this, 'caf_updates')
70
-        );
71
-    }
41
+	/**
42
+	 * @throws InvalidArgumentException
43
+	 * @throws InvalidInterfaceException
44
+	 * @throws InvalidDataTypeException
45
+	 */
46
+	protected function _set_hooks_properties()
47
+	{
48
+		$this->_name = 'pricing';
49
+		// capability check
50
+		if (
51
+			! EE_Registry::instance()->CAP->current_user_can(
52
+				'ee_read_default_prices',
53
+				'advanced_ticket_datetime_metabox'
54
+			)
55
+		) {
56
+			return;
57
+		}
58
+		$this->_setup_metaboxes();
59
+		$this->_set_date_time_formats();
60
+		$this->_validate_format_strings();
61
+		$this->_set_scripts_styles();
62
+		// commented out temporarily until logic is implemented in callback
63
+		// add_action(
64
+		//     'AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page',
65
+		//     array($this, 'autosave_handling')
66
+		// );
67
+		add_filter(
68
+			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
69
+			array($this, 'caf_updates')
70
+		);
71
+	}
72 72
 
73 73
 
74
-    /**
75
-     * @return void
76
-     */
77
-    protected function _setup_metaboxes()
78
-    {
79
-        // if we were going to add our own metaboxes we'd use the below.
80
-        $this->_metaboxes = array(
81
-            0 => array(
82
-                'page_route' => array('edit', 'create_new'),
83
-                'func'       => 'pricing_metabox',
84
-                'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
85
-                'priority'   => 'high',
86
-                'context'    => 'normal',
87
-            ),
88
-        );
89
-        $this->_remove_metaboxes = array(
90
-            0 => array(
91
-                'page_route' => array('edit', 'create_new'),
92
-                'id'         => 'espresso_event_editor_tickets',
93
-                'context'    => 'normal',
94
-            ),
95
-        );
96
-    }
74
+	/**
75
+	 * @return void
76
+	 */
77
+	protected function _setup_metaboxes()
78
+	{
79
+		// if we were going to add our own metaboxes we'd use the below.
80
+		$this->_metaboxes = array(
81
+			0 => array(
82
+				'page_route' => array('edit', 'create_new'),
83
+				'func'       => 'pricing_metabox',
84
+				'label'      => esc_html__('Event Tickets & Datetimes', 'event_espresso'),
85
+				'priority'   => 'high',
86
+				'context'    => 'normal',
87
+			),
88
+		);
89
+		$this->_remove_metaboxes = array(
90
+			0 => array(
91
+				'page_route' => array('edit', 'create_new'),
92
+				'id'         => 'espresso_event_editor_tickets',
93
+				'context'    => 'normal',
94
+			),
95
+		);
96
+	}
97 97
 
98 98
 
99
-    /**
100
-     * @return void
101
-     */
102
-    protected function _set_date_time_formats()
103
-    {
104
-        /**
105
-         * Format strings for date and time.  Defaults are existing behaviour from 4.1.
106
-         * Note, that if you return null as the value for 'date', and 'time' in the array, then
107
-         * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
108
-         *
109
-         * @since 4.6.7
110
-         * @var array  Expected an array returned with 'date' and 'time' keys.
111
-         */
112
-        $this->_date_format_strings = apply_filters(
113
-            'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
114
-            array(
115
-                'date' => 'Y-m-d',
116
-                'time' => 'h:i a',
117
-            )
118
-        );
119
-        // validate
120
-        $this->_date_format_strings['date'] = isset($this->_date_format_strings['date'])
121
-            ? $this->_date_format_strings['date']
122
-            : null;
123
-        $this->_date_format_strings['time'] = isset($this->_date_format_strings['time'])
124
-            ? $this->_date_format_strings['time']
125
-            : null;
126
-        $this->_date_time_format = $this->_date_format_strings['date']
127
-                                   . ' '
128
-                                   . $this->_date_format_strings['time'];
129
-    }
99
+	/**
100
+	 * @return void
101
+	 */
102
+	protected function _set_date_time_formats()
103
+	{
104
+		/**
105
+		 * Format strings for date and time.  Defaults are existing behaviour from 4.1.
106
+		 * Note, that if you return null as the value for 'date', and 'time' in the array, then
107
+		 * EE will automatically use the set wp_options, 'date_format', and 'time_format'.
108
+		 *
109
+		 * @since 4.6.7
110
+		 * @var array  Expected an array returned with 'date' and 'time' keys.
111
+		 */
112
+		$this->_date_format_strings = apply_filters(
113
+			'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings',
114
+			array(
115
+				'date' => 'Y-m-d',
116
+				'time' => 'h:i a',
117
+			)
118
+		);
119
+		// validate
120
+		$this->_date_format_strings['date'] = isset($this->_date_format_strings['date'])
121
+			? $this->_date_format_strings['date']
122
+			: null;
123
+		$this->_date_format_strings['time'] = isset($this->_date_format_strings['time'])
124
+			? $this->_date_format_strings['time']
125
+			: null;
126
+		$this->_date_time_format = $this->_date_format_strings['date']
127
+								   . ' '
128
+								   . $this->_date_format_strings['time'];
129
+	}
130 130
 
131 131
 
132
-    /**
133
-     * @return void
134
-     */
135
-    protected function _validate_format_strings()
136
-    {
137
-        // validate format strings
138
-        $format_validation = EEH_DTT_Helper::validate_format_string(
139
-            $this->_date_time_format
140
-        );
141
-        if (is_array($format_validation)) {
142
-            $msg = '<p>';
143
-            $msg .= sprintf(
144
-                esc_html__(
145
-                    'The format "%s" was likely added via a filter and is invalid for the following reasons:',
146
-                    'event_espresso'
147
-                ),
148
-                $this->_date_time_format
149
-            );
150
-            $msg .= '</p><ul>';
151
-            foreach ($format_validation as $error) {
152
-                $msg .= '<li>' . $error . '</li>';
153
-            }
154
-            $msg .= '</ul><p>';
155
-            $msg .= sprintf(
156
-                esc_html__(
157
-                    '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
158
-                    'event_espresso'
159
-                ),
160
-                '<span style="color:#D54E21;">',
161
-                '</span>'
162
-            );
163
-            $msg .= '</p>';
164
-            EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
165
-            $this->_date_format_strings = array(
166
-                'date' => 'Y-m-d',
167
-                'time' => 'h:i a',
168
-            );
169
-        }
170
-    }
132
+	/**
133
+	 * @return void
134
+	 */
135
+	protected function _validate_format_strings()
136
+	{
137
+		// validate format strings
138
+		$format_validation = EEH_DTT_Helper::validate_format_string(
139
+			$this->_date_time_format
140
+		);
141
+		if (is_array($format_validation)) {
142
+			$msg = '<p>';
143
+			$msg .= sprintf(
144
+				esc_html__(
145
+					'The format "%s" was likely added via a filter and is invalid for the following reasons:',
146
+					'event_espresso'
147
+				),
148
+				$this->_date_time_format
149
+			);
150
+			$msg .= '</p><ul>';
151
+			foreach ($format_validation as $error) {
152
+				$msg .= '<li>' . $error . '</li>';
153
+			}
154
+			$msg .= '</ul><p>';
155
+			$msg .= sprintf(
156
+				esc_html__(
157
+					'%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s',
158
+					'event_espresso'
159
+				),
160
+				'<span style="color:#D54E21;">',
161
+				'</span>'
162
+			);
163
+			$msg .= '</p>';
164
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
165
+			$this->_date_format_strings = array(
166
+				'date' => 'Y-m-d',
167
+				'time' => 'h:i a',
168
+			);
169
+		}
170
+	}
171 171
 
172 172
 
173
-    /**
174
-     * @return void
175
-     */
176
-    protected function _set_scripts_styles()
177
-    {
178
-        $this->_scripts_styles = array(
179
-            'registers'   => array(
180
-                'ee-tickets-datetimes-css' => array(
181
-                    'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
182
-                    'type' => 'css',
183
-                ),
184
-                'ee-dtt-ticket-metabox'    => array(
185
-                    'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
186
-                    'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
187
-                ),
188
-            ),
189
-            'deregisters' => array(
190
-                'event-editor-css'       => array('type' => 'css'),
191
-                'event-datetime-metabox' => array('type' => 'js'),
192
-            ),
193
-            'enqueues'    => array(
194
-                'ee-tickets-datetimes-css' => array('edit', 'create_new'),
195
-                'ee-dtt-ticket-metabox'    => array('edit', 'create_new'),
196
-            ),
197
-            'localize'    => array(
198
-                'ee-dtt-ticket-metabox' => array(
199
-                    'DTT_TRASH_BLOCK'       => array(
200
-                        'main_warning'            => esc_html__(
201
-                            'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
202
-                            'event_espresso'
203
-                        ),
204
-                        'after_warning'           => esc_html__(
205
-                            'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
206
-                            'event_espresso'
207
-                        ),
208
-                        'cancel_button'           => '<button class="button-secondary ee-modal-cancel">'
209
-                                                     . esc_html__('Cancel', 'event_espresso') . '</button>',
210
-                        'close_button'            => '<button class="button-secondary ee-modal-cancel">'
211
-                                                     . esc_html__('Close', 'event_espresso') . '</button>',
212
-                        'single_warning_from_tkt' => esc_html__(
213
-                            '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.',
214
-                            'event_espresso'
215
-                        ),
216
-                        'single_warning_from_dtt' => esc_html__(
217
-                            '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.',
218
-                            'event_espresso'
219
-                        ),
220
-                        'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">'
221
-                                                     . esc_html__('Dismiss', 'event_espresso') . '</button>',
222
-                    ),
223
-                    'DTT_ERROR_MSG'         => array(
224
-                        'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
225
-                        'dismiss_button' => '<div class="save-cancel-button-container">'
226
-                                            . '<button class="button-secondary ee-modal-cancel">'
227
-                                            . esc_html__('Dismiss', 'event_espresso')
228
-                                            . '</button></div>',
229
-                    ),
230
-                    'DTT_OVERSELL_WARNING'  => array(
231
-                        'datetime_ticket' => esc_html__(
232
-                            '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.',
233
-                            'event_espresso'
234
-                        ),
235
-                        'ticket_datetime' => esc_html__(
236
-                            '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.',
237
-                            'event_espresso'
238
-                        ),
239
-                    ),
240
-                    'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
241
-                        $this->_date_format_strings['date'],
242
-                        $this->_date_format_strings['time']
243
-                    ),
244
-                    'DTT_START_OF_WEEK'     => array('dayValue' => (int) get_option('start_of_week')),
245
-                ),
246
-            ),
247
-        );
248
-    }
173
+	/**
174
+	 * @return void
175
+	 */
176
+	protected function _set_scripts_styles()
177
+	{
178
+		$this->_scripts_styles = array(
179
+			'registers'   => array(
180
+				'ee-tickets-datetimes-css' => array(
181
+					'url'  => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
182
+					'type' => 'css',
183
+				),
184
+				'ee-dtt-ticket-metabox'    => array(
185
+					'url'     => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
186
+					'depends' => array('ee-datepicker', 'ee-dialog', 'underscore'),
187
+				),
188
+			),
189
+			'deregisters' => array(
190
+				'event-editor-css'       => array('type' => 'css'),
191
+				'event-datetime-metabox' => array('type' => 'js'),
192
+			),
193
+			'enqueues'    => array(
194
+				'ee-tickets-datetimes-css' => array('edit', 'create_new'),
195
+				'ee-dtt-ticket-metabox'    => array('edit', 'create_new'),
196
+			),
197
+			'localize'    => array(
198
+				'ee-dtt-ticket-metabox' => array(
199
+					'DTT_TRASH_BLOCK'       => array(
200
+						'main_warning'            => esc_html__(
201
+							'The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):',
202
+							'event_espresso'
203
+						),
204
+						'after_warning'           => esc_html__(
205
+							'In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.',
206
+							'event_espresso'
207
+						),
208
+						'cancel_button'           => '<button class="button-secondary ee-modal-cancel">'
209
+													 . esc_html__('Cancel', 'event_espresso') . '</button>',
210
+						'close_button'            => '<button class="button-secondary ee-modal-cancel">'
211
+													 . esc_html__('Close', 'event_espresso') . '</button>',
212
+						'single_warning_from_tkt' => esc_html__(
213
+							'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.',
214
+							'event_espresso'
215
+						),
216
+						'single_warning_from_dtt' => esc_html__(
217
+							'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.',
218
+							'event_espresso'
219
+						),
220
+						'dismiss_button'          => '<button class="button-secondary ee-modal-cancel">'
221
+													 . esc_html__('Dismiss', 'event_espresso') . '</button>',
222
+					),
223
+					'DTT_ERROR_MSG'         => array(
224
+						'no_ticket_name' => esc_html__('General Admission', 'event_espresso'),
225
+						'dismiss_button' => '<div class="save-cancel-button-container">'
226
+											. '<button class="button-secondary ee-modal-cancel">'
227
+											. esc_html__('Dismiss', 'event_espresso')
228
+											. '</button></div>',
229
+					),
230
+					'DTT_OVERSELL_WARNING'  => array(
231
+						'datetime_ticket' => esc_html__(
232
+							'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.',
233
+							'event_espresso'
234
+						),
235
+						'ticket_datetime' => esc_html__(
236
+							'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.',
237
+							'event_espresso'
238
+						),
239
+					),
240
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats(
241
+						$this->_date_format_strings['date'],
242
+						$this->_date_format_strings['time']
243
+					),
244
+					'DTT_START_OF_WEEK'     => array('dayValue' => (int) get_option('start_of_week')),
245
+				),
246
+			),
247
+		);
248
+	}
249 249
 
250 250
 
251
-    /**
252
-     * @param array $update_callbacks
253
-     * @return array
254
-     */
255
-    public function caf_updates(array $update_callbacks)
256
-    {
257
-        foreach ($update_callbacks as $key => $callback) {
258
-            if ($callback[1] === '_default_tickets_update') {
259
-                unset($update_callbacks[ $key ]);
260
-            }
261
-        }
262
-        $update_callbacks[] = array($this, 'datetime_and_tickets_caf_update');
263
-        return $update_callbacks;
264
-    }
251
+	/**
252
+	 * @param array $update_callbacks
253
+	 * @return array
254
+	 */
255
+	public function caf_updates(array $update_callbacks)
256
+	{
257
+		foreach ($update_callbacks as $key => $callback) {
258
+			if ($callback[1] === '_default_tickets_update') {
259
+				unset($update_callbacks[ $key ]);
260
+			}
261
+		}
262
+		$update_callbacks[] = array($this, 'datetime_and_tickets_caf_update');
263
+		return $update_callbacks;
264
+	}
265 265
 
266 266
 
267
-    /**
268
-     * Handles saving everything related to Tickets (datetimes, tickets, prices)
269
-     *
270
-     * @param  EE_Event $event The Event object we're attaching data to
271
-     * @param  array    $data  The request data from the form
272
-     * @throws ReflectionException
273
-     * @throws Exception
274
-     * @throws InvalidInterfaceException
275
-     * @throws InvalidDataTypeException
276
-     * @throws EE_Error
277
-     * @throws InvalidArgumentException
278
-     */
279
-    public function datetime_and_tickets_caf_update($event, $data)
280
-    {
281
-        // first we need to start with datetimes cause they are the "root" items attached to events.
282
-        $saved_datetimes = $this->_update_datetimes($event, $data);
283
-        // next tackle the tickets (and prices?)
284
-        $this->_update_tickets($event, $saved_datetimes, $data);
285
-    }
267
+	/**
268
+	 * Handles saving everything related to Tickets (datetimes, tickets, prices)
269
+	 *
270
+	 * @param  EE_Event $event The Event object we're attaching data to
271
+	 * @param  array    $data  The request data from the form
272
+	 * @throws ReflectionException
273
+	 * @throws Exception
274
+	 * @throws InvalidInterfaceException
275
+	 * @throws InvalidDataTypeException
276
+	 * @throws EE_Error
277
+	 * @throws InvalidArgumentException
278
+	 */
279
+	public function datetime_and_tickets_caf_update($event, $data)
280
+	{
281
+		// first we need to start with datetimes cause they are the "root" items attached to events.
282
+		$saved_datetimes = $this->_update_datetimes($event, $data);
283
+		// next tackle the tickets (and prices?)
284
+		$this->_update_tickets($event, $saved_datetimes, $data);
285
+	}
286 286
 
287 287
 
288
-    /**
289
-     * update event_datetimes
290
-     *
291
-     * @param  EE_Event $event Event being updated
292
-     * @param  array    $data  the request data from the form
293
-     * @return EE_Datetime[]
294
-     * @throws Exception
295
-     * @throws ReflectionException
296
-     * @throws InvalidInterfaceException
297
-     * @throws InvalidDataTypeException
298
-     * @throws InvalidArgumentException
299
-     * @throws EE_Error
300
-     */
301
-    protected function _update_datetimes($event, $data)
302
-    {
303
-        $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
304
-        $saved_dtt_ids = array();
305
-        $saved_dtt_objs = array();
306
-        if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
307
-            throw new InvalidArgumentException(
308
-                esc_html__(
309
-                    'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
310
-                    'event_espresso'
311
-                )
312
-            );
313
-        }
314
-        foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
315
-            // trim all values to ensure any excess whitespace is removed.
316
-            $datetime_data = array_map(
317
-                function ($datetime_data) {
318
-                    return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
319
-                },
320
-                $datetime_data
321
-            );
322
-            $datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
323
-                                            && ! empty($datetime_data['DTT_EVT_end'])
324
-                ? $datetime_data['DTT_EVT_end']
325
-                : $datetime_data['DTT_EVT_start'];
326
-            $datetime_values = array(
327
-                'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
328
-                    ? $datetime_data['DTT_ID']
329
-                    : null,
330
-                'DTT_name'        => ! empty($datetime_data['DTT_name'])
331
-                    ? $datetime_data['DTT_name']
332
-                    : '',
333
-                'DTT_description' => ! empty($datetime_data['DTT_description'])
334
-                    ? $datetime_data['DTT_description']
335
-                    : '',
336
-                'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
337
-                'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
338
-                'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
339
-                    ? EE_INF
340
-                    : $datetime_data['DTT_reg_limit'],
341
-                'DTT_order'       => ! isset($datetime_data['DTT_order'])
342
-                    ? $row
343
-                    : $datetime_data['DTT_order'],
344
-            );
345
-            // if we have an id then let's get existing object first and then set the new values.
346
-            // Otherwise we instantiate a new object for save.
347
-            if (! empty($datetime_data['DTT_ID'])) {
348
-                $datetime = EE_Registry::instance()
349
-                                       ->load_model('Datetime', array($timezone))
350
-                                       ->get_one_by_ID($datetime_data['DTT_ID']);
351
-                // set date and time format according to what is set in this class.
352
-                $datetime->set_date_format($this->_date_format_strings['date']);
353
-                $datetime->set_time_format($this->_date_format_strings['time']);
354
-                foreach ($datetime_values as $field => $value) {
355
-                    $datetime->set($field, $value);
356
-                }
357
-                // make sure the $dtt_id here is saved just in case
358
-                // after the add_relation_to() the autosave replaces it.
359
-                // We need to do this so we dont' TRASH the parent DTT.
360
-                // (save the ID for both key and value to avoid duplications)
361
-                $saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
362
-            } else {
363
-                $datetime = EE_Registry::instance()->load_class(
364
-                    'Datetime',
365
-                    array(
366
-                        $datetime_values,
367
-                        $timezone,
368
-                        array($this->_date_format_strings['date'], $this->_date_format_strings['time']),
369
-                    ),
370
-                    false,
371
-                    false
372
-                );
373
-                foreach ($datetime_values as $field => $value) {
374
-                    $datetime->set($field, $value);
375
-                }
376
-            }
377
-            $datetime->save();
378
-            do_action(
379
-                'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save',
380
-                $datetime,
381
-                $row,
382
-                $datetime_data,
383
-                $data
384
-            );
385
-            $datetime = $event->_add_relation_to($datetime, 'Datetime');
386
-            // before going any further make sure our dates are setup correctly
387
-            // so that the end date is always equal or greater than the start date.
388
-            if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
389
-                $datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
390
-                $datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
391
-                $datetime->save();
392
-            }
393
-            // now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
394
-            // because it is possible there was a new one created for the autosave.
395
-            // (save the ID for both key and value to avoid duplications)
396
-            $DTT_ID = $datetime->ID();
397
-            $saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
398
-            $saved_dtt_objs[ $row ] = $datetime;
399
-            // @todo if ANY of these updates fail then we want the appropriate global error message.
400
-        }
401
-        $event->save();
402
-        // now we need to REMOVE any datetimes that got deleted.
403
-        // Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
404
-        // So its safe to permanently delete at this point.
405
-        $old_datetimes = explode(',', $data['datetime_IDs']);
406
-        $old_datetimes = $old_datetimes[0] === '' ? array() : $old_datetimes;
407
-        if (is_array($old_datetimes)) {
408
-            $datetimes_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
409
-            foreach ($datetimes_to_delete as $id) {
410
-                $id = absint($id);
411
-                if (empty($id)) {
412
-                    continue;
413
-                }
414
-                /** @var EE_Datetime $dtt_to_remove */
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
-                $dtt_to_remove->delete_or_restore();
424
-            }
425
-        }
426
-        return $saved_dtt_objs;
427
-    }
288
+	/**
289
+	 * update event_datetimes
290
+	 *
291
+	 * @param  EE_Event $event Event being updated
292
+	 * @param  array    $data  the request data from the form
293
+	 * @return EE_Datetime[]
294
+	 * @throws Exception
295
+	 * @throws ReflectionException
296
+	 * @throws InvalidInterfaceException
297
+	 * @throws InvalidDataTypeException
298
+	 * @throws InvalidArgumentException
299
+	 * @throws EE_Error
300
+	 */
301
+	protected function _update_datetimes($event, $data)
302
+	{
303
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
304
+		$saved_dtt_ids = array();
305
+		$saved_dtt_objs = array();
306
+		if (empty($data['edit_event_datetimes']) || ! is_array($data['edit_event_datetimes'])) {
307
+			throw new InvalidArgumentException(
308
+				esc_html__(
309
+					'The "edit_event_datetimes" array is invalid therefore the event can not be updated.',
310
+					'event_espresso'
311
+				)
312
+			);
313
+		}
314
+		foreach ($data['edit_event_datetimes'] as $row => $datetime_data) {
315
+			// trim all values to ensure any excess whitespace is removed.
316
+			$datetime_data = array_map(
317
+				function ($datetime_data) {
318
+					return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
319
+				},
320
+				$datetime_data
321
+			);
322
+			$datetime_data['DTT_EVT_end'] = isset($datetime_data['DTT_EVT_end'])
323
+											&& ! empty($datetime_data['DTT_EVT_end'])
324
+				? $datetime_data['DTT_EVT_end']
325
+				: $datetime_data['DTT_EVT_start'];
326
+			$datetime_values = array(
327
+				'DTT_ID'          => ! empty($datetime_data['DTT_ID'])
328
+					? $datetime_data['DTT_ID']
329
+					: null,
330
+				'DTT_name'        => ! empty($datetime_data['DTT_name'])
331
+					? $datetime_data['DTT_name']
332
+					: '',
333
+				'DTT_description' => ! empty($datetime_data['DTT_description'])
334
+					? $datetime_data['DTT_description']
335
+					: '',
336
+				'DTT_EVT_start'   => $datetime_data['DTT_EVT_start'],
337
+				'DTT_EVT_end'     => $datetime_data['DTT_EVT_end'],
338
+				'DTT_reg_limit'   => empty($datetime_data['DTT_reg_limit'])
339
+					? EE_INF
340
+					: $datetime_data['DTT_reg_limit'],
341
+				'DTT_order'       => ! isset($datetime_data['DTT_order'])
342
+					? $row
343
+					: $datetime_data['DTT_order'],
344
+			);
345
+			// if we have an id then let's get existing object first and then set the new values.
346
+			// Otherwise we instantiate a new object for save.
347
+			if (! empty($datetime_data['DTT_ID'])) {
348
+				$datetime = EE_Registry::instance()
349
+									   ->load_model('Datetime', array($timezone))
350
+									   ->get_one_by_ID($datetime_data['DTT_ID']);
351
+				// set date and time format according to what is set in this class.
352
+				$datetime->set_date_format($this->_date_format_strings['date']);
353
+				$datetime->set_time_format($this->_date_format_strings['time']);
354
+				foreach ($datetime_values as $field => $value) {
355
+					$datetime->set($field, $value);
356
+				}
357
+				// make sure the $dtt_id here is saved just in case
358
+				// after the add_relation_to() the autosave replaces it.
359
+				// We need to do this so we dont' TRASH the parent DTT.
360
+				// (save the ID for both key and value to avoid duplications)
361
+				$saved_dtt_ids[ $datetime->ID() ] = $datetime->ID();
362
+			} else {
363
+				$datetime = EE_Registry::instance()->load_class(
364
+					'Datetime',
365
+					array(
366
+						$datetime_values,
367
+						$timezone,
368
+						array($this->_date_format_strings['date'], $this->_date_format_strings['time']),
369
+					),
370
+					false,
371
+					false
372
+				);
373
+				foreach ($datetime_values as $field => $value) {
374
+					$datetime->set($field, $value);
375
+				}
376
+			}
377
+			$datetime->save();
378
+			do_action(
379
+				'AHEE__espresso_events_Pricing_Hooks___update_datetimes_after_save',
380
+				$datetime,
381
+				$row,
382
+				$datetime_data,
383
+				$data
384
+			);
385
+			$datetime = $event->_add_relation_to($datetime, 'Datetime');
386
+			// before going any further make sure our dates are setup correctly
387
+			// so that the end date is always equal or greater than the start date.
388
+			if ($datetime->get_raw('DTT_EVT_start') > $datetime->get_raw('DTT_EVT_end')) {
389
+				$datetime->set('DTT_EVT_end', $datetime->get('DTT_EVT_start'));
390
+				$datetime = EEH_DTT_Helper::date_time_add($datetime, 'DTT_EVT_end', 'days');
391
+				$datetime->save();
392
+			}
393
+			// now we have to make sure we add the new DTT_ID to the $saved_dtt_ids array
394
+			// because it is possible there was a new one created for the autosave.
395
+			// (save the ID for both key and value to avoid duplications)
396
+			$DTT_ID = $datetime->ID();
397
+			$saved_dtt_ids[ $DTT_ID ] = $DTT_ID;
398
+			$saved_dtt_objs[ $row ] = $datetime;
399
+			// @todo if ANY of these updates fail then we want the appropriate global error message.
400
+		}
401
+		$event->save();
402
+		// now we need to REMOVE any datetimes that got deleted.
403
+		// Keep in mind that this process will only kick in for datetimes that don't have any DTT_sold on them.
404
+		// So its safe to permanently delete at this point.
405
+		$old_datetimes = explode(',', $data['datetime_IDs']);
406
+		$old_datetimes = $old_datetimes[0] === '' ? array() : $old_datetimes;
407
+		if (is_array($old_datetimes)) {
408
+			$datetimes_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
409
+			foreach ($datetimes_to_delete as $id) {
410
+				$id = absint($id);
411
+				if (empty($id)) {
412
+					continue;
413
+				}
414
+				/** @var EE_Datetime $dtt_to_remove */
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
+				$dtt_to_remove->delete_or_restore();
424
+			}
425
+		}
426
+		return $saved_dtt_objs;
427
+	}
428 428
 
429 429
 
430
-    /**
431
-     * update tickets
432
-     *
433
-     * @param  EE_Event      $event           Event object being updated
434
-     * @param  EE_Datetime[] $saved_datetimes an array of datetime ids being updated
435
-     * @param  array         $data            incoming request data
436
-     * @return EE_Ticket[]
437
-     * @throws Exception
438
-     * @throws ReflectionException
439
-     * @throws InvalidInterfaceException
440
-     * @throws InvalidDataTypeException
441
-     * @throws InvalidArgumentException
442
-     * @throws EE_Error
443
-     */
444
-    protected function _update_tickets($event, $saved_datetimes, $data)
445
-    {
446
-        $new_tkt = null;
447
-        // stripslashes because WP filtered the $_POST ($data) array to add slashes
448
-        $data = stripslashes_deep($data);
449
-        $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
450
-        $saved_tickets = array();
451
-        $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
452
-        if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
453
-            throw new InvalidArgumentException(
454
-                esc_html__(
455
-                    'The "edit_tickets" array is invalid therefore the event can not be updated.',
456
-                    'event_espresso'
457
-                )
458
-            );
459
-        }
460
-        foreach ($data['edit_tickets'] as $row => $tkt) {
461
-            $update_prices = $create_new_TKT = false;
462
-            // figure out what datetimes were added to the ticket
463
-            // and what datetimes were removed from the ticket in the session.
464
-            $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
465
-            $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
466
-            $datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
467
-            $datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
468
-            // trim inputs to ensure any excess whitespace is removed.
469
-            $tkt = array_map(
470
-                function ($ticket_data) {
471
-                    return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
472
-                },
473
-                $tkt
474
-            );
475
-            // note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
476
-            // because we're doing calculations prior to using the models.
477
-            // note incoming ['TKT_price'] value is already in standard notation (via js).
478
-            $ticket_price = isset($tkt['TKT_price'])
479
-                ? round((float) $tkt['TKT_price'], 3)
480
-                : 0;
481
-            // note incoming base price needs converted from localized value.
482
-            $base_price = isset($tkt['TKT_base_price'])
483
-                ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price'])
484
-                : 0;
485
-            // if ticket price == 0 and $base_price != 0 then ticket price == base_price
486
-            $ticket_price = $ticket_price === 0 && $base_price !== 0
487
-                ? $base_price
488
-                : $ticket_price;
489
-            $base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0;
490
-            $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
491
-                ? $data['edit_prices'][ $row ]
492
-                : array();
493
-            $now = null;
494
-            if (empty($tkt['TKT_start_date'])) {
495
-                // lets' use now in the set timezone.
496
-                $now = new DateTime('now', new DateTimeZone($event->get_timezone()));
497
-                $tkt['TKT_start_date'] = $now->format($this->_date_time_format);
498
-            }
499
-            if (empty($tkt['TKT_end_date'])) {
500
-                /**
501
-                 * set the TKT_end_date to the first datetime attached to the ticket.
502
-                 */
503
-                $first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
504
-                $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
505
-            }
506
-            $TKT_values = array(
507
-                'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
508
-                'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
509
-                'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
510
-                'TKT_description' => ! empty($tkt['TKT_description'])
511
-                                     && $tkt['TKT_description'] !== esc_html__(
512
-                                         'You can modify this description',
513
-                                         'event_espresso'
514
-                                     )
515
-                    ? $tkt['TKT_description']
516
-                    : '',
517
-                'TKT_start_date'  => $tkt['TKT_start_date'],
518
-                'TKT_end_date'    => $tkt['TKT_end_date'],
519
-                'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === ''
520
-                    ? EE_INF
521
-                    : $tkt['TKT_qty'],
522
-                'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === ''
523
-                    ? EE_INF
524
-                    : $tkt['TKT_uses'],
525
-                'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
526
-                'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
527
-                'TKT_row'         => $row,
528
-                'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0,
529
-                'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
530
-                'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
531
-                'TKT_price'       => $ticket_price,
532
-            );
533
-            // if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
534
-            // which means in turn that the prices will become new prices as well.
535
-            if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
536
-                $TKT_values['TKT_ID'] = 0;
537
-                $TKT_values['TKT_is_default'] = 0;
538
-                $update_prices = true;
539
-            }
540
-            // if we have a TKT_ID then we need to get that existing TKT_obj and update it
541
-            // we actually do our saves ahead of doing any add_relations to
542
-            // because its entirely possible that this ticket wasn't removed or added to any datetime in the session
543
-            // but DID have it's items modified.
544
-            // keep in mind that if the TKT has been sold (and we have changed pricing information),
545
-            // then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
546
-            if (absint($TKT_values['TKT_ID'])) {
547
-                $ticket = EE_Registry::instance()
548
-                                     ->load_model('Ticket', array($timezone))
549
-                                     ->get_one_by_ID($tkt['TKT_ID']);
550
-                if ($ticket instanceof EE_Ticket) {
551
-                    $ticket = $this->_update_ticket_datetimes(
552
-                        $ticket,
553
-                        $saved_datetimes,
554
-                        $datetimes_added,
555
-                        $datetimes_removed
556
-                    );
557
-                    // are there any registrations using this ticket ?
558
-                    $tickets_sold = $ticket->count_related(
559
-                        'Registration',
560
-                        array(
561
-                            array(
562
-                                'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)),
563
-                            ),
564
-                        )
565
-                    );
566
-                    // set ticket formats
567
-                    $ticket->set_date_format($this->_date_format_strings['date']);
568
-                    $ticket->set_time_format($this->_date_format_strings['time']);
569
-                    // let's just check the total price for the existing ticket
570
-                    // and determine if it matches the new total price.
571
-                    // if they are different then we create a new ticket (if tickets sold)
572
-                    // if they aren't different then we go ahead and modify existing ticket.
573
-                    $create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
574
-                    // set new values
575
-                    foreach ($TKT_values as $field => $value) {
576
-                        if ($field === 'TKT_qty') {
577
-                            $ticket->set_qty($value);
578
-                        } else {
579
-                            $ticket->set($field, $value);
580
-                        }
581
-                    }
582
-                    // if $create_new_TKT is false then we can safely update the existing ticket.
583
-                    // Otherwise we have to create a new ticket.
584
-                    if ($create_new_TKT) {
585
-                        $new_tkt = $this->_duplicate_ticket(
586
-                            $ticket,
587
-                            $price_rows,
588
-                            $ticket_price,
589
-                            $base_price,
590
-                            $base_price_id
591
-                        );
592
-                    }
593
-                }
594
-            } else {
595
-                // no TKT_id so a new TKT
596
-                $ticket = EE_Ticket::new_instance(
597
-                    $TKT_values,
598
-                    $timezone,
599
-                    array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
600
-                );
601
-                if ($ticket instanceof EE_Ticket) {
602
-                    // make sure ticket has an ID of setting relations won't work
603
-                    $ticket->save();
604
-                    $ticket = $this->_update_ticket_datetimes(
605
-                        $ticket,
606
-                        $saved_datetimes,
607
-                        $datetimes_added,
608
-                        $datetimes_removed
609
-                    );
610
-                    $update_prices = true;
611
-                }
612
-            }
613
-            // make sure any current values have been saved.
614
-            // $ticket->save();
615
-            // before going any further make sure our dates are setup correctly
616
-            // so that the end date is always equal or greater than the start date.
617
-            if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
618
-                $ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
619
-                $ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
620
-            }
621
-            // let's make sure the base price is handled
622
-            $ticket = ! $create_new_TKT
623
-                ? $this->_add_prices_to_ticket(
624
-                    array(),
625
-                    $ticket,
626
-                    $update_prices,
627
-                    $base_price,
628
-                    $base_price_id
629
-                )
630
-                : $ticket;
631
-            // add/update price_modifiers
632
-            $ticket = ! $create_new_TKT
633
-                ? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
634
-                : $ticket;
635
-            // need to make sue that the TKT_price is accurate after saving the prices.
636
-            $ticket->ensure_TKT_Price_correct();
637
-            // handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
638
-            if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
639
-                $update_prices = true;
640
-                $new_default = clone $ticket;
641
-                $new_default->set('TKT_ID', 0);
642
-                $new_default->set('TKT_is_default', 1);
643
-                $new_default->set('TKT_row', 1);
644
-                $new_default->set('TKT_price', $ticket_price);
645
-                // remove any dtt relations cause we DON'T want dtt relations attached
646
-                // (note this is just removing the cached relations in the object)
647
-                $new_default->_remove_relations('Datetime');
648
-                // @todo we need to add the current attached prices as new prices to the new default ticket.
649
-                $new_default = $this->_add_prices_to_ticket(
650
-                    $price_rows,
651
-                    $new_default,
652
-                    $update_prices
653
-                );
654
-                // don't forget the base price!
655
-                $new_default = $this->_add_prices_to_ticket(
656
-                    array(),
657
-                    $new_default,
658
-                    $update_prices,
659
-                    $base_price,
660
-                    $base_price_id
661
-                );
662
-                $new_default->save();
663
-                do_action(
664
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
665
-                    $new_default,
666
-                    $row,
667
-                    $ticket,
668
-                    $data
669
-                );
670
-            }
671
-            // DO ALL dtt relationships for both current tickets and any archived tickets
672
-            // for the given dtt that are related to the current ticket.
673
-            // TODO... not sure exactly how we're going to do this considering we don't know
674
-            // what current ticket the archived tickets are related to
675
-            // (and TKT_parent is used for autosaves so that's not a field we can reliably use).
676
-            // let's assign any tickets that have been setup to the saved_tickets tracker
677
-            // save existing TKT
678
-            $ticket->save();
679
-            if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
680
-                // save new TKT
681
-                $new_tkt->save();
682
-                // add new ticket to array
683
-                $saved_tickets[ $new_tkt->ID() ] = $new_tkt;
684
-                do_action(
685
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
686
-                    $new_tkt,
687
-                    $row,
688
-                    $tkt,
689
-                    $data
690
-                );
691
-            } else {
692
-                // add tkt to saved tkts
693
-                $saved_tickets[ $ticket->ID() ] = $ticket;
694
-                do_action(
695
-                    'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
696
-                    $ticket,
697
-                    $row,
698
-                    $tkt,
699
-                    $data
700
-                );
701
-            }
702
-        }
703
-        // now we need to handle tickets actually "deleted permanently".
704
-        // There are cases where we'd want this to happen
705
-        // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
706
-        // Or a draft event was saved and in the process of editing a ticket is trashed.
707
-        // No sense in keeping all the related data in the db!
708
-        $old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
709
-        $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
710
-        foreach ($tickets_removed as $id) {
711
-            $id = absint($id);
712
-            // get the ticket for this id
713
-            $tkt_to_remove = EEM_Ticket::instance()->get_one_by_ID($id);
714
-            // if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
715
-            if ($tkt_to_remove->get('TKT_is_default')) {
716
-                continue;
717
-            }
718
-            // if this tkt has any registrations attached so then we just ARCHIVE
719
-            // because we don't actually permanently delete these tickets.
720
-            if ($tkt_to_remove->count_related('Registration') > 0) {
721
-                $tkt_to_remove->delete();
722
-                continue;
723
-            }
724
-            // need to get all the related datetimes on this ticket and remove from every single one of them
725
-            // (remember this process can ONLY kick off if there are NO tkts_sold)
726
-            $datetimes = $tkt_to_remove->get_many_related('Datetime');
727
-            foreach ($datetimes as $datetime) {
728
-                $tkt_to_remove->_remove_relation_to($datetime, 'Datetime');
729
-            }
730
-            // need to do the same for prices (except these prices can also be deleted because again,
731
-            // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
732
-            $tkt_to_remove->delete_related('Price');
733
-            do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
734
-            // finally let's delete this ticket
735
-            // (which should not be blocked at this point b/c we've removed all our relationships)
736
-            $tkt_to_remove->delete_or_restore();
737
-        }
738
-        return $saved_tickets;
739
-    }
430
+	/**
431
+	 * update tickets
432
+	 *
433
+	 * @param  EE_Event      $event           Event object being updated
434
+	 * @param  EE_Datetime[] $saved_datetimes an array of datetime ids being updated
435
+	 * @param  array         $data            incoming request data
436
+	 * @return EE_Ticket[]
437
+	 * @throws Exception
438
+	 * @throws ReflectionException
439
+	 * @throws InvalidInterfaceException
440
+	 * @throws InvalidDataTypeException
441
+	 * @throws InvalidArgumentException
442
+	 * @throws EE_Error
443
+	 */
444
+	protected function _update_tickets($event, $saved_datetimes, $data)
445
+	{
446
+		$new_tkt = null;
447
+		// stripslashes because WP filtered the $_POST ($data) array to add slashes
448
+		$data = stripslashes_deep($data);
449
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : null;
450
+		$saved_tickets = array();
451
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
452
+		if (empty($data['edit_tickets']) || ! is_array($data['edit_tickets'])) {
453
+			throw new InvalidArgumentException(
454
+				esc_html__(
455
+					'The "edit_tickets" array is invalid therefore the event can not be updated.',
456
+					'event_espresso'
457
+				)
458
+			);
459
+		}
460
+		foreach ($data['edit_tickets'] as $row => $tkt) {
461
+			$update_prices = $create_new_TKT = false;
462
+			// figure out what datetimes were added to the ticket
463
+			// and what datetimes were removed from the ticket in the session.
464
+			$starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][ $row ]);
465
+			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][ $row ]);
466
+			$datetimes_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
467
+			$datetimes_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
468
+			// trim inputs to ensure any excess whitespace is removed.
469
+			$tkt = array_map(
470
+				function ($ticket_data) {
471
+					return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
472
+				},
473
+				$tkt
474
+			);
475
+			// note we are doing conversions to floats here instead of allowing EE_Money_Field to handle
476
+			// because we're doing calculations prior to using the models.
477
+			// note incoming ['TKT_price'] value is already in standard notation (via js).
478
+			$ticket_price = isset($tkt['TKT_price'])
479
+				? round((float) $tkt['TKT_price'], 3)
480
+				: 0;
481
+			// note incoming base price needs converted from localized value.
482
+			$base_price = isset($tkt['TKT_base_price'])
483
+				? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price'])
484
+				: 0;
485
+			// if ticket price == 0 and $base_price != 0 then ticket price == base_price
486
+			$ticket_price = $ticket_price === 0 && $base_price !== 0
487
+				? $base_price
488
+				: $ticket_price;
489
+			$base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0;
490
+			$price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][ $row ])
491
+				? $data['edit_prices'][ $row ]
492
+				: array();
493
+			$now = null;
494
+			if (empty($tkt['TKT_start_date'])) {
495
+				// lets' use now in the set timezone.
496
+				$now = new DateTime('now', new DateTimeZone($event->get_timezone()));
497
+				$tkt['TKT_start_date'] = $now->format($this->_date_time_format);
498
+			}
499
+			if (empty($tkt['TKT_end_date'])) {
500
+				/**
501
+				 * set the TKT_end_date to the first datetime attached to the ticket.
502
+				 */
503
+				$first_dtt = $saved_datetimes[ reset($tkt_dtt_rows) ];
504
+				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_time_format);
505
+			}
506
+			$TKT_values = array(
507
+				'TKT_ID'          => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null,
508
+				'TTM_ID'          => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
509
+				'TKT_name'        => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
510
+				'TKT_description' => ! empty($tkt['TKT_description'])
511
+									 && $tkt['TKT_description'] !== esc_html__(
512
+										 'You can modify this description',
513
+										 'event_espresso'
514
+									 )
515
+					? $tkt['TKT_description']
516
+					: '',
517
+				'TKT_start_date'  => $tkt['TKT_start_date'],
518
+				'TKT_end_date'    => $tkt['TKT_end_date'],
519
+				'TKT_qty'         => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === ''
520
+					? EE_INF
521
+					: $tkt['TKT_qty'],
522
+				'TKT_uses'        => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === ''
523
+					? EE_INF
524
+					: $tkt['TKT_uses'],
525
+				'TKT_min'         => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
526
+				'TKT_max'         => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
527
+				'TKT_row'         => $row,
528
+				'TKT_order'       => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0,
529
+				'TKT_taxable'     => ! empty($tkt['TKT_taxable']) ? 1 : 0,
530
+				'TKT_required'    => ! empty($tkt['TKT_required']) ? 1 : 0,
531
+				'TKT_price'       => $ticket_price,
532
+			);
533
+			// if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly,
534
+			// which means in turn that the prices will become new prices as well.
535
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
536
+				$TKT_values['TKT_ID'] = 0;
537
+				$TKT_values['TKT_is_default'] = 0;
538
+				$update_prices = true;
539
+			}
540
+			// if we have a TKT_ID then we need to get that existing TKT_obj and update it
541
+			// we actually do our saves ahead of doing any add_relations to
542
+			// because its entirely possible that this ticket wasn't removed or added to any datetime in the session
543
+			// but DID have it's items modified.
544
+			// keep in mind that if the TKT has been sold (and we have changed pricing information),
545
+			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
546
+			if (absint($TKT_values['TKT_ID'])) {
547
+				$ticket = EE_Registry::instance()
548
+									 ->load_model('Ticket', array($timezone))
549
+									 ->get_one_by_ID($tkt['TKT_ID']);
550
+				if ($ticket instanceof EE_Ticket) {
551
+					$ticket = $this->_update_ticket_datetimes(
552
+						$ticket,
553
+						$saved_datetimes,
554
+						$datetimes_added,
555
+						$datetimes_removed
556
+					);
557
+					// are there any registrations using this ticket ?
558
+					$tickets_sold = $ticket->count_related(
559
+						'Registration',
560
+						array(
561
+							array(
562
+								'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)),
563
+							),
564
+						)
565
+					);
566
+					// set ticket formats
567
+					$ticket->set_date_format($this->_date_format_strings['date']);
568
+					$ticket->set_time_format($this->_date_format_strings['time']);
569
+					// let's just check the total price for the existing ticket
570
+					// and determine if it matches the new total price.
571
+					// if they are different then we create a new ticket (if tickets sold)
572
+					// if they aren't different then we go ahead and modify existing ticket.
573
+					$create_new_TKT = $tickets_sold > 0 && $ticket_price !== $ticket->price() && ! $ticket->deleted();
574
+					// set new values
575
+					foreach ($TKT_values as $field => $value) {
576
+						if ($field === 'TKT_qty') {
577
+							$ticket->set_qty($value);
578
+						} else {
579
+							$ticket->set($field, $value);
580
+						}
581
+					}
582
+					// if $create_new_TKT is false then we can safely update the existing ticket.
583
+					// Otherwise we have to create a new ticket.
584
+					if ($create_new_TKT) {
585
+						$new_tkt = $this->_duplicate_ticket(
586
+							$ticket,
587
+							$price_rows,
588
+							$ticket_price,
589
+							$base_price,
590
+							$base_price_id
591
+						);
592
+					}
593
+				}
594
+			} else {
595
+				// no TKT_id so a new TKT
596
+				$ticket = EE_Ticket::new_instance(
597
+					$TKT_values,
598
+					$timezone,
599
+					array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
600
+				);
601
+				if ($ticket instanceof EE_Ticket) {
602
+					// make sure ticket has an ID of setting relations won't work
603
+					$ticket->save();
604
+					$ticket = $this->_update_ticket_datetimes(
605
+						$ticket,
606
+						$saved_datetimes,
607
+						$datetimes_added,
608
+						$datetimes_removed
609
+					);
610
+					$update_prices = true;
611
+				}
612
+			}
613
+			// make sure any current values have been saved.
614
+			// $ticket->save();
615
+			// before going any further make sure our dates are setup correctly
616
+			// so that the end date is always equal or greater than the start date.
617
+			if ($ticket->get_raw('TKT_start_date') > $ticket->get_raw('TKT_end_date')) {
618
+				$ticket->set('TKT_end_date', $ticket->get('TKT_start_date'));
619
+				$ticket = EEH_DTT_Helper::date_time_add($ticket, 'TKT_end_date', 'days');
620
+			}
621
+			// let's make sure the base price is handled
622
+			$ticket = ! $create_new_TKT
623
+				? $this->_add_prices_to_ticket(
624
+					array(),
625
+					$ticket,
626
+					$update_prices,
627
+					$base_price,
628
+					$base_price_id
629
+				)
630
+				: $ticket;
631
+			// add/update price_modifiers
632
+			$ticket = ! $create_new_TKT
633
+				? $this->_add_prices_to_ticket($price_rows, $ticket, $update_prices)
634
+				: $ticket;
635
+			// need to make sue that the TKT_price is accurate after saving the prices.
636
+			$ticket->ensure_TKT_Price_correct();
637
+			// handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
638
+			if (! defined('DOING_AUTOSAVE') && ! empty($tkt['TKT_is_default_selector'])) {
639
+				$update_prices = true;
640
+				$new_default = clone $ticket;
641
+				$new_default->set('TKT_ID', 0);
642
+				$new_default->set('TKT_is_default', 1);
643
+				$new_default->set('TKT_row', 1);
644
+				$new_default->set('TKT_price', $ticket_price);
645
+				// remove any dtt relations cause we DON'T want dtt relations attached
646
+				// (note this is just removing the cached relations in the object)
647
+				$new_default->_remove_relations('Datetime');
648
+				// @todo we need to add the current attached prices as new prices to the new default ticket.
649
+				$new_default = $this->_add_prices_to_ticket(
650
+					$price_rows,
651
+					$new_default,
652
+					$update_prices
653
+				);
654
+				// don't forget the base price!
655
+				$new_default = $this->_add_prices_to_ticket(
656
+					array(),
657
+					$new_default,
658
+					$update_prices,
659
+					$base_price,
660
+					$base_price_id
661
+				);
662
+				$new_default->save();
663
+				do_action(
664
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket',
665
+					$new_default,
666
+					$row,
667
+					$ticket,
668
+					$data
669
+				);
670
+			}
671
+			// DO ALL dtt relationships for both current tickets and any archived tickets
672
+			// for the given dtt that are related to the current ticket.
673
+			// TODO... not sure exactly how we're going to do this considering we don't know
674
+			// what current ticket the archived tickets are related to
675
+			// (and TKT_parent is used for autosaves so that's not a field we can reliably use).
676
+			// let's assign any tickets that have been setup to the saved_tickets tracker
677
+			// save existing TKT
678
+			$ticket->save();
679
+			if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
680
+				// save new TKT
681
+				$new_tkt->save();
682
+				// add new ticket to array
683
+				$saved_tickets[ $new_tkt->ID() ] = $new_tkt;
684
+				do_action(
685
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket',
686
+					$new_tkt,
687
+					$row,
688
+					$tkt,
689
+					$data
690
+				);
691
+			} else {
692
+				// add tkt to saved tkts
693
+				$saved_tickets[ $ticket->ID() ] = $ticket;
694
+				do_action(
695
+					'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket',
696
+					$ticket,
697
+					$row,
698
+					$tkt,
699
+					$data
700
+				);
701
+			}
702
+		}
703
+		// now we need to handle tickets actually "deleted permanently".
704
+		// There are cases where we'd want this to happen
705
+		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
706
+		// Or a draft event was saved and in the process of editing a ticket is trashed.
707
+		// No sense in keeping all the related data in the db!
708
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] === '' ? array() : $old_tickets;
709
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
710
+		foreach ($tickets_removed as $id) {
711
+			$id = absint($id);
712
+			// get the ticket for this id
713
+			$tkt_to_remove = EEM_Ticket::instance()->get_one_by_ID($id);
714
+			// if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
715
+			if ($tkt_to_remove->get('TKT_is_default')) {
716
+				continue;
717
+			}
718
+			// if this tkt has any registrations attached so then we just ARCHIVE
719
+			// because we don't actually permanently delete these tickets.
720
+			if ($tkt_to_remove->count_related('Registration') > 0) {
721
+				$tkt_to_remove->delete();
722
+				continue;
723
+			}
724
+			// need to get all the related datetimes on this ticket and remove from every single one of them
725
+			// (remember this process can ONLY kick off if there are NO tkts_sold)
726
+			$datetimes = $tkt_to_remove->get_many_related('Datetime');
727
+			foreach ($datetimes as $datetime) {
728
+				$tkt_to_remove->_remove_relation_to($datetime, 'Datetime');
729
+			}
730
+			// need to do the same for prices (except these prices can also be deleted because again,
731
+			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
732
+			$tkt_to_remove->delete_related('Price');
733
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
734
+			// finally let's delete this ticket
735
+			// (which should not be blocked at this point b/c we've removed all our relationships)
736
+			$tkt_to_remove->delete_or_restore();
737
+		}
738
+		return $saved_tickets;
739
+	}
740 740
 
741 741
 
742
-    /**
743
-     * @access  protected
744
-     * @param EE_Ticket      $ticket
745
-     * @param \EE_Datetime[] $saved_datetimes
746
-     * @param \EE_Datetime[] $added_datetimes
747
-     * @param \EE_Datetime[] $removed_datetimes
748
-     * @return EE_Ticket
749
-     * @throws EE_Error
750
-     */
751
-    protected function _update_ticket_datetimes(
752
-        EE_Ticket $ticket,
753
-        $saved_datetimes = array(),
754
-        $added_datetimes = array(),
755
-        $removed_datetimes = array()
756
-    ) {
757
-        // to start we have to add the ticket to all the datetimes its supposed to be with,
758
-        // and removing the ticket from datetimes it got removed from.
759
-        // first let's add datetimes
760
-        if (! empty($added_datetimes) && is_array($added_datetimes)) {
761
-            foreach ($added_datetimes as $row_id) {
762
-                $row_id = (int) $row_id;
763
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
764
-                    $ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
765
-                    // Is this an existing ticket (has an ID) and does it have any sold?
766
-                    // If so, then we need to add that to the DTT sold because this DTT is getting added.
767
-                    if ($ticket->ID() && $ticket->sold() > 0) {
768
-                        $saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false);
769
-                    }
770
-                }
771
-            }
772
-        }
773
-        // then remove datetimes
774
-        if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
775
-            foreach ($removed_datetimes as $row_id) {
776
-                $row_id = (int) $row_id;
777
-                // its entirely possible that a datetime got deleted (instead of just removed from relationship.
778
-                // So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
779
-                if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
780
-                    $ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
781
-                    // Is this an existing ticket (has an ID) and does it have any sold?
782
-                    // If so, then we need to remove it's sold from the DTT_sold.
783
-                    if ($ticket->ID() && $ticket->sold() > 0) {
784
-                        $saved_datetimes[ $row_id ]->decreaseSold($ticket->sold());
785
-                    }
786
-                }
787
-            }
788
-        }
789
-        // cap ticket qty by datetime reg limits
790
-        $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
791
-        return $ticket;
792
-    }
742
+	/**
743
+	 * @access  protected
744
+	 * @param EE_Ticket      $ticket
745
+	 * @param \EE_Datetime[] $saved_datetimes
746
+	 * @param \EE_Datetime[] $added_datetimes
747
+	 * @param \EE_Datetime[] $removed_datetimes
748
+	 * @return EE_Ticket
749
+	 * @throws EE_Error
750
+	 */
751
+	protected function _update_ticket_datetimes(
752
+		EE_Ticket $ticket,
753
+		$saved_datetimes = array(),
754
+		$added_datetimes = array(),
755
+		$removed_datetimes = array()
756
+	) {
757
+		// to start we have to add the ticket to all the datetimes its supposed to be with,
758
+		// and removing the ticket from datetimes it got removed from.
759
+		// first let's add datetimes
760
+		if (! empty($added_datetimes) && is_array($added_datetimes)) {
761
+			foreach ($added_datetimes as $row_id) {
762
+				$row_id = (int) $row_id;
763
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
764
+					$ticket->_add_relation_to($saved_datetimes[ $row_id ], 'Datetime');
765
+					// Is this an existing ticket (has an ID) and does it have any sold?
766
+					// If so, then we need to add that to the DTT sold because this DTT is getting added.
767
+					if ($ticket->ID() && $ticket->sold() > 0) {
768
+						$saved_datetimes[ $row_id ]->increaseSold($ticket->sold(), false);
769
+					}
770
+				}
771
+			}
772
+		}
773
+		// then remove datetimes
774
+		if (! empty($removed_datetimes) && is_array($removed_datetimes)) {
775
+			foreach ($removed_datetimes as $row_id) {
776
+				$row_id = (int) $row_id;
777
+				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
778
+				// So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
779
+				if (isset($saved_datetimes[ $row_id ]) && $saved_datetimes[ $row_id ] instanceof EE_Datetime) {
780
+					$ticket->_remove_relation_to($saved_datetimes[ $row_id ], 'Datetime');
781
+					// Is this an existing ticket (has an ID) and does it have any sold?
782
+					// If so, then we need to remove it's sold from the DTT_sold.
783
+					if ($ticket->ID() && $ticket->sold() > 0) {
784
+						$saved_datetimes[ $row_id ]->decreaseSold($ticket->sold());
785
+					}
786
+				}
787
+			}
788
+		}
789
+		// cap ticket qty by datetime reg limits
790
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
791
+		return $ticket;
792
+	}
793 793
 
794 794
 
795
-    /**
796
-     * @access  protected
797
-     * @param EE_Ticket $ticket
798
-     * @param array     $price_rows
799
-     * @param int       $ticket_price
800
-     * @param int       $base_price
801
-     * @param int       $base_price_id
802
-     * @return EE_Ticket
803
-     * @throws ReflectionException
804
-     * @throws InvalidArgumentException
805
-     * @throws InvalidInterfaceException
806
-     * @throws InvalidDataTypeException
807
-     * @throws EE_Error
808
-     */
809
-    protected function _duplicate_ticket(
810
-        EE_Ticket $ticket,
811
-        $price_rows = array(),
812
-        $ticket_price = 0,
813
-        $base_price = 0,
814
-        $base_price_id = 0
815
-    ) {
816
-        // create new ticket that's a copy of the existing
817
-        // except a new id of course (and not archived)
818
-        // AND has the new TKT_price associated with it.
819
-        $new_ticket = clone $ticket;
820
-        $new_ticket->set('TKT_ID', 0);
821
-        $new_ticket->set_deleted(0);
822
-        $new_ticket->set_price($ticket_price);
823
-        $new_ticket->set_sold(0);
824
-        // let's get a new ID for this ticket
825
-        $new_ticket->save();
826
-        // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
827
-        $datetimes_on_existing = $ticket->datetimes();
828
-        $new_ticket = $this->_update_ticket_datetimes(
829
-            $new_ticket,
830
-            $datetimes_on_existing,
831
-            array_keys($datetimes_on_existing)
832
-        );
833
-        // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
834
-        // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
835
-        // available.
836
-        if ($ticket->sold() > 0) {
837
-            $new_qty = $ticket->qty() - $ticket->sold();
838
-            $new_ticket->set_qty($new_qty);
839
-        }
840
-        // now we update the prices just for this ticket
841
-        $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
842
-        // and we update the base price
843
-        $new_ticket = $this->_add_prices_to_ticket(
844
-            array(),
845
-            $new_ticket,
846
-            true,
847
-            $base_price,
848
-            $base_price_id
849
-        );
850
-        return $new_ticket;
851
-    }
795
+	/**
796
+	 * @access  protected
797
+	 * @param EE_Ticket $ticket
798
+	 * @param array     $price_rows
799
+	 * @param int       $ticket_price
800
+	 * @param int       $base_price
801
+	 * @param int       $base_price_id
802
+	 * @return EE_Ticket
803
+	 * @throws ReflectionException
804
+	 * @throws InvalidArgumentException
805
+	 * @throws InvalidInterfaceException
806
+	 * @throws InvalidDataTypeException
807
+	 * @throws EE_Error
808
+	 */
809
+	protected function _duplicate_ticket(
810
+		EE_Ticket $ticket,
811
+		$price_rows = array(),
812
+		$ticket_price = 0,
813
+		$base_price = 0,
814
+		$base_price_id = 0
815
+	) {
816
+		// create new ticket that's a copy of the existing
817
+		// except a new id of course (and not archived)
818
+		// AND has the new TKT_price associated with it.
819
+		$new_ticket = clone $ticket;
820
+		$new_ticket->set('TKT_ID', 0);
821
+		$new_ticket->set_deleted(0);
822
+		$new_ticket->set_price($ticket_price);
823
+		$new_ticket->set_sold(0);
824
+		// let's get a new ID for this ticket
825
+		$new_ticket->save();
826
+		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
827
+		$datetimes_on_existing = $ticket->datetimes();
828
+		$new_ticket = $this->_update_ticket_datetimes(
829
+			$new_ticket,
830
+			$datetimes_on_existing,
831
+			array_keys($datetimes_on_existing)
832
+		);
833
+		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
834
+		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
835
+		// available.
836
+		if ($ticket->sold() > 0) {
837
+			$new_qty = $ticket->qty() - $ticket->sold();
838
+			$new_ticket->set_qty($new_qty);
839
+		}
840
+		// now we update the prices just for this ticket
841
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
842
+		// and we update the base price
843
+		$new_ticket = $this->_add_prices_to_ticket(
844
+			array(),
845
+			$new_ticket,
846
+			true,
847
+			$base_price,
848
+			$base_price_id
849
+		);
850
+		return $new_ticket;
851
+	}
852 852
 
853 853
 
854
-    /**
855
-     * This attaches a list of given prices to a ticket.
856
-     * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
857
-     * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
858
-     * price info and prices are automatically "archived" via the ticket.
859
-     *
860
-     * @access  private
861
-     * @param array     $prices        Array of prices from the form.
862
-     * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
863
-     * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
864
-     * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
865
-     * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
866
-     * @return EE_Ticket
867
-     * @throws ReflectionException
868
-     * @throws InvalidArgumentException
869
-     * @throws InvalidInterfaceException
870
-     * @throws InvalidDataTypeException
871
-     * @throws EE_Error
872
-     */
873
-    protected function _add_prices_to_ticket(
874
-        array $prices,
875
-        EE_Ticket $ticket,
876
-        $new_prices = false,
877
-        $base_price = false,
878
-        $base_price_id = false
879
-    ) {
880
-        // let's just get any current prices that may exist on the given ticket
881
-        // so we can remove any prices that got trashed in this session.
882
-        $current_prices_on_ticket = $base_price !== false
883
-            ? $ticket->base_price(true)
884
-            : $ticket->price_modifiers();
885
-        $updated_prices = array();
886
-        // if $base_price ! FALSE then updating a base price.
887
-        if ($base_price !== false) {
888
-            $prices[1] = array(
889
-                'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
890
-                'PRT_ID'     => 1,
891
-                'PRC_amount' => $base_price,
892
-                'PRC_name'   => $ticket->get('TKT_name'),
893
-                'PRC_desc'   => $ticket->get('TKT_description'),
894
-            );
895
-        }
896
-        // possibly need to save tkt
897
-        if (! $ticket->ID()) {
898
-            $ticket->save();
899
-        }
900
-        foreach ($prices as $row => $prc) {
901
-            $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
902
-            if (empty($prt_id)) {
903
-                continue;
904
-            } //prices MUST have a price type id.
905
-            $PRC_values = array(
906
-                'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
907
-                'PRT_ID'         => $prt_id,
908
-                'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
909
-                'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
910
-                'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
911
-                'PRC_is_default' => false,
912
-                // make sure we set PRC_is_default to false for all ticket saves from event_editor
913
-                'PRC_order'      => $row,
914
-            );
915
-            if ($new_prices || empty($PRC_values['PRC_ID'])) {
916
-                $PRC_values['PRC_ID'] = 0;
917
-                $price = EE_Registry::instance()->load_class(
918
-                    'Price',
919
-                    array($PRC_values),
920
-                    false,
921
-                    false
922
-                );
923
-            } else {
924
-                $price = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
925
-                // update this price with new values
926
-                foreach ($PRC_values as $field => $value) {
927
-                    $price->set($field, $value);
928
-                }
929
-            }
930
-            $price->save();
931
-            $updated_prices[ $price->ID() ] = $price;
932
-            $ticket->_add_relation_to($price, 'Price');
933
-        }
934
-        // now let's remove any prices that got removed from the ticket
935
-        if (! empty($current_prices_on_ticket)) {
936
-            $current = array_keys($current_prices_on_ticket);
937
-            $updated = array_keys($updated_prices);
938
-            $prices_to_remove = array_diff($current, $updated);
939
-            if (! empty($prices_to_remove)) {
940
-                foreach ($prices_to_remove as $prc_id) {
941
-                    $p = $current_prices_on_ticket[ $prc_id ];
942
-                    $ticket->_remove_relation_to($p, 'Price');
943
-                    // delete permanently the price
944
-                    $p->delete_or_restore();
945
-                }
946
-            }
947
-        }
948
-        return $ticket;
949
-    }
854
+	/**
855
+	 * This attaches a list of given prices to a ticket.
856
+	 * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change
857
+	 * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old
858
+	 * price info and prices are automatically "archived" via the ticket.
859
+	 *
860
+	 * @access  private
861
+	 * @param array     $prices        Array of prices from the form.
862
+	 * @param EE_Ticket $ticket        EE_Ticket object that prices are being attached to.
863
+	 * @param bool      $new_prices    Whether attach existing incoming prices or create new ones.
864
+	 * @param int|bool  $base_price    if FALSE then NOT doing a base price add.
865
+	 * @param int|bool  $base_price_id if present then this is the base_price_id being updated.
866
+	 * @return EE_Ticket
867
+	 * @throws ReflectionException
868
+	 * @throws InvalidArgumentException
869
+	 * @throws InvalidInterfaceException
870
+	 * @throws InvalidDataTypeException
871
+	 * @throws EE_Error
872
+	 */
873
+	protected function _add_prices_to_ticket(
874
+		array $prices,
875
+		EE_Ticket $ticket,
876
+		$new_prices = false,
877
+		$base_price = false,
878
+		$base_price_id = false
879
+	) {
880
+		// let's just get any current prices that may exist on the given ticket
881
+		// so we can remove any prices that got trashed in this session.
882
+		$current_prices_on_ticket = $base_price !== false
883
+			? $ticket->base_price(true)
884
+			: $ticket->price_modifiers();
885
+		$updated_prices = array();
886
+		// if $base_price ! FALSE then updating a base price.
887
+		if ($base_price !== false) {
888
+			$prices[1] = array(
889
+				'PRC_ID'     => $new_prices || $base_price_id === 1 ? null : $base_price_id,
890
+				'PRT_ID'     => 1,
891
+				'PRC_amount' => $base_price,
892
+				'PRC_name'   => $ticket->get('TKT_name'),
893
+				'PRC_desc'   => $ticket->get('TKT_description'),
894
+			);
895
+		}
896
+		// possibly need to save tkt
897
+		if (! $ticket->ID()) {
898
+			$ticket->save();
899
+		}
900
+		foreach ($prices as $row => $prc) {
901
+			$prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null;
902
+			if (empty($prt_id)) {
903
+				continue;
904
+			} //prices MUST have a price type id.
905
+			$PRC_values = array(
906
+				'PRC_ID'         => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null,
907
+				'PRT_ID'         => $prt_id,
908
+				'PRC_amount'     => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
909
+				'PRC_name'       => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
910
+				'PRC_desc'       => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
911
+				'PRC_is_default' => false,
912
+				// make sure we set PRC_is_default to false for all ticket saves from event_editor
913
+				'PRC_order'      => $row,
914
+			);
915
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
916
+				$PRC_values['PRC_ID'] = 0;
917
+				$price = EE_Registry::instance()->load_class(
918
+					'Price',
919
+					array($PRC_values),
920
+					false,
921
+					false
922
+				);
923
+			} else {
924
+				$price = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
925
+				// update this price with new values
926
+				foreach ($PRC_values as $field => $value) {
927
+					$price->set($field, $value);
928
+				}
929
+			}
930
+			$price->save();
931
+			$updated_prices[ $price->ID() ] = $price;
932
+			$ticket->_add_relation_to($price, 'Price');
933
+		}
934
+		// now let's remove any prices that got removed from the ticket
935
+		if (! empty($current_prices_on_ticket)) {
936
+			$current = array_keys($current_prices_on_ticket);
937
+			$updated = array_keys($updated_prices);
938
+			$prices_to_remove = array_diff($current, $updated);
939
+			if (! empty($prices_to_remove)) {
940
+				foreach ($prices_to_remove as $prc_id) {
941
+					$p = $current_prices_on_ticket[ $prc_id ];
942
+					$ticket->_remove_relation_to($p, 'Price');
943
+					// delete permanently the price
944
+					$p->delete_or_restore();
945
+				}
946
+			}
947
+		}
948
+		return $ticket;
949
+	}
950 950
 
951 951
 
952
-    /**
953
-     * @param Events_Admin_Page $event_admin_obj
954
-     * @return Events_Admin_Page
955
-     */
956
-    public function autosave_handling(Events_Admin_Page $event_admin_obj)
957
-    {
958
-        return $event_admin_obj;
959
-        // doing nothing for the moment.
960
-        // todo when I get to this remember that I need to set the template args on the $event_admin_obj
961
-        // (use the set_template_args() method)
962
-        /**
963
-         * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
964
-         * 1. TKT_is_default_selector (visible)
965
-         * 2. TKT_is_default (hidden)
966
-         * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket
967
-         * (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want
968
-         * this ticket to be saved as a default.
969
-         * The tricky part is, on an initial display on create or edit (or after manually updating),
970
-         * the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true
971
-         * if this is a create.  However, after an autosave, users will want some sort of indicator that
972
-         * the TKT HAS been saved as a default..
973
-         * in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
974
-         * On Autosave:
975
-         * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements,
976
-         * then set the TKT_is_default to false.
977
-         * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).
978
-         *  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
979
-         * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
980
-         */
981
-    }
952
+	/**
953
+	 * @param Events_Admin_Page $event_admin_obj
954
+	 * @return Events_Admin_Page
955
+	 */
956
+	public function autosave_handling(Events_Admin_Page $event_admin_obj)
957
+	{
958
+		return $event_admin_obj;
959
+		// doing nothing for the moment.
960
+		// todo when I get to this remember that I need to set the template args on the $event_admin_obj
961
+		// (use the set_template_args() method)
962
+		/**
963
+		 * need to remember to handle TICKET DEFAULT saves correctly:  I've got two input fields in the dom:
964
+		 * 1. TKT_is_default_selector (visible)
965
+		 * 2. TKT_is_default (hidden)
966
+		 * I think we'll use the TKT_is_default for recording whether the ticket displayed IS a default ticket
967
+		 * (on new event creations). Whereas the TKT_is_default_selector is for the user to indicate they want
968
+		 * this ticket to be saved as a default.
969
+		 * The tricky part is, on an initial display on create or edit (or after manually updating),
970
+		 * the TKT_is_default_selector will always be unselected and the TKT_is_default will only be true
971
+		 * if this is a create.  However, after an autosave, users will want some sort of indicator that
972
+		 * the TKT HAS been saved as a default..
973
+		 * in other words we don't want to remove the check on TKT_is_default_selector. So here's what I'm thinking.
974
+		 * On Autosave:
975
+		 * 1. If TKT_is_default is true: we create a new TKT, send back the new id and add id to related elements,
976
+		 * then set the TKT_is_default to false.
977
+		 * 2. If TKT_is_default_selector is true: we create/edit existing ticket (following conditions above as well).
978
+		 *  We do NOT create a new default ticket.  The checkbox stays selected after autosave.
979
+		 * 3. only on MANUAL update do we check for the selection and if selected create the new default ticket.
980
+		 */
981
+	}
982 982
 
983 983
 
984
-    /**
985
-     * @throws ReflectionException
986
-     * @throws InvalidArgumentException
987
-     * @throws InvalidInterfaceException
988
-     * @throws InvalidDataTypeException
989
-     * @throws DomainException
990
-     * @throws EE_Error
991
-     */
992
-    public function pricing_metabox()
993
-    {
994
-        $existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
995
-        $event = $this->_adminpage_obj->get_cpt_model_obj();
996
-        // set is_creating_event property.
997
-        $EVT_ID = $event->ID();
998
-        $this->_is_creating_event = empty($this->_req_data['post']);
999
-        // default main template args
1000
-        $main_template_args = array(
1001
-            'event_datetime_help_link' => EEH_Template::get_help_tab_link(
1002
-                'event_editor_event_datetimes_help_tab',
1003
-                $this->_adminpage_obj->page_slug,
1004
-                $this->_adminpage_obj->get_req_action(),
1005
-                false,
1006
-                false
1007
-            ),
1008
-            // todo need to add a filter to the template for the help text
1009
-            // in the Events_Admin_Page core file so we can add further help
1010
-            'existing_datetime_ids'    => '',
1011
-            'total_dtt_rows'           => 1,
1012
-            'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1013
-                'add_new_dtt_info',
1014
-                $this->_adminpage_obj->page_slug,
1015
-                $this->_adminpage_obj->get_req_action(),
1016
-                false,
1017
-                false
1018
-            ),
1019
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1020
-            'datetime_rows'            => '',
1021
-            'show_tickets_container'   => '',
1022
-            // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
1023
-            'ticket_rows'              => '',
1024
-            'existing_ticket_ids'      => '',
1025
-            'total_ticket_rows'        => 1,
1026
-            'ticket_js_structure'      => '',
1027
-            'ee_collapsible_status'    => ' ee-collapsible-open'
1028
-            // $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1029
-        );
1030
-        $timezone = $event instanceof EE_Event ? $event->timezone_string() : null;
1031
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1032
-        /**
1033
-         * 1. Start with retrieving Datetimes
1034
-         * 2. For each datetime get related tickets
1035
-         * 3. For each ticket get related prices
1036
-         */
1037
-        /** @var EEM_Datetime $datetime_model */
1038
-        $datetime_model = EE_Registry::instance()->load_model('Datetime', array($timezone));
1039
-        $datetimes = $datetime_model->get_all_event_dates($EVT_ID);
1040
-        $main_template_args['total_dtt_rows'] = count($datetimes);
1041
-        /**
1042
-         * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1043
-         * for why we are counting $datetime_row and then setting that on the Datetime object
1044
-         */
1045
-        $datetime_row = 1;
1046
-        foreach ($datetimes as $datetime) {
1047
-            $DTT_ID = $datetime->get('DTT_ID');
1048
-            $datetime->set('DTT_order', $datetime_row);
1049
-            $existing_datetime_ids[] = $DTT_ID;
1050
-            // tickets attached
1051
-            $related_tickets = $datetime->ID() > 0
1052
-                ? $datetime->get_many_related(
1053
-                    'Ticket',
1054
-                    array(
1055
-                        array(
1056
-                            'OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0),
1057
-                        ),
1058
-                        'default_where_conditions' => 'none',
1059
-                        'order_by'                 => array('TKT_order' => 'ASC'),
1060
-                    )
1061
-                )
1062
-                : array();
1063
-            // if there are no related tickets this is likely a new event OR autodraft
1064
-            // event so we need to generate the default tickets because datetimes
1065
-            // ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1066
-            // datetime on the event.
1067
-            if (empty($related_tickets) && count($datetimes) < 2) {
1068
-                /** @var EEM_Ticket $ticket_model */
1069
-                $ticket_model = EE_Registry::instance()->load_model('Ticket');
1070
-                $related_tickets = $ticket_model->get_all_default_tickets();
1071
-                // this should be ordered by TKT_ID, so let's grab the first default ticket
1072
-                // (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1073
-                $default_prices = EEM_Price::instance()->get_all_default_prices();
1074
-                $main_default_ticket = reset($related_tickets);
1075
-                if ($main_default_ticket instanceof EE_Ticket) {
1076
-                    foreach ($default_prices as $default_price) {
1077
-                        if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1078
-                            continue;
1079
-                        }
1080
-                        $main_default_ticket->cache('Price', $default_price);
1081
-                    }
1082
-                }
1083
-            }
1084
-            // we can't actually setup rows in this loop yet cause we don't know all
1085
-            // the unique tickets for this event yet (tickets are linked through all datetimes).
1086
-            // So we're going to temporarily cache some of that information.
1087
-            // loop through and setup the ticket rows and make sure the order is set.
1088
-            foreach ($related_tickets as $ticket) {
1089
-                $TKT_ID = $ticket->get('TKT_ID');
1090
-                $ticket_row = $ticket->get('TKT_row');
1091
-                // we only want unique tickets in our final display!!
1092
-                if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1093
-                    $existing_ticket_ids[] = $TKT_ID;
1094
-                    $all_tickets[] = $ticket;
1095
-                }
1096
-                // temporary cache of this ticket info for this datetime for later processing of datetime rows.
1097
-                $datetime_tickets[ $DTT_ID ][] = $ticket_row;
1098
-                // temporary cache of this datetime info for this ticket for later processing of ticket rows.
1099
-                if (
1100
-                    ! isset($ticket_datetimes[ $TKT_ID ])
1101
-                    || ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1102
-                ) {
1103
-                    $ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1104
-                }
1105
-            }
1106
-            $datetime_row++;
1107
-        }
1108
-        $main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
1109
-        $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1110
-        $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1111
-        // sort $all_tickets by order
1112
-        usort(
1113
-            $all_tickets,
1114
-            function (EE_Ticket $a, EE_Ticket $b) {
1115
-                $a_order = (int) $a->get('TKT_order');
1116
-                $b_order = (int) $b->get('TKT_order');
1117
-                if ($a_order === $b_order) {
1118
-                    return 0;
1119
-                }
1120
-                return ($a_order < $b_order) ? -1 : 1;
1121
-            }
1122
-        );
1123
-        // k NOW we have all the data we need for setting up the dtt rows
1124
-        // and ticket rows so we start our dtt loop again.
1125
-        $datetime_row = 1;
1126
-        foreach ($datetimes as $datetime) {
1127
-            $main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1128
-                $datetime_row,
1129
-                $datetime,
1130
-                $datetime_tickets,
1131
-                $all_tickets,
1132
-                false,
1133
-                $datetimes
1134
-            );
1135
-            $datetime_row++;
1136
-        }
1137
-        // then loop through all tickets for the ticket rows.
1138
-        $ticket_row = 1;
1139
-        foreach ($all_tickets as $ticket) {
1140
-            $main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1141
-                $ticket_row,
1142
-                $ticket,
1143
-                $ticket_datetimes,
1144
-                $datetimes,
1145
-                false,
1146
-                $all_tickets
1147
-            );
1148
-            $ticket_row++;
1149
-        }
1150
-        $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
1151
-        EEH_Template::display_template(
1152
-            PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1153
-            $main_template_args
1154
-        );
1155
-    }
984
+	/**
985
+	 * @throws ReflectionException
986
+	 * @throws InvalidArgumentException
987
+	 * @throws InvalidInterfaceException
988
+	 * @throws InvalidDataTypeException
989
+	 * @throws DomainException
990
+	 * @throws EE_Error
991
+	 */
992
+	public function pricing_metabox()
993
+	{
994
+		$existing_datetime_ids = $existing_ticket_ids = $datetime_tickets = $ticket_datetimes = array();
995
+		$event = $this->_adminpage_obj->get_cpt_model_obj();
996
+		// set is_creating_event property.
997
+		$EVT_ID = $event->ID();
998
+		$this->_is_creating_event = empty($this->_req_data['post']);
999
+		// default main template args
1000
+		$main_template_args = array(
1001
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link(
1002
+				'event_editor_event_datetimes_help_tab',
1003
+				$this->_adminpage_obj->page_slug,
1004
+				$this->_adminpage_obj->get_req_action(),
1005
+				false,
1006
+				false
1007
+			),
1008
+			// todo need to add a filter to the template for the help text
1009
+			// in the Events_Admin_Page core file so we can add further help
1010
+			'existing_datetime_ids'    => '',
1011
+			'total_dtt_rows'           => 1,
1012
+			'add_new_dtt_help_link'    => EEH_Template::get_help_tab_link(
1013
+				'add_new_dtt_info',
1014
+				$this->_adminpage_obj->page_slug,
1015
+				$this->_adminpage_obj->get_req_action(),
1016
+				false,
1017
+				false
1018
+			),
1019
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1020
+			'datetime_rows'            => '',
1021
+			'show_tickets_container'   => '',
1022
+			// $this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
1023
+			'ticket_rows'              => '',
1024
+			'existing_ticket_ids'      => '',
1025
+			'total_ticket_rows'        => 1,
1026
+			'ticket_js_structure'      => '',
1027
+			'ee_collapsible_status'    => ' ee-collapsible-open'
1028
+			// $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' ee-collapsible-closed' : ' ee-collapsible-open'
1029
+		);
1030
+		$timezone = $event instanceof EE_Event ? $event->timezone_string() : null;
1031
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1032
+		/**
1033
+		 * 1. Start with retrieving Datetimes
1034
+		 * 2. For each datetime get related tickets
1035
+		 * 3. For each ticket get related prices
1036
+		 */
1037
+		/** @var EEM_Datetime $datetime_model */
1038
+		$datetime_model = EE_Registry::instance()->load_model('Datetime', array($timezone));
1039
+		$datetimes = $datetime_model->get_all_event_dates($EVT_ID);
1040
+		$main_template_args['total_dtt_rows'] = count($datetimes);
1041
+		/**
1042
+		 * @see https://events.codebasehq.com/projects/event-espresso/tickets/9486
1043
+		 * for why we are counting $datetime_row and then setting that on the Datetime object
1044
+		 */
1045
+		$datetime_row = 1;
1046
+		foreach ($datetimes as $datetime) {
1047
+			$DTT_ID = $datetime->get('DTT_ID');
1048
+			$datetime->set('DTT_order', $datetime_row);
1049
+			$existing_datetime_ids[] = $DTT_ID;
1050
+			// tickets attached
1051
+			$related_tickets = $datetime->ID() > 0
1052
+				? $datetime->get_many_related(
1053
+					'Ticket',
1054
+					array(
1055
+						array(
1056
+							'OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0),
1057
+						),
1058
+						'default_where_conditions' => 'none',
1059
+						'order_by'                 => array('TKT_order' => 'ASC'),
1060
+					)
1061
+				)
1062
+				: array();
1063
+			// if there are no related tickets this is likely a new event OR autodraft
1064
+			// event so we need to generate the default tickets because datetimes
1065
+			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
1066
+			// datetime on the event.
1067
+			if (empty($related_tickets) && count($datetimes) < 2) {
1068
+				/** @var EEM_Ticket $ticket_model */
1069
+				$ticket_model = EE_Registry::instance()->load_model('Ticket');
1070
+				$related_tickets = $ticket_model->get_all_default_tickets();
1071
+				// this should be ordered by TKT_ID, so let's grab the first default ticket
1072
+				// (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
1073
+				$default_prices = EEM_Price::instance()->get_all_default_prices();
1074
+				$main_default_ticket = reset($related_tickets);
1075
+				if ($main_default_ticket instanceof EE_Ticket) {
1076
+					foreach ($default_prices as $default_price) {
1077
+						if ($default_price instanceof EE_Price && $default_price->is_base_price()) {
1078
+							continue;
1079
+						}
1080
+						$main_default_ticket->cache('Price', $default_price);
1081
+					}
1082
+				}
1083
+			}
1084
+			// we can't actually setup rows in this loop yet cause we don't know all
1085
+			// the unique tickets for this event yet (tickets are linked through all datetimes).
1086
+			// So we're going to temporarily cache some of that information.
1087
+			// loop through and setup the ticket rows and make sure the order is set.
1088
+			foreach ($related_tickets as $ticket) {
1089
+				$TKT_ID = $ticket->get('TKT_ID');
1090
+				$ticket_row = $ticket->get('TKT_row');
1091
+				// we only want unique tickets in our final display!!
1092
+				if (! in_array($TKT_ID, $existing_ticket_ids, true)) {
1093
+					$existing_ticket_ids[] = $TKT_ID;
1094
+					$all_tickets[] = $ticket;
1095
+				}
1096
+				// temporary cache of this ticket info for this datetime for later processing of datetime rows.
1097
+				$datetime_tickets[ $DTT_ID ][] = $ticket_row;
1098
+				// temporary cache of this datetime info for this ticket for later processing of ticket rows.
1099
+				if (
1100
+					! isset($ticket_datetimes[ $TKT_ID ])
1101
+					|| ! in_array($datetime_row, $ticket_datetimes[ $TKT_ID ], true)
1102
+				) {
1103
+					$ticket_datetimes[ $TKT_ID ][] = $datetime_row;
1104
+				}
1105
+			}
1106
+			$datetime_row++;
1107
+		}
1108
+		$main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
1109
+		$main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1110
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1111
+		// sort $all_tickets by order
1112
+		usort(
1113
+			$all_tickets,
1114
+			function (EE_Ticket $a, EE_Ticket $b) {
1115
+				$a_order = (int) $a->get('TKT_order');
1116
+				$b_order = (int) $b->get('TKT_order');
1117
+				if ($a_order === $b_order) {
1118
+					return 0;
1119
+				}
1120
+				return ($a_order < $b_order) ? -1 : 1;
1121
+			}
1122
+		);
1123
+		// k NOW we have all the data we need for setting up the dtt rows
1124
+		// and ticket rows so we start our dtt loop again.
1125
+		$datetime_row = 1;
1126
+		foreach ($datetimes as $datetime) {
1127
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row(
1128
+				$datetime_row,
1129
+				$datetime,
1130
+				$datetime_tickets,
1131
+				$all_tickets,
1132
+				false,
1133
+				$datetimes
1134
+			);
1135
+			$datetime_row++;
1136
+		}
1137
+		// then loop through all tickets for the ticket rows.
1138
+		$ticket_row = 1;
1139
+		foreach ($all_tickets as $ticket) {
1140
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row(
1141
+				$ticket_row,
1142
+				$ticket,
1143
+				$ticket_datetimes,
1144
+				$datetimes,
1145
+				false,
1146
+				$all_tickets
1147
+			);
1148
+			$ticket_row++;
1149
+		}
1150
+		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($datetimes, $all_tickets);
1151
+		EEH_Template::display_template(
1152
+			PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php',
1153
+			$main_template_args
1154
+		);
1155
+	}
1156 1156
 
1157 1157
 
1158
-    /**
1159
-     * @param int         $datetime_row
1160
-     * @param EE_Datetime $datetime
1161
-     * @param array       $datetime_tickets
1162
-     * @param array       $all_tickets
1163
-     * @param bool        $default
1164
-     * @param array       $all_datetimes
1165
-     * @return mixed
1166
-     * @throws DomainException
1167
-     * @throws EE_Error
1168
-     */
1169
-    protected function _get_datetime_row(
1170
-        $datetime_row,
1171
-        EE_Datetime $datetime,
1172
-        $datetime_tickets = array(),
1173
-        $all_tickets = array(),
1174
-        $default = false,
1175
-        $all_datetimes = array()
1176
-    ) {
1177
-        $dtt_display_template_args = array(
1178
-            'dtt_edit_row'             => $this->_get_dtt_edit_row(
1179
-                $datetime_row,
1180
-                $datetime,
1181
-                $default,
1182
-                $all_datetimes
1183
-            ),
1184
-            'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1185
-                $datetime_row,
1186
-                $datetime,
1187
-                $datetime_tickets,
1188
-                $all_tickets,
1189
-                $default
1190
-            ),
1191
-            'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1192
-        );
1193
-        return EEH_Template::display_template(
1194
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1195
-            $dtt_display_template_args,
1196
-            true
1197
-        );
1198
-    }
1158
+	/**
1159
+	 * @param int         $datetime_row
1160
+	 * @param EE_Datetime $datetime
1161
+	 * @param array       $datetime_tickets
1162
+	 * @param array       $all_tickets
1163
+	 * @param bool        $default
1164
+	 * @param array       $all_datetimes
1165
+	 * @return mixed
1166
+	 * @throws DomainException
1167
+	 * @throws EE_Error
1168
+	 */
1169
+	protected function _get_datetime_row(
1170
+		$datetime_row,
1171
+		EE_Datetime $datetime,
1172
+		$datetime_tickets = array(),
1173
+		$all_tickets = array(),
1174
+		$default = false,
1175
+		$all_datetimes = array()
1176
+	) {
1177
+		$dtt_display_template_args = array(
1178
+			'dtt_edit_row'             => $this->_get_dtt_edit_row(
1179
+				$datetime_row,
1180
+				$datetime,
1181
+				$default,
1182
+				$all_datetimes
1183
+			),
1184
+			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row(
1185
+				$datetime_row,
1186
+				$datetime,
1187
+				$datetime_tickets,
1188
+				$all_tickets,
1189
+				$default
1190
+			),
1191
+			'dtt_row'                  => $default ? 'DTTNUM' : $datetime_row,
1192
+		);
1193
+		return EEH_Template::display_template(
1194
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php',
1195
+			$dtt_display_template_args,
1196
+			true
1197
+		);
1198
+	}
1199 1199
 
1200 1200
 
1201
-    /**
1202
-     * This method is used to generate a dtt fields  edit row.
1203
-     * The same row is used to generate a row with valid DTT objects
1204
-     * and the default row that is used as the skeleton by the js.
1205
-     *
1206
-     * @param int           $datetime_row  The row number for the row being generated.
1207
-     * @param EE_Datetime   $datetime
1208
-     * @param bool          $default       Whether a default row is being generated or not.
1209
-     * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor.
1210
-     * @return string
1211
-     * @throws DomainException
1212
-     * @throws EE_Error
1213
-     */
1214
-    protected function _get_dtt_edit_row($datetime_row, $datetime, $default, $all_datetimes)
1215
-    {
1216
-        // if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1217
-        $default = ! $datetime instanceof EE_Datetime ? true : $default;
1218
-        $template_args = array(
1219
-            'dtt_row'              => $default ? 'DTTNUM' : $datetime_row,
1220
-            'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1221
-            'edit_dtt_expanded'    => '',
1222
-            'DTT_ID'               => $default ? '' : $datetime->ID(),
1223
-            'DTT_name'             => $default ? '' : $datetime->get_f('DTT_name'),
1224
-            'DTT_description'      => $default ? '' : $datetime->get_raw('DTT_description'),
1225
-            'DTT_EVT_start'        => $default ? '' : $datetime->start_date($this->_date_time_format),
1226
-            'DTT_EVT_end'          => $default ? '' : $datetime->end_date($this->_date_time_format),
1227
-            'DTT_reg_limit'        => $default
1228
-                ? ''
1229
-                : $datetime->get_pretty(
1230
-                    'DTT_reg_limit',
1231
-                    'input'
1232
-                ),
1233
-            'DTT_order'            => $default ? 'DTTNUM' : $datetime_row,
1234
-            'dtt_sold'             => $default ? '0' : $datetime->get('DTT_sold'),
1235
-            'dtt_reserved'         => $default ? '0' : $datetime->reserved(),
1236
-            'clone_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1237
-                ? ''
1238
-                : 'clone-icon ee-icon ee-icon-clone clickable',
1239
-            'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1240
-                ? 'ee-lock-icon'
1241
-                : 'trash-icon dashicons dashicons-post-trash clickable',
1242
-            'reg_list_url'         => $default || ! $datetime->event() instanceof \EE_Event
1243
-                ? ''
1244
-                : EE_Admin_Page::add_query_args_and_nonce(
1245
-                    array(
1246
-                        'event_id' => $datetime->event()->ID(),
1247
-                        'datetime_id' => $datetime->ID(),
1248
-                        'use_filters' => true
1249
-                    ),
1250
-                    REG_ADMIN_URL
1251
-                ),
1252
-        );
1253
-        $template_args['show_trash'] = count($all_datetimes) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1254
-            ? 'display:none'
1255
-            : '';
1256
-        // allow filtering of template args at this point.
1257
-        $template_args = apply_filters(
1258
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1259
-            $template_args,
1260
-            $datetime_row,
1261
-            $datetime,
1262
-            $default,
1263
-            $all_datetimes,
1264
-            $this->_is_creating_event
1265
-        );
1266
-        return EEH_Template::display_template(
1267
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1268
-            $template_args,
1269
-            true
1270
-        );
1271
-    }
1201
+	/**
1202
+	 * This method is used to generate a dtt fields  edit row.
1203
+	 * The same row is used to generate a row with valid DTT objects
1204
+	 * and the default row that is used as the skeleton by the js.
1205
+	 *
1206
+	 * @param int           $datetime_row  The row number for the row being generated.
1207
+	 * @param EE_Datetime   $datetime
1208
+	 * @param bool          $default       Whether a default row is being generated or not.
1209
+	 * @param EE_Datetime[] $all_datetimes This is the array of all datetimes used in the editor.
1210
+	 * @return string
1211
+	 * @throws DomainException
1212
+	 * @throws EE_Error
1213
+	 */
1214
+	protected function _get_dtt_edit_row($datetime_row, $datetime, $default, $all_datetimes)
1215
+	{
1216
+		// if the incoming $datetime object is NOT an instance of EE_Datetime then force default to true.
1217
+		$default = ! $datetime instanceof EE_Datetime ? true : $default;
1218
+		$template_args = array(
1219
+			'dtt_row'              => $default ? 'DTTNUM' : $datetime_row,
1220
+			'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1221
+			'edit_dtt_expanded'    => '',
1222
+			'DTT_ID'               => $default ? '' : $datetime->ID(),
1223
+			'DTT_name'             => $default ? '' : $datetime->get_f('DTT_name'),
1224
+			'DTT_description'      => $default ? '' : $datetime->get_raw('DTT_description'),
1225
+			'DTT_EVT_start'        => $default ? '' : $datetime->start_date($this->_date_time_format),
1226
+			'DTT_EVT_end'          => $default ? '' : $datetime->end_date($this->_date_time_format),
1227
+			'DTT_reg_limit'        => $default
1228
+				? ''
1229
+				: $datetime->get_pretty(
1230
+					'DTT_reg_limit',
1231
+					'input'
1232
+				),
1233
+			'DTT_order'            => $default ? 'DTTNUM' : $datetime_row,
1234
+			'dtt_sold'             => $default ? '0' : $datetime->get('DTT_sold'),
1235
+			'dtt_reserved'         => $default ? '0' : $datetime->reserved(),
1236
+			'clone_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1237
+				? ''
1238
+				: 'clone-icon ee-icon ee-icon-clone clickable',
1239
+			'trash_icon'           => ! empty($datetime) && $datetime->get('DTT_sold') > 0
1240
+				? 'ee-lock-icon'
1241
+				: 'trash-icon dashicons dashicons-post-trash clickable',
1242
+			'reg_list_url'         => $default || ! $datetime->event() instanceof \EE_Event
1243
+				? ''
1244
+				: EE_Admin_Page::add_query_args_and_nonce(
1245
+					array(
1246
+						'event_id' => $datetime->event()->ID(),
1247
+						'datetime_id' => $datetime->ID(),
1248
+						'use_filters' => true
1249
+					),
1250
+					REG_ADMIN_URL
1251
+				),
1252
+		);
1253
+		$template_args['show_trash'] = count($all_datetimes) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1254
+			? 'display:none'
1255
+			: '';
1256
+		// allow filtering of template args at this point.
1257
+		$template_args = apply_filters(
1258
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args',
1259
+			$template_args,
1260
+			$datetime_row,
1261
+			$datetime,
1262
+			$default,
1263
+			$all_datetimes,
1264
+			$this->_is_creating_event
1265
+		);
1266
+		return EEH_Template::display_template(
1267
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php',
1268
+			$template_args,
1269
+			true
1270
+		);
1271
+	}
1272 1272
 
1273 1273
 
1274
-    /**
1275
-     * @param int         $datetime_row
1276
-     * @param EE_Datetime $datetime
1277
-     * @param array       $datetime_tickets
1278
-     * @param array       $all_tickets
1279
-     * @param bool       $default
1280
-     * @return mixed
1281
-     * @throws DomainException
1282
-     * @throws EE_Error
1283
-     */
1284
-    protected function _get_dtt_attached_tickets_row(
1285
-        $datetime_row,
1286
-        $datetime,
1287
-        $datetime_tickets = array(),
1288
-        $all_tickets = array(),
1289
-        $default = false
1290
-    ) {
1291
-        $template_args = array(
1292
-            'dtt_row'                           => $default ? 'DTTNUM' : $datetime_row,
1293
-            'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1294
-            'DTT_description'                   => $default ? '' : $datetime->get_raw('DTT_description'),
1295
-            'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1296
-            'show_tickets_row'                  => 'display:none;',
1297
-            'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1298
-                'add_new_ticket_via_datetime',
1299
-                $this->_adminpage_obj->page_slug,
1300
-                $this->_adminpage_obj->get_req_action(),
1301
-                false,
1302
-                false
1303
-            ),
1304
-            // todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1305
-            'DTT_ID'                            => $default ? '' : $datetime->ID(),
1306
-        );
1307
-        // need to setup the list items (but only if this isn't a default skeleton setup)
1308
-        if (! $default) {
1309
-            $ticket_row = 1;
1310
-            foreach ($all_tickets as $ticket) {
1311
-                $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1312
-                    $datetime_row,
1313
-                    $ticket_row,
1314
-                    $datetime,
1315
-                    $ticket,
1316
-                    $datetime_tickets,
1317
-                    $default
1318
-                );
1319
-                $ticket_row++;
1320
-            }
1321
-        }
1322
-        // filter template args at this point
1323
-        $template_args = apply_filters(
1324
-            'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1325
-            $template_args,
1326
-            $datetime_row,
1327
-            $datetime,
1328
-            $datetime_tickets,
1329
-            $all_tickets,
1330
-            $default,
1331
-            $this->_is_creating_event
1332
-        );
1333
-        return EEH_Template::display_template(
1334
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1335
-            $template_args,
1336
-            true
1337
-        );
1338
-    }
1274
+	/**
1275
+	 * @param int         $datetime_row
1276
+	 * @param EE_Datetime $datetime
1277
+	 * @param array       $datetime_tickets
1278
+	 * @param array       $all_tickets
1279
+	 * @param bool       $default
1280
+	 * @return mixed
1281
+	 * @throws DomainException
1282
+	 * @throws EE_Error
1283
+	 */
1284
+	protected function _get_dtt_attached_tickets_row(
1285
+		$datetime_row,
1286
+		$datetime,
1287
+		$datetime_tickets = array(),
1288
+		$all_tickets = array(),
1289
+		$default = false
1290
+	) {
1291
+		$template_args = array(
1292
+			'dtt_row'                           => $default ? 'DTTNUM' : $datetime_row,
1293
+			'event_datetimes_name'              => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
1294
+			'DTT_description'                   => $default ? '' : $datetime->get_raw('DTT_description'),
1295
+			'datetime_tickets_list'             => $default ? '<li class="hidden"></li>' : '',
1296
+			'show_tickets_row'                  => 'display:none;',
1297
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link(
1298
+				'add_new_ticket_via_datetime',
1299
+				$this->_adminpage_obj->page_slug,
1300
+				$this->_adminpage_obj->get_req_action(),
1301
+				false,
1302
+				false
1303
+			),
1304
+			// todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
1305
+			'DTT_ID'                            => $default ? '' : $datetime->ID(),
1306
+		);
1307
+		// need to setup the list items (but only if this isn't a default skeleton setup)
1308
+		if (! $default) {
1309
+			$ticket_row = 1;
1310
+			foreach ($all_tickets as $ticket) {
1311
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
1312
+					$datetime_row,
1313
+					$ticket_row,
1314
+					$datetime,
1315
+					$ticket,
1316
+					$datetime_tickets,
1317
+					$default
1318
+				);
1319
+				$ticket_row++;
1320
+			}
1321
+		}
1322
+		// filter template args at this point
1323
+		$template_args = apply_filters(
1324
+			'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args',
1325
+			$template_args,
1326
+			$datetime_row,
1327
+			$datetime,
1328
+			$datetime_tickets,
1329
+			$all_tickets,
1330
+			$default,
1331
+			$this->_is_creating_event
1332
+		);
1333
+		return EEH_Template::display_template(
1334
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php',
1335
+			$template_args,
1336
+			true
1337
+		);
1338
+	}
1339 1339
 
1340 1340
 
1341
-    /**
1342
-     * @param int         $datetime_row
1343
-     * @param int         $ticket_row
1344
-     * @param EE_Datetime $datetime
1345
-     * @param EE_Ticket   $ticket
1346
-     * @param array       $datetime_tickets
1347
-     * @param bool        $default
1348
-     * @return mixed
1349
-     * @throws DomainException
1350
-     * @throws EE_Error
1351
-     */
1352
-    protected function _get_datetime_tickets_list_item(
1353
-        $datetime_row,
1354
-        $ticket_row,
1355
-        $datetime,
1356
-        $ticket,
1357
-        $datetime_tickets = array(),
1358
-        $default = false
1359
-    ) {
1360
-        $dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1361
-            ? $datetime_tickets[ $datetime->ID() ]
1362
-            : array();
1363
-        $display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1364
-        $no_ticket = $default && empty($ticket);
1365
-        $template_args = array(
1366
-            'dtt_row'                 => $default
1367
-                ? 'DTTNUM'
1368
-                : $datetime_row,
1369
-            'tkt_row'                 => $no_ticket
1370
-                ? 'TICKETNUM'
1371
-                : $ticket_row,
1372
-            'datetime_ticket_checked' => in_array($display_row, $dtt_tkts, true)
1373
-                ? ' checked'
1374
-                : '',
1375
-            'ticket_selected'         => in_array($display_row, $dtt_tkts, true)
1376
-                ? ' ticket-selected'
1377
-                : '',
1378
-            'TKT_name'                => $no_ticket
1379
-                ? 'TKTNAME'
1380
-                : $ticket->get('TKT_name'),
1381
-            'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1382
-                ? ' tkt-status-' . EE_Ticket::onsale
1383
-                : ' tkt-status-' . $ticket->ticket_status(),
1384
-        );
1385
-        // filter template args
1386
-        $template_args = apply_filters(
1387
-            'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1388
-            $template_args,
1389
-            $datetime_row,
1390
-            $ticket_row,
1391
-            $datetime,
1392
-            $ticket,
1393
-            $datetime_tickets,
1394
-            $default,
1395
-            $this->_is_creating_event
1396
-        );
1397
-        return EEH_Template::display_template(
1398
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1399
-            $template_args,
1400
-            true
1401
-        );
1402
-    }
1341
+	/**
1342
+	 * @param int         $datetime_row
1343
+	 * @param int         $ticket_row
1344
+	 * @param EE_Datetime $datetime
1345
+	 * @param EE_Ticket   $ticket
1346
+	 * @param array       $datetime_tickets
1347
+	 * @param bool        $default
1348
+	 * @return mixed
1349
+	 * @throws DomainException
1350
+	 * @throws EE_Error
1351
+	 */
1352
+	protected function _get_datetime_tickets_list_item(
1353
+		$datetime_row,
1354
+		$ticket_row,
1355
+		$datetime,
1356
+		$ticket,
1357
+		$datetime_tickets = array(),
1358
+		$default = false
1359
+	) {
1360
+		$dtt_tkts = $datetime instanceof EE_Datetime && isset($datetime_tickets[ $datetime->ID() ])
1361
+			? $datetime_tickets[ $datetime->ID() ]
1362
+			: array();
1363
+		$display_row = $ticket instanceof EE_Ticket ? $ticket->get('TKT_row') : 0;
1364
+		$no_ticket = $default && empty($ticket);
1365
+		$template_args = array(
1366
+			'dtt_row'                 => $default
1367
+				? 'DTTNUM'
1368
+				: $datetime_row,
1369
+			'tkt_row'                 => $no_ticket
1370
+				? 'TICKETNUM'
1371
+				: $ticket_row,
1372
+			'datetime_ticket_checked' => in_array($display_row, $dtt_tkts, true)
1373
+				? ' checked'
1374
+				: '',
1375
+			'ticket_selected'         => in_array($display_row, $dtt_tkts, true)
1376
+				? ' ticket-selected'
1377
+				: '',
1378
+			'TKT_name'                => $no_ticket
1379
+				? 'TKTNAME'
1380
+				: $ticket->get('TKT_name'),
1381
+			'tkt_status_class'        => $no_ticket || $this->_is_creating_event
1382
+				? ' tkt-status-' . EE_Ticket::onsale
1383
+				: ' tkt-status-' . $ticket->ticket_status(),
1384
+		);
1385
+		// filter template args
1386
+		$template_args = apply_filters(
1387
+			'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args',
1388
+			$template_args,
1389
+			$datetime_row,
1390
+			$ticket_row,
1391
+			$datetime,
1392
+			$ticket,
1393
+			$datetime_tickets,
1394
+			$default,
1395
+			$this->_is_creating_event
1396
+		);
1397
+		return EEH_Template::display_template(
1398
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php',
1399
+			$template_args,
1400
+			true
1401
+		);
1402
+	}
1403 1403
 
1404 1404
 
1405
-    /**
1406
-     * This generates the ticket row for tickets.
1407
-     * This same method is used to generate both the actual rows and the js skeleton row
1408
-     * (when default === true)
1409
-     *
1410
-     * @param int           $ticket_row       Represents the row number being generated.
1411
-     * @param               $ticket
1412
-     * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1413
-     *                                        or empty for default
1414
-     * @param EE_Datetime[] $all_datetimes    All Datetimes on the event or empty for default.
1415
-     * @param bool          $default          Whether default row being generated or not.
1416
-     * @param EE_Ticket[]   $all_tickets      This is an array of all tickets attached to the event
1417
-     *                                        (or empty in the case of defaults)
1418
-     * @return mixed
1419
-     * @throws InvalidArgumentException
1420
-     * @throws InvalidInterfaceException
1421
-     * @throws InvalidDataTypeException
1422
-     * @throws DomainException
1423
-     * @throws EE_Error
1424
-     * @throws ReflectionException
1425
-     */
1426
-    protected function _get_ticket_row(
1427
-        $ticket_row,
1428
-        $ticket,
1429
-        $ticket_datetimes,
1430
-        $all_datetimes,
1431
-        $default = false,
1432
-        $all_tickets = array()
1433
-    ) {
1434
-        // if $ticket is not an instance of EE_Ticket then force default to true.
1435
-        $default = ! $ticket instanceof EE_Ticket ? true : $default;
1436
-        $prices = ! empty($ticket) && ! $default
1437
-            ? $ticket->get_many_related(
1438
-                'Price',
1439
-                array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))
1440
-            )
1441
-            : array();
1442
-        // if there is only one price (which would be the base price)
1443
-        // or NO prices and this ticket is a default ticket,
1444
-        // let's just make sure there are no cached default prices on the object.
1445
-        // This is done by not including any query_params.
1446
-        if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1447
-            $prices = $ticket->prices();
1448
-        }
1449
-        // check if we're dealing with a default ticket in which case
1450
-        // we don't want any starting_ticket_datetime_row values set
1451
-        // (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1452
-        // This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1453
-        $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1454
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1455
-            ? $ticket_datetimes[ $ticket->ID() ]
1456
-            : array();
1457
-        $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1458
-        $base_price = $default ? null : $ticket->base_price();
1459
-        $count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1460
-        // breaking out complicated condition for ticket_status
1461
-        if ($default) {
1462
-            $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1463
-        } else {
1464
-            $ticket_status_class = $ticket->is_default()
1465
-                ? ' tkt-status-' . EE_Ticket::onsale
1466
-                : ' tkt-status-' . $ticket->ticket_status();
1467
-        }
1468
-        // breaking out complicated condition for TKT_taxable
1469
-        if ($default) {
1470
-            $TKT_taxable = '';
1471
-        } else {
1472
-            $TKT_taxable = $ticket->taxable()
1473
-                ? 'checked'
1474
-                : '';
1475
-        }
1476
-        if ($default) {
1477
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1478
-        } elseif ($ticket->is_default()) {
1479
-            $TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1480
-        } else {
1481
-            $TKT_status = $ticket->ticket_status(true);
1482
-        }
1483
-        if ($default) {
1484
-            $TKT_min = '';
1485
-        } else {
1486
-            $TKT_min = $ticket->min();
1487
-            if ($TKT_min === -1 || $TKT_min === 0) {
1488
-                $TKT_min = '';
1489
-            }
1490
-        }
1491
-        $template_args = array(
1492
-            'tkt_row'                       => $default ? 'TICKETNUM' : $ticket_row,
1493
-            'TKT_order'                     => $default ? 'TICKETNUM' : $ticket_row,
1494
-            // on initial page load this will always be the correct order.
1495
-            'tkt_status_class'              => $ticket_status_class,
1496
-            'display_edit_tkt_row'          => 'display:none;',
1497
-            'edit_tkt_expanded'             => '',
1498
-            'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1499
-            'TKT_name'                      => $default ? '' : $ticket->get_f('TKT_name'),
1500
-            'TKT_start_date'                => $default
1501
-                ? ''
1502
-                : $ticket->get_date('TKT_start_date', $this->_date_time_format),
1503
-            'TKT_end_date'                  => $default
1504
-                ? ''
1505
-                : $ticket->get_date('TKT_end_date', $this->_date_time_format),
1506
-            'TKT_status'                    => $TKT_status,
1507
-            'TKT_price'                     => $default
1508
-                ? ''
1509
-                : EEH_Template::format_currency(
1510
-                    $ticket->get_ticket_total_with_taxes(),
1511
-                    false,
1512
-                    false
1513
-                ),
1514
-            'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1515
-            'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1516
-            'TKT_qty'                       => $default
1517
-                ? ''
1518
-                : $ticket->get_pretty('TKT_qty', 'symbol'),
1519
-            'TKT_qty_for_input'             => $default
1520
-                ? ''
1521
-                : $ticket->get_pretty('TKT_qty', 'input'),
1522
-            'TKT_uses'                      => $default
1523
-                ? ''
1524
-                : $ticket->get_pretty('TKT_uses', 'input'),
1525
-            'TKT_min'                       => $TKT_min,
1526
-            'TKT_max'                       => $default
1527
-                ? ''
1528
-                : $ticket->get_pretty('TKT_max', 'input'),
1529
-            'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1530
-            'TKT_reserved'                  => $default ? 0 : $ticket->reserved(),
1531
-            'TKT_registrations'             => $default
1532
-                ? 0
1533
-                : $ticket->count_registrations(
1534
-                    array(
1535
-                        array(
1536
-                            'STS_ID' => array(
1537
-                                '!=',
1538
-                                EEM_Registration::status_id_incomplete,
1539
-                            ),
1540
-                        ),
1541
-                    )
1542
-                ),
1543
-            'TKT_ID'                        => $default ? 0 : $ticket->ID(),
1544
-            'TKT_description'               => $default ? '' : $ticket->get_raw('TKT_description'),
1545
-            'TKT_is_default'                => $default ? 0 : $ticket->is_default(),
1546
-            'TKT_required'                  => $default ? 0 : $ticket->required(),
1547
-            'TKT_is_default_selector'       => '',
1548
-            'ticket_price_rows'             => '',
1549
-            'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1550
-                ? ''
1551
-                : $base_price->get_pretty('PRC_amount', 'localized_float'),
1552
-            'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1553
-            'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1554
-                ? ''
1555
-                : 'display:none;',
1556
-            'show_price_mod_button'         => count($prices) > 1
1557
-                                               || ($default && $count_price_mods > 0)
1558
-                                               || (! $default && $ticket->deleted())
1559
-                ? 'display:none;'
1560
-                : '',
1561
-            'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1562
-            'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1563
-            'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_datetimes),
1564
-            'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_datetimes),
1565
-            'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1566
-            'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1567
-            'TKT_taxable'                   => $TKT_taxable,
1568
-            'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1569
-                ? ''
1570
-                : 'display:none;',
1571
-            'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1572
-            'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1573
-                $ticket_subtotal,
1574
-                false,
1575
-                false
1576
-            ),
1577
-            'TKT_subtotal_amount'           => $ticket_subtotal,
1578
-            'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1579
-            'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1580
-            'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1581
-                ? ' ticket-archived'
1582
-                : '',
1583
-            'trash_icon'                    => $ticket instanceof EE_Ticket
1584
-                                               && $ticket->deleted()
1585
-                                               && ! $ticket->is_permanently_deleteable()
1586
-                ? 'ee-lock-icon '
1587
-                : 'trash-icon dashicons dashicons-post-trash clickable',
1588
-            'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->deleted()
1589
-                ? ''
1590
-                : 'clone-icon ee-icon ee-icon-clone clickable',
1591
-        );
1592
-        $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1593
-            ? 'display:none'
1594
-            : '';
1595
-        // handle rows that should NOT be empty
1596
-        if (empty($template_args['TKT_start_date'])) {
1597
-            // if empty then the start date will be now.
1598
-            $template_args['TKT_start_date'] = date(
1599
-                $this->_date_time_format,
1600
-                current_time('timestamp')
1601
-            );
1602
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1603
-        }
1604
-        if (empty($template_args['TKT_end_date'])) {
1605
-            // get the earliest datetime (if present);
1606
-            $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1607
-                ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1608
-                    'Datetime',
1609
-                    array('order_by' => array('DTT_EVT_start' => 'ASC'))
1610
-                )
1611
-                : null;
1612
-            if (! empty($earliest_dtt)) {
1613
-                $template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1614
-                    'DTT_EVT_start',
1615
-                    $this->_date_time_format
1616
-                );
1617
-            } else {
1618
-                // default so let's just use what's been set for the default date-time which is 30 days from now.
1619
-                $template_args['TKT_end_date'] = date(
1620
-                    $this->_date_time_format,
1621
-                    mktime(
1622
-                        24,
1623
-                        0,
1624
-                        0,
1625
-                        date('m'),
1626
-                        date('d') + 29,
1627
-                        date('Y')
1628
-                    )
1629
-                );
1630
-            }
1631
-            $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1632
-        }
1633
-        // generate ticket_datetime items
1634
-        if (! $default) {
1635
-            $datetime_row = 1;
1636
-            foreach ($all_datetimes as $datetime) {
1637
-                $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1638
-                    $datetime_row,
1639
-                    $ticket_row,
1640
-                    $datetime,
1641
-                    $ticket,
1642
-                    $ticket_datetimes,
1643
-                    $default
1644
-                );
1645
-                $datetime_row++;
1646
-            }
1647
-        }
1648
-        $price_row = 1;
1649
-        foreach ($prices as $price) {
1650
-            if (! $price instanceof EE_Price) {
1651
-                continue;
1652
-            }
1653
-            if ($price->is_base_price()) {
1654
-                $price_row++;
1655
-                continue;
1656
-            }
1657
-            $show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1658
-            $show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1659
-            $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1660
-                $ticket_row,
1661
-                $price_row,
1662
-                $price,
1663
-                $default,
1664
-                $ticket,
1665
-                $show_trash,
1666
-                $show_create
1667
-            );
1668
-            $price_row++;
1669
-        }
1670
-        // filter $template_args
1671
-        $template_args = apply_filters(
1672
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1673
-            $template_args,
1674
-            $ticket_row,
1675
-            $ticket,
1676
-            $ticket_datetimes,
1677
-            $all_datetimes,
1678
-            $default,
1679
-            $all_tickets,
1680
-            $this->_is_creating_event
1681
-        );
1682
-        return EEH_Template::display_template(
1683
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1684
-            $template_args,
1685
-            true
1686
-        );
1687
-    }
1405
+	/**
1406
+	 * This generates the ticket row for tickets.
1407
+	 * This same method is used to generate both the actual rows and the js skeleton row
1408
+	 * (when default === true)
1409
+	 *
1410
+	 * @param int           $ticket_row       Represents the row number being generated.
1411
+	 * @param               $ticket
1412
+	 * @param EE_Datetime[] $ticket_datetimes Either an array of all datetimes on all tickets indexed by each ticket
1413
+	 *                                        or empty for default
1414
+	 * @param EE_Datetime[] $all_datetimes    All Datetimes on the event or empty for default.
1415
+	 * @param bool          $default          Whether default row being generated or not.
1416
+	 * @param EE_Ticket[]   $all_tickets      This is an array of all tickets attached to the event
1417
+	 *                                        (or empty in the case of defaults)
1418
+	 * @return mixed
1419
+	 * @throws InvalidArgumentException
1420
+	 * @throws InvalidInterfaceException
1421
+	 * @throws InvalidDataTypeException
1422
+	 * @throws DomainException
1423
+	 * @throws EE_Error
1424
+	 * @throws ReflectionException
1425
+	 */
1426
+	protected function _get_ticket_row(
1427
+		$ticket_row,
1428
+		$ticket,
1429
+		$ticket_datetimes,
1430
+		$all_datetimes,
1431
+		$default = false,
1432
+		$all_tickets = array()
1433
+	) {
1434
+		// if $ticket is not an instance of EE_Ticket then force default to true.
1435
+		$default = ! $ticket instanceof EE_Ticket ? true : $default;
1436
+		$prices = ! empty($ticket) && ! $default
1437
+			? $ticket->get_many_related(
1438
+				'Price',
1439
+				array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))
1440
+			)
1441
+			: array();
1442
+		// if there is only one price (which would be the base price)
1443
+		// or NO prices and this ticket is a default ticket,
1444
+		// let's just make sure there are no cached default prices on the object.
1445
+		// This is done by not including any query_params.
1446
+		if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1447
+			$prices = $ticket->prices();
1448
+		}
1449
+		// check if we're dealing with a default ticket in which case
1450
+		// we don't want any starting_ticket_datetime_row values set
1451
+		// (otherwise there won't be any new relationships created for tickets based off of the default ticket).
1452
+		// This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1453
+		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->is_default());
1454
+		$tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
1455
+			? $ticket_datetimes[ $ticket->ID() ]
1456
+			: array();
1457
+		$ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1458
+		$base_price = $default ? null : $ticket->base_price();
1459
+		$count_price_mods = EEM_Price::instance()->get_all_default_prices(true);
1460
+		// breaking out complicated condition for ticket_status
1461
+		if ($default) {
1462
+			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1463
+		} else {
1464
+			$ticket_status_class = $ticket->is_default()
1465
+				? ' tkt-status-' . EE_Ticket::onsale
1466
+				: ' tkt-status-' . $ticket->ticket_status();
1467
+		}
1468
+		// breaking out complicated condition for TKT_taxable
1469
+		if ($default) {
1470
+			$TKT_taxable = '';
1471
+		} else {
1472
+			$TKT_taxable = $ticket->taxable()
1473
+				? 'checked'
1474
+				: '';
1475
+		}
1476
+		if ($default) {
1477
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1478
+		} elseif ($ticket->is_default()) {
1479
+			$TKT_status = EEH_Template::pretty_status(EE_Ticket::onsale, false, 'sentence');
1480
+		} else {
1481
+			$TKT_status = $ticket->ticket_status(true);
1482
+		}
1483
+		if ($default) {
1484
+			$TKT_min = '';
1485
+		} else {
1486
+			$TKT_min = $ticket->min();
1487
+			if ($TKT_min === -1 || $TKT_min === 0) {
1488
+				$TKT_min = '';
1489
+			}
1490
+		}
1491
+		$template_args = array(
1492
+			'tkt_row'                       => $default ? 'TICKETNUM' : $ticket_row,
1493
+			'TKT_order'                     => $default ? 'TICKETNUM' : $ticket_row,
1494
+			// on initial page load this will always be the correct order.
1495
+			'tkt_status_class'              => $ticket_status_class,
1496
+			'display_edit_tkt_row'          => 'display:none;',
1497
+			'edit_tkt_expanded'             => '',
1498
+			'edit_tickets_name'             => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1499
+			'TKT_name'                      => $default ? '' : $ticket->get_f('TKT_name'),
1500
+			'TKT_start_date'                => $default
1501
+				? ''
1502
+				: $ticket->get_date('TKT_start_date', $this->_date_time_format),
1503
+			'TKT_end_date'                  => $default
1504
+				? ''
1505
+				: $ticket->get_date('TKT_end_date', $this->_date_time_format),
1506
+			'TKT_status'                    => $TKT_status,
1507
+			'TKT_price'                     => $default
1508
+				? ''
1509
+				: EEH_Template::format_currency(
1510
+					$ticket->get_ticket_total_with_taxes(),
1511
+					false,
1512
+					false
1513
+				),
1514
+			'TKT_price_code'                => EE_Registry::instance()->CFG->currency->code,
1515
+			'TKT_price_amount'              => $default ? 0 : $ticket_subtotal,
1516
+			'TKT_qty'                       => $default
1517
+				? ''
1518
+				: $ticket->get_pretty('TKT_qty', 'symbol'),
1519
+			'TKT_qty_for_input'             => $default
1520
+				? ''
1521
+				: $ticket->get_pretty('TKT_qty', 'input'),
1522
+			'TKT_uses'                      => $default
1523
+				? ''
1524
+				: $ticket->get_pretty('TKT_uses', 'input'),
1525
+			'TKT_min'                       => $TKT_min,
1526
+			'TKT_max'                       => $default
1527
+				? ''
1528
+				: $ticket->get_pretty('TKT_max', 'input'),
1529
+			'TKT_sold'                      => $default ? 0 : $ticket->tickets_sold('ticket'),
1530
+			'TKT_reserved'                  => $default ? 0 : $ticket->reserved(),
1531
+			'TKT_registrations'             => $default
1532
+				? 0
1533
+				: $ticket->count_registrations(
1534
+					array(
1535
+						array(
1536
+							'STS_ID' => array(
1537
+								'!=',
1538
+								EEM_Registration::status_id_incomplete,
1539
+							),
1540
+						),
1541
+					)
1542
+				),
1543
+			'TKT_ID'                        => $default ? 0 : $ticket->ID(),
1544
+			'TKT_description'               => $default ? '' : $ticket->get_raw('TKT_description'),
1545
+			'TKT_is_default'                => $default ? 0 : $ticket->is_default(),
1546
+			'TKT_required'                  => $default ? 0 : $ticket->required(),
1547
+			'TKT_is_default_selector'       => '',
1548
+			'ticket_price_rows'             => '',
1549
+			'TKT_base_price'                => $default || ! $base_price instanceof EE_Price
1550
+				? ''
1551
+				: $base_price->get_pretty('PRC_amount', 'localized_float'),
1552
+			'TKT_base_price_ID'             => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1553
+			'show_price_modifier'           => count($prices) > 1 || ($default && $count_price_mods > 0)
1554
+				? ''
1555
+				: 'display:none;',
1556
+			'show_price_mod_button'         => count($prices) > 1
1557
+											   || ($default && $count_price_mods > 0)
1558
+											   || (! $default && $ticket->deleted())
1559
+				? 'display:none;'
1560
+				: '',
1561
+			'total_price_rows'              => count($prices) > 1 ? count($prices) : 1,
1562
+			'ticket_datetimes_list'         => $default ? '<li class="hidden"></li>' : '',
1563
+			'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_datetimes),
1564
+			'ticket_datetime_rows'          => $default ? '' : implode(',', $tkt_datetimes),
1565
+			'existing_ticket_price_ids'     => $default ? '' : implode(',', array_keys($prices)),
1566
+			'ticket_template_id'            => $default ? 0 : $ticket->get('TTM_ID'),
1567
+			'TKT_taxable'                   => $TKT_taxable,
1568
+			'display_subtotal'              => $ticket instanceof EE_Ticket && $ticket->taxable()
1569
+				? ''
1570
+				: 'display:none;',
1571
+			'price_currency_symbol'         => EE_Registry::instance()->CFG->currency->sign,
1572
+			'TKT_subtotal_amount_display'   => EEH_Template::format_currency(
1573
+				$ticket_subtotal,
1574
+				false,
1575
+				false
1576
+			),
1577
+			'TKT_subtotal_amount'           => $ticket_subtotal,
1578
+			'tax_rows'                      => $this->_get_tax_rows($ticket_row, $ticket),
1579
+			'disabled'                      => $ticket instanceof EE_Ticket && $ticket->deleted(),
1580
+			'ticket_archive_class'          => $ticket instanceof EE_Ticket && $ticket->deleted()
1581
+				? ' ticket-archived'
1582
+				: '',
1583
+			'trash_icon'                    => $ticket instanceof EE_Ticket
1584
+											   && $ticket->deleted()
1585
+											   && ! $ticket->is_permanently_deleteable()
1586
+				? 'ee-lock-icon '
1587
+				: 'trash-icon dashicons dashicons-post-trash clickable',
1588
+			'clone_icon'                    => $ticket instanceof EE_Ticket && $ticket->deleted()
1589
+				? ''
1590
+				: 'clone-icon ee-icon ee-icon-clone clickable',
1591
+		);
1592
+		$template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon'
1593
+			? 'display:none'
1594
+			: '';
1595
+		// handle rows that should NOT be empty
1596
+		if (empty($template_args['TKT_start_date'])) {
1597
+			// if empty then the start date will be now.
1598
+			$template_args['TKT_start_date'] = date(
1599
+				$this->_date_time_format,
1600
+				current_time('timestamp')
1601
+			);
1602
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1603
+		}
1604
+		if (empty($template_args['TKT_end_date'])) {
1605
+			// get the earliest datetime (if present);
1606
+			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0
1607
+				? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related(
1608
+					'Datetime',
1609
+					array('order_by' => array('DTT_EVT_start' => 'ASC'))
1610
+				)
1611
+				: null;
1612
+			if (! empty($earliest_dtt)) {
1613
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime(
1614
+					'DTT_EVT_start',
1615
+					$this->_date_time_format
1616
+				);
1617
+			} else {
1618
+				// default so let's just use what's been set for the default date-time which is 30 days from now.
1619
+				$template_args['TKT_end_date'] = date(
1620
+					$this->_date_time_format,
1621
+					mktime(
1622
+						24,
1623
+						0,
1624
+						0,
1625
+						date('m'),
1626
+						date('d') + 29,
1627
+						date('Y')
1628
+					)
1629
+				);
1630
+			}
1631
+			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1632
+		}
1633
+		// generate ticket_datetime items
1634
+		if (! $default) {
1635
+			$datetime_row = 1;
1636
+			foreach ($all_datetimes as $datetime) {
1637
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
1638
+					$datetime_row,
1639
+					$ticket_row,
1640
+					$datetime,
1641
+					$ticket,
1642
+					$ticket_datetimes,
1643
+					$default
1644
+				);
1645
+				$datetime_row++;
1646
+			}
1647
+		}
1648
+		$price_row = 1;
1649
+		foreach ($prices as $price) {
1650
+			if (! $price instanceof EE_Price) {
1651
+				continue;
1652
+			}
1653
+			if ($price->is_base_price()) {
1654
+				$price_row++;
1655
+				continue;
1656
+			}
1657
+			$show_trash = ! ((count($prices) > 1 && $price_row === 1) || count($prices) === 1);
1658
+			$show_create = ! (count($prices) > 1 && count($prices) !== $price_row);
1659
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row(
1660
+				$ticket_row,
1661
+				$price_row,
1662
+				$price,
1663
+				$default,
1664
+				$ticket,
1665
+				$show_trash,
1666
+				$show_create
1667
+			);
1668
+			$price_row++;
1669
+		}
1670
+		// filter $template_args
1671
+		$template_args = apply_filters(
1672
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args',
1673
+			$template_args,
1674
+			$ticket_row,
1675
+			$ticket,
1676
+			$ticket_datetimes,
1677
+			$all_datetimes,
1678
+			$default,
1679
+			$all_tickets,
1680
+			$this->_is_creating_event
1681
+		);
1682
+		return EEH_Template::display_template(
1683
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php',
1684
+			$template_args,
1685
+			true
1686
+		);
1687
+	}
1688 1688
 
1689 1689
 
1690
-    /**
1691
-     * @param int            $ticket_row
1692
-     * @param EE_Ticket|null $ticket
1693
-     * @return string
1694
-     * @throws DomainException
1695
-     * @throws EE_Error
1696
-     */
1697
-    protected function _get_tax_rows($ticket_row, $ticket)
1698
-    {
1699
-        $tax_rows = '';
1700
-        /** @var EE_Price[] $taxes */
1701
-        $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1702
-        foreach ($taxes as $tax) {
1703
-            $tax_added = $this->_get_tax_added($tax, $ticket);
1704
-            $template_args = array(
1705
-                'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1706
-                    ? ''
1707
-                    : 'display:none;',
1708
-                'tax_id'            => $tax->ID(),
1709
-                'tkt_row'           => $ticket_row,
1710
-                'tax_label'         => $tax->get('PRC_name'),
1711
-                'tax_added'         => $tax_added,
1712
-                'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1713
-                'tax_amount'        => $tax->get('PRC_amount'),
1714
-            );
1715
-            $template_args = apply_filters(
1716
-                'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1717
-                $template_args,
1718
-                $ticket_row,
1719
-                $ticket,
1720
-                $this->_is_creating_event
1721
-            );
1722
-            $tax_rows .= EEH_Template::display_template(
1723
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1724
-                $template_args,
1725
-                true
1726
-            );
1727
-        }
1728
-        return $tax_rows;
1729
-    }
1690
+	/**
1691
+	 * @param int            $ticket_row
1692
+	 * @param EE_Ticket|null $ticket
1693
+	 * @return string
1694
+	 * @throws DomainException
1695
+	 * @throws EE_Error
1696
+	 */
1697
+	protected function _get_tax_rows($ticket_row, $ticket)
1698
+	{
1699
+		$tax_rows = '';
1700
+		/** @var EE_Price[] $taxes */
1701
+		$taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1702
+		foreach ($taxes as $tax) {
1703
+			$tax_added = $this->_get_tax_added($tax, $ticket);
1704
+			$template_args = array(
1705
+				'display_tax'       => ! empty($ticket) && $ticket->get('TKT_taxable')
1706
+					? ''
1707
+					: 'display:none;',
1708
+				'tax_id'            => $tax->ID(),
1709
+				'tkt_row'           => $ticket_row,
1710
+				'tax_label'         => $tax->get('PRC_name'),
1711
+				'tax_added'         => $tax_added,
1712
+				'tax_added_display' => EEH_Template::format_currency($tax_added, false, false),
1713
+				'tax_amount'        => $tax->get('PRC_amount'),
1714
+			);
1715
+			$template_args = apply_filters(
1716
+				'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args',
1717
+				$template_args,
1718
+				$ticket_row,
1719
+				$ticket,
1720
+				$this->_is_creating_event
1721
+			);
1722
+			$tax_rows .= EEH_Template::display_template(
1723
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php',
1724
+				$template_args,
1725
+				true
1726
+			);
1727
+		}
1728
+		return $tax_rows;
1729
+	}
1730 1730
 
1731 1731
 
1732
-    /**
1733
-     * @param EE_Price       $tax
1734
-     * @param EE_Ticket|null $ticket
1735
-     * @return float|int
1736
-     * @throws EE_Error
1737
-     */
1738
-    protected function _get_tax_added(EE_Price $tax, $ticket)
1739
-    {
1740
-        $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1741
-        return $subtotal * $tax->get('PRC_amount') / 100;
1742
-    }
1732
+	/**
1733
+	 * @param EE_Price       $tax
1734
+	 * @param EE_Ticket|null $ticket
1735
+	 * @return float|int
1736
+	 * @throws EE_Error
1737
+	 */
1738
+	protected function _get_tax_added(EE_Price $tax, $ticket)
1739
+	{
1740
+		$subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1741
+		return $subtotal * $tax->get('PRC_amount') / 100;
1742
+	}
1743 1743
 
1744 1744
 
1745
-    /**
1746
-     * @param int            $ticket_row
1747
-     * @param int            $price_row
1748
-     * @param EE_Price|null  $price
1749
-     * @param bool           $default
1750
-     * @param EE_Ticket|null $ticket
1751
-     * @param bool           $show_trash
1752
-     * @param bool           $show_create
1753
-     * @return mixed
1754
-     * @throws InvalidArgumentException
1755
-     * @throws InvalidInterfaceException
1756
-     * @throws InvalidDataTypeException
1757
-     * @throws DomainException
1758
-     * @throws EE_Error
1759
-     * @throws ReflectionException
1760
-     */
1761
-    protected function _get_ticket_price_row(
1762
-        $ticket_row,
1763
-        $price_row,
1764
-        $price,
1765
-        $default,
1766
-        $ticket,
1767
-        $show_trash = true,
1768
-        $show_create = true
1769
-    ) {
1770
-        $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1771
-        $template_args = array(
1772
-            'tkt_row'               => $default && empty($ticket)
1773
-                ? 'TICKETNUM'
1774
-                : $ticket_row,
1775
-            'PRC_order'             => $default && empty($price)
1776
-                ? 'PRICENUM'
1777
-                : $price_row,
1778
-            'edit_prices_name'      => $default && empty($price)
1779
-                ? 'PRICENAMEATTR'
1780
-                : 'edit_prices',
1781
-            'price_type_selector'   => $default && empty($price)
1782
-                ? $this->_get_base_price_template($ticket_row, $price_row, $price, $default)
1783
-                : $this->_get_price_type_selector(
1784
-                    $ticket_row,
1785
-                    $price_row,
1786
-                    $price,
1787
-                    $default,
1788
-                    $send_disabled
1789
-                ),
1790
-            'PRC_ID'                => $default && empty($price)
1791
-                ? 0
1792
-                : $price->ID(),
1793
-            'PRC_is_default'        => $default && empty($price)
1794
-                ? 0
1795
-                : $price->get('PRC_is_default'),
1796
-            'PRC_name'              => $default && empty($price)
1797
-                ? ''
1798
-                : $price->get('PRC_name'),
1799
-            'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1800
-            'show_plus_or_minus'    => $default && empty($price)
1801
-                ? ''
1802
-                : 'display:none;',
1803
-            'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1804
-                ? 'display:none;'
1805
-                : '',
1806
-            'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1807
-                ? 'display:none;'
1808
-                : '',
1809
-            'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1810
-                ? 'display:none'
1811
-                : '',
1812
-            'PRC_amount'            => $default && empty($price)
1813
-                ? 0
1814
-                : $price->get_pretty('PRC_amount', 'localized_float'),
1815
-            'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1816
-                ? 'display:none;'
1817
-                : '',
1818
-            'show_trash_icon'       => $show_trash
1819
-                ? ''
1820
-                : ' style="display:none;"',
1821
-            'show_create_button'    => $show_create
1822
-                ? ''
1823
-                : ' style="display:none;"',
1824
-            'PRC_desc'              => $default && empty($price)
1825
-                ? ''
1826
-                : $price->get('PRC_desc'),
1827
-            'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1828
-        );
1829
-        $template_args = apply_filters(
1830
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1831
-            $template_args,
1832
-            $ticket_row,
1833
-            $price_row,
1834
-            $price,
1835
-            $default,
1836
-            $ticket,
1837
-            $show_trash,
1838
-            $show_create,
1839
-            $this->_is_creating_event
1840
-        );
1841
-        return EEH_Template::display_template(
1842
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1843
-            $template_args,
1844
-            true
1845
-        );
1846
-    }
1745
+	/**
1746
+	 * @param int            $ticket_row
1747
+	 * @param int            $price_row
1748
+	 * @param EE_Price|null  $price
1749
+	 * @param bool           $default
1750
+	 * @param EE_Ticket|null $ticket
1751
+	 * @param bool           $show_trash
1752
+	 * @param bool           $show_create
1753
+	 * @return mixed
1754
+	 * @throws InvalidArgumentException
1755
+	 * @throws InvalidInterfaceException
1756
+	 * @throws InvalidDataTypeException
1757
+	 * @throws DomainException
1758
+	 * @throws EE_Error
1759
+	 * @throws ReflectionException
1760
+	 */
1761
+	protected function _get_ticket_price_row(
1762
+		$ticket_row,
1763
+		$price_row,
1764
+		$price,
1765
+		$default,
1766
+		$ticket,
1767
+		$show_trash = true,
1768
+		$show_create = true
1769
+	) {
1770
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted');
1771
+		$template_args = array(
1772
+			'tkt_row'               => $default && empty($ticket)
1773
+				? 'TICKETNUM'
1774
+				: $ticket_row,
1775
+			'PRC_order'             => $default && empty($price)
1776
+				? 'PRICENUM'
1777
+				: $price_row,
1778
+			'edit_prices_name'      => $default && empty($price)
1779
+				? 'PRICENAMEATTR'
1780
+				: 'edit_prices',
1781
+			'price_type_selector'   => $default && empty($price)
1782
+				? $this->_get_base_price_template($ticket_row, $price_row, $price, $default)
1783
+				: $this->_get_price_type_selector(
1784
+					$ticket_row,
1785
+					$price_row,
1786
+					$price,
1787
+					$default,
1788
+					$send_disabled
1789
+				),
1790
+			'PRC_ID'                => $default && empty($price)
1791
+				? 0
1792
+				: $price->ID(),
1793
+			'PRC_is_default'        => $default && empty($price)
1794
+				? 0
1795
+				: $price->get('PRC_is_default'),
1796
+			'PRC_name'              => $default && empty($price)
1797
+				? ''
1798
+				: $price->get('PRC_name'),
1799
+			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1800
+			'show_plus_or_minus'    => $default && empty($price)
1801
+				? ''
1802
+				: 'display:none;',
1803
+			'show_plus'             => ($default && empty($price)) || ($price->is_discount() || $price->is_base_price())
1804
+				? 'display:none;'
1805
+				: '',
1806
+			'show_minus'            => ($default && empty($price)) || ! $price->is_discount()
1807
+				? 'display:none;'
1808
+				: '',
1809
+			'show_currency_symbol'  => ($default && empty($price)) || $price->is_percent()
1810
+				? 'display:none'
1811
+				: '',
1812
+			'PRC_amount'            => $default && empty($price)
1813
+				? 0
1814
+				: $price->get_pretty('PRC_amount', 'localized_float'),
1815
+			'show_percentage'       => ($default && empty($price)) || ! $price->is_percent()
1816
+				? 'display:none;'
1817
+				: '',
1818
+			'show_trash_icon'       => $show_trash
1819
+				? ''
1820
+				: ' style="display:none;"',
1821
+			'show_create_button'    => $show_create
1822
+				? ''
1823
+				: ' style="display:none;"',
1824
+			'PRC_desc'              => $default && empty($price)
1825
+				? ''
1826
+				: $price->get('PRC_desc'),
1827
+			'disabled'              => ! empty($ticket) && $ticket->get('TKT_deleted'),
1828
+		);
1829
+		$template_args = apply_filters(
1830
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args',
1831
+			$template_args,
1832
+			$ticket_row,
1833
+			$price_row,
1834
+			$price,
1835
+			$default,
1836
+			$ticket,
1837
+			$show_trash,
1838
+			$show_create,
1839
+			$this->_is_creating_event
1840
+		);
1841
+		return EEH_Template::display_template(
1842
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php',
1843
+			$template_args,
1844
+			true
1845
+		);
1846
+	}
1847 1847
 
1848 1848
 
1849
-    /**
1850
-     * @param int      $ticket_row
1851
-     * @param int      $price_row
1852
-     * @param EE_Price $price
1853
-     * @param bool     $default
1854
-     * @param bool     $disabled
1855
-     * @return mixed
1856
-     * @throws ReflectionException
1857
-     * @throws InvalidArgumentException
1858
-     * @throws InvalidInterfaceException
1859
-     * @throws InvalidDataTypeException
1860
-     * @throws DomainException
1861
-     * @throws EE_Error
1862
-     */
1863
-    protected function _get_price_type_selector($ticket_row, $price_row, $price, $default, $disabled = false)
1864
-    {
1865
-        if ($price->is_base_price()) {
1866
-            return $this->_get_base_price_template(
1867
-                $ticket_row,
1868
-                $price_row,
1869
-                $price,
1870
-                $default
1871
-            );
1872
-        }
1873
-        return $this->_get_price_modifier_template(
1874
-            $ticket_row,
1875
-            $price_row,
1876
-            $price,
1877
-            $default,
1878
-            $disabled
1879
-        );
1880
-    }
1849
+	/**
1850
+	 * @param int      $ticket_row
1851
+	 * @param int      $price_row
1852
+	 * @param EE_Price $price
1853
+	 * @param bool     $default
1854
+	 * @param bool     $disabled
1855
+	 * @return mixed
1856
+	 * @throws ReflectionException
1857
+	 * @throws InvalidArgumentException
1858
+	 * @throws InvalidInterfaceException
1859
+	 * @throws InvalidDataTypeException
1860
+	 * @throws DomainException
1861
+	 * @throws EE_Error
1862
+	 */
1863
+	protected function _get_price_type_selector($ticket_row, $price_row, $price, $default, $disabled = false)
1864
+	{
1865
+		if ($price->is_base_price()) {
1866
+			return $this->_get_base_price_template(
1867
+				$ticket_row,
1868
+				$price_row,
1869
+				$price,
1870
+				$default
1871
+			);
1872
+		}
1873
+		return $this->_get_price_modifier_template(
1874
+			$ticket_row,
1875
+			$price_row,
1876
+			$price,
1877
+			$default,
1878
+			$disabled
1879
+		);
1880
+	}
1881 1881
 
1882 1882
 
1883
-    /**
1884
-     * @param int      $ticket_row
1885
-     * @param int      $price_row
1886
-     * @param EE_Price $price
1887
-     * @param bool     $default
1888
-     * @return mixed
1889
-     * @throws DomainException
1890
-     * @throws EE_Error
1891
-     */
1892
-    protected function _get_base_price_template($ticket_row, $price_row, $price, $default)
1893
-    {
1894
-        $template_args = array(
1895
-            'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1896
-            'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $price_row,
1897
-            'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1898
-            'PRT_name'                  => esc_html__('Price', 'event_espresso'),
1899
-            'price_selected_operator'   => '+',
1900
-            'price_selected_is_percent' => 0,
1901
-        );
1902
-        $template_args = apply_filters(
1903
-            'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1904
-            $template_args,
1905
-            $ticket_row,
1906
-            $price_row,
1907
-            $price,
1908
-            $default,
1909
-            $this->_is_creating_event
1910
-        );
1911
-        return EEH_Template::display_template(
1912
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1913
-            $template_args,
1914
-            true
1915
-        );
1916
-    }
1883
+	/**
1884
+	 * @param int      $ticket_row
1885
+	 * @param int      $price_row
1886
+	 * @param EE_Price $price
1887
+	 * @param bool     $default
1888
+	 * @return mixed
1889
+	 * @throws DomainException
1890
+	 * @throws EE_Error
1891
+	 */
1892
+	protected function _get_base_price_template($ticket_row, $price_row, $price, $default)
1893
+	{
1894
+		$template_args = array(
1895
+			'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1896
+			'PRC_order'                 => $default && empty($price) ? 'PRICENUM' : $price_row,
1897
+			'PRT_ID'                    => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1898
+			'PRT_name'                  => esc_html__('Price', 'event_espresso'),
1899
+			'price_selected_operator'   => '+',
1900
+			'price_selected_is_percent' => 0,
1901
+		);
1902
+		$template_args = apply_filters(
1903
+			'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args',
1904
+			$template_args,
1905
+			$ticket_row,
1906
+			$price_row,
1907
+			$price,
1908
+			$default,
1909
+			$this->_is_creating_event
1910
+		);
1911
+		return EEH_Template::display_template(
1912
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php',
1913
+			$template_args,
1914
+			true
1915
+		);
1916
+	}
1917 1917
 
1918 1918
 
1919
-    /**
1920
-     * @param int      $ticket_row
1921
-     * @param int      $price_row
1922
-     * @param EE_Price $price
1923
-     * @param bool     $default
1924
-     * @param bool     $disabled
1925
-     * @return mixed
1926
-     * @throws ReflectionException
1927
-     * @throws InvalidArgumentException
1928
-     * @throws InvalidInterfaceException
1929
-     * @throws InvalidDataTypeException
1930
-     * @throws DomainException
1931
-     * @throws EE_Error
1932
-     */
1933
-    protected function _get_price_modifier_template(
1934
-        $ticket_row,
1935
-        $price_row,
1936
-        $price,
1937
-        $default,
1938
-        $disabled = false
1939
-    ) {
1940
-        $select_name = $default && ! $price instanceof EE_Price
1941
-            ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1942
-            : 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
1943
-        /** @var EEM_Price_Type $price_type_model */
1944
-        $price_type_model = EE_Registry::instance()->load_model('Price_Type');
1945
-        $price_types = $price_type_model->get_all(array(
1946
-            array(
1947
-                'OR' => array(
1948
-                    'PBT_ID'  => '2',
1949
-                    'PBT_ID*' => '3',
1950
-                ),
1951
-            ),
1952
-        ));
1953
-        $all_price_types = $default && ! $price instanceof EE_Price
1954
-            ? array(esc_html__('Select Modifier', 'event_espresso'))
1955
-            : array();
1956
-        $selected_price_type_id = $default && ! $price instanceof EE_Price ? 0 : $price->type();
1957
-        $price_option_spans = '';
1958
-        // setup price types for selector
1959
-        foreach ($price_types as $price_type) {
1960
-            if (! $price_type instanceof EE_Price_Type) {
1961
-                continue;
1962
-            }
1963
-            $all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1964
-            // while we're in the loop let's setup the option spans used by js
1965
-            $span_args = array(
1966
-                'PRT_ID'         => $price_type->ID(),
1967
-                'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1968
-                'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1969
-            );
1970
-            $price_option_spans .= EEH_Template::display_template(
1971
-                PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1972
-                $span_args,
1973
-                true
1974
-            );
1975
-        }
1976
-        $select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1977
-            : $select_name;
1978
-        $select_input = new EE_Select_Input(
1979
-            $all_price_types,
1980
-            array(
1981
-                'default'               => $selected_price_type_id,
1982
-                'html_name'             => $select_name,
1983
-                'html_class'            => 'edit-price-PRT_ID',
1984
-                'other_html_attributes' => $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"',
1985
-            )
1986
-        );
1987
-        $price_selected_operator = $price instanceof EE_Price && $price->is_discount() ? '-' : '+';
1988
-        $price_selected_operator = $default && ! $price instanceof EE_Price ? '' : $price_selected_operator;
1989
-        $price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() ? 1 : 0;
1990
-        $price_selected_is_percent = $default && ! $price instanceof EE_Price ? '' : $price_selected_is_percent;
1991
-        $template_args = array(
1992
-            'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1993
-            'PRC_order'                 => $default && ! $price instanceof EE_Price ? 'PRICENUM' : $price_row,
1994
-            'price_modifier_selector'   => $select_input->get_html_for_input(),
1995
-            'main_name'                 => $select_name,
1996
-            'selected_price_type_id'    => $selected_price_type_id,
1997
-            'price_option_spans'        => $price_option_spans,
1998
-            'price_selected_operator'   => $price_selected_operator,
1999
-            'price_selected_is_percent' => $price_selected_is_percent,
2000
-            'disabled'                  => $disabled,
2001
-        );
2002
-        $template_args = apply_filters(
2003
-            'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
2004
-            $template_args,
2005
-            $ticket_row,
2006
-            $price_row,
2007
-            $price,
2008
-            $default,
2009
-            $disabled,
2010
-            $this->_is_creating_event
2011
-        );
2012
-        return EEH_Template::display_template(
2013
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2014
-            $template_args,
2015
-            true
2016
-        );
2017
-    }
1919
+	/**
1920
+	 * @param int      $ticket_row
1921
+	 * @param int      $price_row
1922
+	 * @param EE_Price $price
1923
+	 * @param bool     $default
1924
+	 * @param bool     $disabled
1925
+	 * @return mixed
1926
+	 * @throws ReflectionException
1927
+	 * @throws InvalidArgumentException
1928
+	 * @throws InvalidInterfaceException
1929
+	 * @throws InvalidDataTypeException
1930
+	 * @throws DomainException
1931
+	 * @throws EE_Error
1932
+	 */
1933
+	protected function _get_price_modifier_template(
1934
+		$ticket_row,
1935
+		$price_row,
1936
+		$price,
1937
+		$default,
1938
+		$disabled = false
1939
+	) {
1940
+		$select_name = $default && ! $price instanceof EE_Price
1941
+			? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]'
1942
+			: 'edit_prices[' . esc_attr($ticket_row) . '][' . esc_attr($price_row) . '][PRT_ID]';
1943
+		/** @var EEM_Price_Type $price_type_model */
1944
+		$price_type_model = EE_Registry::instance()->load_model('Price_Type');
1945
+		$price_types = $price_type_model->get_all(array(
1946
+			array(
1947
+				'OR' => array(
1948
+					'PBT_ID'  => '2',
1949
+					'PBT_ID*' => '3',
1950
+				),
1951
+			),
1952
+		));
1953
+		$all_price_types = $default && ! $price instanceof EE_Price
1954
+			? array(esc_html__('Select Modifier', 'event_espresso'))
1955
+			: array();
1956
+		$selected_price_type_id = $default && ! $price instanceof EE_Price ? 0 : $price->type();
1957
+		$price_option_spans = '';
1958
+		// setup price types for selector
1959
+		foreach ($price_types as $price_type) {
1960
+			if (! $price_type instanceof EE_Price_Type) {
1961
+				continue;
1962
+			}
1963
+			$all_price_types[ $price_type->ID() ] = $price_type->get('PRT_name');
1964
+			// while we're in the loop let's setup the option spans used by js
1965
+			$span_args = array(
1966
+				'PRT_ID'         => $price_type->ID(),
1967
+				'PRT_operator'   => $price_type->is_discount() ? '-' : '+',
1968
+				'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0,
1969
+			);
1970
+			$price_option_spans .= EEH_Template::display_template(
1971
+				PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php',
1972
+				$span_args,
1973
+				true
1974
+			);
1975
+		}
1976
+		$select_name = $disabled ? 'archive_price[' . $ticket_row . '][' . $price_row . '][PRT_ID]'
1977
+			: $select_name;
1978
+		$select_input = new EE_Select_Input(
1979
+			$all_price_types,
1980
+			array(
1981
+				'default'               => $selected_price_type_id,
1982
+				'html_name'             => $select_name,
1983
+				'html_class'            => 'edit-price-PRT_ID',
1984
+				'other_html_attributes' => $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"',
1985
+			)
1986
+		);
1987
+		$price_selected_operator = $price instanceof EE_Price && $price->is_discount() ? '-' : '+';
1988
+		$price_selected_operator = $default && ! $price instanceof EE_Price ? '' : $price_selected_operator;
1989
+		$price_selected_is_percent = $price instanceof EE_Price && $price->is_percent() ? 1 : 0;
1990
+		$price_selected_is_percent = $default && ! $price instanceof EE_Price ? '' : $price_selected_is_percent;
1991
+		$template_args = array(
1992
+			'tkt_row'                   => $default ? 'TICKETNUM' : $ticket_row,
1993
+			'PRC_order'                 => $default && ! $price instanceof EE_Price ? 'PRICENUM' : $price_row,
1994
+			'price_modifier_selector'   => $select_input->get_html_for_input(),
1995
+			'main_name'                 => $select_name,
1996
+			'selected_price_type_id'    => $selected_price_type_id,
1997
+			'price_option_spans'        => $price_option_spans,
1998
+			'price_selected_operator'   => $price_selected_operator,
1999
+			'price_selected_is_percent' => $price_selected_is_percent,
2000
+			'disabled'                  => $disabled,
2001
+		);
2002
+		$template_args = apply_filters(
2003
+			'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args',
2004
+			$template_args,
2005
+			$ticket_row,
2006
+			$price_row,
2007
+			$price,
2008
+			$default,
2009
+			$disabled,
2010
+			$this->_is_creating_event
2011
+		);
2012
+		return EEH_Template::display_template(
2013
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php',
2014
+			$template_args,
2015
+			true
2016
+		);
2017
+	}
2018 2018
 
2019 2019
 
2020
-    /**
2021
-     * @param int              $datetime_row
2022
-     * @param int              $ticket_row
2023
-     * @param EE_Datetime|null $datetime
2024
-     * @param EE_Ticket|null   $ticket
2025
-     * @param array            $ticket_datetimes
2026
-     * @param bool             $default
2027
-     * @return mixed
2028
-     * @throws DomainException
2029
-     * @throws EE_Error
2030
-     */
2031
-    protected function _get_ticket_datetime_list_item(
2032
-        $datetime_row,
2033
-        $ticket_row,
2034
-        $datetime,
2035
-        $ticket,
2036
-        $ticket_datetimes = array(),
2037
-        $default = false
2038
-    ) {
2039
-        $tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2040
-            ? $ticket_datetimes[ $ticket->ID() ]
2041
-            : array();
2042
-        $template_args = array(
2043
-            'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2044
-                ? 'DTTNUM'
2045
-                : $datetime_row,
2046
-            'tkt_row'                  => $default
2047
-                ? 'TICKETNUM'
2048
-                : $ticket_row,
2049
-            'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2050
-                ? ' ticket-selected'
2051
-                : '',
2052
-            'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2053
-                ? ' checked'
2054
-                : '',
2055
-            'DTT_name'                 => $default && empty($datetime)
2056
-                ? 'DTTNAME'
2057
-                : $datetime->get_dtt_display_name(true),
2058
-            'tkt_status_class'         => '',
2059
-        );
2060
-        $template_args = apply_filters(
2061
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2062
-            $template_args,
2063
-            $datetime_row,
2064
-            $ticket_row,
2065
-            $datetime,
2066
-            $ticket,
2067
-            $ticket_datetimes,
2068
-            $default,
2069
-            $this->_is_creating_event
2070
-        );
2071
-        return EEH_Template::display_template(
2072
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2073
-            $template_args,
2074
-            true
2075
-        );
2076
-    }
2020
+	/**
2021
+	 * @param int              $datetime_row
2022
+	 * @param int              $ticket_row
2023
+	 * @param EE_Datetime|null $datetime
2024
+	 * @param EE_Ticket|null   $ticket
2025
+	 * @param array            $ticket_datetimes
2026
+	 * @param bool             $default
2027
+	 * @return mixed
2028
+	 * @throws DomainException
2029
+	 * @throws EE_Error
2030
+	 */
2031
+	protected function _get_ticket_datetime_list_item(
2032
+		$datetime_row,
2033
+		$ticket_row,
2034
+		$datetime,
2035
+		$ticket,
2036
+		$ticket_datetimes = array(),
2037
+		$default = false
2038
+	) {
2039
+		$tkt_datetimes = $ticket instanceof EE_Ticket && isset($ticket_datetimes[ $ticket->ID() ])
2040
+			? $ticket_datetimes[ $ticket->ID() ]
2041
+			: array();
2042
+		$template_args = array(
2043
+			'dtt_row'                  => $default && ! $datetime instanceof EE_Datetime
2044
+				? 'DTTNUM'
2045
+				: $datetime_row,
2046
+			'tkt_row'                  => $default
2047
+				? 'TICKETNUM'
2048
+				: $ticket_row,
2049
+			'ticket_datetime_selected' => in_array($datetime_row, $tkt_datetimes, true)
2050
+				? ' ticket-selected'
2051
+				: '',
2052
+			'ticket_datetime_checked'  => in_array($datetime_row, $tkt_datetimes, true)
2053
+				? ' checked'
2054
+				: '',
2055
+			'DTT_name'                 => $default && empty($datetime)
2056
+				? 'DTTNAME'
2057
+				: $datetime->get_dtt_display_name(true),
2058
+			'tkt_status_class'         => '',
2059
+		);
2060
+		$template_args = apply_filters(
2061
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args',
2062
+			$template_args,
2063
+			$datetime_row,
2064
+			$ticket_row,
2065
+			$datetime,
2066
+			$ticket,
2067
+			$ticket_datetimes,
2068
+			$default,
2069
+			$this->_is_creating_event
2070
+		);
2071
+		return EEH_Template::display_template(
2072
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php',
2073
+			$template_args,
2074
+			true
2075
+		);
2076
+	}
2077 2077
 
2078 2078
 
2079
-    /**
2080
-     * @param array $all_datetimes
2081
-     * @param array $all_tickets
2082
-     * @return mixed
2083
-     * @throws ReflectionException
2084
-     * @throws InvalidArgumentException
2085
-     * @throws InvalidInterfaceException
2086
-     * @throws InvalidDataTypeException
2087
-     * @throws DomainException
2088
-     * @throws EE_Error
2089
-     */
2090
-    protected function _get_ticket_js_structure($all_datetimes = array(), $all_tickets = array())
2091
-    {
2092
-        $template_args = array(
2093
-            'default_datetime_edit_row'                => $this->_get_dtt_edit_row(
2094
-                'DTTNUM',
2095
-                null,
2096
-                true,
2097
-                $all_datetimes
2098
-            ),
2099
-            'default_ticket_row'                       => $this->_get_ticket_row(
2100
-                'TICKETNUM',
2101
-                null,
2102
-                array(),
2103
-                array(),
2104
-                true
2105
-            ),
2106
-            'default_price_row'                        => $this->_get_ticket_price_row(
2107
-                'TICKETNUM',
2108
-                'PRICENUM',
2109
-                null,
2110
-                true,
2111
-                null
2112
-            ),
2113
-            'default_price_rows'                       => '',
2114
-            'default_base_price_amount'                => 0,
2115
-            'default_base_price_name'                  => '',
2116
-            'default_base_price_description'           => '',
2117
-            'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2118
-                'TICKETNUM',
2119
-                'PRICENUM',
2120
-                null,
2121
-                true
2122
-            ),
2123
-            'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2124
-                'DTTNUM',
2125
-                null,
2126
-                array(),
2127
-                array(),
2128
-                true
2129
-            ),
2130
-            'existing_available_datetime_tickets_list' => '',
2131
-            'existing_available_ticket_datetimes_list' => '',
2132
-            'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2133
-                'DTTNUM',
2134
-                'TICKETNUM',
2135
-                null,
2136
-                null,
2137
-                array(),
2138
-                true
2139
-            ),
2140
-            'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2141
-                'DTTNUM',
2142
-                'TICKETNUM',
2143
-                null,
2144
-                null,
2145
-                array(),
2146
-                true
2147
-            ),
2148
-        );
2149
-        $ticket_row = 1;
2150
-        foreach ($all_tickets as $ticket) {
2151
-            $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2152
-                'DTTNUM',
2153
-                $ticket_row,
2154
-                null,
2155
-                $ticket,
2156
-                array(),
2157
-                true
2158
-            );
2159
-            $ticket_row++;
2160
-        }
2161
-        $datetime_row = 1;
2162
-        foreach ($all_datetimes as $datetime) {
2163
-            $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2164
-                $datetime_row,
2165
-                'TICKETNUM',
2166
-                $datetime,
2167
-                null,
2168
-                array(),
2169
-                true
2170
-            );
2171
-            $datetime_row++;
2172
-        }
2173
-        /** @var EEM_Price $price_model */
2174
-        $price_model = EE_Registry::instance()->load_model('Price');
2175
-        $default_prices = $price_model->get_all_default_prices();
2176
-        $price_row = 1;
2177
-        foreach ($default_prices as $price) {
2178
-            if (! $price instanceof EE_Price) {
2179
-                continue;
2180
-            }
2181
-            if ($price->is_base_price()) {
2182
-                $template_args['default_base_price_amount'] = $price->get_pretty(
2183
-                    'PRC_amount',
2184
-                    'localized_float'
2185
-                );
2186
-                $template_args['default_base_price_name'] = $price->get('PRC_name');
2187
-                $template_args['default_base_price_description'] = $price->get('PRC_desc');
2188
-                $price_row++;
2189
-                continue;
2190
-            }
2191
-            $show_trash = ! ((count($default_prices) > 1 && $price_row === 1)
2192
-                             || count($default_prices) === 1);
2193
-            $show_create = ! (count($default_prices) > 1
2194
-                              && count($default_prices)
2195
-                                 !== $price_row);
2196
-            $template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2197
-                'TICKETNUM',
2198
-                $price_row,
2199
-                $price,
2200
-                true,
2201
-                null,
2202
-                $show_trash,
2203
-                $show_create
2204
-            );
2205
-            $price_row++;
2206
-        }
2207
-        $template_args = apply_filters(
2208
-            'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2209
-            $template_args,
2210
-            $all_datetimes,
2211
-            $all_tickets,
2212
-            $this->_is_creating_event
2213
-        );
2214
-        return EEH_Template::display_template(
2215
-            PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2216
-            $template_args,
2217
-            true
2218
-        );
2219
-    }
2079
+	/**
2080
+	 * @param array $all_datetimes
2081
+	 * @param array $all_tickets
2082
+	 * @return mixed
2083
+	 * @throws ReflectionException
2084
+	 * @throws InvalidArgumentException
2085
+	 * @throws InvalidInterfaceException
2086
+	 * @throws InvalidDataTypeException
2087
+	 * @throws DomainException
2088
+	 * @throws EE_Error
2089
+	 */
2090
+	protected function _get_ticket_js_structure($all_datetimes = array(), $all_tickets = array())
2091
+	{
2092
+		$template_args = array(
2093
+			'default_datetime_edit_row'                => $this->_get_dtt_edit_row(
2094
+				'DTTNUM',
2095
+				null,
2096
+				true,
2097
+				$all_datetimes
2098
+			),
2099
+			'default_ticket_row'                       => $this->_get_ticket_row(
2100
+				'TICKETNUM',
2101
+				null,
2102
+				array(),
2103
+				array(),
2104
+				true
2105
+			),
2106
+			'default_price_row'                        => $this->_get_ticket_price_row(
2107
+				'TICKETNUM',
2108
+				'PRICENUM',
2109
+				null,
2110
+				true,
2111
+				null
2112
+			),
2113
+			'default_price_rows'                       => '',
2114
+			'default_base_price_amount'                => 0,
2115
+			'default_base_price_name'                  => '',
2116
+			'default_base_price_description'           => '',
2117
+			'default_price_modifier_selector_row'      => $this->_get_price_modifier_template(
2118
+				'TICKETNUM',
2119
+				'PRICENUM',
2120
+				null,
2121
+				true
2122
+			),
2123
+			'default_available_tickets_for_datetime'   => $this->_get_dtt_attached_tickets_row(
2124
+				'DTTNUM',
2125
+				null,
2126
+				array(),
2127
+				array(),
2128
+				true
2129
+			),
2130
+			'existing_available_datetime_tickets_list' => '',
2131
+			'existing_available_ticket_datetimes_list' => '',
2132
+			'new_available_datetime_ticket_list_item'  => $this->_get_datetime_tickets_list_item(
2133
+				'DTTNUM',
2134
+				'TICKETNUM',
2135
+				null,
2136
+				null,
2137
+				array(),
2138
+				true
2139
+			),
2140
+			'new_available_ticket_datetime_list_item'  => $this->_get_ticket_datetime_list_item(
2141
+				'DTTNUM',
2142
+				'TICKETNUM',
2143
+				null,
2144
+				null,
2145
+				array(),
2146
+				true
2147
+			),
2148
+		);
2149
+		$ticket_row = 1;
2150
+		foreach ($all_tickets as $ticket) {
2151
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item(
2152
+				'DTTNUM',
2153
+				$ticket_row,
2154
+				null,
2155
+				$ticket,
2156
+				array(),
2157
+				true
2158
+			);
2159
+			$ticket_row++;
2160
+		}
2161
+		$datetime_row = 1;
2162
+		foreach ($all_datetimes as $datetime) {
2163
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item(
2164
+				$datetime_row,
2165
+				'TICKETNUM',
2166
+				$datetime,
2167
+				null,
2168
+				array(),
2169
+				true
2170
+			);
2171
+			$datetime_row++;
2172
+		}
2173
+		/** @var EEM_Price $price_model */
2174
+		$price_model = EE_Registry::instance()->load_model('Price');
2175
+		$default_prices = $price_model->get_all_default_prices();
2176
+		$price_row = 1;
2177
+		foreach ($default_prices as $price) {
2178
+			if (! $price instanceof EE_Price) {
2179
+				continue;
2180
+			}
2181
+			if ($price->is_base_price()) {
2182
+				$template_args['default_base_price_amount'] = $price->get_pretty(
2183
+					'PRC_amount',
2184
+					'localized_float'
2185
+				);
2186
+				$template_args['default_base_price_name'] = $price->get('PRC_name');
2187
+				$template_args['default_base_price_description'] = $price->get('PRC_desc');
2188
+				$price_row++;
2189
+				continue;
2190
+			}
2191
+			$show_trash = ! ((count($default_prices) > 1 && $price_row === 1)
2192
+							 || count($default_prices) === 1);
2193
+			$show_create = ! (count($default_prices) > 1
2194
+							  && count($default_prices)
2195
+								 !== $price_row);
2196
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row(
2197
+				'TICKETNUM',
2198
+				$price_row,
2199
+				$price,
2200
+				true,
2201
+				null,
2202
+				$show_trash,
2203
+				$show_create
2204
+			);
2205
+			$price_row++;
2206
+		}
2207
+		$template_args = apply_filters(
2208
+			'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args',
2209
+			$template_args,
2210
+			$all_datetimes,
2211
+			$all_tickets,
2212
+			$this->_is_creating_event
2213
+		);
2214
+		return EEH_Template::display_template(
2215
+			PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php',
2216
+			$template_args,
2217
+			true
2218
+		);
2219
+	}
2220 2220
 }
Please login to merge, or discard this patch.
caffeinated/core/services/licensing/UserExperienceForm.php 2 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -16,129 +16,129 @@
 block discarded – undo
16 16
 
17 17
 class UserExperienceForm
18 18
 {
19
-    /**
20
-     * @var EE_Core_Config
21
-     */
22
-    protected $core_config;
19
+	/**
20
+	 * @var EE_Core_Config
21
+	 */
22
+	protected $core_config;
23 23
 
24
-    /**
25
-     * @var EE_Network_Core_Config
26
-     */
27
-    protected $network_core_config;
24
+	/**
25
+	 * @var EE_Network_Core_Config
26
+	 */
27
+	protected $network_core_config;
28 28
 
29 29
 
30
-    /**
31
-     * @param EE_Core_Config         $core_config
32
-     * @param EE_Network_Core_Config $network_core_config
33
-     */
34
-    public function __construct(EE_Core_Config $core_config, EE_Network_Core_Config $network_core_config)
35
-    {
36
-        $this->core_config         = $core_config;
37
-        $this->network_core_config = $network_core_config;
38
-    }
30
+	/**
31
+	 * @param EE_Core_Config         $core_config
32
+	 * @param EE_Network_Core_Config $network_core_config
33
+	 */
34
+	public function __construct(EE_Core_Config $core_config, EE_Network_Core_Config $network_core_config)
35
+	{
36
+		$this->core_config         = $core_config;
37
+		$this->network_core_config = $network_core_config;
38
+	}
39 39
 
40 40
 
41
-    /**
42
-     * @throws EE_Error
43
-     */
44
-    public function uxipFormSections(EE_Form_Section_Proper $org_settings_form): EE_Form_Section_Proper
45
-    {
46
-        if (is_main_site()) {
47
-            $org_settings_form->add_subsections(
48
-                [
49
-                    'site_license_key_hdr' => new EE_Form_Section_HTML(
50
-                        EEH_HTML::h2(
51
-                            esc_html__('Your Event Espresso License Key', 'event_espresso')
52
-                            . ' '
53
-                            . EEH_HTML::span(
54
-                                EEH_Template::get_help_tab_link('site_license_key_info')
55
-                            ),
56
-                            '',
57
-                            'site-license-key-hdr'
58
-                        )
59
-                    ),
60
-                    'site_license_key'     => new EE_Text_Input(
61
-                        [
62
-                            'html_name'        => 'ee_site_license_key',
63
-                            'html_id'          => 'site_license_key',
64
-                            'html_label_text'  => esc_html__('Support License Key', 'event_espresso'),
65
-                            /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
66
-                            'html_help_text'   => sprintf(
67
-                                esc_html__(
68
-                                    'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
69
-                                    'event_espresso'
70
-                                ),
71
-                                '<strong>',
72
-                                '</strong>'
73
-                            ),
74
-                            /** phpcs:enable */
75
-                            'default'          => $this->network_core_config->site_license_key ?? '',
76
-                            'required'         => false,
77
-                            'form_html_filter' => new VsprintfFilter(
78
-                                '%2$s %1$s',
79
-                                [$this->getValidationIndicator()]
80
-                            )
81
-                        ]
82
-                    )
83
-                ]
84
-            );
85
-            $org_settings_form->add_subsections(
86
-                [
87
-                    'uxip_optin_hdr' => new EE_Form_Section_HTML(Stats::optinText(false)),
88
-                    'ueip_optin'     => new EE_Checkbox_Multi_Input(
89
-                        [
90
-                            true => esc_html__('Yes! I want to help improve Event Espresso!', 'event_espresso')
91
-                        ],
92
-                        [
93
-                            'html_name'       => EE_Core_Config::OPTION_NAME_UXIP,
94
-                            'html_label_text' => esc_html__(
95
-                                'UXIP Opt In?',
96
-                                'event_espresso'
97
-                            ),
98
-                            'default'         => isset($this->core_config->ee_ueip_optin)
99
-                                ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
100
-                                : false,
101
-                            'required'        => false,
102
-                        ]
103
-                    ),
104
-                ],
105
-                'organization_instagram',
106
-                false
107
-            );
108
-        }
109
-        return $org_settings_form;
110
-    }
41
+	/**
42
+	 * @throws EE_Error
43
+	 */
44
+	public function uxipFormSections(EE_Form_Section_Proper $org_settings_form): EE_Form_Section_Proper
45
+	{
46
+		if (is_main_site()) {
47
+			$org_settings_form->add_subsections(
48
+				[
49
+					'site_license_key_hdr' => new EE_Form_Section_HTML(
50
+						EEH_HTML::h2(
51
+							esc_html__('Your Event Espresso License Key', 'event_espresso')
52
+							. ' '
53
+							. EEH_HTML::span(
54
+								EEH_Template::get_help_tab_link('site_license_key_info')
55
+							),
56
+							'',
57
+							'site-license-key-hdr'
58
+						)
59
+					),
60
+					'site_license_key'     => new EE_Text_Input(
61
+						[
62
+							'html_name'        => 'ee_site_license_key',
63
+							'html_id'          => 'site_license_key',
64
+							'html_label_text'  => esc_html__('Support License Key', 'event_espresso'),
65
+							/** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
66
+							'html_help_text'   => sprintf(
67
+								esc_html__(
68
+									'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
69
+									'event_espresso'
70
+								),
71
+								'<strong>',
72
+								'</strong>'
73
+							),
74
+							/** phpcs:enable */
75
+							'default'          => $this->network_core_config->site_license_key ?? '',
76
+							'required'         => false,
77
+							'form_html_filter' => new VsprintfFilter(
78
+								'%2$s %1$s',
79
+								[$this->getValidationIndicator()]
80
+							)
81
+						]
82
+					)
83
+				]
84
+			);
85
+			$org_settings_form->add_subsections(
86
+				[
87
+					'uxip_optin_hdr' => new EE_Form_Section_HTML(Stats::optinText(false)),
88
+					'ueip_optin'     => new EE_Checkbox_Multi_Input(
89
+						[
90
+							true => esc_html__('Yes! I want to help improve Event Espresso!', 'event_espresso')
91
+						],
92
+						[
93
+							'html_name'       => EE_Core_Config::OPTION_NAME_UXIP,
94
+							'html_label_text' => esc_html__(
95
+								'UXIP Opt In?',
96
+								'event_espresso'
97
+							),
98
+							'default'         => isset($this->core_config->ee_ueip_optin)
99
+								? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
100
+								: false,
101
+							'required'        => false,
102
+						]
103
+					),
104
+				],
105
+				'organization_instagram',
106
+				false
107
+			);
108
+		}
109
+		return $org_settings_form;
110
+	}
111 111
 
112 112
 
113 113
 
114
-    /**
115
-     * Return whether the site license key has been verified or not.
116
-     *
117
-     * @return bool
118
-     */
119
-    private function licenseKeyVerified(): bool
120
-    {
121
-        if (empty($this->network_core_config->site_license_key)) {
122
-            return false;
123
-        }
124
-        $verify_fail = get_option(
125
-            'puvererr_' . basename(EE_PLUGIN_BASENAME),
126
-            false
127
-        );
128
-        return $verify_fail === false
129
-               || (
130
-                   ! empty($this->network_core_config->site_license_key)
131
-                   && $verify_fail === false
132
-               );
133
-    }
114
+	/**
115
+	 * Return whether the site license key has been verified or not.
116
+	 *
117
+	 * @return bool
118
+	 */
119
+	private function licenseKeyVerified(): bool
120
+	{
121
+		if (empty($this->network_core_config->site_license_key)) {
122
+			return false;
123
+		}
124
+		$verify_fail = get_option(
125
+			'puvererr_' . basename(EE_PLUGIN_BASENAME),
126
+			false
127
+		);
128
+		return $verify_fail === false
129
+			   || (
130
+				   ! empty($this->network_core_config->site_license_key)
131
+				   && $verify_fail === false
132
+			   );
133
+	}
134 134
 
135 135
 
136
-    /**
137
-     * @return string
138
-     */
139
-    private function getValidationIndicator(): string
140
-    {
141
-        $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
142
-        return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
143
-    }
136
+	/**
137
+	 * @return string
138
+	 */
139
+	private function getValidationIndicator(): string
140
+	{
141
+		$verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
142
+		return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
143
+	}
144 144
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
             return false;
123 123
         }
124 124
         $verify_fail = get_option(
125
-            'puvererr_' . basename(EE_PLUGIN_BASENAME),
125
+            'puvererr_'.basename(EE_PLUGIN_BASENAME),
126 126
             false
127 127
         );
128 128
         return $verify_fail === false
@@ -139,6 +139,6 @@  discard block
 block discarded – undo
139 139
     private function getValidationIndicator(): string
140 140
     {
141 141
         $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
142
-        return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
142
+        return '<span class="dashicons dashicons-admin-network '.$verified_class.' ee-icon-size-20"></span>';
143 143
     }
144 144
 }
Please login to merge, or discard this patch.
core/services/address/AddressInterface.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,41 +10,41 @@
 block discarded – undo
10 10
  */
11 11
 interface AddressInterface
12 12
 {
13
-    public function address(): string;
13
+	public function address(): string;
14 14
 
15 15
 
16
-    public function address2(): string;
16
+	public function address2(): string;
17 17
 
18 18
 
19
-    public function city(): string;
19
+	public function city(): string;
20 20
 
21 21
 
22
-    public function state_obj(): ?EE_State;
22
+	public function state_obj(): ?EE_State;
23 23
 
24 24
 
25
-    public function state_ID(): int;
25
+	public function state_ID(): int;
26 26
 
27 27
 
28
-    public function state_name(): string;
28
+	public function state_name(): string;
29 29
 
30 30
 
31
-    public function state_abbrev(): string;
31
+	public function state_abbrev(): string;
32 32
 
33 33
 
34
-    public function state(): string;
34
+	public function state(): string;
35 35
 
36 36
 
37
-    public function country_obj(): ?EE_Country;
37
+	public function country_obj(): ?EE_Country;
38 38
 
39 39
 
40
-    public function country_ID(): string;
40
+	public function country_ID(): string;
41 41
 
42 42
 
43
-    public function country_name(): string;
43
+	public function country_name(): string;
44 44
 
45 45
 
46
-    public function country(): string;
46
+	public function country(): string;
47 47
 
48 48
 
49
-    public function zip(): string;
49
+	public function zip(): string;
50 50
 }
Please login to merge, or discard this patch.
core/libraries/messages/messenger/EE_Html_messenger.class.php 2 patches
Indentation   +545 added lines, -545 removed lines patch added patch discarded remove patch
@@ -12,549 +12,549 @@
 block discarded – undo
12 12
  */
13 13
 class EE_Html_messenger extends EE_messenger
14 14
 {
15
-    /**
16
-     * The following are the properties that this messenger requires for displaying the html
17
-     */
18
-    /**
19
-     * This is the html body generated by the template via the message type.
20
-     *
21
-     * @var string
22
-     */
23
-    protected $_content = '';
24
-
25
-    /**
26
-     * This is for the page title that gets displayed.  (Why use "subject"?  Because the "title" tag in html is
27
-     * equivalent to the "subject" of the page.
28
-     *
29
-     * @var string
30
-     */
31
-    protected $_subject = '';
32
-
33
-
34
-    /**
35
-     * EE_Html_messenger constructor.
36
-     */
37
-    public function __construct()
38
-    {
39
-        // set properties
40
-        $this->name                = 'html';
41
-        $this->description         = esc_html__(
42
-            'This messenger outputs a message to a browser for display.',
43
-            'event_espresso'
44
-        );
45
-        $this->label               = [
46
-            'singular' => esc_html__('html', 'event_espresso'),
47
-            'plural'   => esc_html__('html', 'event_espresso'),
48
-        ];
49
-        $this->activate_on_install = true;
50
-        // add the "powered by EE" credit link to the HTML receipt and invoice
51
-        add_filter(
52
-            'FHEE__EE_Html_messenger___send_message__main_body',
53
-            [$this, 'add_powered_by_credit_link_to_receipt_and_invoice'],
54
-            10,
55
-            3
56
-        );
57
-        parent::__construct();
58
-    }
59
-
60
-
61
-    /**
62
-     * HTML Messenger desires execution immediately.
63
-     *
64
-     * @return bool
65
-     * @since  4.9.0
66
-     * @see    parent::send_now() for documentation.
67
-     */
68
-    public function send_now(): bool
69
-    {
70
-        return true;
71
-    }
72
-
73
-
74
-    /**
75
-     * HTML Messenger allows an empty to field.
76
-     *
77
-     * @return bool
78
-     * @since  4.9.0
79
-     * @see    parent::allow_empty_to_field() for documentation
80
-     */
81
-    public function allow_empty_to_field(): bool
82
-    {
83
-        return true;
84
-    }
85
-
86
-
87
-    /**
88
-     * @see abstract declaration in EE_messenger for details.
89
-     */
90
-    protected function _set_admin_pages()
91
-    {
92
-        $this->admin_registered_pages = ['events_edit' => true];
93
-    }
94
-
95
-
96
-    /**
97
-     * @see abstract declaration in EE_messenger for details.
98
-     */
99
-    protected function _set_valid_shortcodes()
100
-    {
101
-        $this->_valid_shortcodes = [];
102
-    }
103
-
104
-
105
-    /**
106
-     * @see abstract declaration in EE_messenger for details.
107
-     */
108
-    protected function _set_validator_config()
109
-    {
110
-        $this->_validator_config = [
111
-            'subject'                       => [
112
-                'shortcodes' => ['organization', 'primary_registration_details', 'email', 'transaction'],
113
-            ],
114
-            'content'                       => [
115
-                'shortcodes' => [
116
-                    'organization',
117
-                    'primary_registration_list',
118
-                    'primary_registration_details',
119
-                    'email',
120
-                    'transaction',
121
-                    'event_list',
122
-                    'payment_list',
123
-                    'venue',
124
-                    'line_item_list',
125
-                    'messenger',
126
-                    'ticket_list',
127
-                ],
128
-            ],
129
-            'event_list'                    => [
130
-                'shortcodes' => [
131
-                    'event',
132
-                    'ticket_list',
133
-                    'venue',
134
-                    'primary_registration_details',
135
-                    'primary_registration_list',
136
-                    'event_author',
137
-                ],
138
-                'required'   => ['[EVENT_LIST]'],
139
-            ],
140
-            'ticket_list'                   => [
141
-                'shortcodes' => [
142
-                    'attendee_list',
143
-                    'ticket',
144
-                    'datetime_list',
145
-                    'primary_registration_details',
146
-                    'line_item_list',
147
-                    'venue',
148
-                ],
149
-                'required'   => ['[TICKET_LIST]'],
150
-            ],
151
-            'ticket_line_item_no_pms'       => [
152
-                'shortcodes' => ['line_item', 'ticket'],
153
-                'required'   => ['[TICKET_LINE_ITEM_LIST]'],
154
-            ],
155
-            'ticket_line_item_pms'          => [
156
-                'shortcodes' => ['line_item', 'ticket', 'line_item_list'],
157
-                'required'   => ['[TICKET_LINE_ITEM_LIST]'],
158
-            ],
159
-            'price_modifier_line_item_list' => [
160
-                'shortcodes' => ['line_item'],
161
-                'required'   => ['[PRICE_MODIFIER_LINE_ITEM_LIST]'],
162
-            ],
163
-            'datetime_list'                 => [
164
-                'shortcodes' => ['datetime'],
165
-                'required'   => ['[DATETIME_LIST]'],
166
-            ],
167
-            'attendee_list'                 => [
168
-                'shortcodes' => ['attendee'],
169
-                'required'   => ['[ATTENDEE_LIST]'],
170
-            ],
171
-            'tax_line_item_list'            => [
172
-                'shortcodes' => ['line_item'],
173
-                'required'   => ['[TAX_LINE_ITEM_LIST]'],
174
-            ],
175
-            'additional_line_item_list'     => [
176
-                'shortcodes' => ['line_item'],
177
-                'required'   => ['[ADDITIONAL_LINE_ITEM_LIST]'],
178
-            ],
179
-            'payment_list'                  => [
180
-                'shortcodes' => ['payment'],
181
-                'required'   => ['[PAYMENT_LIST_*]'],
182
-            ],
183
-        ];
184
-    }
185
-
186
-
187
-    /**
188
-     * This is a method called from EE_messages when this messenger is a generating messenger and the sending messenger
189
-     * is a different messenger.  Child messengers can set hooks for the sending messenger to callback on if necessary
190
-     * (i.e. swap out css files or something else).
191
-     *
192
-     * @param string $sending_messenger_name the name of the sending messenger so we only set the hooks needed.
193
-     * @return void
194
-     * @since 4.5.0
195
-     */
196
-    public function do_secondary_messenger_hooks($sending_messenger_name)
197
-    {
198
-        if ($sending_messenger_name === 'pdf') {
199
-            add_filter('EE_messenger__get_variation__variation', [$this, 'add_html_css'], 10, 8);
200
-        }
201
-    }
202
-
203
-
204
-    /**
205
-     * @param                            $variation_path
206
-     * @param EE_Messages_Template_Pack  $template_pack
207
-     * @param                            $messenger_name
208
-     * @param                            $message_type_name
209
-     * @param                            $url
210
-     * @param                            $type
211
-     * @param                            $variation
212
-     * @param                            $skip_filters
213
-     * @return string
214
-     */
215
-    public function add_html_css(
216
-        $variation_path,
217
-        EE_Messages_Template_Pack $template_pack,
218
-        $messenger_name,
219
-        $message_type_name,
220
-        $url,
221
-        $type,
222
-        $variation,
223
-        $skip_filters
224
-    ): string {
225
-        return $template_pack->get_variation(
226
-            $this->name,
227
-            $message_type_name,
228
-            $type,
229
-            $variation,
230
-            $url,
231
-            '.css',
232
-            $skip_filters
233
-        );
234
-    }
235
-
236
-
237
-    /**
238
-     * Takes care of enqueuing any necessary scripts or styles for the page.  A do_action() so message types using this
239
-     * messenger can add their own js.
240
-     *
241
-     * @return void.
242
-     */
243
-    public function enqueue_scripts_styles()
244
-    {
245
-        parent::enqueue_scripts_styles();
246
-        do_action('AHEE__EE_Html_messenger__enqueue_scripts_styles');
247
-    }
248
-
249
-
250
-    /**
251
-     * _set_template_fields
252
-     * This sets up the fields that a messenger requires for the message to go out.
253
-     *
254
-     * @access  protected
255
-     * @return void
256
-     */
257
-    protected function _set_template_fields()
258
-    {
259
-        // any extra template fields that are NOT used by the messenger
260
-        // but will get used by a messenger field for shortcode replacement
261
-        // get added to the 'extra' key in an associated array
262
-        // indexed by the messenger field they relate to.
263
-        // This is important for the Messages_admin to know what fields to display to the user.
264
-        // Also, notice that the "values" are equal to the field type
265
-        // that messages admin will use to know what kind of field to display.
266
-        // The values ALSO have one index labeled "shortcode".
267
-        // The values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE])
268
-        // is required in order for this extra field to be displayed.
269
-        //  If the required shortcode isn't part of the shortcodes array
270
-        // then the field is not needed and will not be displayed/parsed.
271
-        $this->_template_fields = [
272
-            'subject' => [
273
-                'input'      => 'text',
274
-                'label'      => esc_html__('Page Title', 'event_espresso'),
275
-                'type'       => 'string',
276
-                'required'   => true,
277
-                'validation' => true,
278
-                'css_class'  => 'large-text',
279
-                'format'     => '%s',
280
-            ],
281
-            'content' => '',
282
-            // left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
283
-            'extra'   => [
284
-                'content' => [
285
-                    'main'                          => [
286
-                        'input'      => 'wp_editor',
287
-                        'label'      => esc_html__('Main Content', 'event_espresso'),
288
-                        'type'       => 'string',
289
-                        'required'   => true,
290
-                        'validation' => true,
291
-                        'format'     => '%s',
292
-                        'rows'       => '15',
293
-                    ],
294
-                    'event_list'                    => [
295
-                        'input'               => 'wp_editor',
296
-                        'label'               => '[EVENT_LIST]',
297
-                        'type'                => 'string',
298
-                        'required'            => true,
299
-                        'validation'          => true,
300
-                        'format'              => '%s',
301
-                        'rows'                => '15',
302
-                        'shortcodes_required' => ['[EVENT_LIST]'],
303
-                    ],
304
-                    'ticket_list'                   => [
305
-                        'input'               => 'textarea',
306
-                        'label'               => '[TICKET_LIST]',
307
-                        'type'                => 'string',
308
-                        'required'            => true,
309
-                        'validation'          => true,
310
-                        'format'              => '%s',
311
-                        'css_class'           => 'large-text',
312
-                        'rows'                => '10',
313
-                        'shortcodes_required' => ['[TICKET_LIST]'],
314
-                    ],
315
-                    'ticket_line_item_no_pms'       => [
316
-                        'input'               => 'textarea',
317
-                        'label'               => '[TICKET_LINE_ITEM_LIST] <br>' . esc_html__(
318
-                            'Ticket Line Item List with no Price Modifiers',
319
-                            'event_espresso'
320
-                        ),
321
-                        'type'                => 'string',
322
-                        'required'            => false,
323
-                        'validation'          => true,
324
-                        'format'              => '%s',
325
-                        'css_class'           => 'large-text',
326
-                        'rows'                => '5',
327
-                        'shortcodes_required' => ['[TICKET_LINE_ITEM_LIST]'],
328
-                    ],
329
-                    'ticket_line_item_pms'          => [
330
-                        'input'               => 'textarea',
331
-                        'label'               => '[TICKET_LINE_ITEM_LIST] <br>' . esc_html__(
332
-                            'Ticket Line Item List with Price Modifiers',
333
-                            'event_espresso'
334
-                        ),
335
-                        'type'                => 'string',
336
-                        'required'            => false,
337
-                        'validation'          => true,
338
-                        'format'              => '%s',
339
-                        'css_class'           => 'large-text',
340
-                        'rows'                => '5',
341
-                        'shortcodes_required' => ['[TICKET_LINE_ITEM_LIST]'],
342
-                    ],
343
-                    'price_modifier_line_item_list' => [
344
-                        'input'               => 'textarea',
345
-                        'label'               => '[PRICE_MODIFIER_LINE_ITEM_LIST]',
346
-                        'type'                => 'string',
347
-                        'required'            => false,
348
-                        'validation'          => true,
349
-                        'format'              => '%s',
350
-                        'css_class'           => 'large-text',
351
-                        'rows'                => '5',
352
-                        'shortcodes_required' => ['[PRICE_MODIFIER_LINE_ITEM_LIST]'],
353
-                    ],
354
-                    'datetime_list'                 => [
355
-                        'input'               => 'textarea',
356
-                        'label'               => '[DATETIME_LIST]',
357
-                        'type'                => 'string',
358
-                        'required'            => true,
359
-                        'validation'          => true,
360
-                        'format'              => '%s',
361
-                        'css_class'           => 'large-text',
362
-                        'rows'                => '5',
363
-                        'shortcodes_required' => ['[DATETIME_LIST]'],
364
-                    ],
365
-                    'attendee_list'                 => [
366
-                        'input'               => 'textarea',
367
-                        'label'               => '[ATTENDEE_LIST]',
368
-                        'type'                => 'string',
369
-                        'required'            => true,
370
-                        'validation'          => true,
371
-                        'format'              => '%s',
372
-                        'css_class'           => 'large-text',
373
-                        'rows'                => '5',
374
-                        'shortcodes_required' => ['[ATTENDEE_LIST]'],
375
-                    ],
376
-                    'tax_line_item_list'            => [
377
-                        'input'               => 'textarea',
378
-                        'label'               => '[TAX_LINE_ITEM_LIST]',
379
-                        'type'                => 'string',
380
-                        'required'            => false,
381
-                        'validation'          => true,
382
-                        'format'              => '%s',
383
-                        'css_class'           => 'large-text',
384
-                        'rows'                => '5',
385
-                        'shortcodes_required' => ['[TAX_LINE_ITEM_LIST]'],
386
-                    ],
387
-                    'additional_line_item_list'     => [
388
-                        'input'               => 'textarea',
389
-                        'label'               => '[ADDITIONAL_LINE_ITEM_LIST]',
390
-                        'type'                => 'string',
391
-                        'required'            => false,
392
-                        'validation'          => true,
393
-                        'format'              => '%s',
394
-                        'css_class'           => 'large-text',
395
-                        'rows'                => '5',
396
-                        'shortcodes_required' => ['[ADDITIONAL_LINE_ITEM_LIST]'],
397
-                    ],
398
-                    'payment_list'                  => [
399
-                        'input'               => 'textarea',
400
-                        'label'               => '[PAYMENT_LIST]',
401
-                        'type'                => 'string',
402
-                        'required'            => true,
403
-                        'validation'          => true,
404
-                        'format'              => '%s',
405
-                        'css_class'           => 'large-text',
406
-                        'rows'                => '5',
407
-                        'shortcodes_required' => ['[PAYMENT_LIST_*]'],
408
-                    ],
409
-                ],
410
-            ],
411
-        ];
412
-    }
413
-
414
-
415
-    /**
416
-     * @see   definition of this method in parent
417
-     * @since 4.5.0
418
-     */
419
-    protected function _set_default_message_types()
420
-    {
421
-        $this->_default_message_types = ['receipt', 'invoice'];
422
-    }
423
-
424
-
425
-    /**
426
-     * @see   definition of this method in parent
427
-     * @since 4.5.0
428
-     */
429
-    protected function _set_valid_message_types()
430
-    {
431
-        $this->_valid_message_types = ['receipt', 'invoice'];
432
-    }
433
-
434
-
435
-    /**
436
-     * Displays the message in the browser.
437
-     *
438
-     * @return void.
439
-     * @since 4.5.0
440
-     */
441
-    protected function _send_message()
442
-    {
443
-        $this->_template_args = [
444
-            'page_title' => $this->_subject,
445
-            'base_css'   => $this->get_variation(
446
-                $this->_tmp_pack,
447
-                $this->_incoming_message_type->name,
448
-                true,
449
-                'base',
450
-                $this->_variation
451
-            ),
452
-            'print_css'  => $this->get_variation(
453
-                $this->_tmp_pack,
454
-                $this->_incoming_message_type->name,
455
-                true,
456
-                'print',
457
-                $this->_variation
458
-            ),
459
-            'main_css'   => $this->get_variation(
460
-                $this->_tmp_pack,
461
-                $this->_incoming_message_type->name,
462
-                true,
463
-                'main',
464
-                $this->_variation
465
-            ),
466
-            'main_body'  => wpautop(
467
-                apply_filters(
468
-                    'FHEE__EE_Html_messenger___send_message__main_body',
469
-                    $this->_content,
470
-                    $this->_content,
471
-                    $this->_incoming_message_type
472
-                )
473
-            ),
474
-        ];
475
-        $this->_deregister_wp_hooks();
476
-        add_action('wp_enqueue_scripts', [$this, 'enqueue_scripts_styles']);
477
-        echo '<!doctype html>' . wp_kses($this->_get_main_template(), AllowedTags::getWithFullTags());
478
-        exit();
479
-    }
480
-
481
-
482
-    /**
483
-     * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't
484
-     * interfere with our templates.  If users want to add any custom styles or scripts they must use the
485
-     * AHEE__EE_Html_messenger__enqueue_scripts_styles hook.
486
-     *
487
-     * @return void
488
-     * @since 4.5.0
489
-     */
490
-    protected function _deregister_wp_hooks()
491
-    {
492
-        remove_all_actions('wp_head');
493
-        remove_all_actions('wp_footer');
494
-        remove_all_actions('wp_print_footer_scripts');
495
-        remove_all_actions('wp_enqueue_scripts');
496
-        global $wp_scripts, $wp_styles;
497
-        $wp_scripts = $wp_styles = [];
498
-        // just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load.
499
-        add_action('wp_footer', 'wp_print_footer_scripts');
500
-        add_action('wp_print_footer_scripts', '_wp_footer_scripts');
501
-        add_action('wp_head', 'wp_enqueue_scripts');
502
-    }
503
-
504
-
505
-    /**
506
-     * Overwrite parent _get_main_template for display_html purposes.
507
-     *
508
-     * @param bool $preview
509
-     * @return string
510
-     * @since  4.5.0
511
-     */
512
-    protected function _get_main_template($preview = false): string
513
-    {
514
-        $wrapper_template = $this->_tmp_pack->get_wrapper($this->name);
515
-        // include message type as a template arg
516
-        $this->_template_args['message_type'] = $this->_incoming_message_type;
517
-        return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
518
-    }
519
-
520
-
521
-    /**
522
-     * @return void
523
-     */
524
-    protected function _preview()
525
-    {
526
-        $this->_send_message();
527
-    }
528
-
529
-
530
-    protected function _set_admin_settings_fields()
531
-    {
532
-    }
533
-
534
-
535
-    /**
536
-     * add the "powered by EE" credit link to the HTML receipt and invoice
537
-     *
538
-     * @param string          $content
539
-     * @param string          $content_again
540
-     * @param EE_message_type $incoming_message_type
541
-     * @return string
542
-     */
543
-    public function add_powered_by_credit_link_to_receipt_and_invoice(
544
-        string $content,
545
-        string $content_again,
546
-        EE_message_type $incoming_message_type
547
-    ): string {
548
-        if (
549
-            ($incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt')
550
-            && apply_filters('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true)
551
-        ) {
552
-            $content .= EEH_Template::powered_by_event_espresso(
553
-                'aln-cntr',
554
-                '',
555
-                ['utm_content' => 'messages_system']
556
-            ) . EEH_HTML::div(EEH_HTML::p('&nbsp;'));
557
-        }
558
-        return $content;
559
-    }
15
+	/**
16
+	 * The following are the properties that this messenger requires for displaying the html
17
+	 */
18
+	/**
19
+	 * This is the html body generated by the template via the message type.
20
+	 *
21
+	 * @var string
22
+	 */
23
+	protected $_content = '';
24
+
25
+	/**
26
+	 * This is for the page title that gets displayed.  (Why use "subject"?  Because the "title" tag in html is
27
+	 * equivalent to the "subject" of the page.
28
+	 *
29
+	 * @var string
30
+	 */
31
+	protected $_subject = '';
32
+
33
+
34
+	/**
35
+	 * EE_Html_messenger constructor.
36
+	 */
37
+	public function __construct()
38
+	{
39
+		// set properties
40
+		$this->name                = 'html';
41
+		$this->description         = esc_html__(
42
+			'This messenger outputs a message to a browser for display.',
43
+			'event_espresso'
44
+		);
45
+		$this->label               = [
46
+			'singular' => esc_html__('html', 'event_espresso'),
47
+			'plural'   => esc_html__('html', 'event_espresso'),
48
+		];
49
+		$this->activate_on_install = true;
50
+		// add the "powered by EE" credit link to the HTML receipt and invoice
51
+		add_filter(
52
+			'FHEE__EE_Html_messenger___send_message__main_body',
53
+			[$this, 'add_powered_by_credit_link_to_receipt_and_invoice'],
54
+			10,
55
+			3
56
+		);
57
+		parent::__construct();
58
+	}
59
+
60
+
61
+	/**
62
+	 * HTML Messenger desires execution immediately.
63
+	 *
64
+	 * @return bool
65
+	 * @since  4.9.0
66
+	 * @see    parent::send_now() for documentation.
67
+	 */
68
+	public function send_now(): bool
69
+	{
70
+		return true;
71
+	}
72
+
73
+
74
+	/**
75
+	 * HTML Messenger allows an empty to field.
76
+	 *
77
+	 * @return bool
78
+	 * @since  4.9.0
79
+	 * @see    parent::allow_empty_to_field() for documentation
80
+	 */
81
+	public function allow_empty_to_field(): bool
82
+	{
83
+		return true;
84
+	}
85
+
86
+
87
+	/**
88
+	 * @see abstract declaration in EE_messenger for details.
89
+	 */
90
+	protected function _set_admin_pages()
91
+	{
92
+		$this->admin_registered_pages = ['events_edit' => true];
93
+	}
94
+
95
+
96
+	/**
97
+	 * @see abstract declaration in EE_messenger for details.
98
+	 */
99
+	protected function _set_valid_shortcodes()
100
+	{
101
+		$this->_valid_shortcodes = [];
102
+	}
103
+
104
+
105
+	/**
106
+	 * @see abstract declaration in EE_messenger for details.
107
+	 */
108
+	protected function _set_validator_config()
109
+	{
110
+		$this->_validator_config = [
111
+			'subject'                       => [
112
+				'shortcodes' => ['organization', 'primary_registration_details', 'email', 'transaction'],
113
+			],
114
+			'content'                       => [
115
+				'shortcodes' => [
116
+					'organization',
117
+					'primary_registration_list',
118
+					'primary_registration_details',
119
+					'email',
120
+					'transaction',
121
+					'event_list',
122
+					'payment_list',
123
+					'venue',
124
+					'line_item_list',
125
+					'messenger',
126
+					'ticket_list',
127
+				],
128
+			],
129
+			'event_list'                    => [
130
+				'shortcodes' => [
131
+					'event',
132
+					'ticket_list',
133
+					'venue',
134
+					'primary_registration_details',
135
+					'primary_registration_list',
136
+					'event_author',
137
+				],
138
+				'required'   => ['[EVENT_LIST]'],
139
+			],
140
+			'ticket_list'                   => [
141
+				'shortcodes' => [
142
+					'attendee_list',
143
+					'ticket',
144
+					'datetime_list',
145
+					'primary_registration_details',
146
+					'line_item_list',
147
+					'venue',
148
+				],
149
+				'required'   => ['[TICKET_LIST]'],
150
+			],
151
+			'ticket_line_item_no_pms'       => [
152
+				'shortcodes' => ['line_item', 'ticket'],
153
+				'required'   => ['[TICKET_LINE_ITEM_LIST]'],
154
+			],
155
+			'ticket_line_item_pms'          => [
156
+				'shortcodes' => ['line_item', 'ticket', 'line_item_list'],
157
+				'required'   => ['[TICKET_LINE_ITEM_LIST]'],
158
+			],
159
+			'price_modifier_line_item_list' => [
160
+				'shortcodes' => ['line_item'],
161
+				'required'   => ['[PRICE_MODIFIER_LINE_ITEM_LIST]'],
162
+			],
163
+			'datetime_list'                 => [
164
+				'shortcodes' => ['datetime'],
165
+				'required'   => ['[DATETIME_LIST]'],
166
+			],
167
+			'attendee_list'                 => [
168
+				'shortcodes' => ['attendee'],
169
+				'required'   => ['[ATTENDEE_LIST]'],
170
+			],
171
+			'tax_line_item_list'            => [
172
+				'shortcodes' => ['line_item'],
173
+				'required'   => ['[TAX_LINE_ITEM_LIST]'],
174
+			],
175
+			'additional_line_item_list'     => [
176
+				'shortcodes' => ['line_item'],
177
+				'required'   => ['[ADDITIONAL_LINE_ITEM_LIST]'],
178
+			],
179
+			'payment_list'                  => [
180
+				'shortcodes' => ['payment'],
181
+				'required'   => ['[PAYMENT_LIST_*]'],
182
+			],
183
+		];
184
+	}
185
+
186
+
187
+	/**
188
+	 * This is a method called from EE_messages when this messenger is a generating messenger and the sending messenger
189
+	 * is a different messenger.  Child messengers can set hooks for the sending messenger to callback on if necessary
190
+	 * (i.e. swap out css files or something else).
191
+	 *
192
+	 * @param string $sending_messenger_name the name of the sending messenger so we only set the hooks needed.
193
+	 * @return void
194
+	 * @since 4.5.0
195
+	 */
196
+	public function do_secondary_messenger_hooks($sending_messenger_name)
197
+	{
198
+		if ($sending_messenger_name === 'pdf') {
199
+			add_filter('EE_messenger__get_variation__variation', [$this, 'add_html_css'], 10, 8);
200
+		}
201
+	}
202
+
203
+
204
+	/**
205
+	 * @param                            $variation_path
206
+	 * @param EE_Messages_Template_Pack  $template_pack
207
+	 * @param                            $messenger_name
208
+	 * @param                            $message_type_name
209
+	 * @param                            $url
210
+	 * @param                            $type
211
+	 * @param                            $variation
212
+	 * @param                            $skip_filters
213
+	 * @return string
214
+	 */
215
+	public function add_html_css(
216
+		$variation_path,
217
+		EE_Messages_Template_Pack $template_pack,
218
+		$messenger_name,
219
+		$message_type_name,
220
+		$url,
221
+		$type,
222
+		$variation,
223
+		$skip_filters
224
+	): string {
225
+		return $template_pack->get_variation(
226
+			$this->name,
227
+			$message_type_name,
228
+			$type,
229
+			$variation,
230
+			$url,
231
+			'.css',
232
+			$skip_filters
233
+		);
234
+	}
235
+
236
+
237
+	/**
238
+	 * Takes care of enqueuing any necessary scripts or styles for the page.  A do_action() so message types using this
239
+	 * messenger can add their own js.
240
+	 *
241
+	 * @return void.
242
+	 */
243
+	public function enqueue_scripts_styles()
244
+	{
245
+		parent::enqueue_scripts_styles();
246
+		do_action('AHEE__EE_Html_messenger__enqueue_scripts_styles');
247
+	}
248
+
249
+
250
+	/**
251
+	 * _set_template_fields
252
+	 * This sets up the fields that a messenger requires for the message to go out.
253
+	 *
254
+	 * @access  protected
255
+	 * @return void
256
+	 */
257
+	protected function _set_template_fields()
258
+	{
259
+		// any extra template fields that are NOT used by the messenger
260
+		// but will get used by a messenger field for shortcode replacement
261
+		// get added to the 'extra' key in an associated array
262
+		// indexed by the messenger field they relate to.
263
+		// This is important for the Messages_admin to know what fields to display to the user.
264
+		// Also, notice that the "values" are equal to the field type
265
+		// that messages admin will use to know what kind of field to display.
266
+		// The values ALSO have one index labeled "shortcode".
267
+		// The values in that array indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE])
268
+		// is required in order for this extra field to be displayed.
269
+		//  If the required shortcode isn't part of the shortcodes array
270
+		// then the field is not needed and will not be displayed/parsed.
271
+		$this->_template_fields = [
272
+			'subject' => [
273
+				'input'      => 'text',
274
+				'label'      => esc_html__('Page Title', 'event_espresso'),
275
+				'type'       => 'string',
276
+				'required'   => true,
277
+				'validation' => true,
278
+				'css_class'  => 'large-text',
279
+				'format'     => '%s',
280
+			],
281
+			'content' => '',
282
+			// left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field.
283
+			'extra'   => [
284
+				'content' => [
285
+					'main'                          => [
286
+						'input'      => 'wp_editor',
287
+						'label'      => esc_html__('Main Content', 'event_espresso'),
288
+						'type'       => 'string',
289
+						'required'   => true,
290
+						'validation' => true,
291
+						'format'     => '%s',
292
+						'rows'       => '15',
293
+					],
294
+					'event_list'                    => [
295
+						'input'               => 'wp_editor',
296
+						'label'               => '[EVENT_LIST]',
297
+						'type'                => 'string',
298
+						'required'            => true,
299
+						'validation'          => true,
300
+						'format'              => '%s',
301
+						'rows'                => '15',
302
+						'shortcodes_required' => ['[EVENT_LIST]'],
303
+					],
304
+					'ticket_list'                   => [
305
+						'input'               => 'textarea',
306
+						'label'               => '[TICKET_LIST]',
307
+						'type'                => 'string',
308
+						'required'            => true,
309
+						'validation'          => true,
310
+						'format'              => '%s',
311
+						'css_class'           => 'large-text',
312
+						'rows'                => '10',
313
+						'shortcodes_required' => ['[TICKET_LIST]'],
314
+					],
315
+					'ticket_line_item_no_pms'       => [
316
+						'input'               => 'textarea',
317
+						'label'               => '[TICKET_LINE_ITEM_LIST] <br>' . esc_html__(
318
+							'Ticket Line Item List with no Price Modifiers',
319
+							'event_espresso'
320
+						),
321
+						'type'                => 'string',
322
+						'required'            => false,
323
+						'validation'          => true,
324
+						'format'              => '%s',
325
+						'css_class'           => 'large-text',
326
+						'rows'                => '5',
327
+						'shortcodes_required' => ['[TICKET_LINE_ITEM_LIST]'],
328
+					],
329
+					'ticket_line_item_pms'          => [
330
+						'input'               => 'textarea',
331
+						'label'               => '[TICKET_LINE_ITEM_LIST] <br>' . esc_html__(
332
+							'Ticket Line Item List with Price Modifiers',
333
+							'event_espresso'
334
+						),
335
+						'type'                => 'string',
336
+						'required'            => false,
337
+						'validation'          => true,
338
+						'format'              => '%s',
339
+						'css_class'           => 'large-text',
340
+						'rows'                => '5',
341
+						'shortcodes_required' => ['[TICKET_LINE_ITEM_LIST]'],
342
+					],
343
+					'price_modifier_line_item_list' => [
344
+						'input'               => 'textarea',
345
+						'label'               => '[PRICE_MODIFIER_LINE_ITEM_LIST]',
346
+						'type'                => 'string',
347
+						'required'            => false,
348
+						'validation'          => true,
349
+						'format'              => '%s',
350
+						'css_class'           => 'large-text',
351
+						'rows'                => '5',
352
+						'shortcodes_required' => ['[PRICE_MODIFIER_LINE_ITEM_LIST]'],
353
+					],
354
+					'datetime_list'                 => [
355
+						'input'               => 'textarea',
356
+						'label'               => '[DATETIME_LIST]',
357
+						'type'                => 'string',
358
+						'required'            => true,
359
+						'validation'          => true,
360
+						'format'              => '%s',
361
+						'css_class'           => 'large-text',
362
+						'rows'                => '5',
363
+						'shortcodes_required' => ['[DATETIME_LIST]'],
364
+					],
365
+					'attendee_list'                 => [
366
+						'input'               => 'textarea',
367
+						'label'               => '[ATTENDEE_LIST]',
368
+						'type'                => 'string',
369
+						'required'            => true,
370
+						'validation'          => true,
371
+						'format'              => '%s',
372
+						'css_class'           => 'large-text',
373
+						'rows'                => '5',
374
+						'shortcodes_required' => ['[ATTENDEE_LIST]'],
375
+					],
376
+					'tax_line_item_list'            => [
377
+						'input'               => 'textarea',
378
+						'label'               => '[TAX_LINE_ITEM_LIST]',
379
+						'type'                => 'string',
380
+						'required'            => false,
381
+						'validation'          => true,
382
+						'format'              => '%s',
383
+						'css_class'           => 'large-text',
384
+						'rows'                => '5',
385
+						'shortcodes_required' => ['[TAX_LINE_ITEM_LIST]'],
386
+					],
387
+					'additional_line_item_list'     => [
388
+						'input'               => 'textarea',
389
+						'label'               => '[ADDITIONAL_LINE_ITEM_LIST]',
390
+						'type'                => 'string',
391
+						'required'            => false,
392
+						'validation'          => true,
393
+						'format'              => '%s',
394
+						'css_class'           => 'large-text',
395
+						'rows'                => '5',
396
+						'shortcodes_required' => ['[ADDITIONAL_LINE_ITEM_LIST]'],
397
+					],
398
+					'payment_list'                  => [
399
+						'input'               => 'textarea',
400
+						'label'               => '[PAYMENT_LIST]',
401
+						'type'                => 'string',
402
+						'required'            => true,
403
+						'validation'          => true,
404
+						'format'              => '%s',
405
+						'css_class'           => 'large-text',
406
+						'rows'                => '5',
407
+						'shortcodes_required' => ['[PAYMENT_LIST_*]'],
408
+					],
409
+				],
410
+			],
411
+		];
412
+	}
413
+
414
+
415
+	/**
416
+	 * @see   definition of this method in parent
417
+	 * @since 4.5.0
418
+	 */
419
+	protected function _set_default_message_types()
420
+	{
421
+		$this->_default_message_types = ['receipt', 'invoice'];
422
+	}
423
+
424
+
425
+	/**
426
+	 * @see   definition of this method in parent
427
+	 * @since 4.5.0
428
+	 */
429
+	protected function _set_valid_message_types()
430
+	{
431
+		$this->_valid_message_types = ['receipt', 'invoice'];
432
+	}
433
+
434
+
435
+	/**
436
+	 * Displays the message in the browser.
437
+	 *
438
+	 * @return void.
439
+	 * @since 4.5.0
440
+	 */
441
+	protected function _send_message()
442
+	{
443
+		$this->_template_args = [
444
+			'page_title' => $this->_subject,
445
+			'base_css'   => $this->get_variation(
446
+				$this->_tmp_pack,
447
+				$this->_incoming_message_type->name,
448
+				true,
449
+				'base',
450
+				$this->_variation
451
+			),
452
+			'print_css'  => $this->get_variation(
453
+				$this->_tmp_pack,
454
+				$this->_incoming_message_type->name,
455
+				true,
456
+				'print',
457
+				$this->_variation
458
+			),
459
+			'main_css'   => $this->get_variation(
460
+				$this->_tmp_pack,
461
+				$this->_incoming_message_type->name,
462
+				true,
463
+				'main',
464
+				$this->_variation
465
+			),
466
+			'main_body'  => wpautop(
467
+				apply_filters(
468
+					'FHEE__EE_Html_messenger___send_message__main_body',
469
+					$this->_content,
470
+					$this->_content,
471
+					$this->_incoming_message_type
472
+				)
473
+			),
474
+		];
475
+		$this->_deregister_wp_hooks();
476
+		add_action('wp_enqueue_scripts', [$this, 'enqueue_scripts_styles']);
477
+		echo '<!doctype html>' . wp_kses($this->_get_main_template(), AllowedTags::getWithFullTags());
478
+		exit();
479
+	}
480
+
481
+
482
+	/**
483
+	 * The purpose of this function is to de register all actions hooked into wp_head and wp_footer so that it doesn't
484
+	 * interfere with our templates.  If users want to add any custom styles or scripts they must use the
485
+	 * AHEE__EE_Html_messenger__enqueue_scripts_styles hook.
486
+	 *
487
+	 * @return void
488
+	 * @since 4.5.0
489
+	 */
490
+	protected function _deregister_wp_hooks()
491
+	{
492
+		remove_all_actions('wp_head');
493
+		remove_all_actions('wp_footer');
494
+		remove_all_actions('wp_print_footer_scripts');
495
+		remove_all_actions('wp_enqueue_scripts');
496
+		global $wp_scripts, $wp_styles;
497
+		$wp_scripts = $wp_styles = [];
498
+		// just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load.
499
+		add_action('wp_footer', 'wp_print_footer_scripts');
500
+		add_action('wp_print_footer_scripts', '_wp_footer_scripts');
501
+		add_action('wp_head', 'wp_enqueue_scripts');
502
+	}
503
+
504
+
505
+	/**
506
+	 * Overwrite parent _get_main_template for display_html purposes.
507
+	 *
508
+	 * @param bool $preview
509
+	 * @return string
510
+	 * @since  4.5.0
511
+	 */
512
+	protected function _get_main_template($preview = false): string
513
+	{
514
+		$wrapper_template = $this->_tmp_pack->get_wrapper($this->name);
515
+		// include message type as a template arg
516
+		$this->_template_args['message_type'] = $this->_incoming_message_type;
517
+		return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
518
+	}
519
+
520
+
521
+	/**
522
+	 * @return void
523
+	 */
524
+	protected function _preview()
525
+	{
526
+		$this->_send_message();
527
+	}
528
+
529
+
530
+	protected function _set_admin_settings_fields()
531
+	{
532
+	}
533
+
534
+
535
+	/**
536
+	 * add the "powered by EE" credit link to the HTML receipt and invoice
537
+	 *
538
+	 * @param string          $content
539
+	 * @param string          $content_again
540
+	 * @param EE_message_type $incoming_message_type
541
+	 * @return string
542
+	 */
543
+	public function add_powered_by_credit_link_to_receipt_and_invoice(
544
+		string $content,
545
+		string $content_again,
546
+		EE_message_type $incoming_message_type
547
+	): string {
548
+		if (
549
+			($incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt')
550
+			&& apply_filters('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true)
551
+		) {
552
+			$content .= EEH_Template::powered_by_event_espresso(
553
+				'aln-cntr',
554
+				'',
555
+				['utm_content' => 'messages_system']
556
+			) . EEH_HTML::div(EEH_HTML::p('&nbsp;'));
557
+		}
558
+		return $content;
559
+	}
560 560
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
             'This messenger outputs a message to a browser for display.',
43 43
             'event_espresso'
44 44
         );
45
-        $this->label               = [
45
+        $this->label = [
46 46
             'singular' => esc_html__('html', 'event_espresso'),
47 47
             'plural'   => esc_html__('html', 'event_espresso'),
48 48
         ];
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
                     ],
315 315
                     'ticket_line_item_no_pms'       => [
316 316
                         'input'               => 'textarea',
317
-                        'label'               => '[TICKET_LINE_ITEM_LIST] <br>' . esc_html__(
317
+                        'label'               => '[TICKET_LINE_ITEM_LIST] <br>'.esc_html__(
318 318
                             'Ticket Line Item List with no Price Modifiers',
319 319
                             'event_espresso'
320 320
                         ),
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
                     ],
329 329
                     'ticket_line_item_pms'          => [
330 330
                         'input'               => 'textarea',
331
-                        'label'               => '[TICKET_LINE_ITEM_LIST] <br>' . esc_html__(
331
+                        'label'               => '[TICKET_LINE_ITEM_LIST] <br>'.esc_html__(
332 332
                             'Ticket Line Item List with Price Modifiers',
333 333
                             'event_espresso'
334 334
                         ),
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
         ];
475 475
         $this->_deregister_wp_hooks();
476 476
         add_action('wp_enqueue_scripts', [$this, 'enqueue_scripts_styles']);
477
-        echo '<!doctype html>' . wp_kses($this->_get_main_template(), AllowedTags::getWithFullTags());
477
+        echo '<!doctype html>'.wp_kses($this->_get_main_template(), AllowedTags::getWithFullTags());
478 478
         exit();
479 479
     }
480 480
 
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
                 'aln-cntr',
554 554
                 '',
555 555
                 ['utm_content' => 'messages_system']
556
-            ) . EEH_HTML::div(EEH_HTML::p('&nbsp;'));
556
+            ).EEH_HTML::div(EEH_HTML::p('&nbsp;'));
557 557
         }
558 558
         return $content;
559 559
     }
Please login to merge, or discard this patch.
core/db_classes/EE_Venue.class.php 1 patch
Indentation   +562 added lines, -562 removed lines patch added patch discarded remove patch
@@ -11,566 +11,566 @@
 block discarded – undo
11 11
  */
12 12
 class EE_Venue extends EE_CPT_Base implements AddressInterface
13 13
 {
14
-    /**
15
-     *
16
-     * @param array  $props_n_values          incoming values
17
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
18
-     *                                        used.)
19
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
20
-     *                                        date_format and the second value is the time format
21
-     * @return EE_Attendee
22
-     */
23
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
24
-    {
25
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
26
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
27
-    }
28
-
29
-
30
-    /**
31
-     * @param array  $props_n_values  incoming values from the database
32
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
33
-     *                                the website will be used.
34
-     * @return EE_Attendee
35
-     */
36
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
37
-    {
38
-        return new self($props_n_values, true, $timezone);
39
-    }
40
-
41
-
42
-    /**
43
-     * Gets name
44
-     *
45
-     * @return string
46
-     */
47
-    public function name()
48
-    {
49
-        return $this->get('VNU_name');
50
-    }
51
-
52
-
53
-    /**
54
-     * Gets phone
55
-     *
56
-     * @return string
57
-     */
58
-    public function phone()
59
-    {
60
-        return $this->get('VNU_phone');
61
-    }
62
-
63
-
64
-    /**
65
-     * venue_url
66
-     *
67
-     * @return string
68
-     */
69
-    public function venue_url()
70
-    {
71
-        return $this->get('VNU_url');
72
-    }
73
-
74
-
75
-    /**
76
-     * Gets desc
77
-     *
78
-     * @return string
79
-     */
80
-    public function description()
81
-    {
82
-        return $this->get('VNU_desc');
83
-    }
84
-
85
-
86
-    /**
87
-     * Gets short description (AKA: the excerpt)
88
-     *
89
-     * @return string
90
-     */
91
-    public function excerpt()
92
-    {
93
-        return $this->get('VNU_short_desc');
94
-    }
95
-
96
-
97
-    /**
98
-     * Gets identifier
99
-     *
100
-     * @return string
101
-     */
102
-    public function identifier()
103
-    {
104
-        return $this->get('VNU_identifier');
105
-    }
106
-
107
-
108
-    /**
109
-     * Gets address
110
-     *
111
-     * @return string
112
-     */
113
-    public function address(): string
114
-    {
115
-        return $this->get('VNU_address');
116
-    }
117
-
118
-
119
-    /**
120
-     * Gets address2
121
-     *
122
-     * @return string
123
-     */
124
-    public function address2(): string
125
-    {
126
-        return $this->get('VNU_address2');
127
-    }
128
-
129
-
130
-    /**
131
-     * Gets city
132
-     *
133
-     * @return string
134
-     */
135
-    public function city(): string
136
-    {
137
-        return $this->get('VNU_city');
138
-    }
139
-
140
-    /**
141
-     * Gets state
142
-     *
143
-     * @return int
144
-     */
145
-    public function state_ID(): int
146
-    {
147
-        return $this->get('STA_ID');
148
-    }
149
-
150
-
151
-    /**
152
-     * @return string
153
-     */
154
-    public function state_abbrev(): string
155
-    {
156
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
157
-    }
158
-
159
-
160
-    /**
161
-     * @return string
162
-     */
163
-    public function state_name(): string
164
-    {
165
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : '';
166
-    }
167
-
168
-
169
-    /**
170
-     * Gets the state for this venue
171
-     *
172
-     * @return EE_State|null
173
-     */
174
-    public function state_obj(): ?EE_State
175
-    {
176
-        return $this->get_first_related('State');
177
-    }
178
-
179
-
180
-    /**
181
-     * either displays the state abbreviation or the state name, as determined
182
-     * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
183
-     * defaults to abbreviation
184
-     *
185
-     * @return string
186
-     */
187
-    public function state(): string
188
-    {
189
-        if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
190
-            return $this->state_abbrev();
191
-        } else {
192
-            return $this->state_name();
193
-        }
194
-    }
195
-
196
-
197
-    /**
198
-     * country_ID
199
-     *
200
-     * @return string
201
-     */
202
-    public function country_ID(): string
203
-    {
204
-        return $this->get('CNT_ISO');
205
-    }
206
-
207
-
208
-    /**
209
-     * @return string
210
-     */
211
-    public function country_name(): string
212
-    {
213
-        return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : '';
214
-    }
215
-
216
-
217
-    /**
218
-     * Gets the country of this venue
219
-     *
220
-     * @return EE_Country|null
221
-     */
222
-    public function country_obj(): ?EE_Country
223
-    {
224
-        return $this->get_first_related('Country');
225
-    }
226
-
227
-
228
-    /**
229
-     * either displays the country ISO2 code or the country name, as determined
230
-     * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
231
-     * defaults to abbreviation
232
-     *
233
-     * @return string
234
-     */
235
-    public function country(): string
236
-    {
237
-        if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
238
-            return $this->country_ID();
239
-        } else {
240
-            return $this->country_name();
241
-        }
242
-    }
243
-
244
-
245
-    /**
246
-     * Gets zip
247
-     *
248
-     * @return string
249
-     */
250
-    public function zip(): string
251
-    {
252
-        return $this->get('VNU_zip');
253
-    }
254
-
255
-
256
-    /**
257
-     * Gets capacity
258
-     *
259
-     * @return int|string
260
-     * @throws EE_Error
261
-     * @throws ReflectionException
262
-     */
263
-    public function capacity()
264
-    {
265
-        return $this->get_pretty('VNU_capacity', 'symbol');
266
-    }
267
-
268
-
269
-    /**
270
-     * Gets created
271
-     *
272
-     * @return string
273
-     */
274
-    public function created()
275
-    {
276
-        return $this->get('VNU_created');
277
-    }
278
-
279
-
280
-    /**
281
-     * Gets modified
282
-     *
283
-     * @return string
284
-     */
285
-    public function modified()
286
-    {
287
-        return $this->get('VNU_modified');
288
-    }
289
-
290
-
291
-    /**
292
-     * Gets order
293
-     *
294
-     * @return int
295
-     */
296
-    public function order()
297
-    {
298
-        return $this->get('VNU_order');
299
-    }
300
-
301
-
302
-    /**
303
-     * Gets wp_user
304
-     *
305
-     * @return int
306
-     */
307
-    public function wp_user()
308
-    {
309
-        return $this->get('VNU_wp_user');
310
-    }
311
-
312
-
313
-    /**
314
-     * @return string
315
-     */
316
-    public function virtual_phone()
317
-    {
318
-        return $this->get('VNU_virtual_phone');
319
-    }
320
-
321
-
322
-    /**
323
-     * @return string
324
-     */
325
-    public function virtual_url()
326
-    {
327
-        return $this->get('VNU_virtual_url');
328
-    }
329
-
330
-
331
-    /**
332
-     * @return bool
333
-     */
334
-    public function enable_for_gmap()
335
-    {
336
-        return $this->get('VNU_enable_for_gmap');
337
-    }
338
-
339
-
340
-    /**
341
-     * @return string
342
-     */
343
-    public function google_map_link()
344
-    {
345
-        return $this->get('VNU_google_map_link');
346
-    }
347
-
348
-
349
-    /**
350
-     * Gets all events happening at this venue. Query parameters can be added to
351
-     * fetch a subset of those events.
352
-     *
353
-     * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
354
-     * @param bool  $upcoming
355
-     * @return EE_Event[]
356
-     */
357
-    public function events($query_params = array(), $upcoming = false)
358
-    {
359
-        if ($upcoming) {
360
-            $query_params = array(
361
-                array(
362
-                    'status'                 => 'publish',
363
-                    'Datetime.DTT_EVT_start' => array(
364
-                        '>',
365
-                        EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
366
-                    ),
367
-                ),
368
-            );
369
-        }
370
-        return $this->get_many_related('Event', $query_params);
371
-    }
372
-
373
-
374
-    /**
375
-     * Sets address
376
-     */
377
-    public function set_address($address = '')
378
-    {
379
-        $this->set('VNU_address', $address);
380
-    }
381
-
382
-
383
-    /**
384
-     * @param string $address2
385
-     */
386
-    public function set_address2($address2 = '')
387
-    {
388
-        $this->set('VNU_address2', $address2);
389
-    }
390
-
391
-
392
-    /**
393
-     * @param string $city
394
-     */
395
-    public function set_city($city = '')
396
-    {
397
-        $this->set('VNU_city', $city);
398
-    }
399
-
400
-
401
-    /**
402
-     * @param int $state
403
-     */
404
-    public function set_state_ID($state = 0)
405
-    {
406
-        $this->set('STA_ID', $state);
407
-    }
408
-
409
-
410
-    /**
411
-     * Sets the state, given either a state id or state object
412
-     *
413
-     * @param EE_State /int $state_id_or_obj
414
-     * @return EE_State
415
-     */
416
-    public function set_state_obj($state_id_or_obj)
417
-    {
418
-        return $this->_add_relation_to($state_id_or_obj, 'State');
419
-    }
420
-
421
-
422
-    /**
423
-     * @param int $country_ID
424
-     */
425
-    public function set_country_ID($country_ID = 0)
426
-    {
427
-        $this->set('CNT_ISO', $country_ID);
428
-    }
429
-
430
-
431
-    /**
432
-     * Sets the country on the venue
433
-     *
434
-     * @param EE_Country /string $country_id_or_obj
435
-     * @return EE_Country
436
-     */
437
-    public function set_country_obj($country_id_or_obj)
438
-    {
439
-        return $this->_add_relation_to($country_id_or_obj, 'Country');
440
-    }
441
-
442
-
443
-    /**
444
-     * @param string $zip
445
-     */
446
-    public function set_zip($zip = '')
447
-    {
448
-        $this->set('VNU_zip', $zip);
449
-    }
450
-
451
-
452
-    /**
453
-     * @param int $capacity
454
-     */
455
-    public function set_capacity($capacity = 0)
456
-    {
457
-        $this->set('VNU_capacity', $capacity);
458
-    }
459
-
460
-
461
-    /**
462
-     * @param string $created
463
-     */
464
-    public function set_created($created = '')
465
-    {
466
-        $this->set('VNU_created', $created);
467
-    }
468
-
469
-
470
-    /**
471
-     * @param string $desc
472
-     */
473
-    public function set_description($desc = '')
474
-    {
475
-        $this->set('VNU_desc', $desc);
476
-    }
477
-
478
-
479
-    /**
480
-     * @param string $identifier
481
-     */
482
-    public function set_identifier($identifier = '')
483
-    {
484
-        $this->set('VNU_identifier', $identifier);
485
-    }
486
-
487
-
488
-    /**
489
-     * @param string $modified
490
-     */
491
-    public function set_modified($modified = '')
492
-    {
493
-        $this->set('VNU_modified', $modified);
494
-    }
495
-
496
-
497
-    /**
498
-     * @param string $name
499
-     */
500
-    public function set_name($name = '')
501
-    {
502
-        $this->set('VNU_name', $name);
503
-    }
504
-
505
-
506
-    /**
507
-     * @param int $order
508
-     */
509
-    public function set_order($order = 0)
510
-    {
511
-        $this->set('VNU_order', $order);
512
-    }
513
-
514
-
515
-    /**
516
-     * @param string $phone
517
-     */
518
-    public function set_phone($phone = '')
519
-    {
520
-        $this->set('VNU_phone', $phone);
521
-    }
522
-
523
-
524
-    /**
525
-     * @param int $wp_user
526
-     */
527
-    public function set_wp_user($wp_user = 1)
528
-    {
529
-        $this->set('VNU_wp_user', $wp_user);
530
-    }
531
-
532
-
533
-    /**
534
-     * @param string $url
535
-     */
536
-    public function set_venue_url($url = '')
537
-    {
538
-        $this->set('VNU_url', $url);
539
-    }
540
-
541
-
542
-    /**
543
-     * @param string $phone
544
-     */
545
-    public function set_virtual_phone($phone = '')
546
-    {
547
-        $this->set('VNU_virtual_phone', $phone);
548
-    }
549
-
550
-
551
-    /**
552
-     * @param string $url
553
-     */
554
-    public function set_virtual_url($url = '')
555
-    {
556
-        $this->set('VNU_virtual_url', $url);
557
-    }
558
-
559
-
560
-    /**
561
-     * @param string $enable
562
-     */
563
-    public function set_enable_for_gmap($enable = '')
564
-    {
565
-        $this->set('VNU_enable_for_gmap', $enable);
566
-    }
567
-
568
-
569
-    /**
570
-     * @param string $google_map_link
571
-     */
572
-    public function set_google_map_link($google_map_link = '')
573
-    {
574
-        $this->set('VNU_google_map_link', $google_map_link);
575
-    }
14
+	/**
15
+	 *
16
+	 * @param array  $props_n_values          incoming values
17
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
18
+	 *                                        used.)
19
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
20
+	 *                                        date_format and the second value is the time format
21
+	 * @return EE_Attendee
22
+	 */
23
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
24
+	{
25
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
26
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
27
+	}
28
+
29
+
30
+	/**
31
+	 * @param array  $props_n_values  incoming values from the database
32
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
33
+	 *                                the website will be used.
34
+	 * @return EE_Attendee
35
+	 */
36
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
37
+	{
38
+		return new self($props_n_values, true, $timezone);
39
+	}
40
+
41
+
42
+	/**
43
+	 * Gets name
44
+	 *
45
+	 * @return string
46
+	 */
47
+	public function name()
48
+	{
49
+		return $this->get('VNU_name');
50
+	}
51
+
52
+
53
+	/**
54
+	 * Gets phone
55
+	 *
56
+	 * @return string
57
+	 */
58
+	public function phone()
59
+	{
60
+		return $this->get('VNU_phone');
61
+	}
62
+
63
+
64
+	/**
65
+	 * venue_url
66
+	 *
67
+	 * @return string
68
+	 */
69
+	public function venue_url()
70
+	{
71
+		return $this->get('VNU_url');
72
+	}
73
+
74
+
75
+	/**
76
+	 * Gets desc
77
+	 *
78
+	 * @return string
79
+	 */
80
+	public function description()
81
+	{
82
+		return $this->get('VNU_desc');
83
+	}
84
+
85
+
86
+	/**
87
+	 * Gets short description (AKA: the excerpt)
88
+	 *
89
+	 * @return string
90
+	 */
91
+	public function excerpt()
92
+	{
93
+		return $this->get('VNU_short_desc');
94
+	}
95
+
96
+
97
+	/**
98
+	 * Gets identifier
99
+	 *
100
+	 * @return string
101
+	 */
102
+	public function identifier()
103
+	{
104
+		return $this->get('VNU_identifier');
105
+	}
106
+
107
+
108
+	/**
109
+	 * Gets address
110
+	 *
111
+	 * @return string
112
+	 */
113
+	public function address(): string
114
+	{
115
+		return $this->get('VNU_address');
116
+	}
117
+
118
+
119
+	/**
120
+	 * Gets address2
121
+	 *
122
+	 * @return string
123
+	 */
124
+	public function address2(): string
125
+	{
126
+		return $this->get('VNU_address2');
127
+	}
128
+
129
+
130
+	/**
131
+	 * Gets city
132
+	 *
133
+	 * @return string
134
+	 */
135
+	public function city(): string
136
+	{
137
+		return $this->get('VNU_city');
138
+	}
139
+
140
+	/**
141
+	 * Gets state
142
+	 *
143
+	 * @return int
144
+	 */
145
+	public function state_ID(): int
146
+	{
147
+		return $this->get('STA_ID');
148
+	}
149
+
150
+
151
+	/**
152
+	 * @return string
153
+	 */
154
+	public function state_abbrev(): string
155
+	{
156
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
157
+	}
158
+
159
+
160
+	/**
161
+	 * @return string
162
+	 */
163
+	public function state_name(): string
164
+	{
165
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->name() : '';
166
+	}
167
+
168
+
169
+	/**
170
+	 * Gets the state for this venue
171
+	 *
172
+	 * @return EE_State|null
173
+	 */
174
+	public function state_obj(): ?EE_State
175
+	{
176
+		return $this->get_first_related('State');
177
+	}
178
+
179
+
180
+	/**
181
+	 * either displays the state abbreviation or the state name, as determined
182
+	 * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
183
+	 * defaults to abbreviation
184
+	 *
185
+	 * @return string
186
+	 */
187
+	public function state(): string
188
+	{
189
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
190
+			return $this->state_abbrev();
191
+		} else {
192
+			return $this->state_name();
193
+		}
194
+	}
195
+
196
+
197
+	/**
198
+	 * country_ID
199
+	 *
200
+	 * @return string
201
+	 */
202
+	public function country_ID(): string
203
+	{
204
+		return $this->get('CNT_ISO');
205
+	}
206
+
207
+
208
+	/**
209
+	 * @return string
210
+	 */
211
+	public function country_name(): string
212
+	{
213
+		return $this->country_obj() instanceof EE_Country ? $this->country_obj()->name() : '';
214
+	}
215
+
216
+
217
+	/**
218
+	 * Gets the country of this venue
219
+	 *
220
+	 * @return EE_Country|null
221
+	 */
222
+	public function country_obj(): ?EE_Country
223
+	{
224
+		return $this->get_first_related('Country');
225
+	}
226
+
227
+
228
+	/**
229
+	 * either displays the country ISO2 code or the country name, as determined
230
+	 * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
231
+	 * defaults to abbreviation
232
+	 *
233
+	 * @return string
234
+	 */
235
+	public function country(): string
236
+	{
237
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
238
+			return $this->country_ID();
239
+		} else {
240
+			return $this->country_name();
241
+		}
242
+	}
243
+
244
+
245
+	/**
246
+	 * Gets zip
247
+	 *
248
+	 * @return string
249
+	 */
250
+	public function zip(): string
251
+	{
252
+		return $this->get('VNU_zip');
253
+	}
254
+
255
+
256
+	/**
257
+	 * Gets capacity
258
+	 *
259
+	 * @return int|string
260
+	 * @throws EE_Error
261
+	 * @throws ReflectionException
262
+	 */
263
+	public function capacity()
264
+	{
265
+		return $this->get_pretty('VNU_capacity', 'symbol');
266
+	}
267
+
268
+
269
+	/**
270
+	 * Gets created
271
+	 *
272
+	 * @return string
273
+	 */
274
+	public function created()
275
+	{
276
+		return $this->get('VNU_created');
277
+	}
278
+
279
+
280
+	/**
281
+	 * Gets modified
282
+	 *
283
+	 * @return string
284
+	 */
285
+	public function modified()
286
+	{
287
+		return $this->get('VNU_modified');
288
+	}
289
+
290
+
291
+	/**
292
+	 * Gets order
293
+	 *
294
+	 * @return int
295
+	 */
296
+	public function order()
297
+	{
298
+		return $this->get('VNU_order');
299
+	}
300
+
301
+
302
+	/**
303
+	 * Gets wp_user
304
+	 *
305
+	 * @return int
306
+	 */
307
+	public function wp_user()
308
+	{
309
+		return $this->get('VNU_wp_user');
310
+	}
311
+
312
+
313
+	/**
314
+	 * @return string
315
+	 */
316
+	public function virtual_phone()
317
+	{
318
+		return $this->get('VNU_virtual_phone');
319
+	}
320
+
321
+
322
+	/**
323
+	 * @return string
324
+	 */
325
+	public function virtual_url()
326
+	{
327
+		return $this->get('VNU_virtual_url');
328
+	}
329
+
330
+
331
+	/**
332
+	 * @return bool
333
+	 */
334
+	public function enable_for_gmap()
335
+	{
336
+		return $this->get('VNU_enable_for_gmap');
337
+	}
338
+
339
+
340
+	/**
341
+	 * @return string
342
+	 */
343
+	public function google_map_link()
344
+	{
345
+		return $this->get('VNU_google_map_link');
346
+	}
347
+
348
+
349
+	/**
350
+	 * Gets all events happening at this venue. Query parameters can be added to
351
+	 * fetch a subset of those events.
352
+	 *
353
+	 * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
354
+	 * @param bool  $upcoming
355
+	 * @return EE_Event[]
356
+	 */
357
+	public function events($query_params = array(), $upcoming = false)
358
+	{
359
+		if ($upcoming) {
360
+			$query_params = array(
361
+				array(
362
+					'status'                 => 'publish',
363
+					'Datetime.DTT_EVT_start' => array(
364
+						'>',
365
+						EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start'),
366
+					),
367
+				),
368
+			);
369
+		}
370
+		return $this->get_many_related('Event', $query_params);
371
+	}
372
+
373
+
374
+	/**
375
+	 * Sets address
376
+	 */
377
+	public function set_address($address = '')
378
+	{
379
+		$this->set('VNU_address', $address);
380
+	}
381
+
382
+
383
+	/**
384
+	 * @param string $address2
385
+	 */
386
+	public function set_address2($address2 = '')
387
+	{
388
+		$this->set('VNU_address2', $address2);
389
+	}
390
+
391
+
392
+	/**
393
+	 * @param string $city
394
+	 */
395
+	public function set_city($city = '')
396
+	{
397
+		$this->set('VNU_city', $city);
398
+	}
399
+
400
+
401
+	/**
402
+	 * @param int $state
403
+	 */
404
+	public function set_state_ID($state = 0)
405
+	{
406
+		$this->set('STA_ID', $state);
407
+	}
408
+
409
+
410
+	/**
411
+	 * Sets the state, given either a state id or state object
412
+	 *
413
+	 * @param EE_State /int $state_id_or_obj
414
+	 * @return EE_State
415
+	 */
416
+	public function set_state_obj($state_id_or_obj)
417
+	{
418
+		return $this->_add_relation_to($state_id_or_obj, 'State');
419
+	}
420
+
421
+
422
+	/**
423
+	 * @param int $country_ID
424
+	 */
425
+	public function set_country_ID($country_ID = 0)
426
+	{
427
+		$this->set('CNT_ISO', $country_ID);
428
+	}
429
+
430
+
431
+	/**
432
+	 * Sets the country on the venue
433
+	 *
434
+	 * @param EE_Country /string $country_id_or_obj
435
+	 * @return EE_Country
436
+	 */
437
+	public function set_country_obj($country_id_or_obj)
438
+	{
439
+		return $this->_add_relation_to($country_id_or_obj, 'Country');
440
+	}
441
+
442
+
443
+	/**
444
+	 * @param string $zip
445
+	 */
446
+	public function set_zip($zip = '')
447
+	{
448
+		$this->set('VNU_zip', $zip);
449
+	}
450
+
451
+
452
+	/**
453
+	 * @param int $capacity
454
+	 */
455
+	public function set_capacity($capacity = 0)
456
+	{
457
+		$this->set('VNU_capacity', $capacity);
458
+	}
459
+
460
+
461
+	/**
462
+	 * @param string $created
463
+	 */
464
+	public function set_created($created = '')
465
+	{
466
+		$this->set('VNU_created', $created);
467
+	}
468
+
469
+
470
+	/**
471
+	 * @param string $desc
472
+	 */
473
+	public function set_description($desc = '')
474
+	{
475
+		$this->set('VNU_desc', $desc);
476
+	}
477
+
478
+
479
+	/**
480
+	 * @param string $identifier
481
+	 */
482
+	public function set_identifier($identifier = '')
483
+	{
484
+		$this->set('VNU_identifier', $identifier);
485
+	}
486
+
487
+
488
+	/**
489
+	 * @param string $modified
490
+	 */
491
+	public function set_modified($modified = '')
492
+	{
493
+		$this->set('VNU_modified', $modified);
494
+	}
495
+
496
+
497
+	/**
498
+	 * @param string $name
499
+	 */
500
+	public function set_name($name = '')
501
+	{
502
+		$this->set('VNU_name', $name);
503
+	}
504
+
505
+
506
+	/**
507
+	 * @param int $order
508
+	 */
509
+	public function set_order($order = 0)
510
+	{
511
+		$this->set('VNU_order', $order);
512
+	}
513
+
514
+
515
+	/**
516
+	 * @param string $phone
517
+	 */
518
+	public function set_phone($phone = '')
519
+	{
520
+		$this->set('VNU_phone', $phone);
521
+	}
522
+
523
+
524
+	/**
525
+	 * @param int $wp_user
526
+	 */
527
+	public function set_wp_user($wp_user = 1)
528
+	{
529
+		$this->set('VNU_wp_user', $wp_user);
530
+	}
531
+
532
+
533
+	/**
534
+	 * @param string $url
535
+	 */
536
+	public function set_venue_url($url = '')
537
+	{
538
+		$this->set('VNU_url', $url);
539
+	}
540
+
541
+
542
+	/**
543
+	 * @param string $phone
544
+	 */
545
+	public function set_virtual_phone($phone = '')
546
+	{
547
+		$this->set('VNU_virtual_phone', $phone);
548
+	}
549
+
550
+
551
+	/**
552
+	 * @param string $url
553
+	 */
554
+	public function set_virtual_url($url = '')
555
+	{
556
+		$this->set('VNU_virtual_url', $url);
557
+	}
558
+
559
+
560
+	/**
561
+	 * @param string $enable
562
+	 */
563
+	public function set_enable_for_gmap($enable = '')
564
+	{
565
+		$this->set('VNU_enable_for_gmap', $enable);
566
+	}
567
+
568
+
569
+	/**
570
+	 * @param string $google_map_link
571
+	 */
572
+	public function set_google_map_link($google_map_link = '')
573
+	{
574
+		$this->set('VNU_google_map_link', $google_map_link);
575
+	}
576 576
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Attendee.class.php 2 patches
Indentation   +747 added lines, -747 removed lines patch added patch discarded remove patch
@@ -25,751 +25,751 @@
 block discarded – undo
25 25
  */
26 26
 class EE_Attendee extends EE_CPT_Base implements EEI_Contact, AddressInterface, EEI_Admin_Links, EEI_Attendee
27 27
 {
28
-    /**
29
-     * Sets some dynamic defaults
30
-     *
31
-     * @param array  $fieldValues
32
-     * @param bool   $bydb
33
-     * @param string $timezone
34
-     * @param array  $date_formats
35
-     * @throws EE_Error
36
-     */
37
-    protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
38
-    {
39
-        if (! isset($fieldValues['ATT_full_name'])) {
40
-            $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
41
-            $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
42
-            $fieldValues['ATT_full_name'] = $fname . $lname;
43
-        }
44
-        if (! isset($fieldValues['ATT_slug'])) {
45
-            // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
46
-            $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
47
-        }
48
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
49
-            $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
50
-        }
51
-        parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
52
-    }
53
-
54
-
55
-    /**
56
-     * @param array  $props_n_values          incoming values
57
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
58
-     *                                        used.)
59
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
60
-     *                                        date_format and the second value is the time format
61
-     * @return EE_Attendee
62
-     * @throws EE_Error
63
-     */
64
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
65
-    {
66
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
67
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
68
-    }
69
-
70
-
71
-    /**
72
-     * @param array  $props_n_values  incoming values from the database
73
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
74
-     *                                the website will be used.
75
-     * @return EE_Attendee
76
-     */
77
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
78
-    {
79
-        return new self($props_n_values, true, $timezone);
80
-    }
81
-
82
-
83
-    /**
84
-     *        Set Attendee First Name
85
-     *
86
-     * @access        public
87
-     * @param string $fname
88
-     * @throws EE_Error
89
-     */
90
-    public function set_fname($fname = '')
91
-    {
92
-        $this->set('ATT_fname', $fname);
93
-    }
94
-
95
-
96
-    /**
97
-     *        Set Attendee Last Name
98
-     *
99
-     * @access        public
100
-     * @param string $lname
101
-     * @throws EE_Error
102
-     */
103
-    public function set_lname($lname = '')
104
-    {
105
-        $this->set('ATT_lname', $lname);
106
-    }
107
-
108
-
109
-    /**
110
-     *        Set Attendee Address
111
-     *
112
-     * @access        public
113
-     * @param string $address
114
-     * @throws EE_Error
115
-     */
116
-    public function set_address($address = '')
117
-    {
118
-        $this->set('ATT_address', $address);
119
-    }
120
-
121
-
122
-    /**
123
-     *        Set Attendee Address2
124
-     *
125
-     * @access        public
126
-     * @param        string $address2
127
-     * @throws EE_Error
128
-     */
129
-    public function set_address2($address2 = '')
130
-    {
131
-        $this->set('ATT_address2', $address2);
132
-    }
133
-
134
-
135
-    /**
136
-     *        Set Attendee City
137
-     *
138
-     * @access        public
139
-     * @param        string $city
140
-     * @throws EE_Error
141
-     */
142
-    public function set_city($city = '')
143
-    {
144
-        $this->set('ATT_city', $city);
145
-    }
146
-
147
-
148
-    /**
149
-     *        Set Attendee State ID
150
-     *
151
-     * @access        public
152
-     * @param        int $STA_ID
153
-     * @throws EE_Error
154
-     */
155
-    public function set_state($STA_ID = 0)
156
-    {
157
-        $this->set('STA_ID', $STA_ID);
158
-    }
159
-
160
-
161
-    /**
162
-     *        Set Attendee Country ISO Code
163
-     *
164
-     * @access        public
165
-     * @param        string $CNT_ISO
166
-     * @throws EE_Error
167
-     */
168
-    public function set_country($CNT_ISO = '')
169
-    {
170
-        $this->set('CNT_ISO', $CNT_ISO);
171
-    }
172
-
173
-
174
-    /**
175
-     *        Set Attendee Zip/Postal Code
176
-     *
177
-     * @access        public
178
-     * @param        string $zip
179
-     * @throws EE_Error
180
-     */
181
-    public function set_zip($zip = '')
182
-    {
183
-        $this->set('ATT_zip', $zip);
184
-    }
185
-
186
-
187
-    /**
188
-     *        Set Attendee Email Address
189
-     *
190
-     * @access        public
191
-     * @param        string $email
192
-     * @throws EE_Error
193
-     */
194
-    public function set_email($email = '')
195
-    {
196
-        $this->set('ATT_email', $email);
197
-    }
198
-
199
-
200
-    /**
201
-     *        Set Attendee Phone
202
-     *
203
-     * @access        public
204
-     * @param        string $phone
205
-     * @throws EE_Error
206
-     */
207
-    public function set_phone($phone = '')
208
-    {
209
-        $this->set('ATT_phone', $phone);
210
-    }
211
-
212
-
213
-    /**
214
-     *        set deleted
215
-     *
216
-     * @access        public
217
-     * @param        bool $ATT_deleted
218
-     * @throws EE_Error
219
-     */
220
-    public function set_deleted($ATT_deleted = false)
221
-    {
222
-        $this->set('ATT_deleted', $ATT_deleted);
223
-    }
224
-
225
-
226
-    /**
227
-     * Returns the value for the post_author id saved with the cpt
228
-     *
229
-     * @since 4.5.0
230
-     * @return int
231
-     * @throws EE_Error
232
-     */
233
-    public function wp_user()
234
-    {
235
-        return $this->get('ATT_author');
236
-    }
237
-
238
-
239
-    /**
240
-     *        get Attendee First Name
241
-     *
242
-     * @access        public
243
-     * @return string
244
-     * @throws EE_Error
245
-     */
246
-    public function fname()
247
-    {
248
-        return $this->get('ATT_fname');
249
-    }
250
-
251
-
252
-    /**
253
-     * echoes out the attendee's first name
254
-     *
255
-     * @return void
256
-     * @throws EE_Error
257
-     */
258
-    public function e_full_name()
259
-    {
260
-        echo esc_html($this->full_name());
261
-    }
262
-
263
-
264
-    /**
265
-     * Returns the first and last name concatenated together with a space.
266
-     *
267
-     * @param bool $apply_html_entities
268
-     * @return string
269
-     * @throws EE_Error
270
-     */
271
-    public function full_name($apply_html_entities = false)
272
-    {
273
-        $full_name = array(
274
-            $this->fname(),
275
-            $this->lname(),
276
-        );
277
-        $full_name = array_filter($full_name);
278
-        $full_name = implode(' ', $full_name);
279
-        return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
280
-    }
281
-
282
-
283
-    /**
284
-     * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
285
-     * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
286
-     * attendee.
287
-     *
288
-     * @param bool $apply_html_entities
289
-     * @return string
290
-     * @throws EE_Error
291
-     */
292
-    public function ATT_full_name($apply_html_entities = false)
293
-    {
294
-        return $apply_html_entities
295
-            ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
296
-            : $this->get('ATT_full_name');
297
-    }
298
-
299
-
300
-    /**
301
-     *        get Attendee Last Name
302
-     *
303
-     * @access        public
304
-     * @return string
305
-     * @throws EE_Error
306
-     */
307
-    public function lname()
308
-    {
309
-        return $this->get('ATT_lname');
310
-    }
311
-
312
-
313
-    /**
314
-     * Gets the attendee's full address as an array so client code can decide hwo to display it
315
-     *
316
-     * @return array numerically indexed, with each part of the address that is known.
317
-     * Eg, if the user only responded to state and country,
318
-     * it would be array(0=>'Alabama',1=>'USA')
319
-     * @return array
320
-     * @throws EE_Error
321
-     */
322
-    public function full_address_as_array()
323
-    {
324
-        $full_address_array = array();
325
-        $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
326
-        foreach ($initial_address_fields as $address_field_name) {
327
-            $address_fields_value = $this->get($address_field_name);
328
-            if (! empty($address_fields_value)) {
329
-                $full_address_array[] = $address_fields_value;
330
-            }
331
-        }
332
-        // now handle state and country
333
-        $state_obj = $this->state_obj();
334
-        if ($state_obj instanceof EE_State) {
335
-            $full_address_array[] = $state_obj->name();
336
-        }
337
-        $country_obj = $this->country_obj();
338
-        if ($country_obj instanceof EE_Country) {
339
-            $full_address_array[] = $country_obj->name();
340
-        }
341
-        // lastly get the xip
342
-        $zip_value = $this->zip();
343
-        if (! empty($zip_value)) {
344
-            $full_address_array[] = $zip_value;
345
-        }
346
-        return $full_address_array;
347
-    }
348
-
349
-
350
-    /**
351
-     *        get Attendee Address
352
-     *
353
-     * @return string
354
-     * @throws EE_Error
355
-     */
356
-    public function address(): string
357
-    {
358
-        return $this->get('ATT_address');
359
-    }
360
-
361
-
362
-    /**
363
-     *        get Attendee Address2
364
-     *
365
-     * @return string
366
-     * @throws EE_Error
367
-     */
368
-    public function address2(): string
369
-    {
370
-        return $this->get('ATT_address2');
371
-    }
372
-
373
-
374
-    /**
375
-     *        get Attendee City
376
-     *
377
-     * @return string
378
-     * @throws EE_Error
379
-     */
380
-    public function city(): string
381
-    {
382
-        return $this->get('ATT_city');
383
-    }
384
-
385
-
386
-    /**
387
-     * get Attendee State ID
388
-     *
389
-     * @return int
390
-     * @throws EE_Error
391
-     */
392
-    public function state_ID(): int
393
-    {
394
-        return $this->get('STA_ID');
395
-    }
396
-
397
-
398
-    /**
399
-     * @return string
400
-     * @throws EE_Error
401
-     */
402
-    public function state_abbrev(): string
403
-    {
404
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
405
-    }
406
-
407
-
408
-    /**
409
-     * Gets the state set to this attendee
410
-     *
411
-     * @return EE_State|null
412
-     * @throws EE_Error
413
-     */
414
-    public function state_obj(): ?EE_State
415
-    {
416
-        return $this->get_first_related('State');
417
-    }
418
-
419
-
420
-    /**
421
-     * Returns the state's name, otherwise 'Unknown'
422
-     *
423
-     * @return string
424
-     * @throws EE_Error
425
-     */
426
-    public function state_name(): string
427
-    {
428
-        if ($this->state_obj()) {
429
-            return $this->state_obj()->name();
430
-        } else {
431
-            return '';
432
-        }
433
-    }
434
-
435
-
436
-    /**
437
-     * either displays the state abbreviation or the state name, as determined
438
-     * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
439
-     * defaults to abbreviation
440
-     *
441
-     * @return string
442
-     * @throws EE_Error
443
-     */
444
-    public function state(): string
445
-    {
446
-        if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
447
-            return $this->state_abbrev();
448
-        }
449
-        return $this->state_name();
450
-    }
451
-
452
-
453
-    /**
454
-     *    get Attendee Country ISO Code
455
-     *
456
-     * @return string
457
-     * @throws EE_Error
458
-     */
459
-    public function country_ID(): string
460
-    {
461
-        return $this->get('CNT_ISO');
462
-    }
463
-
464
-
465
-    /**
466
-     * Gets country set for this attendee
467
-     *
468
-     * @return EE_Country|null
469
-     * @throws EE_Error
470
-     */
471
-    public function country_obj(): ?EE_Country
472
-    {
473
-        return $this->get_first_related('Country');
474
-    }
475
-
476
-
477
-    /**
478
-     * Returns the country's name if known, otherwise 'Unknown'
479
-     *
480
-     * @return string
481
-     * @throws EE_Error
482
-     */
483
-    public function country_name(): string
484
-    {
485
-        if ($this->country_obj()) {
486
-            return $this->country_obj()->name();
487
-        }
488
-        return '';
489
-    }
490
-
491
-
492
-    /**
493
-     * either displays the country ISO2 code or the country name, as determined
494
-     * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
495
-     * defaults to abbreviation
496
-     *
497
-     * @return string
498
-     * @throws EE_Error
499
-     */
500
-    public function country(): string
501
-    {
502
-        if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
503
-            return $this->country_ID();
504
-        }
505
-        return $this->country_name();
506
-    }
507
-
508
-
509
-    /**
510
-     *        get Attendee Zip/Postal Code
511
-     *
512
-     * @return string
513
-     * @throws EE_Error
514
-     */
515
-    public function zip(): string
516
-    {
517
-        return $this->get('ATT_zip');
518
-    }
519
-
520
-
521
-    /**
522
-     *        get Attendee Email Address
523
-     *
524
-     * @return string
525
-     * @throws EE_Error
526
-     */
527
-    public function email()
528
-    {
529
-        return $this->get('ATT_email');
530
-    }
531
-
532
-
533
-    /**
534
-     *        get Attendee Phone #
535
-     *
536
-     * @return string
537
-     * @throws EE_Error
538
-     */
539
-    public function phone()
540
-    {
541
-        return $this->get('ATT_phone');
542
-    }
543
-
544
-
545
-    /**
546
-     *    get deleted
547
-     *
548
-     * @return        bool
549
-     * @throws EE_Error
550
-     */
551
-    public function deleted()
552
-    {
553
-        return $this->get('ATT_deleted');
554
-    }
555
-
556
-
557
-    /**
558
-     * Gets registrations of this attendee
559
-     *
560
-     * @param array $query_params
561
-     * @return EE_Registration[]
562
-     * @throws EE_Error
563
-     */
564
-    public function get_registrations($query_params = array())
565
-    {
566
-        return $this->get_many_related('Registration', $query_params);
567
-    }
568
-
569
-
570
-    /**
571
-     * Gets the most recent registration of this attendee
572
-     *
573
-     * @return EE_Registration
574
-     * @throws EE_Error
575
-     */
576
-    public function get_most_recent_registration()
577
-    {
578
-        return $this->get_first_related(
579
-            'Registration',
580
-            array('order_by' => array('REG_date' => 'DESC'))
581
-        ); // null, 'REG_date', 'DESC', '=', 'OBJECT_K');
582
-    }
583
-
584
-
585
-    /**
586
-     * Gets the most recent registration for this attend at this event
587
-     *
588
-     * @param int $event_id
589
-     * @return EE_Registration
590
-     * @throws EE_Error
591
-     */
592
-    public function get_most_recent_registration_for_event($event_id)
593
-    {
594
-        return $this->get_first_related(
595
-            'Registration',
596
-            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))
597
-        );
598
-    }
599
-
600
-
601
-    /**
602
-     * returns any events attached to this attendee ($_Event property);
603
-     *
604
-     * @return array
605
-     * @throws EE_Error
606
-     */
607
-    public function events()
608
-    {
609
-        return $this->get_many_related('Event');
610
-    }
611
-
612
-
613
-    /**
614
-     * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
615
-     * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
616
-     * used to save the billing info
617
-     *
618
-     * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
619
-     * @return EE_Form_Section_Proper|null
620
-     * @throws EE_Error
621
-     */
622
-    public function billing_info_for_payment_method($payment_method)
623
-    {
624
-        $pm_type = $payment_method->type_obj();
625
-        if (! $pm_type instanceof EE_PMT_Base) {
626
-            return null;
627
-        }
628
-        $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
629
-        if (! $billing_info) {
630
-            return null;
631
-        }
632
-        $billing_form = $pm_type->billing_form();
633
-        // double-check the form isn't totally hidden, in which case pretend there is no form
634
-        $form_totally_hidden = true;
635
-        foreach ($billing_form->inputs_in_subsections() as $input) {
636
-            if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
637
-                $form_totally_hidden = false;
638
-                break;
639
-            }
640
-        }
641
-        if ($form_totally_hidden) {
642
-            return null;
643
-        }
644
-        if ($billing_form instanceof EE_Form_Section_Proper) {
645
-            $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
646
-        }
647
-
648
-        return $billing_form;
649
-    }
650
-
651
-
652
-    /**
653
-     * Gets the postmeta key that holds this attendee's billing info for the
654
-     * specified payment method
655
-     *
656
-     * @param EE_Payment_Method $payment_method
657
-     * @return string
658
-     * @throws EE_Error
659
-     */
660
-    public function get_billing_info_postmeta_name($payment_method)
661
-    {
662
-        if ($payment_method->type_obj() instanceof EE_PMT_Base) {
663
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
664
-        }
665
-        return null;
666
-    }
667
-
668
-
669
-    /**
670
-     * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
671
-     * retrieve it
672
-     *
673
-     * @param EE_Billing_Attendee_Info_Form $billing_form
674
-     * @param EE_Payment_Method             $payment_method
675
-     * @return boolean
676
-     * @throws EE_Error
677
-     */
678
-    public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
679
-    {
680
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
681
-            EE_Error::add_error(
682
-                esc_html__('Cannot save billing info because there is none.', 'event_espresso'),
683
-                __FILE__,
684
-                __FUNCTION__,
685
-                __LINE__
686
-        );
687
-            return false;
688
-        }
689
-        $billing_form->clean_sensitive_data();
690
-        return update_post_meta(
691
-            $this->ID(),
692
-            $this->get_billing_info_postmeta_name($payment_method),
693
-            $billing_form->input_values(true)
694
-        );
695
-    }
696
-
697
-
698
-    /**
699
-     * Return the link to the admin details for the object.
700
-     *
701
-     * @return string
702
-     * @throws EE_Error
703
-     * @throws InvalidArgumentException
704
-     * @throws InvalidDataTypeException
705
-     * @throws InvalidInterfaceException
706
-     * @throws ReflectionException
707
-     */
708
-    public function get_admin_details_link()
709
-    {
710
-        return $this->get_admin_edit_link();
711
-    }
712
-
713
-
714
-    /**
715
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
716
-     *
717
-     * @return string
718
-     * @throws EE_Error
719
-     * @throws InvalidArgumentException
720
-     * @throws ReflectionException
721
-     * @throws InvalidDataTypeException
722
-     * @throws InvalidInterfaceException
723
-     */
724
-    public function get_admin_edit_link()
725
-    {
726
-        EE_Registry::instance()->load_helper('URL');
727
-        return EEH_URL::add_query_args_and_nonce(
728
-            array(
729
-                'page'   => 'espresso_registrations',
730
-                'action' => 'edit_attendee',
731
-                'post'   => $this->ID(),
732
-            ),
733
-            admin_url('admin.php')
734
-        );
735
-    }
736
-
737
-
738
-    /**
739
-     * Returns the link to a settings page for the object.
740
-     *
741
-     * @return string
742
-     * @throws EE_Error
743
-     * @throws InvalidArgumentException
744
-     * @throws InvalidDataTypeException
745
-     * @throws InvalidInterfaceException
746
-     * @throws ReflectionException
747
-     */
748
-    public function get_admin_settings_link()
749
-    {
750
-        return $this->get_admin_edit_link();
751
-    }
752
-
753
-
754
-    /**
755
-     * Returns the link to the "overview" for the object (typically the "list table" view).
756
-     *
757
-     * @return string
758
-     * @throws EE_Error
759
-     * @throws InvalidArgumentException
760
-     * @throws ReflectionException
761
-     * @throws InvalidDataTypeException
762
-     * @throws InvalidInterfaceException
763
-     */
764
-    public function get_admin_overview_link()
765
-    {
766
-        EE_Registry::instance()->load_helper('URL');
767
-        return EEH_URL::add_query_args_and_nonce(
768
-            array(
769
-                'page'   => 'espresso_registrations',
770
-                'action' => 'contact_list',
771
-            ),
772
-            admin_url('admin.php')
773
-        );
774
-    }
28
+	/**
29
+	 * Sets some dynamic defaults
30
+	 *
31
+	 * @param array  $fieldValues
32
+	 * @param bool   $bydb
33
+	 * @param string $timezone
34
+	 * @param array  $date_formats
35
+	 * @throws EE_Error
36
+	 */
37
+	protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
38
+	{
39
+		if (! isset($fieldValues['ATT_full_name'])) {
40
+			$fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
41
+			$lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
42
+			$fieldValues['ATT_full_name'] = $fname . $lname;
43
+		}
44
+		if (! isset($fieldValues['ATT_slug'])) {
45
+			// $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
46
+			$fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
47
+		}
48
+		if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
49
+			$fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
50
+		}
51
+		parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @param array  $props_n_values          incoming values
57
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
58
+	 *                                        used.)
59
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
60
+	 *                                        date_format and the second value is the time format
61
+	 * @return EE_Attendee
62
+	 * @throws EE_Error
63
+	 */
64
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
65
+	{
66
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
67
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
68
+	}
69
+
70
+
71
+	/**
72
+	 * @param array  $props_n_values  incoming values from the database
73
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
74
+	 *                                the website will be used.
75
+	 * @return EE_Attendee
76
+	 */
77
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
78
+	{
79
+		return new self($props_n_values, true, $timezone);
80
+	}
81
+
82
+
83
+	/**
84
+	 *        Set Attendee First Name
85
+	 *
86
+	 * @access        public
87
+	 * @param string $fname
88
+	 * @throws EE_Error
89
+	 */
90
+	public function set_fname($fname = '')
91
+	{
92
+		$this->set('ATT_fname', $fname);
93
+	}
94
+
95
+
96
+	/**
97
+	 *        Set Attendee Last Name
98
+	 *
99
+	 * @access        public
100
+	 * @param string $lname
101
+	 * @throws EE_Error
102
+	 */
103
+	public function set_lname($lname = '')
104
+	{
105
+		$this->set('ATT_lname', $lname);
106
+	}
107
+
108
+
109
+	/**
110
+	 *        Set Attendee Address
111
+	 *
112
+	 * @access        public
113
+	 * @param string $address
114
+	 * @throws EE_Error
115
+	 */
116
+	public function set_address($address = '')
117
+	{
118
+		$this->set('ATT_address', $address);
119
+	}
120
+
121
+
122
+	/**
123
+	 *        Set Attendee Address2
124
+	 *
125
+	 * @access        public
126
+	 * @param        string $address2
127
+	 * @throws EE_Error
128
+	 */
129
+	public function set_address2($address2 = '')
130
+	{
131
+		$this->set('ATT_address2', $address2);
132
+	}
133
+
134
+
135
+	/**
136
+	 *        Set Attendee City
137
+	 *
138
+	 * @access        public
139
+	 * @param        string $city
140
+	 * @throws EE_Error
141
+	 */
142
+	public function set_city($city = '')
143
+	{
144
+		$this->set('ATT_city', $city);
145
+	}
146
+
147
+
148
+	/**
149
+	 *        Set Attendee State ID
150
+	 *
151
+	 * @access        public
152
+	 * @param        int $STA_ID
153
+	 * @throws EE_Error
154
+	 */
155
+	public function set_state($STA_ID = 0)
156
+	{
157
+		$this->set('STA_ID', $STA_ID);
158
+	}
159
+
160
+
161
+	/**
162
+	 *        Set Attendee Country ISO Code
163
+	 *
164
+	 * @access        public
165
+	 * @param        string $CNT_ISO
166
+	 * @throws EE_Error
167
+	 */
168
+	public function set_country($CNT_ISO = '')
169
+	{
170
+		$this->set('CNT_ISO', $CNT_ISO);
171
+	}
172
+
173
+
174
+	/**
175
+	 *        Set Attendee Zip/Postal Code
176
+	 *
177
+	 * @access        public
178
+	 * @param        string $zip
179
+	 * @throws EE_Error
180
+	 */
181
+	public function set_zip($zip = '')
182
+	{
183
+		$this->set('ATT_zip', $zip);
184
+	}
185
+
186
+
187
+	/**
188
+	 *        Set Attendee Email Address
189
+	 *
190
+	 * @access        public
191
+	 * @param        string $email
192
+	 * @throws EE_Error
193
+	 */
194
+	public function set_email($email = '')
195
+	{
196
+		$this->set('ATT_email', $email);
197
+	}
198
+
199
+
200
+	/**
201
+	 *        Set Attendee Phone
202
+	 *
203
+	 * @access        public
204
+	 * @param        string $phone
205
+	 * @throws EE_Error
206
+	 */
207
+	public function set_phone($phone = '')
208
+	{
209
+		$this->set('ATT_phone', $phone);
210
+	}
211
+
212
+
213
+	/**
214
+	 *        set deleted
215
+	 *
216
+	 * @access        public
217
+	 * @param        bool $ATT_deleted
218
+	 * @throws EE_Error
219
+	 */
220
+	public function set_deleted($ATT_deleted = false)
221
+	{
222
+		$this->set('ATT_deleted', $ATT_deleted);
223
+	}
224
+
225
+
226
+	/**
227
+	 * Returns the value for the post_author id saved with the cpt
228
+	 *
229
+	 * @since 4.5.0
230
+	 * @return int
231
+	 * @throws EE_Error
232
+	 */
233
+	public function wp_user()
234
+	{
235
+		return $this->get('ATT_author');
236
+	}
237
+
238
+
239
+	/**
240
+	 *        get Attendee First Name
241
+	 *
242
+	 * @access        public
243
+	 * @return string
244
+	 * @throws EE_Error
245
+	 */
246
+	public function fname()
247
+	{
248
+		return $this->get('ATT_fname');
249
+	}
250
+
251
+
252
+	/**
253
+	 * echoes out the attendee's first name
254
+	 *
255
+	 * @return void
256
+	 * @throws EE_Error
257
+	 */
258
+	public function e_full_name()
259
+	{
260
+		echo esc_html($this->full_name());
261
+	}
262
+
263
+
264
+	/**
265
+	 * Returns the first and last name concatenated together with a space.
266
+	 *
267
+	 * @param bool $apply_html_entities
268
+	 * @return string
269
+	 * @throws EE_Error
270
+	 */
271
+	public function full_name($apply_html_entities = false)
272
+	{
273
+		$full_name = array(
274
+			$this->fname(),
275
+			$this->lname(),
276
+		);
277
+		$full_name = array_filter($full_name);
278
+		$full_name = implode(' ', $full_name);
279
+		return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
280
+	}
281
+
282
+
283
+	/**
284
+	 * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
285
+	 * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
286
+	 * attendee.
287
+	 *
288
+	 * @param bool $apply_html_entities
289
+	 * @return string
290
+	 * @throws EE_Error
291
+	 */
292
+	public function ATT_full_name($apply_html_entities = false)
293
+	{
294
+		return $apply_html_entities
295
+			? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
296
+			: $this->get('ATT_full_name');
297
+	}
298
+
299
+
300
+	/**
301
+	 *        get Attendee Last Name
302
+	 *
303
+	 * @access        public
304
+	 * @return string
305
+	 * @throws EE_Error
306
+	 */
307
+	public function lname()
308
+	{
309
+		return $this->get('ATT_lname');
310
+	}
311
+
312
+
313
+	/**
314
+	 * Gets the attendee's full address as an array so client code can decide hwo to display it
315
+	 *
316
+	 * @return array numerically indexed, with each part of the address that is known.
317
+	 * Eg, if the user only responded to state and country,
318
+	 * it would be array(0=>'Alabama',1=>'USA')
319
+	 * @return array
320
+	 * @throws EE_Error
321
+	 */
322
+	public function full_address_as_array()
323
+	{
324
+		$full_address_array = array();
325
+		$initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
326
+		foreach ($initial_address_fields as $address_field_name) {
327
+			$address_fields_value = $this->get($address_field_name);
328
+			if (! empty($address_fields_value)) {
329
+				$full_address_array[] = $address_fields_value;
330
+			}
331
+		}
332
+		// now handle state and country
333
+		$state_obj = $this->state_obj();
334
+		if ($state_obj instanceof EE_State) {
335
+			$full_address_array[] = $state_obj->name();
336
+		}
337
+		$country_obj = $this->country_obj();
338
+		if ($country_obj instanceof EE_Country) {
339
+			$full_address_array[] = $country_obj->name();
340
+		}
341
+		// lastly get the xip
342
+		$zip_value = $this->zip();
343
+		if (! empty($zip_value)) {
344
+			$full_address_array[] = $zip_value;
345
+		}
346
+		return $full_address_array;
347
+	}
348
+
349
+
350
+	/**
351
+	 *        get Attendee Address
352
+	 *
353
+	 * @return string
354
+	 * @throws EE_Error
355
+	 */
356
+	public function address(): string
357
+	{
358
+		return $this->get('ATT_address');
359
+	}
360
+
361
+
362
+	/**
363
+	 *        get Attendee Address2
364
+	 *
365
+	 * @return string
366
+	 * @throws EE_Error
367
+	 */
368
+	public function address2(): string
369
+	{
370
+		return $this->get('ATT_address2');
371
+	}
372
+
373
+
374
+	/**
375
+	 *        get Attendee City
376
+	 *
377
+	 * @return string
378
+	 * @throws EE_Error
379
+	 */
380
+	public function city(): string
381
+	{
382
+		return $this->get('ATT_city');
383
+	}
384
+
385
+
386
+	/**
387
+	 * get Attendee State ID
388
+	 *
389
+	 * @return int
390
+	 * @throws EE_Error
391
+	 */
392
+	public function state_ID(): int
393
+	{
394
+		return $this->get('STA_ID');
395
+	}
396
+
397
+
398
+	/**
399
+	 * @return string
400
+	 * @throws EE_Error
401
+	 */
402
+	public function state_abbrev(): string
403
+	{
404
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
405
+	}
406
+
407
+
408
+	/**
409
+	 * Gets the state set to this attendee
410
+	 *
411
+	 * @return EE_State|null
412
+	 * @throws EE_Error
413
+	 */
414
+	public function state_obj(): ?EE_State
415
+	{
416
+		return $this->get_first_related('State');
417
+	}
418
+
419
+
420
+	/**
421
+	 * Returns the state's name, otherwise 'Unknown'
422
+	 *
423
+	 * @return string
424
+	 * @throws EE_Error
425
+	 */
426
+	public function state_name(): string
427
+	{
428
+		if ($this->state_obj()) {
429
+			return $this->state_obj()->name();
430
+		} else {
431
+			return '';
432
+		}
433
+	}
434
+
435
+
436
+	/**
437
+	 * either displays the state abbreviation or the state name, as determined
438
+	 * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
439
+	 * defaults to abbreviation
440
+	 *
441
+	 * @return string
442
+	 * @throws EE_Error
443
+	 */
444
+	public function state(): string
445
+	{
446
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
447
+			return $this->state_abbrev();
448
+		}
449
+		return $this->state_name();
450
+	}
451
+
452
+
453
+	/**
454
+	 *    get Attendee Country ISO Code
455
+	 *
456
+	 * @return string
457
+	 * @throws EE_Error
458
+	 */
459
+	public function country_ID(): string
460
+	{
461
+		return $this->get('CNT_ISO');
462
+	}
463
+
464
+
465
+	/**
466
+	 * Gets country set for this attendee
467
+	 *
468
+	 * @return EE_Country|null
469
+	 * @throws EE_Error
470
+	 */
471
+	public function country_obj(): ?EE_Country
472
+	{
473
+		return $this->get_first_related('Country');
474
+	}
475
+
476
+
477
+	/**
478
+	 * Returns the country's name if known, otherwise 'Unknown'
479
+	 *
480
+	 * @return string
481
+	 * @throws EE_Error
482
+	 */
483
+	public function country_name(): string
484
+	{
485
+		if ($this->country_obj()) {
486
+			return $this->country_obj()->name();
487
+		}
488
+		return '';
489
+	}
490
+
491
+
492
+	/**
493
+	 * either displays the country ISO2 code or the country name, as determined
494
+	 * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
495
+	 * defaults to abbreviation
496
+	 *
497
+	 * @return string
498
+	 * @throws EE_Error
499
+	 */
500
+	public function country(): string
501
+	{
502
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
503
+			return $this->country_ID();
504
+		}
505
+		return $this->country_name();
506
+	}
507
+
508
+
509
+	/**
510
+	 *        get Attendee Zip/Postal Code
511
+	 *
512
+	 * @return string
513
+	 * @throws EE_Error
514
+	 */
515
+	public function zip(): string
516
+	{
517
+		return $this->get('ATT_zip');
518
+	}
519
+
520
+
521
+	/**
522
+	 *        get Attendee Email Address
523
+	 *
524
+	 * @return string
525
+	 * @throws EE_Error
526
+	 */
527
+	public function email()
528
+	{
529
+		return $this->get('ATT_email');
530
+	}
531
+
532
+
533
+	/**
534
+	 *        get Attendee Phone #
535
+	 *
536
+	 * @return string
537
+	 * @throws EE_Error
538
+	 */
539
+	public function phone()
540
+	{
541
+		return $this->get('ATT_phone');
542
+	}
543
+
544
+
545
+	/**
546
+	 *    get deleted
547
+	 *
548
+	 * @return        bool
549
+	 * @throws EE_Error
550
+	 */
551
+	public function deleted()
552
+	{
553
+		return $this->get('ATT_deleted');
554
+	}
555
+
556
+
557
+	/**
558
+	 * Gets registrations of this attendee
559
+	 *
560
+	 * @param array $query_params
561
+	 * @return EE_Registration[]
562
+	 * @throws EE_Error
563
+	 */
564
+	public function get_registrations($query_params = array())
565
+	{
566
+		return $this->get_many_related('Registration', $query_params);
567
+	}
568
+
569
+
570
+	/**
571
+	 * Gets the most recent registration of this attendee
572
+	 *
573
+	 * @return EE_Registration
574
+	 * @throws EE_Error
575
+	 */
576
+	public function get_most_recent_registration()
577
+	{
578
+		return $this->get_first_related(
579
+			'Registration',
580
+			array('order_by' => array('REG_date' => 'DESC'))
581
+		); // null, 'REG_date', 'DESC', '=', 'OBJECT_K');
582
+	}
583
+
584
+
585
+	/**
586
+	 * Gets the most recent registration for this attend at this event
587
+	 *
588
+	 * @param int $event_id
589
+	 * @return EE_Registration
590
+	 * @throws EE_Error
591
+	 */
592
+	public function get_most_recent_registration_for_event($event_id)
593
+	{
594
+		return $this->get_first_related(
595
+			'Registration',
596
+			array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))
597
+		);
598
+	}
599
+
600
+
601
+	/**
602
+	 * returns any events attached to this attendee ($_Event property);
603
+	 *
604
+	 * @return array
605
+	 * @throws EE_Error
606
+	 */
607
+	public function events()
608
+	{
609
+		return $this->get_many_related('Event');
610
+	}
611
+
612
+
613
+	/**
614
+	 * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
615
+	 * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
616
+	 * used to save the billing info
617
+	 *
618
+	 * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
619
+	 * @return EE_Form_Section_Proper|null
620
+	 * @throws EE_Error
621
+	 */
622
+	public function billing_info_for_payment_method($payment_method)
623
+	{
624
+		$pm_type = $payment_method->type_obj();
625
+		if (! $pm_type instanceof EE_PMT_Base) {
626
+			return null;
627
+		}
628
+		$billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
629
+		if (! $billing_info) {
630
+			return null;
631
+		}
632
+		$billing_form = $pm_type->billing_form();
633
+		// double-check the form isn't totally hidden, in which case pretend there is no form
634
+		$form_totally_hidden = true;
635
+		foreach ($billing_form->inputs_in_subsections() as $input) {
636
+			if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
637
+				$form_totally_hidden = false;
638
+				break;
639
+			}
640
+		}
641
+		if ($form_totally_hidden) {
642
+			return null;
643
+		}
644
+		if ($billing_form instanceof EE_Form_Section_Proper) {
645
+			$billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
646
+		}
647
+
648
+		return $billing_form;
649
+	}
650
+
651
+
652
+	/**
653
+	 * Gets the postmeta key that holds this attendee's billing info for the
654
+	 * specified payment method
655
+	 *
656
+	 * @param EE_Payment_Method $payment_method
657
+	 * @return string
658
+	 * @throws EE_Error
659
+	 */
660
+	public function get_billing_info_postmeta_name($payment_method)
661
+	{
662
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
663
+			return 'billing_info_' . $payment_method->type_obj()->system_name();
664
+		}
665
+		return null;
666
+	}
667
+
668
+
669
+	/**
670
+	 * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
671
+	 * retrieve it
672
+	 *
673
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
674
+	 * @param EE_Payment_Method             $payment_method
675
+	 * @return boolean
676
+	 * @throws EE_Error
677
+	 */
678
+	public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
679
+	{
680
+		if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
681
+			EE_Error::add_error(
682
+				esc_html__('Cannot save billing info because there is none.', 'event_espresso'),
683
+				__FILE__,
684
+				__FUNCTION__,
685
+				__LINE__
686
+		);
687
+			return false;
688
+		}
689
+		$billing_form->clean_sensitive_data();
690
+		return update_post_meta(
691
+			$this->ID(),
692
+			$this->get_billing_info_postmeta_name($payment_method),
693
+			$billing_form->input_values(true)
694
+		);
695
+	}
696
+
697
+
698
+	/**
699
+	 * Return the link to the admin details for the object.
700
+	 *
701
+	 * @return string
702
+	 * @throws EE_Error
703
+	 * @throws InvalidArgumentException
704
+	 * @throws InvalidDataTypeException
705
+	 * @throws InvalidInterfaceException
706
+	 * @throws ReflectionException
707
+	 */
708
+	public function get_admin_details_link()
709
+	{
710
+		return $this->get_admin_edit_link();
711
+	}
712
+
713
+
714
+	/**
715
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
716
+	 *
717
+	 * @return string
718
+	 * @throws EE_Error
719
+	 * @throws InvalidArgumentException
720
+	 * @throws ReflectionException
721
+	 * @throws InvalidDataTypeException
722
+	 * @throws InvalidInterfaceException
723
+	 */
724
+	public function get_admin_edit_link()
725
+	{
726
+		EE_Registry::instance()->load_helper('URL');
727
+		return EEH_URL::add_query_args_and_nonce(
728
+			array(
729
+				'page'   => 'espresso_registrations',
730
+				'action' => 'edit_attendee',
731
+				'post'   => $this->ID(),
732
+			),
733
+			admin_url('admin.php')
734
+		);
735
+	}
736
+
737
+
738
+	/**
739
+	 * Returns the link to a settings page for the object.
740
+	 *
741
+	 * @return string
742
+	 * @throws EE_Error
743
+	 * @throws InvalidArgumentException
744
+	 * @throws InvalidDataTypeException
745
+	 * @throws InvalidInterfaceException
746
+	 * @throws ReflectionException
747
+	 */
748
+	public function get_admin_settings_link()
749
+	{
750
+		return $this->get_admin_edit_link();
751
+	}
752
+
753
+
754
+	/**
755
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
756
+	 *
757
+	 * @return string
758
+	 * @throws EE_Error
759
+	 * @throws InvalidArgumentException
760
+	 * @throws ReflectionException
761
+	 * @throws InvalidDataTypeException
762
+	 * @throws InvalidInterfaceException
763
+	 */
764
+	public function get_admin_overview_link()
765
+	{
766
+		EE_Registry::instance()->load_helper('URL');
767
+		return EEH_URL::add_query_args_and_nonce(
768
+			array(
769
+				'page'   => 'espresso_registrations',
770
+				'action' => 'contact_list',
771
+			),
772
+			admin_url('admin.php')
773
+		);
774
+	}
775 775
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
      */
37 37
     protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
38 38
     {
39
-        if (! isset($fieldValues['ATT_full_name'])) {
40
-            $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
39
+        if ( ! isset($fieldValues['ATT_full_name'])) {
40
+            $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : '';
41 41
             $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
42
-            $fieldValues['ATT_full_name'] = $fname . $lname;
42
+            $fieldValues['ATT_full_name'] = $fname.$lname;
43 43
         }
44
-        if (! isset($fieldValues['ATT_slug'])) {
44
+        if ( ! isset($fieldValues['ATT_slug'])) {
45 45
             // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
46 46
             $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
47 47
         }
48
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
48
+        if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
49 49
             $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
50 50
         }
51 51
         parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
         $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
326 326
         foreach ($initial_address_fields as $address_field_name) {
327 327
             $address_fields_value = $this->get($address_field_name);
328
-            if (! empty($address_fields_value)) {
328
+            if ( ! empty($address_fields_value)) {
329 329
                 $full_address_array[] = $address_fields_value;
330 330
             }
331 331
         }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
         }
341 341
         // lastly get the xip
342 342
         $zip_value = $this->zip();
343
-        if (! empty($zip_value)) {
343
+        if ( ! empty($zip_value)) {
344 344
             $full_address_array[] = $zip_value;
345 345
         }
346 346
         return $full_address_array;
@@ -622,18 +622,18 @@  discard block
 block discarded – undo
622 622
     public function billing_info_for_payment_method($payment_method)
623 623
     {
624 624
         $pm_type = $payment_method->type_obj();
625
-        if (! $pm_type instanceof EE_PMT_Base) {
625
+        if ( ! $pm_type instanceof EE_PMT_Base) {
626 626
             return null;
627 627
         }
628 628
         $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
629
-        if (! $billing_info) {
629
+        if ( ! $billing_info) {
630 630
             return null;
631 631
         }
632 632
         $billing_form = $pm_type->billing_form();
633 633
         // double-check the form isn't totally hidden, in which case pretend there is no form
634 634
         $form_totally_hidden = true;
635 635
         foreach ($billing_form->inputs_in_subsections() as $input) {
636
-            if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
636
+            if ( ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
637 637
                 $form_totally_hidden = false;
638 638
                 break;
639 639
             }
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
     public function get_billing_info_postmeta_name($payment_method)
661 661
     {
662 662
         if ($payment_method->type_obj() instanceof EE_PMT_Base) {
663
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
663
+            return 'billing_info_'.$payment_method->type_obj()->system_name();
664 664
         }
665 665
         return null;
666 666
     }
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
      */
678 678
     public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
679 679
     {
680
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
680
+        if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
681 681
             EE_Error::add_error(
682 682
                 esc_html__('Cannot save billing info because there is none.', 'event_espresso'),
683 683
                 __FILE__,
Please login to merge, or discard this patch.
core/helpers/EEH_Schema.helper.php 2 patches
Indentation   +294 added lines, -294 removed lines patch added patch discarded remove patch
@@ -12,298 +12,298 @@
 block discarded – undo
12 12
  */
13 13
 class EEH_Schema
14 14
 {
15
-    /**
16
-     * generates JSON-based linked data for an event
17
-     *
18
-     * @param EE_Event $event
19
-     * @throws EE_Error
20
-     */
21
-    public static function add_json_linked_data_for_event(EE_Event $event)
22
-    {
23
-        // Check we have a valid datetime for the event
24
-        if (! $event->primary_datetime() instanceof EE_Datetime) {
25
-            return;
26
-        }
27
-
28
-        $template_args = array(
29
-            'event_permalink' => '',
30
-            'event_name' => '',
31
-            'event_description' => '',
32
-            'event_start' => '',
33
-            'event_end' => '',
34
-            'event_attendance_mode' => '',
35
-            'event_status' => '',
36
-            'currency' => '',
37
-            'event_tickets' => array(),
38
-            'venue_name' => '',
39
-            'venue_url' => '',
40
-            'venue_locality' => '',
41
-            'venue_region' => '',
42
-            'venue_address' => '',
43
-            'event_image' => '',
44
-        );
45
-        $template_args['event_permalink'] = $event->get_permalink();
46
-        $template_args['event_name'] = $event->name();
47
-        $template_args['event_description'] = wp_strip_all_tags($event->short_description(200));
48
-        // clone datetime so that date formats don't override those for the original datetime
49
-        $primary_datetime = clone $event->primary_datetime();
50
-        $template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM);
51
-        $template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM);
52
-        unset($primary_datetime);
53
-        switch ($event->status()) {
54
-            case EEM_Event::cancelled:
55
-                $event_status = 'EventCancelled';
56
-                break;
57
-            case EEM_Event::postponed:
58
-                $event_status = 'EventPostponed';
59
-                break;
60
-            default:
61
-                $event_status = 'EventScheduled';
62
-        }
63
-        $template_args['event_attendance_mode'] = 'OfflineEventAttendanceMode';
64
-        $template_args['event_status'] = 'https://schema.org/' . $event_status;
65
-        $template_args['currency'] = EE_Registry::instance()->CFG->currency->code;
66
-        foreach ($event->tickets() as $original_ticket) {
67
-            // clone tickets so that date formats don't override those for the original ticket
68
-            $ticket = clone $original_ticket;
69
-            $ID = $ticket->ID();
70
-            $template_args['event_tickets'][ $ID ]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
71
-            $template_args['event_tickets'][ $ID ]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
72
-            $template_args['event_tickets'][ $ID ]['price'] = number_format(
73
-                $ticket->price(),
74
-                EE_Registry::instance()->CFG->currency->dec_plc,
75
-                EE_Registry::instance()->CFG->currency->dec_mrk,
76
-                ''
77
-            );
78
-            switch ($ticket->ticket_status()) {
79
-                case 'TKO':
80
-                    $availability = 'InStock';
81
-                    break;
82
-                case 'TKS':
83
-                    $availability = 'SoldOut';
84
-                    break;
85
-                default:
86
-                    $availability = null;
87
-                    break;
88
-            }
89
-            $template_args['event_tickets'][ $ID ]['availability'] = $availability;
90
-            unset($ticket);
91
-        }
92
-        $VNU_ID = espresso_venue_id();
93
-        if (! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) {
94
-            $venue = EEH_Venue_View::get_venue($VNU_ID);
95
-            $template_args['venue_name'] = get_the_title($VNU_ID);
96
-            $template_args['venue_url'] = get_permalink($VNU_ID);
97
-            $template_args['venue_locality'] = $venue->city();
98
-            $template_args['venue_region'] = $venue->state_name();
99
-            $template_args['venue_address'] = $venue->address();
100
-            if ($venue->virtual_url() !== '') {
101
-                $template_args['event_attendance_mode'] = 'OnlineEventAttendanceMode';
102
-            }
103
-            if ($venue->virtual_url() !== '' && $venue->address() !== '') {
104
-                $template_args['event_attendance_mode'] = 'MixedEventAttendanceMode';
105
-            }
106
-        }
107
-        $template_args['event_image'] = $event->feature_image_url();
108
-        $template_args = apply_filters(
109
-            'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args',
110
-            $template_args,
111
-            $event,
112
-            $VNU_ID
113
-        );
114
-        extract($template_args, EXTR_OVERWRITE);
115
-        include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
116
-    }
117
-
118
-
119
-    /**
120
-     *    location
121
-     *    The location of the event, organization or action.
122
-     *    Should include the Venue name AND schema formatted address info
123
-     *
124
-     * @access public
125
-     * @param string $location
126
-     * @return string
127
-     */
128
-    public static function location($location = null)
129
-    {
130
-        return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'
131
-                                      . $location
132
-                                      . '</div>' : '';
133
-    }
134
-
135
-
136
-
137
-    /**
138
-     *    name
139
-     *    The name of the Event or Venue.
140
-     *
141
-     * @access public
142
-     * @param string $name
143
-     * @return string
144
-     */
145
-    public static function name($name = null)
146
-    {
147
-        return ! empty($name) ? '<span itemprop="name">' . $name . '</span>' : '';
148
-    }
149
-
150
-
151
-
152
-    /**
153
-     *    streetAddress
154
-     *    The street address. For example, 1600 Amphitheatre Pkwy.
155
-     *
156
-     * @access public
157
-     * @param AddressInterface $obj_with_address
158
-     * @return string
159
-     */
160
-    public static function streetAddress(AddressInterface $obj_with_address = null)
161
-    {
162
-        return $obj_with_address->address() !== null && $obj_with_address->address() !== ''
163
-            ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';
164
-    }
165
-
166
-
167
-
168
-    /**
169
-     *    postOfficeBoxNumber
170
-     *    The post office box number for PO box addresses.
171
-     *
172
-     * @access public
173
-     * @param AddressInterface $obj_with_address
174
-     * @return string
175
-     */
176
-    public static function postOfficeBoxNumber(AddressInterface $obj_with_address = null)
177
-    {
178
-        // regex check for some form of PO Box or P.O. Box, etc, etc, etc
179
-        if (
180
-            preg_match(
181
-                "/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i",
182
-                $obj_with_address->address2()
183
-            )
184
-        ) {
185
-            return $obj_with_address->address2() !== null && $obj_with_address->address2() !== ''
186
-                ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : '';
187
-        } else {
188
-            return $obj_with_address->address2();
189
-        }
190
-    }
191
-
192
-
193
-
194
-    /**
195
-     *    addressLocality
196
-     *    The locality (city, town, etc). For example, Mountain View.
197
-     *
198
-     * @access public
199
-     * @param AddressInterface $obj_with_address
200
-     * @return string
201
-     */
202
-    public static function addressLocality(AddressInterface $obj_with_address = null)
203
-    {
204
-        return $obj_with_address->city() !== null && $obj_with_address->city() !== ''
205
-            ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';
206
-    }
207
-
208
-
209
-
210
-    /**
211
-     *    addressRegion
212
-     *    The region (state, province, etc). For example, CA.
213
-     *
214
-     * @access public
215
-     * @param AddressInterface $obj_with_address
216
-     * @return string
217
-     */
218
-    public static function addressRegion(AddressInterface $obj_with_address = null)
219
-    {
220
-        $state = $obj_with_address->state_name();
221
-        if (! empty($state)) {
222
-            return '<span itemprop="addressRegion">' . $state . '</span>';
223
-        } else {
224
-            return '';
225
-        }
226
-    }
227
-
228
-
229
-
230
-    /**
231
-     *    addressCountry
232
-     *    The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code.
233
-     *
234
-     * @access public
235
-     * @param AddressInterface $obj_with_address
236
-     * @return string
237
-     */
238
-    public static function addressCountry(AddressInterface $obj_with_address = null)
239
-    {
240
-        $country = $obj_with_address->country_name();
241
-        if (! empty($country)) {
242
-            return '<span itemprop="addressCountry">' . $country . '</span>';
243
-        } else {
244
-            return '';
245
-        }
246
-    }
247
-
248
-
249
-
250
-    /**
251
-     *    postalCode
252
-     *    The postal code. For example, 94043.
253
-     *
254
-     * @access public
255
-     * @param AddressInterface $obj_with_address
256
-     * @return string
257
-     */
258
-    public static function postalCode(AddressInterface $obj_with_address = null)
259
-    {
260
-        return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'
261
-                                                                                      . $obj_with_address->zip()
262
-                                                                                      . '</span>' : '';
263
-    }
264
-
265
-
266
-
267
-    /**
268
-     *    telephone
269
-     *    The telephone number.
270
-     *
271
-     * @access public
272
-     * @param string $phone_nmbr
273
-     * @return string
274
-     */
275
-    public static function telephone($phone_nmbr = null)
276
-    {
277
-        return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>'
278
-            : '';
279
-    }
280
-
281
-
282
-
283
-    /**
284
-     *    URL
285
-     *    URL of the item as a clickable link
286
-     *
287
-     * @access public
288
-     * @param string $url        - the URL that the link will resolve to
289
-     * @param string $text       - the text that will be used for the visible link
290
-     * @param array  $attributes - array of additional link attributes in  attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' )
291
-     * @return string (link)
292
-     */
293
-    public static function url($url = null, $text = null, $attributes = array())
294
-    {
295
-        // Check the URL includes a scheme
296
-        $parsed_url = parse_url($url);
297
-        if (empty($parsed_url['scheme'])) {
298
-            $url = 'https://' . ltrim($url, '/');
299
-        }
300
-        $atts = '';
301
-        foreach ($attributes as $attribute => $value) {
302
-            $atts .= ' ' . $attribute . '="' . $value . '"';
303
-        }
304
-        $text = $text !== null && $text !== '' ? $text : esc_url($url);
305
-        return ! empty($url)
306
-            ? '<a itemprop="url" href="' . esc_url_raw($url) . '"' . $atts . '>' . $text . '</a>'
307
-            : '';
308
-    }
15
+	/**
16
+	 * generates JSON-based linked data for an event
17
+	 *
18
+	 * @param EE_Event $event
19
+	 * @throws EE_Error
20
+	 */
21
+	public static function add_json_linked_data_for_event(EE_Event $event)
22
+	{
23
+		// Check we have a valid datetime for the event
24
+		if (! $event->primary_datetime() instanceof EE_Datetime) {
25
+			return;
26
+		}
27
+
28
+		$template_args = array(
29
+			'event_permalink' => '',
30
+			'event_name' => '',
31
+			'event_description' => '',
32
+			'event_start' => '',
33
+			'event_end' => '',
34
+			'event_attendance_mode' => '',
35
+			'event_status' => '',
36
+			'currency' => '',
37
+			'event_tickets' => array(),
38
+			'venue_name' => '',
39
+			'venue_url' => '',
40
+			'venue_locality' => '',
41
+			'venue_region' => '',
42
+			'venue_address' => '',
43
+			'event_image' => '',
44
+		);
45
+		$template_args['event_permalink'] = $event->get_permalink();
46
+		$template_args['event_name'] = $event->name();
47
+		$template_args['event_description'] = wp_strip_all_tags($event->short_description(200));
48
+		// clone datetime so that date formats don't override those for the original datetime
49
+		$primary_datetime = clone $event->primary_datetime();
50
+		$template_args['event_start'] = $primary_datetime->start_date(DateTime::ATOM);
51
+		$template_args['event_end'] = $primary_datetime->end_date(DateTime::ATOM);
52
+		unset($primary_datetime);
53
+		switch ($event->status()) {
54
+			case EEM_Event::cancelled:
55
+				$event_status = 'EventCancelled';
56
+				break;
57
+			case EEM_Event::postponed:
58
+				$event_status = 'EventPostponed';
59
+				break;
60
+			default:
61
+				$event_status = 'EventScheduled';
62
+		}
63
+		$template_args['event_attendance_mode'] = 'OfflineEventAttendanceMode';
64
+		$template_args['event_status'] = 'https://schema.org/' . $event_status;
65
+		$template_args['currency'] = EE_Registry::instance()->CFG->currency->code;
66
+		foreach ($event->tickets() as $original_ticket) {
67
+			// clone tickets so that date formats don't override those for the original ticket
68
+			$ticket = clone $original_ticket;
69
+			$ID = $ticket->ID();
70
+			$template_args['event_tickets'][ $ID ]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
71
+			$template_args['event_tickets'][ $ID ]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
72
+			$template_args['event_tickets'][ $ID ]['price'] = number_format(
73
+				$ticket->price(),
74
+				EE_Registry::instance()->CFG->currency->dec_plc,
75
+				EE_Registry::instance()->CFG->currency->dec_mrk,
76
+				''
77
+			);
78
+			switch ($ticket->ticket_status()) {
79
+				case 'TKO':
80
+					$availability = 'InStock';
81
+					break;
82
+				case 'TKS':
83
+					$availability = 'SoldOut';
84
+					break;
85
+				default:
86
+					$availability = null;
87
+					break;
88
+			}
89
+			$template_args['event_tickets'][ $ID ]['availability'] = $availability;
90
+			unset($ticket);
91
+		}
92
+		$VNU_ID = espresso_venue_id();
93
+		if (! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) {
94
+			$venue = EEH_Venue_View::get_venue($VNU_ID);
95
+			$template_args['venue_name'] = get_the_title($VNU_ID);
96
+			$template_args['venue_url'] = get_permalink($VNU_ID);
97
+			$template_args['venue_locality'] = $venue->city();
98
+			$template_args['venue_region'] = $venue->state_name();
99
+			$template_args['venue_address'] = $venue->address();
100
+			if ($venue->virtual_url() !== '') {
101
+				$template_args['event_attendance_mode'] = 'OnlineEventAttendanceMode';
102
+			}
103
+			if ($venue->virtual_url() !== '' && $venue->address() !== '') {
104
+				$template_args['event_attendance_mode'] = 'MixedEventAttendanceMode';
105
+			}
106
+		}
107
+		$template_args['event_image'] = $event->feature_image_url();
108
+		$template_args = apply_filters(
109
+			'FHEE__EEH_Schema__add_json_linked_data_for_event__template_args',
110
+			$template_args,
111
+			$event,
112
+			$VNU_ID
113
+		);
114
+		extract($template_args, EXTR_OVERWRITE);
115
+		include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
116
+	}
117
+
118
+
119
+	/**
120
+	 *    location
121
+	 *    The location of the event, organization or action.
122
+	 *    Should include the Venue name AND schema formatted address info
123
+	 *
124
+	 * @access public
125
+	 * @param string $location
126
+	 * @return string
127
+	 */
128
+	public static function location($location = null)
129
+	{
130
+		return ! empty($location) ? '<div itemprop="location" itemscope itemtype="http://schema.org/Place">'
131
+									  . $location
132
+									  . '</div>' : '';
133
+	}
134
+
135
+
136
+
137
+	/**
138
+	 *    name
139
+	 *    The name of the Event or Venue.
140
+	 *
141
+	 * @access public
142
+	 * @param string $name
143
+	 * @return string
144
+	 */
145
+	public static function name($name = null)
146
+	{
147
+		return ! empty($name) ? '<span itemprop="name">' . $name . '</span>' : '';
148
+	}
149
+
150
+
151
+
152
+	/**
153
+	 *    streetAddress
154
+	 *    The street address. For example, 1600 Amphitheatre Pkwy.
155
+	 *
156
+	 * @access public
157
+	 * @param AddressInterface $obj_with_address
158
+	 * @return string
159
+	 */
160
+	public static function streetAddress(AddressInterface $obj_with_address = null)
161
+	{
162
+		return $obj_with_address->address() !== null && $obj_with_address->address() !== ''
163
+			? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';
164
+	}
165
+
166
+
167
+
168
+	/**
169
+	 *    postOfficeBoxNumber
170
+	 *    The post office box number for PO box addresses.
171
+	 *
172
+	 * @access public
173
+	 * @param AddressInterface $obj_with_address
174
+	 * @return string
175
+	 */
176
+	public static function postOfficeBoxNumber(AddressInterface $obj_with_address = null)
177
+	{
178
+		// regex check for some form of PO Box or P.O. Box, etc, etc, etc
179
+		if (
180
+			preg_match(
181
+				"/^\s*((P(OST)?.?\s*(O(FF(ICE)?)?)?.?\s+(B(IN|OX))?)|B(IN|OX))/i",
182
+				$obj_with_address->address2()
183
+			)
184
+		) {
185
+			return $obj_with_address->address2() !== null && $obj_with_address->address2() !== ''
186
+				? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : '';
187
+		} else {
188
+			return $obj_with_address->address2();
189
+		}
190
+	}
191
+
192
+
193
+
194
+	/**
195
+	 *    addressLocality
196
+	 *    The locality (city, town, etc). For example, Mountain View.
197
+	 *
198
+	 * @access public
199
+	 * @param AddressInterface $obj_with_address
200
+	 * @return string
201
+	 */
202
+	public static function addressLocality(AddressInterface $obj_with_address = null)
203
+	{
204
+		return $obj_with_address->city() !== null && $obj_with_address->city() !== ''
205
+			? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';
206
+	}
207
+
208
+
209
+
210
+	/**
211
+	 *    addressRegion
212
+	 *    The region (state, province, etc). For example, CA.
213
+	 *
214
+	 * @access public
215
+	 * @param AddressInterface $obj_with_address
216
+	 * @return string
217
+	 */
218
+	public static function addressRegion(AddressInterface $obj_with_address = null)
219
+	{
220
+		$state = $obj_with_address->state_name();
221
+		if (! empty($state)) {
222
+			return '<span itemprop="addressRegion">' . $state . '</span>';
223
+		} else {
224
+			return '';
225
+		}
226
+	}
227
+
228
+
229
+
230
+	/**
231
+	 *    addressCountry
232
+	 *    The country. For example, USA. You can also provide the two-letter ISO 3166-1 alpha-2 country code.
233
+	 *
234
+	 * @access public
235
+	 * @param AddressInterface $obj_with_address
236
+	 * @return string
237
+	 */
238
+	public static function addressCountry(AddressInterface $obj_with_address = null)
239
+	{
240
+		$country = $obj_with_address->country_name();
241
+		if (! empty($country)) {
242
+			return '<span itemprop="addressCountry">' . $country . '</span>';
243
+		} else {
244
+			return '';
245
+		}
246
+	}
247
+
248
+
249
+
250
+	/**
251
+	 *    postalCode
252
+	 *    The postal code. For example, 94043.
253
+	 *
254
+	 * @access public
255
+	 * @param AddressInterface $obj_with_address
256
+	 * @return string
257
+	 */
258
+	public static function postalCode(AddressInterface $obj_with_address = null)
259
+	{
260
+		return $obj_with_address->zip() !== null && $obj_with_address->zip() !== '' ? '<span itemprop="postalCode">'
261
+																					  . $obj_with_address->zip()
262
+																					  . '</span>' : '';
263
+	}
264
+
265
+
266
+
267
+	/**
268
+	 *    telephone
269
+	 *    The telephone number.
270
+	 *
271
+	 * @access public
272
+	 * @param string $phone_nmbr
273
+	 * @return string
274
+	 */
275
+	public static function telephone($phone_nmbr = null)
276
+	{
277
+		return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>'
278
+			: '';
279
+	}
280
+
281
+
282
+
283
+	/**
284
+	 *    URL
285
+	 *    URL of the item as a clickable link
286
+	 *
287
+	 * @access public
288
+	 * @param string $url        - the URL that the link will resolve to
289
+	 * @param string $text       - the text that will be used for the visible link
290
+	 * @param array  $attributes - array of additional link attributes in  attribute_name => value pairs. ie: array( 'title' => 'click here', 'class' => 'link-class' )
291
+	 * @return string (link)
292
+	 */
293
+	public static function url($url = null, $text = null, $attributes = array())
294
+	{
295
+		// Check the URL includes a scheme
296
+		$parsed_url = parse_url($url);
297
+		if (empty($parsed_url['scheme'])) {
298
+			$url = 'https://' . ltrim($url, '/');
299
+		}
300
+		$atts = '';
301
+		foreach ($attributes as $attribute => $value) {
302
+			$atts .= ' ' . $attribute . '="' . $value . '"';
303
+		}
304
+		$text = $text !== null && $text !== '' ? $text : esc_url($url);
305
+		return ! empty($url)
306
+			? '<a itemprop="url" href="' . esc_url_raw($url) . '"' . $atts . '>' . $text . '</a>'
307
+			: '';
308
+	}
309 309
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     public static function add_json_linked_data_for_event(EE_Event $event)
22 22
     {
23 23
         // Check we have a valid datetime for the event
24
-        if (! $event->primary_datetime() instanceof EE_Datetime) {
24
+        if ( ! $event->primary_datetime() instanceof EE_Datetime) {
25 25
             return;
26 26
         }
27 27
 
@@ -61,15 +61,15 @@  discard block
 block discarded – undo
61 61
                 $event_status = 'EventScheduled';
62 62
         }
63 63
         $template_args['event_attendance_mode'] = 'OfflineEventAttendanceMode';
64
-        $template_args['event_status'] = 'https://schema.org/' . $event_status;
64
+        $template_args['event_status'] = 'https://schema.org/'.$event_status;
65 65
         $template_args['currency'] = EE_Registry::instance()->CFG->currency->code;
66 66
         foreach ($event->tickets() as $original_ticket) {
67 67
             // clone tickets so that date formats don't override those for the original ticket
68 68
             $ticket = clone $original_ticket;
69 69
             $ID = $ticket->ID();
70
-            $template_args['event_tickets'][ $ID ]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
71
-            $template_args['event_tickets'][ $ID ]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
72
-            $template_args['event_tickets'][ $ID ]['price'] = number_format(
70
+            $template_args['event_tickets'][$ID]['start_date'] = $ticket->start_date(DateTime::ATOM, null);
71
+            $template_args['event_tickets'][$ID]['end_date'] = $ticket->end_date(DateTime::ATOM, null);
72
+            $template_args['event_tickets'][$ID]['price'] = number_format(
73 73
                 $ticket->price(),
74 74
                 EE_Registry::instance()->CFG->currency->dec_plc,
75 75
                 EE_Registry::instance()->CFG->currency->dec_mrk,
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
                     $availability = null;
87 87
                     break;
88 88
             }
89
-            $template_args['event_tickets'][ $ID ]['availability'] = $availability;
89
+            $template_args['event_tickets'][$ID]['availability'] = $availability;
90 90
             unset($ticket);
91 91
         }
92 92
         $VNU_ID = espresso_venue_id();
93
-        if (! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) {
93
+        if ( ! empty($VNU_ID) && ! espresso_is_venue_private($VNU_ID)) {
94 94
             $venue = EEH_Venue_View::get_venue($VNU_ID);
95 95
             $template_args['venue_name'] = get_the_title($VNU_ID);
96 96
             $template_args['venue_url'] = get_permalink($VNU_ID);
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
             $VNU_ID
113 113
         );
114 114
         extract($template_args, EXTR_OVERWRITE);
115
-        include EE_TEMPLATES . 'json_linked_data_for_event.template.php';
115
+        include EE_TEMPLATES.'json_linked_data_for_event.template.php';
116 116
     }
117 117
 
118 118
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public static function name($name = null)
146 146
     {
147
-        return ! empty($name) ? '<span itemprop="name">' . $name . '</span>' : '';
147
+        return ! empty($name) ? '<span itemprop="name">'.$name.'</span>' : '';
148 148
     }
149 149
 
150 150
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     public static function streetAddress(AddressInterface $obj_with_address = null)
161 161
     {
162 162
         return $obj_with_address->address() !== null && $obj_with_address->address() !== ''
163
-            ? '<span itemprop="streetAddress">' . $obj_with_address->address() . '</span>' : '';
163
+            ? '<span itemprop="streetAddress">'.$obj_with_address->address().'</span>' : '';
164 164
     }
165 165
 
166 166
 
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
             )
184 184
         ) {
185 185
             return $obj_with_address->address2() !== null && $obj_with_address->address2() !== ''
186
-                ? '<span itemprop="postOfficeBoxNumber">' . $obj_with_address->address2() . '</span>' : '';
186
+                ? '<span itemprop="postOfficeBoxNumber">'.$obj_with_address->address2().'</span>' : '';
187 187
         } else {
188 188
             return $obj_with_address->address2();
189 189
         }
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
     public static function addressLocality(AddressInterface $obj_with_address = null)
203 203
     {
204 204
         return $obj_with_address->city() !== null && $obj_with_address->city() !== ''
205
-            ? '<span itemprop="addressLocality">' . $obj_with_address->city() . '</span>' : '';
205
+            ? '<span itemprop="addressLocality">'.$obj_with_address->city().'</span>' : '';
206 206
     }
207 207
 
208 208
 
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
     public static function addressRegion(AddressInterface $obj_with_address = null)
219 219
     {
220 220
         $state = $obj_with_address->state_name();
221
-        if (! empty($state)) {
222
-            return '<span itemprop="addressRegion">' . $state . '</span>';
221
+        if ( ! empty($state)) {
222
+            return '<span itemprop="addressRegion">'.$state.'</span>';
223 223
         } else {
224 224
             return '';
225 225
         }
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
     public static function addressCountry(AddressInterface $obj_with_address = null)
239 239
     {
240 240
         $country = $obj_with_address->country_name();
241
-        if (! empty($country)) {
242
-            return '<span itemprop="addressCountry">' . $country . '</span>';
241
+        if ( ! empty($country)) {
242
+            return '<span itemprop="addressCountry">'.$country.'</span>';
243 243
         } else {
244 244
             return '';
245 245
         }
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
      */
275 275
     public static function telephone($phone_nmbr = null)
276 276
     {
277
-        return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">' . $phone_nmbr . '</span>'
277
+        return $phone_nmbr !== null && $phone_nmbr !== '' ? '<span itemprop="telephone">'.$phone_nmbr.'</span>'
278 278
             : '';
279 279
     }
280 280
 
@@ -295,15 +295,15 @@  discard block
 block discarded – undo
295 295
         // Check the URL includes a scheme
296 296
         $parsed_url = parse_url($url);
297 297
         if (empty($parsed_url['scheme'])) {
298
-            $url = 'https://' . ltrim($url, '/');
298
+            $url = 'https://'.ltrim($url, '/');
299 299
         }
300 300
         $atts = '';
301 301
         foreach ($attributes as $attribute => $value) {
302
-            $atts .= ' ' . $attribute . '="' . $value . '"';
302
+            $atts .= ' '.$attribute.'="'.$value.'"';
303 303
         }
304 304
         $text = $text !== null && $text !== '' ? $text : esc_url($url);
305 305
         return ! empty($url)
306
-            ? '<a itemprop="url" href="' . esc_url_raw($url) . '"' . $atts . '>' . $text . '</a>'
306
+            ? '<a itemprop="url" href="'.esc_url_raw($url).'"'.$atts.'>'.$text.'</a>'
307 307
             : '';
308 308
     }
309 309
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Address.helper.php 2 patches
Indentation   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -13,124 +13,124 @@
 block discarded – undo
13 13
  */
14 14
 class EEH_Address
15 15
 {
16
-    /**
17
-     *    format - output formatted EE object address information
18
-     *
19
-     * @access public
20
-     * @param         object      AddressInterface $obj_with_address
21
-     * @param string  $type       how the address is formatted. for example: 'multiline' or 'inline'
22
-     * @param boolean $use_schema whether to apply schema.org formatting to the address
23
-     * @param bool    $add_wrapper
24
-     * @return string
25
-     */
26
-    public static function format(
27
-        $obj_with_address = null,
28
-        $type = 'multiline',
29
-        $use_schema = true,
30
-        $add_wrapper = true
31
-    ) {
32
-        // check that incoming object implements the AddressInterface interface
33
-        if (! $obj_with_address instanceof AddressInterface) {
34
-            $msg = esc_html__('The address could not be formatted.', 'event_espresso');
35
-            $dev_msg = esc_html__(
36
-                'The Address Formatter requires passed objects to implement the AddressInterface interface.',
37
-                'event_espresso'
38
-            );
39
-            EE_Error::add_error($msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
40
-            return null;
41
-        }
42
-        // obtain an address formatter
43
-        $formatter = EEH_Address::_get_formatter($type);
44
-        // apply schema.org formatting ?
45
-        $use_schema = ! is_admin() ? $use_schema : false;
46
-        $formatted_address = $use_schema
47
-            ? EEH_Address::_schema_formatting($formatter, $obj_with_address)
48
-            : EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper);
49
-        $formatted_address = $add_wrapper && ! $use_schema
50
-            ? '<div class="espresso-address-dv">' . $formatted_address . '</div>'
51
-            : $formatted_address;
52
-        // return the formatted address
53
-        return $formatted_address;
54
-    }
16
+	/**
17
+	 *    format - output formatted EE object address information
18
+	 *
19
+	 * @access public
20
+	 * @param         object      AddressInterface $obj_with_address
21
+	 * @param string  $type       how the address is formatted. for example: 'multiline' or 'inline'
22
+	 * @param boolean $use_schema whether to apply schema.org formatting to the address
23
+	 * @param bool    $add_wrapper
24
+	 * @return string
25
+	 */
26
+	public static function format(
27
+		$obj_with_address = null,
28
+		$type = 'multiline',
29
+		$use_schema = true,
30
+		$add_wrapper = true
31
+	) {
32
+		// check that incoming object implements the AddressInterface interface
33
+		if (! $obj_with_address instanceof AddressInterface) {
34
+			$msg = esc_html__('The address could not be formatted.', 'event_espresso');
35
+			$dev_msg = esc_html__(
36
+				'The Address Formatter requires passed objects to implement the AddressInterface interface.',
37
+				'event_espresso'
38
+			);
39
+			EE_Error::add_error($msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
40
+			return null;
41
+		}
42
+		// obtain an address formatter
43
+		$formatter = EEH_Address::_get_formatter($type);
44
+		// apply schema.org formatting ?
45
+		$use_schema = ! is_admin() ? $use_schema : false;
46
+		$formatted_address = $use_schema
47
+			? EEH_Address::_schema_formatting($formatter, $obj_with_address)
48
+			: EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper);
49
+		$formatted_address = $add_wrapper && ! $use_schema
50
+			? '<div class="espresso-address-dv">' . $formatted_address . '</div>'
51
+			: $formatted_address;
52
+		// return the formatted address
53
+		return $formatted_address;
54
+	}
55 55
 
56 56
 
57 57
 
58
-    /**
59
-     *    _get_formatter - obtain the requester formatter class
60
-     *
61
-     * @access private
62
-     * @param string $type how the address is formatted. for example: 'multiline' or 'inline'
63
-     * @return AddressFormatterInterface
64
-     */
65
-    private static function _get_formatter($type)
66
-    {
67
-        switch ($type) {
68
-            case 'multiline':
69
-                return new EventEspresso\core\services\address\formatters\MultiLineAddressFormatter();
70
-            case 'inline':
71
-                return new EventEspresso\core\services\address\formatters\InlineAddressFormatter();
72
-            default:
73
-                return new EventEspresso\core\services\address\formatters\NullAddressFormatter();
74
-        }
75
-    }
58
+	/**
59
+	 *    _get_formatter - obtain the requester formatter class
60
+	 *
61
+	 * @access private
62
+	 * @param string $type how the address is formatted. for example: 'multiline' or 'inline'
63
+	 * @return AddressFormatterInterface
64
+	 */
65
+	private static function _get_formatter($type)
66
+	{
67
+		switch ($type) {
68
+			case 'multiline':
69
+				return new EventEspresso\core\services\address\formatters\MultiLineAddressFormatter();
70
+			case 'inline':
71
+				return new EventEspresso\core\services\address\formatters\InlineAddressFormatter();
72
+			default:
73
+				return new EventEspresso\core\services\address\formatters\NullAddressFormatter();
74
+		}
75
+	}
76 76
 
77 77
 
78 78
 
79
-    /**
80
-     *    _regular_formatting
81
-     *    adds formatting to an address
82
-     *
83
-     * @access private
84
-     * @param      object AddressInterface_Formatter $formatter
85
-     * @param      object AddressInterface $obj_with_address
86
-     * @param bool $add_wrapper
87
-     * @return string
88
-     */
89
-    private static function _regular_formatting(
90
-        AddressFormatterInterface $formatter,
91
-        AddressInterface $obj_with_address,
92
-        $add_wrapper = true
93
-    ) {
94
-        $formatted_address = $add_wrapper ? '<div>' : '';
95
-        $formatted_address .= $formatter->format(
96
-            $obj_with_address->address(),
97
-            $obj_with_address->address2(),
98
-            $obj_with_address->city(),
99
-            $obj_with_address->state_name(),
100
-            $obj_with_address->zip(),
101
-            $obj_with_address->country_name(),
102
-            $obj_with_address->country_ID()
103
-        );
104
-        $formatted_address .= $add_wrapper ? '</div>' : '';
105
-        // return the formatted address
106
-        return $formatted_address;
107
-    }
79
+	/**
80
+	 *    _regular_formatting
81
+	 *    adds formatting to an address
82
+	 *
83
+	 * @access private
84
+	 * @param      object AddressInterface_Formatter $formatter
85
+	 * @param      object AddressInterface $obj_with_address
86
+	 * @param bool $add_wrapper
87
+	 * @return string
88
+	 */
89
+	private static function _regular_formatting(
90
+		AddressFormatterInterface $formatter,
91
+		AddressInterface $obj_with_address,
92
+		$add_wrapper = true
93
+	) {
94
+		$formatted_address = $add_wrapper ? '<div>' : '';
95
+		$formatted_address .= $formatter->format(
96
+			$obj_with_address->address(),
97
+			$obj_with_address->address2(),
98
+			$obj_with_address->city(),
99
+			$obj_with_address->state_name(),
100
+			$obj_with_address->zip(),
101
+			$obj_with_address->country_name(),
102
+			$obj_with_address->country_ID()
103
+		);
104
+		$formatted_address .= $add_wrapper ? '</div>' : '';
105
+		// return the formatted address
106
+		return $formatted_address;
107
+	}
108 108
 
109 109
 
110 110
 
111
-    /**
112
-     *    _schema_formatting
113
-     *    adds schema.org formatting to an address
114
-     *
115
-     * @access private
116
-     * @param object AddressFormatterInterface $formatter
117
-     * @param object AddressInterface $obj_with_address
118
-     * @return string
119
-     */
120
-    private static function _schema_formatting(AddressFormatterInterface $formatter, AddressInterface $obj_with_address)
121
-    {
122
-        $formatted_address = '<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';
123
-        $formatted_address .= $formatter->format(
124
-            EEH_Schema::streetAddress($obj_with_address),
125
-            EEH_Schema::postOfficeBoxNumber($obj_with_address),
126
-            EEH_Schema::addressLocality($obj_with_address),
127
-            EEH_Schema::addressRegion($obj_with_address),
128
-            EEH_Schema::postalCode($obj_with_address),
129
-            EEH_Schema::addressCountry($obj_with_address),
130
-            $obj_with_address->country_ID()
131
-        );
132
-        $formatted_address .= '</div>';
133
-        // return the formatted address
134
-        return $formatted_address;
135
-    }
111
+	/**
112
+	 *    _schema_formatting
113
+	 *    adds schema.org formatting to an address
114
+	 *
115
+	 * @access private
116
+	 * @param object AddressFormatterInterface $formatter
117
+	 * @param object AddressInterface $obj_with_address
118
+	 * @return string
119
+	 */
120
+	private static function _schema_formatting(AddressFormatterInterface $formatter, AddressInterface $obj_with_address)
121
+	{
122
+		$formatted_address = '<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';
123
+		$formatted_address .= $formatter->format(
124
+			EEH_Schema::streetAddress($obj_with_address),
125
+			EEH_Schema::postOfficeBoxNumber($obj_with_address),
126
+			EEH_Schema::addressLocality($obj_with_address),
127
+			EEH_Schema::addressRegion($obj_with_address),
128
+			EEH_Schema::postalCode($obj_with_address),
129
+			EEH_Schema::addressCountry($obj_with_address),
130
+			$obj_with_address->country_ID()
131
+		);
132
+		$formatted_address .= '</div>';
133
+		// return the formatted address
134
+		return $formatted_address;
135
+	}
136 136
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
         $add_wrapper = true
31 31
     ) {
32 32
         // check that incoming object implements the AddressInterface interface
33
-        if (! $obj_with_address instanceof AddressInterface) {
33
+        if ( ! $obj_with_address instanceof AddressInterface) {
34 34
             $msg = esc_html__('The address could not be formatted.', 'event_espresso');
35 35
             $dev_msg = esc_html__(
36 36
                 'The Address Formatter requires passed objects to implement the AddressInterface interface.',
37 37
                 'event_espresso'
38 38
             );
39
-            EE_Error::add_error($msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
39
+            EE_Error::add_error($msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
40 40
             return null;
41 41
         }
42 42
         // obtain an address formatter
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             ? EEH_Address::_schema_formatting($formatter, $obj_with_address)
48 48
             : EEH_Address::_regular_formatting($formatter, $obj_with_address, $add_wrapper);
49 49
         $formatted_address = $add_wrapper && ! $use_schema
50
-            ? '<div class="espresso-address-dv">' . $formatted_address . '</div>'
50
+            ? '<div class="espresso-address-dv">'.$formatted_address.'</div>'
51 51
             : $formatted_address;
52 52
         // return the formatted address
53 53
         return $formatted_address;
Please login to merge, or discard this patch.