@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -54,23 +54,23 @@ discard block |
||
54 | 54 | $this->_name = 'pricing'; |
55 | 55 | |
56 | 56 | //capability check |
57 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_default_prices', 'advanced_ticket_datetime_metabox' ) ) { |
|
57 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices', 'advanced_ticket_datetime_metabox')) { |
|
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
61 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
62 | 62 | |
63 | 63 | //if we were going to add our own metaboxes we'd use the below. |
64 | 64 | $this->_metaboxes = array( |
65 | 65 | 0 => array( |
66 | - 'page_route' => array('edit','create_new'), |
|
66 | + 'page_route' => array('edit', 'create_new'), |
|
67 | 67 | 'func' => 'pricing_metabox', |
68 | 68 | 'label' => __('Event Tickets & Datetimes', 'event_espresso'), |
69 | 69 | 'priority' => 'high', |
70 | 70 | 'context' => 'normal' |
71 | 71 | ), |
72 | 72 | |
73 | - );/**/ |
|
73 | + ); /**/ |
|
74 | 74 | |
75 | 75 | $this->_remove_metaboxes = array( |
76 | 76 | 0 => array( |
@@ -89,24 +89,24 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @var array Expected an array returned with 'date' and 'time' keys. |
91 | 91 | */ |
92 | - $this->_date_format_strings = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
92 | + $this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array( |
|
93 | 93 | 'date' => 'Y-m-d', |
94 | 94 | 'time' => 'h:i a' |
95 | 95 | )); |
96 | 96 | |
97 | 97 | //validate |
98 | - $this->_date_format_strings['date'] = isset( $this->_date_format_strings['date'] ) ? $this->_date_format_strings['date'] : null; |
|
99 | - $this->_date_format_strings['time'] = isset( $this->_date_format_strings['time'] ) ? $this->_date_format_strings['time'] : null; |
|
98 | + $this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null; |
|
99 | + $this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null; |
|
100 | 100 | |
101 | 101 | //validate format strings |
102 | - $format_validation = EEH_DTT_Helper::validate_format_string( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
103 | - if ( is_array( $format_validation ) ) { |
|
104 | - $msg = '<p>' . sprintf( __( 'The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso' ), $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ) . '</p><ul>'; |
|
105 | - foreach ( $format_validation as $error ) { |
|
106 | - $msg .= '<li>' . $error . '</li>'; |
|
102 | + $format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
103 | + if (is_array($format_validation)) { |
|
104 | + $msg = '<p>'.sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso'), $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']).'</p><ul>'; |
|
105 | + foreach ($format_validation as $error) { |
|
106 | + $msg .= '<li>'.$error.'</li>'; |
|
107 | 107 | } |
108 | - $msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>'; |
|
109 | - EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
108 | + $msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>'; |
|
109 | + EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__); |
|
110 | 110 | $this->_date_format_strings = array( |
111 | 111 | 'date' => 'Y-m-d', |
112 | 112 | 'time' => 'h:i a' |
@@ -117,60 +117,60 @@ discard block |
||
117 | 117 | $this->_scripts_styles = array( |
118 | 118 | 'registers' => array( |
119 | 119 | 'ee-tickets-datetimes-css' => array( |
120 | - 'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css', |
|
120 | + 'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css', |
|
121 | 121 | 'type' => 'css' |
122 | 122 | ), |
123 | 123 | 'ee-dtt-ticket-metabox' => array( |
124 | - 'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js', |
|
124 | + 'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js', |
|
125 | 125 | 'depends' => array('ee-datepicker', 'ee-dialog', 'underscore') |
126 | 126 | ) |
127 | 127 | ), |
128 | 128 | 'deregisters' => array( |
129 | - 'event-editor-css' => array('type' => 'css' ), |
|
129 | + 'event-editor-css' => array('type' => 'css'), |
|
130 | 130 | 'event-datetime-metabox' => array('type' => 'js') |
131 | 131 | ), |
132 | 132 | 'enqueues' => array( |
133 | - 'ee-tickets-datetimes-css' => array( 'edit', 'create_new' ), |
|
134 | - 'ee-dtt-ticket-metabox' => array( 'edit', 'create_new' ) |
|
133 | + 'ee-tickets-datetimes-css' => array('edit', 'create_new'), |
|
134 | + 'ee-dtt-ticket-metabox' => array('edit', 'create_new') |
|
135 | 135 | ), |
136 | 136 | 'localize' => array( |
137 | 137 | 'ee-dtt-ticket-metabox' => array( |
138 | 138 | 'DTT_TRASH_BLOCK' => array( |
139 | 139 | 'main_warning' => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', 'event_espresso'), |
140 | 140 | 'after_warning' => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', 'event_espresso'), |
141 | - 'cancel_button' => '<button class="button-secondary ee-modal-cancel">' . __('Cancel', 'event_espresso') . '</button>', |
|
141 | + 'cancel_button' => '<button class="button-secondary ee-modal-cancel">'.__('Cancel', 'event_espresso').'</button>', |
|
142 | 142 | 'single_warning_from_tkt' => __('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.', 'event_espresso'), |
143 | 143 | 'single_warning_from_dtt' => __('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.', 'event_espresso'), |
144 | - 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button>' |
|
144 | + 'dismiss_button' => '<button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button>' |
|
145 | 145 | ), |
146 | 146 | 'DTT_ERROR_MSG' => array( |
147 | 147 | 'no_ticket_name' => __('General Admission', 'event_espresso'), |
148 | - 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button></div>' |
|
148 | + 'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button></div>' |
|
149 | 149 | ), |
150 | 150 | 'DTT_OVERSELL_WARNING' => array( |
151 | 151 | 'datetime_ticket' => __('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.', 'event_espresso'), |
152 | 152 | 'ticket_datetime' => __('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.', 'event_espresso') |
153 | 153 | ), |
154 | - 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( $this->_date_format_strings['date'], $this->_date_format_strings['time'] ), |
|
155 | - 'DTT_START_OF_WEEK' => array( 'dayValue' => (int) get_option( 'start_of_week' ) ) |
|
154 | + 'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'], $this->_date_format_strings['time']), |
|
155 | + 'DTT_START_OF_WEEK' => array('dayValue' => (int) get_option('start_of_week')) |
|
156 | 156 | ) |
157 | 157 | ) |
158 | 158 | ); |
159 | 159 | |
160 | 160 | |
161 | - add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array( $this, 'autosave_handling' ), 10 ); |
|
162 | - add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( $this, 'caf_updates' ), 10 ); |
|
161 | + add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array($this, 'autosave_handling'), 10); |
|
162 | + add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array($this, 'caf_updates'), 10); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
166 | 166 | |
167 | - public function caf_updates( $update_callbacks ) { |
|
168 | - foreach ( $update_callbacks as $key => $callback ) { |
|
169 | - if ( $callback[1] == '_default_tickets_update' ) |
|
170 | - unset( $update_callbacks[$key] ); |
|
167 | + public function caf_updates($update_callbacks) { |
|
168 | + foreach ($update_callbacks as $key => $callback) { |
|
169 | + if ($callback[1] == '_default_tickets_update') |
|
170 | + unset($update_callbacks[$key]); |
|
171 | 171 | } |
172 | 172 | |
173 | - $update_callbacks[] = array( $this, 'dtt_and_tickets_caf_update' ); |
|
173 | + $update_callbacks[] = array($this, 'dtt_and_tickets_caf_update'); |
|
174 | 174 | return $update_callbacks; |
175 | 175 | } |
176 | 176 | |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @param array $data The request data from the form |
184 | 184 | * @return bool success or fail |
185 | 185 | */ |
186 | - public function dtt_and_tickets_caf_update( $evtobj, $data ) { |
|
186 | + public function dtt_and_tickets_caf_update($evtobj, $data) { |
|
187 | 187 | //first we need to start with datetimes cause they are the "root" items attached to events. |
188 | - $saved_dtts = $this->_update_dtts( $evtobj, $data ); |
|
188 | + $saved_dtts = $this->_update_dtts($evtobj, $data); |
|
189 | 189 | //next tackle the tickets (and prices?) |
190 | - $this->_update_tkts( $evtobj, $saved_dtts, $data ); |
|
190 | + $this->_update_tkts($evtobj, $saved_dtts, $data); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | |
@@ -198,41 +198,41 @@ discard block |
||
198 | 198 | * @param array $data the request data from the form |
199 | 199 | * @return EE_Datetime[] |
200 | 200 | */ |
201 | - protected function _update_dtts( $evt_obj, $data ) { |
|
202 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
201 | + protected function _update_dtts($evt_obj, $data) { |
|
202 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
203 | 203 | $saved_dtt_ids = array(); |
204 | 204 | $saved_dtt_objs = array(); |
205 | 205 | |
206 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
206 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
207 | 207 | //trim all values to ensure any excess whitespace is removed. |
208 | 208 | $dtt = array_map( |
209 | - function( $datetime_data ) { |
|
210 | - return is_array( $datetime_data ) ? $datetime_data : trim( $datetime_data ); |
|
209 | + function($datetime_data) { |
|
210 | + return is_array($datetime_data) ? $datetime_data : trim($datetime_data); |
|
211 | 211 | }, |
212 | 212 | $dtt |
213 | 213 | ); |
214 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
214 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start']; |
|
215 | 215 | $datetime_values = array( |
216 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL, |
|
217 | - 'DTT_name' => ! empty( $dtt['DTT_name'] ) ? $dtt['DTT_name'] : '', |
|
218 | - 'DTT_description' => ! empty( $dtt['DTT_description'] ) ? $dtt['DTT_description'] : '', |
|
216 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL, |
|
217 | + 'DTT_name' => ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '', |
|
218 | + 'DTT_description' => ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '', |
|
219 | 219 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
220 | 220 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
221 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt[ 'DTT_reg_limit' ], |
|
222 | - 'DTT_order' => ! isset( $dtt['DTT_order'] ) ? $row : $dtt['DTT_order'], |
|
221 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
222 | + 'DTT_order' => ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'], |
|
223 | 223 | ); |
224 | 224 | |
225 | 225 | //if we have an id then let's get existing object first and then set the new values. Otherwise we instantiate a new object for save. |
226 | 226 | |
227 | - if ( !empty( $dtt['DTT_ID'] ) ) { |
|
228 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) )->get_one_by_ID($dtt['DTT_ID'] ); |
|
227 | + if ( ! empty($dtt['DTT_ID'])) { |
|
228 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']); |
|
229 | 229 | |
230 | 230 | //set date and time format according to what is set in this class. |
231 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
232 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
231 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
232 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
233 | 233 | |
234 | - foreach ( $datetime_values as $field => $value ) { |
|
235 | - $DTM->set( $field, $value ); |
|
234 | + foreach ($datetime_values as $field => $value) { |
|
235 | + $DTM->set($field, $value); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | // make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. |
@@ -240,24 +240,24 @@ discard block |
||
240 | 240 | $saved_dtt_ids[$DTM->ID()] = $DTM->ID(); |
241 | 241 | |
242 | 242 | } else { |
243 | - $DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values, $timezone ), FALSE, FALSE ); |
|
243 | + $DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values, $timezone), FALSE, FALSE); |
|
244 | 244 | |
245 | 245 | //reset date and times to match the format |
246 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
247 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
248 | - foreach( $datetime_values as $field => $value ) { |
|
249 | - $DTM->set( $field, $value ); |
|
246 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
247 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
248 | + foreach ($datetime_values as $field => $value) { |
|
249 | + $DTM->set($field, $value); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | 253 | |
254 | 254 | $DTM->save(); |
255 | - $DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' ); |
|
255 | + $DTM = $evt_obj->_add_relation_to($DTM, 'Datetime'); |
|
256 | 256 | $evt_obj->save(); |
257 | 257 | |
258 | 258 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
259 | - if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) { |
|
260 | - $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') ); |
|
259 | + if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) { |
|
260 | + $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start')); |
|
261 | 261 | EE_Registry::instance()->load_helper('DTT_Helper'); |
262 | 262 | $DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days'); |
263 | 263 | $DTM->save(); |
@@ -273,25 +273,25 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | //now we need to REMOVE any dtts that got deleted. Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point. |
276 | - $old_datetimes = explode(',', $data['datetime_IDs'] ); |
|
276 | + $old_datetimes = explode(',', $data['datetime_IDs']); |
|
277 | 277 | $old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes; |
278 | 278 | |
279 | - if ( is_array( $old_datetimes ) ) { |
|
280 | - $dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids ); |
|
281 | - foreach ( $dtts_to_delete as $id ) { |
|
282 | - $id = absint( $id ); |
|
283 | - if ( empty( $id ) ) |
|
279 | + if (is_array($old_datetimes)) { |
|
280 | + $dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids); |
|
281 | + foreach ($dtts_to_delete as $id) { |
|
282 | + $id = absint($id); |
|
283 | + if (empty($id)) |
|
284 | 284 | continue; |
285 | 285 | |
286 | 286 | $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id); |
287 | 287 | |
288 | 288 | //remove tkt relationships. |
289 | 289 | $related_tickets = $dtt_to_remove->get_many_related('Ticket'); |
290 | - foreach ( $related_tickets as $tkt ) { |
|
290 | + foreach ($related_tickets as $tkt) { |
|
291 | 291 | $dtt_to_remove->_remove_relation_to($tkt, 'Ticket'); |
292 | 292 | } |
293 | 293 | |
294 | - $evt_obj->_remove_relation_to( $id, 'Datetime' ); |
|
294 | + $evt_obj->_remove_relation_to($id, 'Datetime'); |
|
295 | 295 | $dtt_to_remove->refresh_cache_of_related_objects(); |
296 | 296 | |
297 | 297 | } |
@@ -312,86 +312,86 @@ discard block |
||
312 | 312 | * @param array $data incoming request data |
313 | 313 | * @return EE_Ticket[] |
314 | 314 | */ |
315 | - protected function _update_tkts( $evtobj, $saved_dtts, $data ) { |
|
315 | + protected function _update_tkts($evtobj, $saved_dtts, $data) { |
|
316 | 316 | |
317 | 317 | $new_tkt = null; |
318 | 318 | $new_default = null; |
319 | 319 | //stripslashes because WP filtered the $_POST ($data) array to add slashes |
320 | 320 | $data = stripslashes_deep($data); |
321 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
321 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
322 | 322 | $saved_tickets = $dtts_on_existing = array(); |
323 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
323 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
324 | 324 | |
325 | 325 | //load money helper |
326 | - EE_Registry::instance()->load_helper( 'Money' ); |
|
326 | + EE_Registry::instance()->load_helper('Money'); |
|
327 | 327 | |
328 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
328 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
329 | 329 | |
330 | 330 | $update_prices = $create_new_TKT = FALSE; |
331 | 331 | |
332 | 332 | //figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session. |
333 | 333 | |
334 | - $starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]); |
|
335 | - $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] ); |
|
334 | + $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]); |
|
335 | + $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]); |
|
336 | 336 | $dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows); |
337 | 337 | $dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows); |
338 | 338 | |
339 | 339 | // trim inputs to ensure any excess whitespace is removed. |
340 | 340 | $tkt = array_map( |
341 | - function( $ticket_data ) { |
|
342 | - return is_array( $ticket_data ) ? $ticket_data : trim( $ticket_data ); |
|
341 | + function($ticket_data) { |
|
342 | + return is_array($ticket_data) ? $ticket_data : trim($ticket_data); |
|
343 | 343 | }, |
344 | 344 | $tkt |
345 | 345 | ); |
346 | 346 | |
347 | 347 | //note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models. |
348 | 348 | //note incoming ['TKT_price'] value is already in standard notation (via js). |
349 | - $ticket_price = isset( $tkt['TKT_price'] ) ? round ( (float) $tkt['TKT_price'], 3 ) : 0; |
|
349 | + $ticket_price = isset($tkt['TKT_price']) ? round((float) $tkt['TKT_price'], 3) : 0; |
|
350 | 350 | |
351 | 351 | //note incoming base price needs converted from localized value. |
352 | - $base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0; |
|
352 | + $base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0; |
|
353 | 353 | //if ticket price == 0 and $base_price != 0 then ticket price == base_price |
354 | 354 | $ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price; |
355 | - $base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0; |
|
355 | + $base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0; |
|
356 | 356 | |
357 | 357 | $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array(); |
358 | 358 | |
359 | 359 | $now = null; |
360 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
360 | + if (empty($tkt['TKT_start_date'])) { |
|
361 | 361 | //lets' use now in the set timezone. |
362 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
363 | - $tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
362 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
363 | + $tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
364 | 364 | } |
365 | 365 | |
366 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
366 | + if (empty($tkt['TKT_end_date'])) { |
|
367 | 367 | /** |
368 | 368 | * set the TKT_end_date to the first datetime attached to the ticket. |
369 | 369 | */ |
370 | - $first_dtt = $saved_dtts[reset( $tkt_dtt_rows )]; |
|
371 | - $tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] ); |
|
370 | + $first_dtt = $saved_dtts[reset($tkt_dtt_rows)]; |
|
371 | + $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | $TKT_values = array( |
375 | - 'TKT_ID' => ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
376 | - 'TTM_ID' => ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
377 | - 'TKT_name' => ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
378 | - 'TKT_description' => ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
375 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
376 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
377 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
378 | + 'TKT_description' => ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
379 | 379 | 'TKT_start_date' => $tkt['TKT_start_date'], |
380 | 380 | 'TKT_end_date' => $tkt['TKT_end_date'], |
381 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ], |
|
382 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'], |
|
383 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
384 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
381 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
382 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
383 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
384 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
385 | 385 | 'TKT_row' => $row, |
386 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0, |
|
387 | - 'TKT_taxable' => ! empty( $tkt['TKT_taxable'] ) ? 1 : 0, |
|
388 | - 'TKT_required' => ! empty( $tkt['TKT_required'] ) ? 1 : 0, |
|
386 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0, |
|
387 | + 'TKT_taxable' => ! empty($tkt['TKT_taxable']) ? 1 : 0, |
|
388 | + 'TKT_required' => ! empty($tkt['TKT_required']) ? 1 : 0, |
|
389 | 389 | 'TKT_price' => $ticket_price |
390 | 390 | ); |
391 | 391 | |
392 | 392 | |
393 | 393 | //if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well. |
394 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
394 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
395 | 395 | $TKT_values['TKT_ID'] = 0; |
396 | 396 | $TKT_values['TKT_is_default'] = 0; |
397 | 397 | $update_prices = TRUE; |
@@ -403,21 +403,21 @@ discard block |
||
403 | 403 | // but DID have it's items modified. |
404 | 404 | // keep in mind that if the TKT has been sold (and we have changed pricing information), |
405 | 405 | // then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
406 | - if ( absint( $TKT_values['TKT_ID'] ) ) { |
|
407 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
408 | - if ( $TKT instanceof EE_Ticket ) { |
|
406 | + if (absint($TKT_values['TKT_ID'])) { |
|
407 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']); |
|
408 | + if ($TKT instanceof EE_Ticket) { |
|
409 | 409 | |
410 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
410 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
411 | 411 | // are there any registrations using this ticket ? |
412 | 412 | $tickets_sold = $TKT->count_related( |
413 | 413 | 'Registration', |
414 | - array( array( |
|
415 | - 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) |
|
416 | - ) ) |
|
414 | + array(array( |
|
415 | + 'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)) |
|
416 | + )) |
|
417 | 417 | ); |
418 | 418 | //set ticket formats |
419 | - $TKT->set_date_format( $this->_date_format_strings['date'] ); |
|
420 | - $TKT->set_time_format( $this->_date_format_strings['time'] ); |
|
419 | + $TKT->set_date_format($this->_date_format_strings['date']); |
|
420 | + $TKT->set_time_format($this->_date_format_strings['time']); |
|
421 | 421 | |
422 | 422 | // let's just check the total price for the existing ticket |
423 | 423 | // and determine if it matches the new total price. |
@@ -427,17 +427,17 @@ discard block |
||
427 | 427 | ? TRUE : FALSE; |
428 | 428 | |
429 | 429 | //set new values |
430 | - foreach ( $TKT_values as $field => $value ) { |
|
431 | - if ( $field === 'TKT_qty' ) { |
|
432 | - $TKT->set_qty( $value ); |
|
430 | + foreach ($TKT_values as $field => $value) { |
|
431 | + if ($field === 'TKT_qty') { |
|
432 | + $TKT->set_qty($value); |
|
433 | 433 | } else { |
434 | - $TKT->set( $field, $value ); |
|
434 | + $TKT->set($field, $value); |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
438 | 438 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
439 | - if ( $create_new_TKT ) { |
|
440 | - $new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id ); |
|
439 | + if ($create_new_TKT) { |
|
440 | + $new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
@@ -446,12 +446,12 @@ discard block |
||
446 | 446 | $TKT = EE_Ticket::new_instance( |
447 | 447 | $TKT_values, |
448 | 448 | $timezone, |
449 | - array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ] ) |
|
449 | + array($this->_date_format_strings['date'], $this->_date_format_strings['time']) |
|
450 | 450 | ); |
451 | - if ( $TKT instanceof EE_Ticket ) { |
|
451 | + if ($TKT instanceof EE_Ticket) { |
|
452 | 452 | // make sure ticket has an ID of setting relations won't work |
453 | 453 | $TKT->save(); |
454 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
454 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
455 | 455 | $update_prices = TRUE; |
456 | 456 | } |
457 | 457 | } |
@@ -459,38 +459,38 @@ discard block |
||
459 | 459 | //$TKT->save(); |
460 | 460 | |
461 | 461 | //before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date. |
462 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
463 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
462 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
463 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
464 | 464 | EE_Registry::instance()->load_helper('DTT_Helper'); |
465 | 465 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
466 | 466 | } |
467 | 467 | |
468 | 468 | //let's make sure the base price is handled |
469 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT; |
|
469 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT; |
|
470 | 470 | |
471 | 471 | //add/update price_modifiers |
472 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT; |
|
472 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT; |
|
473 | 473 | |
474 | 474 | //need to make sue that the TKT_price is accurate after saving the prices. |
475 | 475 | $TKT->ensure_TKT_Price_correct(); |
476 | 476 | |
477 | 477 | //handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave. |
478 | - if ( ! defined('DOING_AUTOSAVE' ) ) { |
|
479 | - if ( !empty($tkt['TKT_is_default_selector'] ) ) { |
|
478 | + if ( ! defined('DOING_AUTOSAVE')) { |
|
479 | + if ( ! empty($tkt['TKT_is_default_selector'])) { |
|
480 | 480 | $update_prices = TRUE; |
481 | 481 | $new_default = clone $TKT; |
482 | - $new_default->set( 'TKT_ID', 0 ); |
|
483 | - $new_default->set( 'TKT_is_default', 1 ); |
|
484 | - $new_default->set( 'TKT_row', 1 ); |
|
485 | - $new_default->set( 'TKT_price', $ticket_price ); |
|
482 | + $new_default->set('TKT_ID', 0); |
|
483 | + $new_default->set('TKT_is_default', 1); |
|
484 | + $new_default->set('TKT_row', 1); |
|
485 | + $new_default->set('TKT_price', $ticket_price); |
|
486 | 486 | //remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object) |
487 | 487 | $new_default->_remove_relations('Datetime'); |
488 | 488 | //todo we need to add the current attached prices as new prices to the new default ticket. |
489 | - $new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices ); |
|
489 | + $new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices); |
|
490 | 490 | //don't forget the base price! |
491 | - $new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id ); |
|
491 | + $new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id); |
|
492 | 492 | $new_default->save(); |
493 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data ); |
|
493 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
@@ -501,19 +501,19 @@ discard block |
||
501 | 501 | //let's assign any tickets that have been setup to the saved_tickets tracker |
502 | 502 | //save existing TKT |
503 | 503 | $TKT->save(); |
504 | - if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) { |
|
504 | + if ($create_new_TKT && $new_tkt instanceof EE_Ticket) { |
|
505 | 505 | //save new TKT |
506 | 506 | $new_tkt->save(); |
507 | 507 | //add new ticket to array |
508 | - $saved_tickets[ $new_tkt->ID() ] = $new_tkt; |
|
508 | + $saved_tickets[$new_tkt->ID()] = $new_tkt; |
|
509 | 509 | |
510 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data ); |
|
510 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data); |
|
511 | 511 | |
512 | 512 | } else { |
513 | 513 | //add tkt to saved tkts |
514 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
514 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
515 | 515 | |
516 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data ); |
|
516 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | } |
@@ -523,22 +523,22 @@ discard block |
||
523 | 523 | // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket). |
524 | 524 | // Or a draft event was saved and in the process of editing a ticket is trashed. |
525 | 525 | // No sense in keeping all the related data in the db! |
526 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
527 | - $tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) ); |
|
526 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
527 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
528 | 528 | |
529 | - foreach ( $tickets_removed as $id ) { |
|
530 | - $id = absint( $id ); |
|
529 | + foreach ($tickets_removed as $id) { |
|
530 | + $id = absint($id); |
|
531 | 531 | |
532 | 532 | //get the ticket for this id |
533 | 533 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
534 | 534 | |
535 | 535 | //if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime |
536 | - if ( $tkt_to_remove->get('TKT_is_default') ) |
|
536 | + if ($tkt_to_remove->get('TKT_is_default')) |
|
537 | 537 | continue; |
538 | 538 | |
539 | 539 | // if this tkt has any registrations attached so then we just ARCHIVE |
540 | 540 | // because we don't actually permanently delete these tickets. |
541 | - if ( $tkt_to_remove->count_related('Registration') > 0 ) { |
|
541 | + if ($tkt_to_remove->count_related('Registration') > 0) { |
|
542 | 542 | $tkt_to_remove->delete(); |
543 | 543 | continue; |
544 | 544 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | // (remember this process can ONLY kick off if there are NO tkts_sold) |
548 | 548 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
549 | 549 | |
550 | - foreach( $dtts as $dtt ) { |
|
550 | + foreach ($dtts as $dtt) { |
|
551 | 551 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
552 | 552 | } |
553 | 553 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
556 | 556 | $tkt_to_remove->delete_related_permanently('Price'); |
557 | 557 | |
558 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove ); |
|
558 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove); |
|
559 | 559 | |
560 | 560 | // finally let's delete this ticket |
561 | 561 | // (which should not be blocked at this point b/c we've removed all our relationships) |
@@ -587,39 +587,39 @@ discard block |
||
587 | 587 | // and removing the ticket from datetimes it got removed from. |
588 | 588 | |
589 | 589 | // first let's add datetimes |
590 | - if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) { |
|
591 | - foreach ( $added_datetimes as $row_id ) { |
|
592 | - $row_id = (int)$row_id; |
|
593 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
594 | - $ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
590 | + if ( ! empty($added_datetimes) && is_array($added_datetimes)) { |
|
591 | + foreach ($added_datetimes as $row_id) { |
|
592 | + $row_id = (int) $row_id; |
|
593 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
594 | + $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
595 | 595 | // Is this an existing ticket (has an ID) and does it have any sold? |
596 | 596 | // If so, then we need to add that to the DTT sold because this DTT is getting added. |
597 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
598 | - $saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() ); |
|
599 | - $saved_datetimes[ $row_id ]->save(); |
|
597 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
598 | + $saved_datetimes[$row_id]->increase_sold($ticket->sold()); |
|
599 | + $saved_datetimes[$row_id]->save(); |
|
600 | 600 | } |
601 | 601 | } |
602 | 602 | } |
603 | 603 | } |
604 | 604 | // then remove datetimes |
605 | - if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) { |
|
606 | - foreach ( $removed_datetimes as $row_id ) { |
|
607 | - $row_id = (int)$row_id; |
|
605 | + if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) { |
|
606 | + foreach ($removed_datetimes as $row_id) { |
|
607 | + $row_id = (int) $row_id; |
|
608 | 608 | // its entirely possible that a datetime got deleted (instead of just removed from relationship. |
609 | 609 | // So make sure we skip over this if the dtt isn't in the $saved_datetimes array) |
610 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
611 | - $ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
610 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
611 | + $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
612 | 612 | // Is this an existing ticket (has an ID) and does it have any sold? |
613 | 613 | // If so, then we need to remove it's sold from the DTT_sold. |
614 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
615 | - $saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() ); |
|
616 | - $saved_datetimes[ $row_id ]->save(); |
|
614 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
615 | + $saved_datetimes[$row_id]->decrease_sold($ticket->sold()); |
|
616 | + $saved_datetimes[$row_id]->save(); |
|
617 | 617 | } |
618 | 618 | } |
619 | 619 | } |
620 | 620 | } |
621 | 621 | // cap ticket qty by datetime reg limits |
622 | - $ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) ); |
|
622 | + $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit'))); |
|
623 | 623 | return $ticket; |
624 | 624 | } |
625 | 625 | |
@@ -640,39 +640,39 @@ discard block |
||
640 | 640 | EE_Ticket $ticket, |
641 | 641 | $price_rows = array(), |
642 | 642 | $ticket_price = 0, |
643 | - $base_price = 0 , |
|
643 | + $base_price = 0, |
|
644 | 644 | $base_price_id = 0 |
645 | 645 | ) { |
646 | 646 | |
647 | 647 | // create new ticket that's a copy of the existing |
648 | 648 | // except a new id of course (and not archived) |
649 | 649 | // AND has the new TKT_price associated with it. |
650 | - $new_ticket = clone( $ticket ); |
|
651 | - $new_ticket->set( 'TKT_ID', 0 ); |
|
652 | - $new_ticket->set( 'TKT_deleted', 0 ); |
|
653 | - $new_ticket->set( 'TKT_price', $ticket_price ); |
|
654 | - $new_ticket->set( 'TKT_sold', 0 ); |
|
650 | + $new_ticket = clone($ticket); |
|
651 | + $new_ticket->set('TKT_ID', 0); |
|
652 | + $new_ticket->set('TKT_deleted', 0); |
|
653 | + $new_ticket->set('TKT_price', $ticket_price); |
|
654 | + $new_ticket->set('TKT_sold', 0); |
|
655 | 655 | // let's get a new ID for this ticket |
656 | 656 | $new_ticket->save(); |
657 | 657 | // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket |
658 | - $datetimes_on_existing = $ticket->get_many_related( 'Datetime' ); |
|
658 | + $datetimes_on_existing = $ticket->get_many_related('Datetime'); |
|
659 | 659 | $new_ticket = $this->_update_ticket_datetimes( |
660 | 660 | $new_ticket, |
661 | 661 | $datetimes_on_existing, |
662 | - array_keys( $datetimes_on_existing ) |
|
662 | + array_keys($datetimes_on_existing) |
|
663 | 663 | ); |
664 | 664 | |
665 | 665 | // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array. |
666 | 666 | // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining |
667 | 667 | // available. |
668 | - if ( $ticket->sold() > 0 ) { |
|
668 | + if ($ticket->sold() > 0) { |
|
669 | 669 | $new_qty = $ticket->qty() - $ticket->sold(); |
670 | - $new_ticket->set_qty( $new_qty ); |
|
670 | + $new_ticket->set_qty($new_qty); |
|
671 | 671 | } |
672 | 672 | //now we update the prices just for this ticket |
673 | - $new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true ); |
|
673 | + $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true); |
|
674 | 674 | //and we update the base price |
675 | - $new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id ); |
|
675 | + $new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id); |
|
676 | 676 | return $new_ticket; |
677 | 677 | } |
678 | 678 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | * @param int|bool $base_price_id if present then this is the base_price_id being updated. |
693 | 693 | * @return EE_Ticket |
694 | 694 | */ |
695 | - protected function _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) { |
|
695 | + protected function _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) { |
|
696 | 696 | |
697 | 697 | //let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session. |
698 | 698 | $current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers(); |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | $updated_prices = array(); |
701 | 701 | |
702 | 702 | // if $base_price ! FALSE then updating a base price. |
703 | - if ( $base_price !== FALSE ) { |
|
703 | + if ($base_price !== FALSE) { |
|
704 | 704 | $prices[1] = array( |
705 | 705 | 'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id, |
706 | 706 | 'PRT_ID' => 1, |
@@ -711,47 +711,47 @@ discard block |
||
711 | 711 | } |
712 | 712 | |
713 | 713 | //possibly need to save tkt |
714 | - if ( ! $ticket->ID() ) |
|
714 | + if ( ! $ticket->ID()) |
|
715 | 715 | $ticket->save(); |
716 | 716 | |
717 | - foreach ( $prices as $row => $prc ) { |
|
718 | - $prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL; |
|
719 | - if ( empty($prt_id) ) |
|
717 | + foreach ($prices as $row => $prc) { |
|
718 | + $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL; |
|
719 | + if (empty($prt_id)) |
|
720 | 720 | continue; //prices MUST have a price type id. |
721 | 721 | $PRC_values = array( |
722 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
722 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
723 | 723 | 'PRT_ID' => $prt_id, |
724 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
725 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
726 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
724 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
725 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
726 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
727 | 727 | 'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor |
728 | 728 | 'PRC_order' => $row |
729 | 729 | ); |
730 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
730 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
731 | 731 | $PRC_values['PRC_ID'] = 0; |
732 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
732 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
733 | 733 | } else { |
734 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
734 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
735 | 735 | //update this price with new values |
736 | - foreach ( $PRC_values as $field => $newprc ) { |
|
737 | - $PRC->set( $field, $newprc ); |
|
736 | + foreach ($PRC_values as $field => $newprc) { |
|
737 | + $PRC->set($field, $newprc); |
|
738 | 738 | } |
739 | 739 | } |
740 | 740 | $PRC->save(); |
741 | 741 | $prcid = $PRC->ID(); |
742 | 742 | $updated_prices[$prcid] = $PRC; |
743 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
743 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | //now let's remove any prices that got removed from the ticket |
747 | - if ( !empty ( $current_prices_on_ticket ) ) { |
|
747 | + if ( ! empty ($current_prices_on_ticket)) { |
|
748 | 748 | $current = array_keys($current_prices_on_ticket); |
749 | 749 | $updated = array_keys($updated_prices); |
750 | 750 | $prices_to_remove = array_diff($current, $updated); |
751 | - if ( !empty( $prices_to_remove ) ) { |
|
752 | - foreach ( $prices_to_remove as $prc_id ) { |
|
751 | + if ( ! empty($prices_to_remove)) { |
|
752 | + foreach ($prices_to_remove as $prc_id) { |
|
753 | 753 | $p = $current_prices_on_ticket[$prc_id]; |
754 | - $ticket->_remove_relation_to( $p, 'Price' ); |
|
754 | + $ticket->_remove_relation_to($p, 'Price'); |
|
755 | 755 | |
756 | 756 | //delete permanently the price |
757 | 757 | $p->delete_permanently(); |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | |
765 | 765 | |
766 | 766 | |
767 | - public function autosave_handling( $event_admin_obj ) { |
|
767 | + public function autosave_handling($event_admin_obj) { |
|
768 | 768 | return $event_admin_obj; //doing nothing for the moment. |
769 | 769 | //todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method) |
770 | 770 | |
@@ -798,12 +798,12 @@ discard block |
||
798 | 798 | |
799 | 799 | //default main template args |
800 | 800 | $main_template_args = array( |
801 | - 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
801 | + 'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help |
|
802 | 802 | 'existing_datetime_ids' => '', |
803 | 803 | 'total_dtt_rows' => 1, |
804 | - 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
804 | + 'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
805 | 805 | 'datetime_rows' => '', |
806 | - 'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
806 | + 'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
807 | 807 | 'ticket_rows' => '', |
808 | 808 | 'existing_ticket_ids' => '', |
809 | 809 | 'total_ticket_rows' => 1, |
@@ -813,7 +813,7 @@ discard block |
||
813 | 813 | |
814 | 814 | $timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL; |
815 | 815 | |
816 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
816 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
817 | 817 | |
818 | 818 | /** |
819 | 819 | * 1. Start with retrieving Datetimes |
@@ -821,25 +821,25 @@ discard block |
||
821 | 821 | * 3. For each ticket get related prices |
822 | 822 | */ |
823 | 823 | |
824 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) ); |
|
825 | - $times = $DTM->get_all_event_dates( $evtID ); |
|
824 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone)); |
|
825 | + $times = $DTM->get_all_event_dates($evtID); |
|
826 | 826 | |
827 | 827 | |
828 | 828 | |
829 | 829 | $main_template_args['total_dtt_rows'] = count($times); |
830 | - foreach ( $times as $time ) { |
|
830 | + foreach ($times as $time) { |
|
831 | 831 | $dttid = $time->get('DTT_ID'); |
832 | 832 | $dttrow = $time->get('DTT_order'); |
833 | 833 | $existing_datetime_ids[] = $dttid; |
834 | 834 | |
835 | 835 | //tickets attached |
836 | - $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array( array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC' ) ) ) : array(); |
|
836 | + $related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC'))) : array(); |
|
837 | 837 | |
838 | 838 | //if there are no related tickets this is likely a new event OR autodraft |
839 | 839 | // event so we need to generate the default tickets because dtts |
840 | 840 | // ALWAYS have at least one related ticket!!. EXCEPT, we dont' do this if there is already more than one |
841 | 841 | // datetime on the event. |
842 | - if ( empty ( $related_tickets ) && count( $times ) < 2 ) { |
|
842 | + if (empty ($related_tickets) && count($times) < 2) { |
|
843 | 843 | $related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
844 | 844 | } |
845 | 845 | |
@@ -848,11 +848,11 @@ discard block |
||
848 | 848 | |
849 | 849 | //loop through and setup the ticket rows and make sure the order is set. |
850 | 850 | $order = 0; |
851 | - foreach ( $related_tickets as $ticket ) { |
|
851 | + foreach ($related_tickets as $ticket) { |
|
852 | 852 | $tktid = $ticket->get('TKT_ID'); |
853 | 853 | $tktrow = $ticket->get('TKT_row'); |
854 | 854 | //we only want unique tickets in our final display!! |
855 | - if ( !in_array( $tktid, $existing_ticket_ids ) ) { |
|
855 | + if ( ! in_array($tktid, $existing_ticket_ids)) { |
|
856 | 856 | $existing_ticket_ids[] = $tktid; |
857 | 857 | $all_tickets[] = $ticket; |
858 | 858 | } |
@@ -861,56 +861,56 @@ discard block |
||
861 | 861 | $datetime_tickets[$dttid][] = $tktrow; |
862 | 862 | |
863 | 863 | //temporary cache of this datetime info for this ticket for later processing of ticket rows. |
864 | - if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) ) |
|
864 | + if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid])) |
|
865 | 865 | $ticket_datetimes[$tktid][] = $dttrow; |
866 | 866 | } |
867 | 867 | } |
868 | 868 | |
869 | - $main_template_args['total_ticket_rows'] = count( $existing_ticket_ids ); |
|
870 | - $main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids ); |
|
871 | - $main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids ); |
|
869 | + $main_template_args['total_ticket_rows'] = count($existing_ticket_ids); |
|
870 | + $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
871 | + $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
872 | 872 | |
873 | 873 | //sort $all_tickets by order |
874 | - usort( $all_tickets, function( $a, $b ) { |
|
874 | + usort($all_tickets, function($a, $b) { |
|
875 | 875 | $a_order = (int) $a->get('TKT_order'); |
876 | 876 | $b_order = (int) $b->get('TKT_order'); |
877 | - if ( $a_order == $b_order ) { |
|
877 | + if ($a_order == $b_order) { |
|
878 | 878 | return 0; |
879 | 879 | } |
880 | - return ( $a_order < $b_order ) ? -1 : 1; |
|
880 | + return ($a_order < $b_order) ? -1 : 1; |
|
881 | 881 | }); |
882 | 882 | |
883 | 883 | //k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again. |
884 | 884 | $dttrow = 1; |
885 | - foreach ( $times as $time ) { |
|
886 | - $main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times ); |
|
885 | + foreach ($times as $time) { |
|
886 | + $main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times); |
|
887 | 887 | $dttrow++; |
888 | 888 | } |
889 | 889 | |
890 | 890 | //then loop through all tickets for the ticket rows. |
891 | 891 | $tktrow = 1; |
892 | - foreach ( $all_tickets as $ticket ) { |
|
893 | - $main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets ); |
|
892 | + foreach ($all_tickets as $ticket) { |
|
893 | + $main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets); |
|
894 | 894 | $tktrow++; |
895 | 895 | } |
896 | 896 | |
897 | 897 | $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets); |
898 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'; |
|
899 | - EEH_Template::display_template( $template, $main_template_args ); |
|
898 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'; |
|
899 | + EEH_Template::display_template($template, $main_template_args); |
|
900 | 900 | return; |
901 | 901 | } |
902 | 902 | |
903 | 903 | |
904 | 904 | |
905 | - protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) { |
|
905 | + protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) { |
|
906 | 906 | |
907 | 907 | $dtt_display_template_args = array( |
908 | - 'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ), |
|
909 | - 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ), |
|
908 | + 'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts), |
|
909 | + 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default), |
|
910 | 910 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow |
911 | 911 | ); |
912 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php'; |
|
913 | - return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE); |
|
912 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php'; |
|
913 | + return EEH_Template::display_template($template, $dtt_display_template_args, TRUE); |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | |
@@ -928,7 +928,7 @@ discard block |
||
928 | 928 | * |
929 | 929 | * @return string Generated edit row. |
930 | 930 | */ |
931 | - protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) { |
|
931 | + protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) { |
|
932 | 932 | |
933 | 933 | // if the incomign $dtt object is NOT an instance of EE_Datetime then force default to true. |
934 | 934 | $default = ! $dtt instanceof EE_Datetime ? true : false; |
@@ -936,30 +936,30 @@ discard block |
||
936 | 936 | $template_args = array( |
937 | 937 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
938 | 938 | 'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes', |
939 | - 'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
939 | + 'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
940 | 940 | 'DTT_ID' => $default ? '' : $dtt->ID(), |
941 | 941 | 'DTT_name' => $default ? '' : $dtt->name(), |
942 | 942 | 'DTT_description' => $default ? '' : $dtt->description(), |
943 | - 'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
944 | - 'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
945 | - 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'), |
|
943 | + 'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
944 | + 'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
945 | + 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'), |
|
946 | 946 | 'DTT_order' => $default ? 'DTTNUM' : $dttrow, |
947 | 947 | 'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'), |
948 | - 'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
949 | - 'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
948 | + 'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
949 | + 'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable' |
|
950 | 950 | ); |
951 | 951 | |
952 | - $template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
952 | + $template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
953 | 953 | |
954 | 954 | //allow filtering of template args at this point. |
955 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event ); |
|
955 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event); |
|
956 | 956 | |
957 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php'; |
|
958 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
957 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php'; |
|
958 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
959 | 959 | } |
960 | 960 | |
961 | 961 | |
962 | - protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) { |
|
962 | + protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) { |
|
963 | 963 | |
964 | 964 | $template_args = array( |
965 | 965 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
@@ -967,47 +967,47 @@ discard block |
||
967 | 967 | 'DTT_description' => $default ? '' : $dtt->description(), |
968 | 968 | 'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '', |
969 | 969 | 'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '', |
970 | - 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
970 | + 'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here. |
|
971 | 971 | 'DTT_ID' => $default ? '' : $dtt->ID() |
972 | 972 | ); |
973 | 973 | |
974 | 974 | //need to setup the list items (but only if this isnt' a default skeleton setup) |
975 | - if ( !$default ) { |
|
975 | + if ( ! $default) { |
|
976 | 976 | $tktrow = 1; |
977 | - foreach ( $all_tickets as $ticket ) { |
|
978 | - $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ); |
|
977 | + foreach ($all_tickets as $ticket) { |
|
978 | + $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default); |
|
979 | 979 | $tktrow++; |
980 | 980 | } |
981 | 981 | } |
982 | 982 | |
983 | 983 | //filter template args at this point |
984 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event ); |
|
984 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event); |
|
985 | 985 | |
986 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php'; |
|
987 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
986 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php'; |
|
987 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | |
991 | 991 | |
992 | - protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) { |
|
993 | - $tktid = !empty( $ticket ) ? $ticket->ID() : 0; |
|
994 | - $dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array(); |
|
992 | + protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) { |
|
993 | + $tktid = ! empty($ticket) ? $ticket->ID() : 0; |
|
994 | + $dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array(); |
|
995 | 995 | |
996 | - $displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0; |
|
996 | + $displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0; |
|
997 | 997 | $template_args = array( |
998 | 998 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
999 | - 'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow, |
|
999 | + 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
|
1000 | 1000 | 'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '', |
1001 | 1001 | 'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '', |
1002 | - 'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1003 | - 'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(), |
|
1002 | + 'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1003 | + 'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(), |
|
1004 | 1004 | ); |
1005 | 1005 | |
1006 | 1006 | //filter template args |
1007 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event ); |
|
1007 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event); |
|
1008 | 1008 | |
1009 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1010 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1009 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1010 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1011 | 1011 | } |
1012 | 1012 | |
1013 | 1013 | |
@@ -1029,32 +1029,32 @@ discard block |
||
1029 | 1029 | * |
1030 | 1030 | * @return [type] [description] |
1031 | 1031 | */ |
1032 | - protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) { |
|
1032 | + protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) { |
|
1033 | 1033 | |
1034 | 1034 | //if $ticket is not an instance of EE_Ticket then force default to true. |
1035 | - $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1035 | + $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1036 | 1036 | |
1037 | 1037 | |
1038 | - $prices = !empty($ticket) && !$default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array(); |
|
1038 | + $prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array(); |
|
1039 | 1039 | |
1040 | 1040 | // check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket). This will future proof in case there is ever any behaviour change between what the primary_key defaults to. |
1041 | - $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE; |
|
1041 | + $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE; |
|
1042 | 1042 | |
1043 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1043 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1044 | 1044 | |
1045 | 1045 | $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal(); |
1046 | - $base_price = $default ? NULL : $ticket->base_price(); |
|
1046 | + $base_price = $default ? NULL : $ticket->base_price(); |
|
1047 | 1047 | $count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE); |
1048 | 1048 | |
1049 | 1049 | //breaking out complicated condition for ticket_status |
1050 | - if ( $default ) { |
|
1051 | - $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale; |
|
1050 | + if ($default) { |
|
1051 | + $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale; |
|
1052 | 1052 | } else { |
1053 | - $ticket_status_class = $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(); |
|
1053 | + $ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(); |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | //breaking out complicated condition for TKT_taxable |
1057 | - if ( $default ) { |
|
1057 | + if ($default) { |
|
1058 | 1058 | $TKT_taxable = ''; |
1059 | 1059 | } else { |
1060 | 1060 | $TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : ''; |
@@ -1069,19 +1069,19 @@ discard block |
||
1069 | 1069 | 'edit_tkt_expanded' => '', |
1070 | 1070 | 'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets', |
1071 | 1071 | 'TKT_name' => $default ? '' : $ticket->get('TKT_name'), |
1072 | - 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1073 | - 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1074 | - 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1072 | + 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1073 | + 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1074 | + 'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE), |
|
1075 | 1075 | 'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE), |
1076 | 1076 | 'TKT_price_code' => EE_Registry::instance()->CFG->currency->code, |
1077 | 1077 | 'TKT_price_amount' => $default ? 0 : $ticket_subtotal, |
1078 | - 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'), |
|
1079 | - 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'), |
|
1080 | - 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'), |
|
1081 | - 'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ), |
|
1082 | - 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max','input'), |
|
1078 | + 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'), |
|
1079 | + 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'), |
|
1080 | + 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'), |
|
1081 | + 'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')), |
|
1082 | + 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'), |
|
1083 | 1083 | 'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'), |
1084 | - 'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ), |
|
1084 | + 'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))), |
|
1085 | 1085 | 'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'), |
1086 | 1086 | 'TKT_description' => $default ? '' : $ticket->get('TKT_description'), |
1087 | 1087 | 'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'), |
@@ -1090,99 +1090,99 @@ discard block |
||
1090 | 1090 | 'ticket_price_rows' => '', |
1091 | 1091 | 'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'), |
1092 | 1092 | 'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(), |
1093 | - 'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"', |
|
1094 | - 'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '', |
|
1093 | + 'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"', |
|
1094 | + 'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '', |
|
1095 | 1095 | 'total_price_rows' => count($prices) > 1 ? count($prices) : 1, |
1096 | 1096 | 'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '', |
1097 | 1097 | 'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts), |
1098 | 1098 | 'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts), |
1099 | - 'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ), |
|
1099 | + 'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)), |
|
1100 | 1100 | 'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'), |
1101 | 1101 | 'TKT_taxable' => $TKT_taxable, |
1102 | 1102 | 'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"', |
1103 | 1103 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1104 | - 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ), |
|
1104 | + 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE), |
|
1105 | 1105 | 'TKT_subtotal_amount' => $ticket_subtotal, |
1106 | - 'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ), |
|
1107 | - 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE, |
|
1106 | + 'tax_rows' => $this->_get_tax_rows($tktrow, $ticket), |
|
1107 | + 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE : FALSE, |
|
1108 | 1108 | 'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '', |
1109 | 1109 | 'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable', |
1110 | 1110 | 'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable' |
1111 | 1111 | ); |
1112 | 1112 | |
1113 | - $template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1113 | + $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1114 | 1114 | |
1115 | 1115 | //handle rows that should NOT be empty |
1116 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1116 | + if (empty($template_args['TKT_start_date'])) { |
|
1117 | 1117 | //if empty then the start date will be now. |
1118 | - $template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp')); |
|
1119 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1118 | + $template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp')); |
|
1119 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1122 | + if (empty($template_args['TKT_end_date'])) { |
|
1123 | 1123 | |
1124 | 1124 | //get the earliest datetime (if present); |
1125 | - $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL; |
|
1125 | + $earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL; |
|
1126 | 1126 | |
1127 | - if ( !empty( $earliest_dtt ) ) { |
|
1128 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
1127 | + if ( ! empty($earliest_dtt)) { |
|
1128 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
1129 | 1129 | } else { |
1130 | 1130 | //default so let's just use what's been set for the default date-time which is 30 days from now. |
1131 | - $template_args['TKT_end_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , mktime(24, 0, 0, date("m"), date("d") + 29, date("Y") ) ); |
|
1131 | + $template_args['TKT_end_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], mktime(24, 0, 0, date("m"), date("d") + 29, date("Y"))); |
|
1132 | 1132 | } |
1133 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1133 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | //generate ticket_datetime items |
1137 | - if ( ! $default ) { |
|
1137 | + if ( ! $default) { |
|
1138 | 1138 | $dttrow = 1; |
1139 | - foreach ( $all_dtts as $dtt ) { |
|
1140 | - $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ); |
|
1139 | + foreach ($all_dtts as $dtt) { |
|
1140 | + $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default); |
|
1141 | 1141 | $dttrow++; |
1142 | 1142 | } |
1143 | 1143 | } |
1144 | 1144 | |
1145 | 1145 | $prcrow = 1; |
1146 | - foreach ( $prices as $price ) { |
|
1147 | - if ( $price->is_base_price() ) { |
|
1146 | + foreach ($prices as $price) { |
|
1147 | + if ($price->is_base_price()) { |
|
1148 | 1148 | $prcrow++; |
1149 | 1149 | continue; |
1150 | 1150 | } |
1151 | - $show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1 ? FALSE : TRUE; |
|
1152 | - $show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE; |
|
1153 | - $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create ); |
|
1151 | + $show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE; |
|
1152 | + $show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE; |
|
1153 | + $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create); |
|
1154 | 1154 | $prcrow++; |
1155 | 1155 | } |
1156 | 1156 | |
1157 | 1157 | //filter $template_args |
1158 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event ); |
|
1158 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event); |
|
1159 | 1159 | |
1160 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php'; |
|
1161 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1160 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php'; |
|
1161 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | |
1165 | 1165 | |
1166 | 1166 | |
1167 | 1167 | |
1168 | - protected function _get_tax_rows( $tktrow, $ticket ) { |
|
1168 | + protected function _get_tax_rows($tktrow, $ticket) { |
|
1169 | 1169 | $tax_rows = ''; |
1170 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1170 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1171 | 1171 | $template_args = array(); |
1172 | - $taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1173 | - foreach ( $taxes as $tax ) { |
|
1174 | - $tax_added = $this->_get_tax_added( $tax, $ticket ); |
|
1172 | + $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1173 | + foreach ($taxes as $tax) { |
|
1174 | + $tax_added = $this->_get_tax_added($tax, $ticket); |
|
1175 | 1175 | $template_args = array( |
1176 | - 'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1176 | + 'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1177 | 1177 | 'tax_id' => $tax->ID(), |
1178 | 1178 | 'tkt_row' => $tktrow, |
1179 | 1179 | 'tax_label' => $tax->get('PRC_name'), |
1180 | 1180 | 'tax_added' => $tax_added, |
1181 | - 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ), |
|
1181 | + 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE), |
|
1182 | 1182 | 'tax_amount' => $tax->get('PRC_amount') |
1183 | 1183 | ); |
1184 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event ); |
|
1185 | - $tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1184 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event); |
|
1185 | + $tax_rows .= EEH_Template::display_template($template, $template_args, TRUE); |
|
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | |
@@ -1190,81 +1190,81 @@ discard block |
||
1190 | 1190 | } |
1191 | 1191 | |
1192 | 1192 | |
1193 | - protected function _get_tax_added( EE_Price $tax, $ticket ) { |
|
1194 | - $subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal(); |
|
1193 | + protected function _get_tax_added(EE_Price $tax, $ticket) { |
|
1194 | + $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal(); |
|
1195 | 1195 | return $subtotal * $tax->get('PRC_amount') / 100; |
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | |
1199 | 1199 | |
1200 | 1200 | |
1201 | - protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) { |
|
1202 | - $send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1201 | + protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) { |
|
1202 | + $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1203 | 1203 | $template_args = array( |
1204 | 1204 | 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
1205 | 1205 | 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
1206 | 1206 | 'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices', |
1207 | - 'price_type_selector' => $default && empty( $price ) ? $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ) : $this->_get_price_type_selector( $tktrow, $prcrow, $price, $default, $send_disabled ), |
|
1207 | + 'price_type_selector' => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow, $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled), |
|
1208 | 1208 | 'PRC_ID' => $default && empty($price) ? 0 : $price->ID(), |
1209 | 1209 | 'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'), |
1210 | 1210 | 'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'), |
1211 | 1211 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1212 | 1212 | 'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"', |
1213 | - 'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1214 | - 'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1215 | - 'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ), |
|
1216 | - 'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1217 | - 'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ), |
|
1213 | + 'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1214 | + 'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1215 | + 'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''), |
|
1216 | + 'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1217 | + 'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'), |
|
1218 | 1218 | 'show_trash_icon' => $show_trash ? '' : ' style="display:none;"', |
1219 | 1219 | 'show_create_button' => $show_create ? '' : ' style="display:none;"', |
1220 | - 'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'), |
|
1221 | - 'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1220 | + 'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'), |
|
1221 | + 'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1222 | 1222 | ); |
1223 | 1223 | |
1224 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event ); |
|
1224 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event); |
|
1225 | 1225 | |
1226 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php'; |
|
1227 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1226 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php'; |
|
1227 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | |
1231 | - protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1232 | - if ( $price->is_base_price() ) { |
|
1233 | - return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ); |
|
1231 | + protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1232 | + if ($price->is_base_price()) { |
|
1233 | + return $this->_get_base_price_template($tktrow, $prcrow, $price, $default); |
|
1234 | 1234 | } else { |
1235 | - return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled ); |
|
1235 | + return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled); |
|
1236 | 1236 | } |
1237 | 1237 | |
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | |
1241 | - protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) { |
|
1241 | + protected function _get_base_price_template($tktrow, $prcrow, $price, $default) { |
|
1242 | 1242 | $template_args = array( |
1243 | 1243 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1244 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1245 | - 'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'), |
|
1244 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1245 | + 'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'), |
|
1246 | 1246 | 'PRT_name' => __('Price', 'event_espresso'), |
1247 | 1247 | 'price_selected_operator' => '+', |
1248 | 1248 | 'price_selected_is_percent' => 0 |
1249 | 1249 | ); |
1250 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php'; |
|
1250 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php'; |
|
1251 | 1251 | |
1252 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event ); |
|
1252 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event); |
|
1253 | 1253 | |
1254 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1254 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | |
1258 | 1258 | |
1259 | - protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1260 | - $select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]'; |
|
1261 | - $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) ); |
|
1262 | - $price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php'; |
|
1263 | - $all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array(); |
|
1264 | - $selected_price_type_id = $default && empty( $price ) ? 0 : $price->type(); |
|
1259 | + protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1260 | + $select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]'; |
|
1261 | + $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3')))); |
|
1262 | + $price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php'; |
|
1263 | + $all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array(); |
|
1264 | + $selected_price_type_id = $default && empty($price) ? 0 : $price->type(); |
|
1265 | 1265 | $price_option_spans = ''; |
1266 | 1266 | //setup pricetypes for selector |
1267 | - foreach ( $price_types as $price_type ) { |
|
1267 | + foreach ($price_types as $price_type) { |
|
1268 | 1268 | $all_price_types[] = array( |
1269 | 1269 | 'id' => $price_type->ID(), |
1270 | 1270 | 'text' => $price_type->get('PRT_name'), |
@@ -1276,50 +1276,50 @@ discard block |
||
1276 | 1276 | 'PRT_operator' => $price_type->is_discount() ? '-' : '+', |
1277 | 1277 | 'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0 |
1278 | 1278 | ); |
1279 | - $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE ); |
|
1279 | + $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE); |
|
1280 | 1280 | } |
1281 | 1281 | |
1282 | - $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1282 | + $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1283 | 1283 | $main_name = $select_name; |
1284 | - $select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name; |
|
1284 | + $select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name; |
|
1285 | 1285 | |
1286 | 1286 | $template_args = array( |
1287 | 1287 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1288 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1289 | - 'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ), |
|
1288 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1289 | + 'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'), |
|
1290 | 1290 | 'main_name' => $main_name, |
1291 | 1291 | 'selected_price_type_id' => $selected_price_type_id, |
1292 | 1292 | 'price_option_spans' => $price_option_spans, |
1293 | - 'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ), |
|
1294 | - 'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ), |
|
1293 | + 'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'), |
|
1294 | + 'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0), |
|
1295 | 1295 | 'disabled' => $disabled |
1296 | 1296 | ); |
1297 | 1297 | |
1298 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event ); |
|
1298 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event); |
|
1299 | 1299 | |
1300 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1300 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1301 | 1301 | |
1302 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1302 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1303 | 1303 | } |
1304 | 1304 | |
1305 | 1305 | |
1306 | 1306 | |
1307 | - protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) { |
|
1308 | - $dttid = !empty($dtt) ? $dtt->ID() : 0; |
|
1309 | - $displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1310 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1307 | + protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) { |
|
1308 | + $dttid = ! empty($dtt) ? $dtt->ID() : 0; |
|
1309 | + $displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1310 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1311 | 1311 | $template_args = array( |
1312 | - 'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow, |
|
1312 | + 'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow, |
|
1313 | 1313 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1314 | - 'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '', |
|
1315 | - 'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '', |
|
1316 | - 'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ), |
|
1314 | + 'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '', |
|
1315 | + 'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '', |
|
1316 | + 'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE), |
|
1317 | 1317 | 'tkt_status_class' => '', |
1318 | 1318 | ); |
1319 | 1319 | |
1320 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event ); |
|
1321 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1322 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1320 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event); |
|
1321 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1322 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1323 | 1323 | } |
1324 | 1324 | |
1325 | 1325 | |
@@ -1327,53 +1327,53 @@ discard block |
||
1327 | 1327 | protected function _get_ticket_js_structure($all_dtts, $all_tickets) { |
1328 | 1328 | $template_args = array( |
1329 | 1329 | 'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts), |
1330 | - 'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE), |
|
1331 | - 'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ), |
|
1330 | + 'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE), |
|
1331 | + 'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL), |
|
1332 | 1332 | 'default_price_rows' => '', |
1333 | 1333 | 'default_base_price_amount' => 0, |
1334 | 1334 | 'default_base_price_name' => '', |
1335 | 1335 | 'default_base_price_description' => '', |
1336 | - 'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ), |
|
1337 | - 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ), |
|
1336 | + 'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE), |
|
1337 | + 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE), |
|
1338 | 1338 | 'existing_available_datetime_tickets_list' => '', |
1339 | 1339 | 'existing_available_ticket_datetimes_list' => '', |
1340 | - 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ), |
|
1341 | - 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ) |
|
1340 | + 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE), |
|
1341 | + 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE) |
|
1342 | 1342 | ); |
1343 | 1343 | |
1344 | 1344 | $tktrow = 1; |
1345 | - foreach ( $all_tickets as $ticket ) { |
|
1346 | - $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE ); |
|
1345 | + foreach ($all_tickets as $ticket) { |
|
1346 | + $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE); |
|
1347 | 1347 | $tktrow++; |
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | |
1351 | 1351 | $dttrow = 1; |
1352 | - foreach ( $all_dtts as $dtt ) { |
|
1353 | - $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE ); |
|
1352 | + foreach ($all_dtts as $dtt) { |
|
1353 | + $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE); |
|
1354 | 1354 | $dttrow++; |
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | $default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices(); |
1358 | 1358 | $prcrow = 1; |
1359 | - foreach ( $default_prices as $price ) { |
|
1360 | - if ( $price->is_base_price() ) { |
|
1359 | + foreach ($default_prices as $price) { |
|
1360 | + if ($price->is_base_price()) { |
|
1361 | 1361 | $template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float'); |
1362 | 1362 | $template_args['default_base_price_name'] = $price->get('PRC_name'); |
1363 | 1363 | $template_args['default_base_price_description'] = $price->get('PRC_desc'); |
1364 | 1364 | $prcrow++; |
1365 | 1365 | continue; |
1366 | 1366 | } |
1367 | - $show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1 ? FALSE : TRUE; |
|
1368 | - $show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE; |
|
1369 | - $template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create ); |
|
1367 | + $show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE; |
|
1368 | + $show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE; |
|
1369 | + $template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create); |
|
1370 | 1370 | $prcrow++; |
1371 | 1371 | } |
1372 | 1372 | |
1373 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event ); |
|
1373 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event); |
|
1374 | 1374 | |
1375 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1376 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1375 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1376 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return EED_Event_Single |
41 | 41 | */ |
42 | 42 | public static function instance() { |
43 | - return parent::get_instance( __CLASS__ ); |
|
43 | + return parent::get_instance(__CLASS__); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * @return void |
53 | 53 | */ |
54 | 54 | public static function set_hooks() { |
55 | - add_filter( 'FHEE_run_EE_wp', '__return_true' ); |
|
56 | - add_action( 'wp_loaded', array( 'EED_Event_Single', 'set_definitions' ), 2 ); |
|
57 | - EE_Config::register_route( __( 'event', 'event_espresso' ), 'Event_Single', 'run' ); |
|
55 | + add_filter('FHEE_run_EE_wp', '__return_true'); |
|
56 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
57 | + EE_Config::register_route(__('event', 'event_espresso'), 'Event_Single', 'run'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return void |
65 | 65 | */ |
66 | 66 | public static function set_hooks_admin() { |
67 | - add_action( 'wp_loaded', array( 'EED_Event_Single', 'set_definitions' ), 2 ); |
|
67 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @return void |
79 | 79 | */ |
80 | 80 | public static function set_definitions() { |
81 | - define( 'EVENT_SINGLE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
82 | - define( 'EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path( __FILE__ ) . 'templates' . DS ); |
|
81 | + define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
82 | + define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @void |
91 | 91 | */ |
92 | - protected function set_config(){ |
|
93 | - $this->set_config_section( 'template_settings' ); |
|
94 | - $this->set_config_class( 'EE_Event_Single_Config' ); |
|
95 | - $this->set_config_name( 'EED_Event_Single' ); |
|
92 | + protected function set_config() { |
|
93 | + $this->set_config_section('template_settings'); |
|
94 | + $this->set_config_class('EE_Event_Single_Config'); |
|
95 | + $this->set_config_name('EED_Event_Single'); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -105,35 +105,35 @@ discard block |
||
105 | 105 | * @param \EE_Event_Single_Config $config |
106 | 106 | * @return \EE_Template_Part_Manager |
107 | 107 | */ |
108 | - public function initialize_template_parts( EE_Event_Single_Config $config = null ) { |
|
108 | + public function initialize_template_parts(EE_Event_Single_Config $config = null) { |
|
109 | 109 | $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
110 | 110 | EEH_Autoloader::instance()->register_template_part_autoloaders(); |
111 | 111 | $template_parts = new EE_Template_Part_Manager(); |
112 | 112 | $template_parts->add_template_part( |
113 | 113 | 'tickets', |
114 | - __( 'Ticket Selector', 'event_espresso' ), |
|
114 | + __('Ticket Selector', 'event_espresso'), |
|
115 | 115 | 'content-espresso_events-tickets.php', |
116 | 116 | $config->display_order_tickets |
117 | 117 | ); |
118 | 118 | $template_parts->add_template_part( |
119 | 119 | 'datetimes', |
120 | - __( 'Dates and Times', 'event_espresso' ), |
|
120 | + __('Dates and Times', 'event_espresso'), |
|
121 | 121 | 'content-espresso_events-datetimes.php', |
122 | 122 | $config->display_order_datetimes |
123 | 123 | ); |
124 | 124 | $template_parts->add_template_part( |
125 | 125 | 'event', |
126 | - __( 'Event Description', 'event_espresso' ), |
|
126 | + __('Event Description', 'event_espresso'), |
|
127 | 127 | 'content-espresso_events-details.php', |
128 | 128 | $config->display_order_event |
129 | 129 | ); |
130 | 130 | $template_parts->add_template_part( |
131 | 131 | 'venue', |
132 | - __( 'Venue Information', 'event_espresso' ), |
|
132 | + __('Venue Information', 'event_espresso'), |
|
133 | 133 | 'content-espresso_events-venues.php', |
134 | 134 | $config->display_order_venue |
135 | 135 | ); |
136 | - do_action( 'AHEE__EED_Event_Single__initialize_template_parts', $template_parts ); |
|
136 | + do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
137 | 137 | return $template_parts; |
138 | 138 | } |
139 | 139 | |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | * @param WP $WP |
148 | 148 | * @return void |
149 | 149 | */ |
150 | - public function run( $WP ) { |
|
150 | + public function run($WP) { |
|
151 | 151 | // ensure valid EE_Events_Single_Config() object exists |
152 | 152 | $this->set_config(); |
153 | 153 | // check what template is loaded |
154 | - add_filter( 'template_include', array( $this, 'template_include' ), 999, 1 ); |
|
155 | - add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
154 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
155 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
156 | 156 | // load css |
157 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
|
158 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
157 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
158 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | |
@@ -167,26 +167,26 @@ discard block |
||
167 | 167 | * @param string $template |
168 | 168 | * @return string |
169 | 169 | */ |
170 | - public function template_include( $template ) { |
|
170 | + public function template_include($template) { |
|
171 | 171 | global $post; |
172 | 172 | /** @type EE_Event_Single_Config $config */ |
173 | 173 | $config = $this->config(); |
174 | - if ( $config->display_status_banner_single ) { |
|
175 | - add_filter( 'the_title', array( 'EED_Event_Single', 'the_title' ), 100, 2 ); |
|
174 | + if ($config->display_status_banner_single) { |
|
175 | + add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
176 | 176 | } |
177 | 177 | // not a custom template? |
178 | 178 | if ( |
179 | 179 | EE_Front_Controller::instance()->get_selected_template() != 'single-espresso_events.php' |
180 | - && ! post_password_required( $post ) |
|
180 | + && ! post_password_required($post) |
|
181 | 181 | ) { |
182 | 182 | EEH_Template::load_espresso_theme_functions(); |
183 | 183 | // then add extra event data via hooks |
184 | - add_action( 'loop_start', array( 'EED_Event_Single', 'loop_start' )); |
|
185 | - add_filter( 'get_the_excerpt', array( 'EED_Event_Single', 'get_the_excerpt' ), 1, 1 ); |
|
186 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
187 | - add_action( 'loop_end', array( 'EED_Event_Single', 'loop_end' )); |
|
184 | + add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
185 | + add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
186 | + add_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
187 | + add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
188 | 188 | // don't display entry meta because the existing theme will take car of that |
189 | - add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
189 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
190 | 190 | } |
191 | 191 | return $template; |
192 | 192 | } |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | * @param array $wp_query_array an array containing the WP_Query object |
201 | 201 | * @return void |
202 | 202 | */ |
203 | - public static function loop_start( $wp_query_array ) { |
|
203 | + public static function loop_start($wp_query_array) { |
|
204 | 204 | global $post; |
205 | - do_action( 'AHEE_event_details_before_post', $post, $wp_query_array ); |
|
205 | + do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | * @param int $id |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public static function the_title( $title = '', $id = 0 ) { |
|
218 | + public static function the_title($title = '', $id = 0) { |
|
219 | 219 | global $post; |
220 | - return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID ) . $title : $title; |
|
220 | + return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | * @param string $excerpt |
230 | 230 | * @return string |
231 | 231 | */ |
232 | - public static function get_the_excerpt( $excerpt = '' ) { |
|
232 | + public static function get_the_excerpt($excerpt = '') { |
|
233 | 233 | EED_Event_Single::$using_get_the_excerpt = true; |
234 | - add_filter( 'wp_trim_excerpt', array( 'EED_Event_Single', 'end_get_the_excerpt' ), 999, 1 ); |
|
234 | + add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
235 | 235 | return $excerpt; |
236 | 236 | } |
237 | 237 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @param string $text |
245 | 245 | * @return string |
246 | 246 | */ |
247 | - public static function end_get_the_excerpt( $text = '' ) { |
|
247 | + public static function end_get_the_excerpt($text = '') { |
|
248 | 248 | EED_Event_Single::$using_get_the_excerpt = false; |
249 | 249 | return $text; |
250 | 250 | } |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @param string $content |
259 | 259 | * @return string |
260 | 260 | */ |
261 | - public static function event_details( $content ) { |
|
261 | + public static function event_details($content) { |
|
262 | 262 | global $post; |
263 | 263 | static $current_post_ID = 0; |
264 | 264 | if ( |
@@ -273,15 +273,15 @@ discard block |
||
273 | 273 | // We want to allow those plugins to still do their thing and have access to our content, but depending on |
274 | 274 | // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
275 | 275 | // so the following allows this filter to be applied multiple times, but only once for real |
276 | - $current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0; |
|
277 | - if ( EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order ) { |
|
276 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
277 | + if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
278 | 278 | // we need to first remove this callback from being applied to the_content() |
279 | 279 | // (otherwise it will recurse and blow up the interweb) |
280 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
280 | + remove_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
281 | 281 | EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts(); |
282 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
283 | - $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters( $content ); |
|
284 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
282 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
283 | + $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
284 | + add_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
285 | 285 | } else { |
286 | 286 | $content = EED_Event_Single::use_filterable_display_order(); |
287 | 287 | } |
@@ -302,19 +302,19 @@ discard block |
||
302 | 302 | // it uses the_content() for displaying the $post->post_content |
303 | 303 | // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
304 | 304 | // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
305 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
305 | + remove_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
306 | 306 | //now add additional content |
307 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_datetimes' ), 110, 1 ); |
|
308 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_tickets' ), 120, 1 ); |
|
309 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_venues' ), 130, 1 ); |
|
310 | - do_action( 'AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters' ); |
|
307 | + add_filter('the_content', array('EED_Event_Single', 'event_datetimes'), 110, 1); |
|
308 | + add_filter('the_content', array('EED_Event_Single', 'event_tickets'), 120, 1); |
|
309 | + add_filter('the_content', array('EED_Event_Single', 'event_venues'), 130, 1); |
|
310 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
311 | 311 | // now load our template |
312 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
312 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
313 | 313 | //now add our filter back in, plus some others |
314 | - add_filter( 'the_content', array( 'EED_Event_Single', 'event_details' ), 100 ); |
|
315 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_datetimes' ), 110 ); |
|
316 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_tickets' ), 120 ); |
|
317 | - remove_filter( 'the_content', array( 'EED_Event_Single', 'event_venues' ), 130 ); |
|
314 | + add_filter('the_content', array('EED_Event_Single', 'event_details'), 100); |
|
315 | + remove_filter('the_content', array('EED_Event_Single', 'event_datetimes'), 110); |
|
316 | + remove_filter('the_content', array('EED_Event_Single', 'event_tickets'), 120); |
|
317 | + remove_filter('the_content', array('EED_Event_Single', 'event_venues'), 130); |
|
318 | 318 | // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
319 | 319 | return $content; |
320 | 320 | } |
@@ -328,8 +328,8 @@ discard block |
||
328 | 328 | * @param string $content |
329 | 329 | * @return string |
330 | 330 | */ |
331 | - public static function event_datetimes( $content ) { |
|
332 | - return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content; |
|
331 | + public static function event_datetimes($content) { |
|
332 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | * @param string $content |
342 | 342 | * @return string |
343 | 343 | */ |
344 | - public static function event_tickets( $content ) { |
|
345 | - return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content; |
|
344 | + public static function event_tickets($content) { |
|
345 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * @param string $content |
355 | 355 | * @return string |
356 | 356 | */ |
357 | - public static function event_venue( $content ) { |
|
358 | - return EED_Event_Single::event_venues( $content ); |
|
357 | + public static function event_venue($content) { |
|
358 | + return EED_Event_Single::event_venues($content); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | * @param string $content |
368 | 368 | * @return string |
369 | 369 | */ |
370 | - public static function event_venues( $content ) { |
|
371 | - return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' ); |
|
370 | + public static function event_venues($content) { |
|
371 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | |
@@ -380,9 +380,9 @@ discard block |
||
380 | 380 | * @param array $wp_query_array an array containing the WP_Query object |
381 | 381 | * @return void |
382 | 382 | */ |
383 | - public static function loop_end( $wp_query_array ) { |
|
383 | + public static function loop_end($wp_query_array) { |
|
384 | 384 | global $post; |
385 | - do_action( 'AHEE_event_details_after_post', $post, $wp_query_array ); |
|
385 | + do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -395,18 +395,18 @@ discard block |
||
395 | 395 | */ |
396 | 396 | public function wp_enqueue_scripts() { |
397 | 397 | // get some style |
398 | - if ( apply_filters( 'FHEE_enable_default_espresso_css', TRUE ) && apply_filters( 'FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE )) { |
|
399 | - EE_Registry::instance()->load_helper( 'File' ); |
|
398 | + if (apply_filters('FHEE_enable_default_espresso_css', TRUE) && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', TRUE)) { |
|
399 | + EE_Registry::instance()->load_helper('File'); |
|
400 | 400 | // first check uploads folder |
401 | - if ( is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) { |
|
402 | - wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
401 | + if (is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
402 | + wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
403 | 403 | } else { |
404 | - wp_register_style( $this->theme, EE_TEMPLATES_URL . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
404 | + wp_register_style($this->theme, EE_TEMPLATES_URL.$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
405 | 405 | } |
406 | - wp_enqueue_script( $this->theme ); |
|
407 | - if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
|
408 | - EE_Registry::instance()->load_helper( 'Maps' ); |
|
409 | - add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 ); |
|
406 | + wp_enqueue_script($this->theme); |
|
407 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
408 | + EE_Registry::instance()->load_helper('Maps'); |
|
409 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
410 | 410 | } |
411 | 411 | } |
412 | 412 | } |
@@ -425,12 +425,12 @@ discard block |
||
425 | 425 | * @return bool |
426 | 426 | */ |
427 | 427 | public static function display_venue() { |
428 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
428 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
429 | 429 | /** @type EE_Event_Single_Config $config */ |
430 | 430 | $config = EED_Event_Single::instance()->config(); |
431 | - $display_venue= isset( $config->display_venue ) ? $config->display_venue : TRUE; |
|
431 | + $display_venue = isset($config->display_venue) ? $config->display_venue : TRUE; |
|
432 | 432 | $venue_name = EEH_Venue_View::venue_name(); |
433 | - return $display_venue && ! empty( $venue_name ) ? TRUE : FALSE; |
|
433 | + return $display_venue && ! empty($venue_name) ? TRUE : FALSE; |
|
434 | 434 | } |
435 | 435 | |
436 | 436 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return EED_Events_Archive |
44 | 44 | */ |
45 | 45 | public static function instance() { |
46 | - return parent::get_instance( __CLASS__ ); |
|
46 | + return parent::get_instance(__CLASS__); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * @return void |
56 | 56 | */ |
57 | 57 | public static function set_hooks() { |
58 | - EE_Config::register_route( EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run' ); |
|
59 | - EE_Config::register_route( 'event_list', 'Events_Archive', 'event_list' ); |
|
60 | - add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
58 | + EE_Config::register_route(EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run'); |
|
59 | + EE_Config::register_route('event_list', 'Events_Archive', 'event_list'); |
|
60 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @return void |
68 | 68 | */ |
69 | 69 | public static function set_hooks_admin() { |
70 | - add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
70 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * @return void |
81 | 81 | */ |
82 | 82 | public static function set_definitions() { |
83 | - define( 'EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
84 | - define( 'EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
83 | + define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
84 | + define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return \EE_Events_Archive_Config |
93 | 93 | */ |
94 | - protected function set_config(){ |
|
95 | - $this->set_config_section( 'template_settings' ); |
|
96 | - $this->set_config_class( 'EE_Events_Archive_Config' ); |
|
97 | - $this->set_config_name( 'EED_Events_Archive' ); |
|
94 | + protected function set_config() { |
|
95 | + $this->set_config_section('template_settings'); |
|
96 | + $this->set_config_class('EE_Events_Archive_Config'); |
|
97 | + $this->set_config_name('EED_Events_Archive'); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -106,35 +106,35 @@ discard block |
||
106 | 106 | * @param \EE_Events_Archive_Config $config |
107 | 107 | * @return \EE_Template_Part_Manager |
108 | 108 | */ |
109 | - public function initialize_template_parts( EE_Events_Archive_Config $config = null ) { |
|
109 | + public function initialize_template_parts(EE_Events_Archive_Config $config = null) { |
|
110 | 110 | $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
111 | 111 | EEH_Autoloader::instance()->register_template_part_autoloaders(); |
112 | 112 | $template_parts = new EE_Template_Part_Manager(); |
113 | 113 | $template_parts->add_template_part( |
114 | 114 | 'tickets', |
115 | - __( 'Ticket Selector', 'event_espresso' ), |
|
115 | + __('Ticket Selector', 'event_espresso'), |
|
116 | 116 | 'content-espresso_events-tickets.php', |
117 | 117 | $config->display_order_tickets |
118 | 118 | ); |
119 | 119 | $template_parts->add_template_part( |
120 | 120 | 'datetimes', |
121 | - __( 'Dates and Times', 'event_espresso' ), |
|
121 | + __('Dates and Times', 'event_espresso'), |
|
122 | 122 | 'content-espresso_events-datetimes.php', |
123 | 123 | $config->display_order_datetimes |
124 | 124 | ); |
125 | 125 | $template_parts->add_template_part( |
126 | 126 | 'event', |
127 | - __( 'Event Description', 'event_espresso' ), |
|
127 | + __('Event Description', 'event_espresso'), |
|
128 | 128 | 'content-espresso_events-details.php', |
129 | 129 | $config->display_order_event |
130 | 130 | ); |
131 | 131 | $template_parts->add_template_part( |
132 | 132 | 'venue', |
133 | - __( 'Venue Information', 'event_espresso' ), |
|
133 | + __('Venue Information', 'event_espresso'), |
|
134 | 134 | 'content-espresso_events-venues.php', |
135 | 135 | $config->display_order_venue |
136 | 136 | ); |
137 | - do_action( 'AHEE__EED_Event_Archive__initialize_template_parts', $template_parts ); |
|
137 | + do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
138 | 138 | return $template_parts; |
139 | 139 | } |
140 | 140 | |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * @param WP $WP |
148 | 148 | * @return void |
149 | 149 | */ |
150 | - public function run( $WP ) { |
|
151 | - do_action( 'AHEE__EED_Events_Archive__before_run' ); |
|
150 | + public function run($WP) { |
|
151 | + do_action('AHEE__EED_Events_Archive__before_run'); |
|
152 | 152 | // ensure valid EE_Events_Archive_Config() object exists |
153 | 153 | $this->set_config(); |
154 | 154 | /** @type EE_Events_Archive_Config $config */ |
@@ -156,19 +156,19 @@ discard block |
||
156 | 156 | // load other required components |
157 | 157 | $this->load_event_list_assets(); |
158 | 158 | // filter the WP posts_join, posts_where, and posts_orderby SQL clauses |
159 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
159 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
160 | 160 | //add query filters |
161 | 161 | EEH_Event_Query::add_query_filters(); |
162 | 162 | // set params that will get used by the filters |
163 | 163 | EEH_Event_Query::set_query_params( |
164 | - '', // month |
|
165 | - '', // category |
|
166 | - $config->display_expired_events, // show_expired |
|
167 | - 'start_date', // orderby |
|
164 | + '', // month |
|
165 | + '', // category |
|
166 | + $config->display_expired_events, // show_expired |
|
167 | + 'start_date', // orderby |
|
168 | 168 | 'ASC' // sort |
169 | 169 | ); |
170 | 170 | // check what template is loaded |
171 | - add_filter( 'template_include', array( $this, 'template_include' ), 999, 1 ); |
|
171 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -200,30 +200,30 @@ discard block |
||
200 | 200 | * @param string $template |
201 | 201 | * @return string |
202 | 202 | */ |
203 | - public function template_include( $template = '' ) { |
|
203 | + public function template_include($template = '') { |
|
204 | 204 | // don't add content filter for dedicated EE child themes or private posts |
205 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
206 | - if ( ! EEH_Template::is_espresso_theme() ) { |
|
205 | + EE_Registry::instance()->load_helper('Template'); |
|
206 | + if ( ! EEH_Template::is_espresso_theme()) { |
|
207 | 207 | /** @type EE_Events_Archive_Config $config */ |
208 | 208 | $config = $this->config(); |
209 | 209 | // add status banner ? |
210 | - if ( $config->display_status_banner ) { |
|
211 | - add_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100, 2 ); |
|
210 | + if ($config->display_status_banner) { |
|
211 | + add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2); |
|
212 | 212 | } |
213 | 213 | // if NOT a custom template |
214 | - if ( EE_Front_Controller::instance()->get_selected_template() != 'archive-espresso_events.php' ) { |
|
214 | + if (EE_Front_Controller::instance()->get_selected_template() != 'archive-espresso_events.php') { |
|
215 | 215 | // don't display entry meta because the existing theme will take care of that |
216 | - add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' ); |
|
216 | + add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
217 | 217 | // load functions.php file for the theme (loaded by WP if using child theme) |
218 | 218 | EEH_Template::load_espresso_theme_functions(); |
219 | 219 | // because we don't know if the theme is using the_excerpt() |
220 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
220 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
221 | 221 | // or the_content |
222 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
222 | + add_filter('the_content', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
223 | 223 | // and just in case they are running get_the_excerpt() which DESTROYS things |
224 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
224 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
225 | 225 | // don't display entry meta because the existing theme will take care of that |
226 | - add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
226 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
227 | 227 | } |
228 | 228 | } |
229 | 229 | return $template; |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | * @param string $excerpt |
239 | 239 | * @return string |
240 | 240 | */ |
241 | - public static function get_the_excerpt( $excerpt = '' ) { |
|
242 | - if ( post_password_required() ) { |
|
241 | + public static function get_the_excerpt($excerpt = '') { |
|
242 | + if (post_password_required()) { |
|
243 | 243 | return $excerpt; |
244 | 244 | } |
245 | - if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) { |
|
246 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
247 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
248 | - $excerpt = EED_Events_Archive::event_details( $excerpt ); |
|
245 | + if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
246 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100); |
|
247 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 100); |
|
248 | + $excerpt = EED_Events_Archive::event_details($excerpt); |
|
249 | 249 | } else { |
250 | 250 | EED_Events_Archive::$using_get_the_excerpt = true; |
251 | - add_filter( 'wp_trim_excerpt', array( 'EED_Events_Archive', 'end_get_the_excerpt' ), 999, 1 ); |
|
251 | + add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1); |
|
252 | 252 | } |
253 | 253 | return $excerpt; |
254 | 254 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param string $text |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public static function end_get_the_excerpt( $text = '' ) { |
|
265 | + public static function end_get_the_excerpt($text = '') { |
|
266 | 266 | EED_Events_Archive::$using_get_the_excerpt = false; |
267 | 267 | return $text; |
268 | 268 | } |
@@ -277,10 +277,10 @@ discard block |
||
277 | 277 | * @param string $id |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - public static function the_title( $title = '', $id = '' ) { |
|
280 | + public static function the_title($title = '', $id = '') { |
|
281 | 281 | global $post; |
282 | - if ( $post instanceof WP_Post ) { |
|
283 | - return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID ) . $title : $title; |
|
282 | + if ($post instanceof WP_Post) { |
|
283 | + return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title; |
|
284 | 284 | } |
285 | 285 | return $title; |
286 | 286 | } |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | * @param string $content |
295 | 295 | * @return string |
296 | 296 | */ |
297 | - public static function event_details( $content ) { |
|
297 | + public static function event_details($content) { |
|
298 | 298 | global $post; |
299 | 299 | static $current_post_ID = 0; |
300 | 300 | if ( |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | && ! EED_Events_Archive::$using_get_the_excerpt |
304 | 304 | && ! post_password_required() |
305 | 305 | && ( |
306 | - apply_filters( 'FHEE__EES_Espresso_Events__process_shortcode__true', false ) |
|
307 | - || ! apply_filters( 'FHEE__content_espresso_events__template_loaded', false ) |
|
306 | + apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
307 | + || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
308 | 308 | ) |
309 | 309 | ) { |
310 | 310 | // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | // We want to allow those plugins to still do their thing and have access to our content, but depending on |
314 | 314 | // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
315 | 315 | // so the following allows this filter to be applied multiple times, but only once for real |
316 | - $current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0; |
|
317 | - if ( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order ) { |
|
316 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
317 | + if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
318 | 318 | $content = \EED_Events_Archive::use_sortable_display_order(); |
319 | 319 | } else { |
320 | 320 | $content = \EED_Events_Archive::use_filterable_display_order(); |
@@ -333,20 +333,20 @@ discard block |
||
333 | 333 | */ |
334 | 334 | protected static function use_sortable_display_order() { |
335 | 335 | // no further password checks required atm |
336 | - add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
|
336 | + add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
337 | 337 | // we need to first remove this callback from being applied to the_content() or the_excerpt() (otherwise it will recurse and blow up the interweb) |
338 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
339 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
340 | - remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
338 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100); |
|
339 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 100); |
|
340 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
341 | 341 | // now add additional content depending on whether event is using the_excerpt() or the_content() |
342 | 342 | EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
343 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
344 | - $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content ); |
|
343 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
344 | + $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
345 | 345 | // re-add our main filters (or else the next event won't have them) |
346 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
347 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
348 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
349 | - remove_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
|
346 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
347 | + add_filter('the_content', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
348 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
349 | + remove_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
350 | 350 | return $content; |
351 | 351 | } |
352 | 352 | |
@@ -361,22 +361,22 @@ discard block |
||
361 | 361 | protected static function use_filterable_display_order() { |
362 | 362 | // we need to first remove this callback from being applied to the_content() |
363 | 363 | // (otherwise it will recurse and blow up the interweb) |
364 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
365 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
366 | - remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
364 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100); |
|
365 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 100); |
|
366 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
367 | 367 | //now add additional content depending on whether event is using the_excerpt() or the_content() |
368 | 368 | EED_Events_Archive::_add_additional_excerpt_filters(); |
369 | 369 | EED_Events_Archive::_add_additional_content_filters(); |
370 | - do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters' ); |
|
370 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
371 | 371 | // now load our template |
372 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
372 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
373 | 373 | // re-add our main filters (or else the next event won't have them) |
374 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
375 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
376 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
374 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
375 | + add_filter('the_content', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
376 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
377 | 377 | // but remove the other filters so that they don't get applied to the next post |
378 | 378 | EED_Events_Archive::_remove_additional_events_archive_filters(); |
379 | - do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters' ); |
|
379 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
380 | 380 | // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
381 | 381 | //return ! empty( $template ) ? $template : $content; |
382 | 382 | return $content; |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | * @param string $content |
392 | 392 | * @return string |
393 | 393 | */ |
394 | - public static function event_datetimes( $content ) { |
|
395 | - if ( post_password_required() ) { |
|
394 | + public static function event_datetimes($content) { |
|
395 | + if (post_password_required()) { |
|
396 | 396 | return $content; |
397 | 397 | } |
398 | - return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content; |
|
398 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -405,11 +405,11 @@ discard block |
||
405 | 405 | * @param string $content |
406 | 406 | * @return string |
407 | 407 | */ |
408 | - public static function event_tickets( $content ) { |
|
409 | - if ( post_password_required() ) { |
|
408 | + public static function event_tickets($content) { |
|
409 | + if (post_password_required()) { |
|
410 | 410 | return $content; |
411 | 411 | } |
412 | - return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content; |
|
412 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | * @param string $content |
422 | 422 | * @return string |
423 | 423 | */ |
424 | - public static function event_venue( $content ) { |
|
425 | - return EED_Events_Archive::event_venues( $content ); |
|
424 | + public static function event_venue($content) { |
|
425 | + return EED_Events_Archive::event_venues($content); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -432,11 +432,11 @@ discard block |
||
432 | 432 | * @param string $content |
433 | 433 | * @return string |
434 | 434 | */ |
435 | - public static function event_venues( $content ) { |
|
436 | - if ( post_password_required() ) { |
|
435 | + public static function event_venues($content) { |
|
436 | + if (post_password_required()) { |
|
437 | 437 | return $content; |
438 | 438 | } |
439 | - return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' ); |
|
439 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | |
@@ -448,9 +448,9 @@ discard block |
||
448 | 448 | * @return void |
449 | 449 | */ |
450 | 450 | private static function _add_additional_excerpt_filters() { |
451 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110, 1 ); |
|
452 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120, 1 ); |
|
453 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130, 1 ); |
|
451 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 110, 1); |
|
452 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 120, 1); |
|
453 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 130, 1); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | |
@@ -462,9 +462,9 @@ discard block |
||
462 | 462 | * @return void |
463 | 463 | */ |
464 | 464 | private static function _add_additional_content_filters() { |
465 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110, 1 ); |
|
466 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120, 1 ); |
|
467 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130, 1 ); |
|
465 | + add_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 110, 1); |
|
466 | + add_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 120, 1); |
|
467 | + add_filter('the_content', array('EED_Events_Archive', 'event_venues'), 130, 1); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | * @return void |
477 | 477 | */ |
478 | 478 | private static function _remove_additional_events_archive_filters() { |
479 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
480 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
481 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
482 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
483 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
484 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
479 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
480 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 120); |
|
481 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 130); |
|
482 | + remove_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
483 | + remove_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 120); |
|
484 | + remove_filter('the_content', array('EED_Events_Archive', 'event_venues'), 130); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | |
@@ -494,17 +494,17 @@ discard block |
||
494 | 494 | */ |
495 | 495 | public static function remove_all_events_archive_filters() { |
496 | 496 | //remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
497 | - remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100 ); |
|
498 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
499 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
500 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
501 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
502 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
503 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
504 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
505 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
497 | + remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 100); |
|
498 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100); |
|
499 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
500 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 120); |
|
501 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 130); |
|
502 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 100); |
|
503 | + remove_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
504 | + remove_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 120); |
|
505 | + remove_filter('the_content', array('EED_Events_Archive', 'event_venues'), 130); |
|
506 | 506 | // don't display entry meta because the existing theme will take care of that |
507 | - remove_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
507 | + remove_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
@@ -519,15 +519,15 @@ discard block |
||
519 | 519 | * @return void |
520 | 520 | */ |
521 | 521 | public function load_event_list_assets() { |
522 | - do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
523 | - add_filter( 'FHEE_load_EE_Session', '__return_true' ); |
|
524 | - add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
525 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
|
526 | - if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
|
527 | - EE_Registry::instance()->load_helper( 'Maps' ); |
|
528 | - add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 ); |
|
522 | + do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
523 | + add_filter('FHEE_load_EE_Session', '__return_true'); |
|
524 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
525 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
526 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
527 | + EE_Registry::instance()->load_helper('Maps'); |
|
528 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
529 | 529 | } |
530 | - EE_Registry::instance()->load_helper( 'Event_View' ); |
|
530 | + EE_Registry::instance()->load_helper('Event_View'); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | |
@@ -543,14 +543,14 @@ discard block |
||
543 | 543 | */ |
544 | 544 | public function wp_enqueue_scripts() { |
545 | 545 | // get some style |
546 | - if ( apply_filters( 'FHEE_enable_default_espresso_css', FALSE ) ) { |
|
546 | + if (apply_filters('FHEE_enable_default_espresso_css', FALSE)) { |
|
547 | 547 | // first check uploads folder |
548 | - EE_Registry::instance()->load_helper( 'File' ); |
|
549 | - if ( EEH_File::is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) { |
|
550 | - wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
548 | + EE_Registry::instance()->load_helper('File'); |
|
549 | + if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
550 | + wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
551 | 551 | } else { |
552 | 552 | } |
553 | - wp_enqueue_style( $this->theme ); |
|
553 | + wp_enqueue_style($this->theme); |
|
554 | 554 | |
555 | 555 | } |
556 | 556 | } |
@@ -568,8 +568,8 @@ discard block |
||
568 | 568 | */ |
569 | 569 | public static function template_settings_form() { |
570 | 570 | $template_settings = EE_Registry::instance()->CFG->template_settings; |
571 | - $template_settings->EED_Events_Archive = isset( $template_settings->EED_Events_Archive ) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
572 | - $template_settings->EED_Events_Archive = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive ); |
|
571 | + $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
572 | + $template_settings->EED_Events_Archive = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive); |
|
573 | 573 | $events_archive_settings = array( |
574 | 574 | 'display_status_banner' => 0, |
575 | 575 | 'display_description' => 1, |
@@ -578,8 +578,8 @@ discard block |
||
578 | 578 | 'display_venue' => 0, |
579 | 579 | 'display_expired_events' => 0 |
580 | 580 | ); |
581 | - $events_archive_settings = array_merge( $events_archive_settings, (array)$template_settings->EED_Events_Archive ); |
|
582 | - EEH_Template::display_template( EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $events_archive_settings ); |
|
581 | + $events_archive_settings = array_merge($events_archive_settings, (array) $template_settings->EED_Events_Archive); |
|
582 | + EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', $events_archive_settings); |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | |
@@ -595,16 +595,16 @@ discard block |
||
595 | 595 | * @param EE_Request_Handler $REQ |
596 | 596 | * @return EE_Template_Config |
597 | 597 | */ |
598 | - public static function update_template_settings( $CFG, $REQ ) { |
|
598 | + public static function update_template_settings($CFG, $REQ) { |
|
599 | 599 | $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
600 | 600 | // unless we are resetting the config... |
601 | - if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) { |
|
602 | - $CFG->EED_Events_Archive->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0; |
|
603 | - $CFG->EED_Events_Archive->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1; |
|
604 | - $CFG->EED_Events_Archive->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0; |
|
605 | - $CFG->EED_Events_Archive->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1; |
|
606 | - $CFG->EED_Events_Archive->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0; |
|
607 | - $CFG->EED_Events_Archive->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0; } |
|
601 | + if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) { |
|
602 | + $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
603 | + $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
604 | + $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
605 | + $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1; |
|
606 | + $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0; |
|
607 | + $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; } |
|
608 | 608 | return $CFG; |
609 | 609 | } |
610 | 610 | |
@@ -617,10 +617,10 @@ discard block |
||
617 | 617 | * @param string $extra_class |
618 | 618 | * @return string |
619 | 619 | */ |
620 | - public static function event_list_css( $extra_class = '' ) { |
|
621 | - $event_list_css = ! empty( $extra_class ) ? array( $extra_class ) : array(); |
|
620 | + public static function event_list_css($extra_class = '') { |
|
621 | + $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
622 | 622 | $event_list_css[] = 'espresso-event-list-event'; |
623 | - return implode( ' ', $event_list_css ); |
|
623 | + return implode(' ', $event_list_css); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | |
@@ -647,9 +647,9 @@ discard block |
||
647 | 647 | * @param $value |
648 | 648 | * @return bool |
649 | 649 | */ |
650 | - public static function display_description( $value ) { |
|
650 | + public static function display_description($value) { |
|
651 | 651 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
652 | - $display_description= isset( $config->display_description ) ? $config->display_description : 1; |
|
652 | + $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
653 | 653 | return $display_description === $value ? TRUE : FALSE; |
654 | 654 | } |
655 | 655 | |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | */ |
663 | 663 | public static function display_ticket_selector() { |
664 | 664 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
665 | - return isset( $config->display_ticket_selector ) && $config->display_ticket_selector ? TRUE : FALSE; |
|
665 | + return isset($config->display_ticket_selector) && $config->display_ticket_selector ? TRUE : FALSE; |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | |
@@ -674,9 +674,9 @@ discard block |
||
674 | 674 | * @return bool |
675 | 675 | */ |
676 | 676 | public static function display_venue() { |
677 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
677 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
678 | 678 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
679 | - return isset( $config->display_venue ) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE; |
|
679 | + return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE; |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | */ |
689 | 689 | public static function display_datetimes() { |
690 | 690 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
691 | - return isset( $config->display_datetimes ) && $config->display_datetimes ? TRUE : FALSE; |
|
691 | + return isset($config->display_datetimes) && $config->display_datetimes ? TRUE : FALSE; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | * @return string |
704 | 704 | */ |
705 | 705 | public static function event_list_title() { |
706 | - return apply_filters( 'FHEE__archive_espresso_events_template__upcoming_events_h1', __( 'Upcoming Events', 'event_espresso' )); |
|
706 | + return apply_filters('FHEE__archive_espresso_events_template__upcoming_events_h1', __('Upcoming Events', 'event_espresso')); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | |
@@ -712,11 +712,11 @@ discard block |
||
712 | 712 | /** |
713 | 713 | * @since 4.4.0 |
714 | 714 | */ |
715 | - public static function _doing_it_wrong_notice( $function = '' ) { |
|
715 | + public static function _doing_it_wrong_notice($function = '') { |
|
716 | 716 | EE_Error::doing_it_wrong( |
717 | 717 | __FUNCTION__, |
718 | 718 | sprintf( |
719 | - __( 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso' ), |
|
719 | + __('EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso'), |
|
720 | 720 | $function, |
721 | 721 | '<br />', |
722 | 722 | '4.6.0' |
@@ -732,107 +732,107 @@ discard block |
||
732 | 732 | * @since 4.4.0 |
733 | 733 | */ |
734 | 734 | public function get_post_data() { |
735 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
735 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
736 | 736 | EEH_Event_Query::set_query_params(); |
737 | 737 | } |
738 | 738 | /** |
739 | 739 | * @deprecated |
740 | 740 | * @since 4.4.0 |
741 | 741 | */ |
742 | - public function posts_fields( $SQL, WP_Query $wp_query ) { |
|
743 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
744 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
745 | - return EEH_Event_Query::posts_fields( $SQL, $wp_query ); |
|
742 | + public function posts_fields($SQL, WP_Query $wp_query) { |
|
743 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
744 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
745 | + return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
746 | 746 | } |
747 | 747 | /** |
748 | 748 | * @deprecated |
749 | 749 | * @since 4.4.0 |
750 | 750 | */ |
751 | - public static function posts_fields_sql_for_orderby( $orderby_params = array() ) { |
|
752 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
753 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
754 | - return EEH_Event_Query::posts_fields_sql_for_orderby( $orderby_params ); |
|
751 | + public static function posts_fields_sql_for_orderby($orderby_params = array()) { |
|
752 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
753 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
754 | + return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
755 | 755 | } |
756 | 756 | /** |
757 | 757 | * @deprecated |
758 | 758 | * @since 4.4.0 |
759 | 759 | */ |
760 | - public function posts_join( $SQL, WP_Query $wp_query ) { |
|
761 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
762 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
763 | - return EEH_Event_Query::posts_join( $SQL, $wp_query ); |
|
760 | + public function posts_join($SQL, WP_Query $wp_query) { |
|
761 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
762 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
763 | + return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
764 | 764 | } |
765 | 765 | /** |
766 | 766 | * @deprecated |
767 | 767 | * @since 4.4.0 |
768 | 768 | */ |
769 | - public static function posts_join_sql_for_terms( $join_terms = NULL ) { |
|
770 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
771 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
772 | - return EEH_Event_Query::posts_join_sql_for_terms( $join_terms ); |
|
769 | + public static function posts_join_sql_for_terms($join_terms = NULL) { |
|
770 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
771 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
772 | + return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
773 | 773 | } |
774 | 774 | /** |
775 | 775 | * @deprecated |
776 | 776 | * @since 4.4.0 |
777 | 777 | */ |
778 | - public static function posts_join_for_orderby( $orderby_params = array() ) { |
|
779 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
780 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
781 | - return EEH_Event_Query::posts_join_for_orderby( $orderby_params ); |
|
778 | + public static function posts_join_for_orderby($orderby_params = array()) { |
|
779 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
780 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
781 | + return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
782 | 782 | } |
783 | 783 | /** |
784 | 784 | * @deprecated |
785 | 785 | * @since 4.4.0 |
786 | 786 | */ |
787 | - public function posts_where( $SQL, WP_Query $wp_query ) { |
|
788 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
789 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
790 | - return EEH_Event_Query::posts_where( $SQL, $wp_query ); |
|
787 | + public function posts_where($SQL, WP_Query $wp_query) { |
|
788 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
789 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
790 | + return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
791 | 791 | } |
792 | 792 | /** |
793 | 793 | * @deprecated |
794 | 794 | * @since 4.4.0 |
795 | 795 | */ |
796 | - public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) { |
|
797 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
798 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
799 | - return EEH_Event_Query::posts_where_sql_for_show_expired( $show_expired ); |
|
796 | + public static function posts_where_sql_for_show_expired($show_expired = FALSE) { |
|
797 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
798 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
799 | + return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
800 | 800 | } |
801 | 801 | /** |
802 | 802 | * @deprecated |
803 | 803 | * @since 4.4.0 |
804 | 804 | */ |
805 | - public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) { |
|
806 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
807 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
808 | - return EEH_Event_Query::posts_where_sql_for_event_category_slug( $event_category_slug ); |
|
805 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) { |
|
806 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
807 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
808 | + return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
809 | 809 | } |
810 | 810 | /** |
811 | 811 | * @deprecated |
812 | 812 | * @since 4.4.0 |
813 | 813 | */ |
814 | - public static function posts_where_sql_for_event_list_month( $month = NULL ) { |
|
815 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
816 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
817 | - return EEH_Event_Query::posts_where_sql_for_event_list_month( $month ); |
|
814 | + public static function posts_where_sql_for_event_list_month($month = NULL) { |
|
815 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
816 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
817 | + return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
818 | 818 | } |
819 | 819 | /** |
820 | 820 | * @deprecated |
821 | 821 | * @since 4.4.0 |
822 | 822 | */ |
823 | - public function posts_orderby( $SQL, WP_Query $wp_query ) { |
|
824 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
825 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
826 | - return EEH_Event_Query::posts_orderby( $SQL, $wp_query ); |
|
823 | + public function posts_orderby($SQL, WP_Query $wp_query) { |
|
824 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
825 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
826 | + return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
827 | 827 | } |
828 | 828 | /** |
829 | 829 | * @deprecated |
830 | 830 | * @since 4.4.0 |
831 | 831 | */ |
832 | - public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) { |
|
833 | - EE_Registry::instance()->load_helper( 'Event_Query' ); |
|
834 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
835 | - return EEH_Event_Query::posts_orderby_sql( $orderby_params, $sort ); |
|
832 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') { |
|
833 | + EE_Registry::instance()->load_helper('Event_Query'); |
|
834 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
835 | + return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | |
@@ -863,8 +863,8 @@ discard block |
||
863 | 863 | * @param string $extra_class |
864 | 864 | * @return string |
865 | 865 | */ |
866 | -function espresso_event_list_css( $extra_class = '' ) { |
|
867 | - return EED_Events_Archive::event_list_css( $extra_class ); |
|
866 | +function espresso_event_list_css($extra_class = '') { |
|
867 | + return EED_Events_Archive::event_list_css($extra_class); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | /** |
@@ -878,14 +878,14 @@ discard block |
||
878 | 878 | * @return bool |
879 | 879 | */ |
880 | 880 | function espresso_display_full_description_in_event_list() { |
881 | - return EED_Events_Archive::display_description( 2 ); |
|
881 | + return EED_Events_Archive::display_description(2); |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | /** |
885 | 885 | * @return bool |
886 | 886 | */ |
887 | 887 | function espresso_display_excerpt_in_event_list() { |
888 | - return EED_Events_Archive::display_description( 1 ); |
|
888 | + return EED_Events_Archive::display_description(1); |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | /** |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
2 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Transaction Model |
@@ -68,36 +68,36 @@ discard block |
||
68 | 68 | * Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
69 | 69 | * @return EEM_Transaction |
70 | 70 | */ |
71 | - protected function __construct( $timezone ) { |
|
72 | - $this->singular_item = __('Transaction','event_espresso'); |
|
73 | - $this->plural_item = __('Transactions','event_espresso'); |
|
71 | + protected function __construct($timezone) { |
|
72 | + $this->singular_item = __('Transaction', 'event_espresso'); |
|
73 | + $this->plural_item = __('Transactions', 'event_espresso'); |
|
74 | 74 | |
75 | 75 | $this->_tables = array( |
76 | - 'Transaction'=>new EE_Primary_Table('esp_transaction','TXN_ID') |
|
76 | + 'Transaction'=>new EE_Primary_Table('esp_transaction', 'TXN_ID') |
|
77 | 77 | ); |
78 | 78 | $this->_fields = array( |
79 | 79 | 'Transaction'=>array( |
80 | - 'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso')), |
|
81 | - 'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created','event_espresso'), false, time(), $timezone ), |
|
82 | - 'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction','event_espresso'), false, 0), |
|
83 | - 'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date','event_espresso'), false, 0), |
|
84 | - 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'), |
|
85 | - 'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data','event_espresso'), true, ''), |
|
86 | - 'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt','event_espresso'), true, ''), |
|
80 | + 'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')), |
|
81 | + 'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created', 'event_espresso'), false, time(), $timezone), |
|
82 | + 'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction', 'event_espresso'), false, 0), |
|
83 | + 'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date', 'event_espresso'), false, 0), |
|
84 | + 'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'), |
|
85 | + 'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data', 'event_espresso'), true, ''), |
|
86 | + 'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt', 'event_espresso'), true, ''), |
|
87 | 87 | 'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Last Used Payment Method", 'event_espresso'), true, NULL, 'Payment_Method'), |
88 | - 'TXN_reg_steps' => new EE_Serialized_Text_Field( 'TXN_reg_steps', __( 'Registration Steps', 'event_espresso' ), FALSE, array() ), |
|
88 | + 'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', __('Registration Steps', 'event_espresso'), FALSE, array()), |
|
89 | 89 | ) |
90 | 90 | ); |
91 | 91 | $this->_model_relations = array( |
92 | 92 | 'Registration'=>new EE_Has_Many_Relation(), |
93 | 93 | 'Payment'=>new EE_Has_Many_Relation(), |
94 | 94 | 'Status'=>new EE_Belongs_To_Relation(), |
95 | - 'Line_Item'=>new EE_Has_Many_Relation(false),//you can delete a transaction without needing to delete its line items |
|
95 | + 'Line_Item'=>new EE_Has_Many_Relation(false), //you can delete a transaction without needing to delete its line items |
|
96 | 96 | 'Payment_Method'=>new EE_Belongs_To_Relation(), |
97 | 97 | 'Message' => new EE_Has_Many_Relation() |
98 | 98 | ); |
99 | 99 | $this->_model_chain_to_wp_user = 'Registration.Event'; |
100 | - parent::__construct( $timezone ); |
|
100 | + parent::__construct($timezone); |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
@@ -108,19 +108,19 @@ discard block |
||
108 | 108 | * @param string $period |
109 | 109 | * @return \stdClass[] |
110 | 110 | */ |
111 | - public function get_revenue_per_day_report( $period = '-1 month' ) { |
|
111 | + public function get_revenue_per_day_report($period = '-1 month') { |
|
112 | 112 | |
113 | - $sql_date = $this->convert_datetime_for_query( 'TXN_timestamp', date("Y-m-d H:i:s", strtotime($period) ), 'Y-m-d H:i:s', 'UTC' ); |
|
113 | + $sql_date = $this->convert_datetime_for_query('TXN_timestamp', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC'); |
|
114 | 114 | $results = $this->_get_all_wpdb_results( |
115 | 115 | array( |
116 | 116 | array( |
117 | 117 | 'TXN_timestamp' => array('>=', $sql_date)), |
118 | 118 | 'group_by' => 'txnDate', |
119 | - 'order_by' => array('TXN_timestamp' => 'DESC' ) |
|
119 | + 'order_by' => array('TXN_timestamp' => 'DESC') |
|
120 | 120 | ), |
121 | 121 | OBJECT, |
122 | 122 | array( |
123 | - 'txnDate' => array('DATE(Transaction.TXN_timestamp)','%s'), |
|
123 | + 'txnDate' => array('DATE(Transaction.TXN_timestamp)', '%s'), |
|
124 | 124 | 'revenue' => array('SUM(Transaction.TXN_paid)', '%d') |
125 | 125 | )); |
126 | 126 | return $results; |
@@ -136,22 +136,22 @@ discard block |
||
136 | 136 | * @throws \EE_Error |
137 | 137 | * @return mixed |
138 | 138 | */ |
139 | - public function get_revenue_per_event_report( $period = 'month' ) { |
|
139 | + public function get_revenue_per_event_report($period = 'month') { |
|
140 | 140 | /** @type WPDB $wpdb */ |
141 | 141 | global $wpdb; |
142 | - $date_mod = strtotime( '-1 ' . $period ); |
|
142 | + $date_mod = strtotime('-1 '.$period); |
|
143 | 143 | |
144 | 144 | $SQL = 'SELECT post_title as event_name, SUM(TXN_paid) AS revenue'; |
145 | - $SQL .= ' FROM ' . $this->_get_main_table()->get_table_name() . ' txn'; |
|
146 | - $SQL .= ' LEFT JOIN ' . $wpdb->prefix . 'esp_registration reg ON reg.TXN_ID = txn.TXN_ID'; |
|
147 | - $SQL .= ' LEFT JOIN ' . $wpdb->posts . ' evt ON evt.ID = reg.EVT_ID'; |
|
145 | + $SQL .= ' FROM '.$this->_get_main_table()->get_table_name().' txn'; |
|
146 | + $SQL .= ' LEFT JOIN '.$wpdb->prefix.'esp_registration reg ON reg.TXN_ID = txn.TXN_ID'; |
|
147 | + $SQL .= ' LEFT JOIN '.$wpdb->posts.' evt ON evt.ID = reg.EVT_ID'; |
|
148 | 148 | $SQL .= ' WHERE REG_count = 1'; |
149 | 149 | $SQL .= ' AND REG_date >= %d'; |
150 | 150 | $SQL .= ' GROUP BY event_name'; |
151 | 151 | $SQL .= ' ORDER BY event_name'; |
152 | 152 | $SQL .= ' LIMIT 0, 24'; |
153 | 153 | |
154 | - return $this->_do_wpdb_query( 'get_results', array( $wpdb->prepare( $SQL, $date_mod ) ) ); |
|
154 | + return $this->_do_wpdb_query('get_results', array($wpdb->prepare($SQL, $date_mod))); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 | |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | * @param string $reg_url_link |
168 | 168 | * @return EE_Transaction |
169 | 169 | */ |
170 | - public function get_transaction_from_reg_url_link( $reg_url_link = '' ){ |
|
171 | - return $this->get_one( array( |
|
170 | + public function get_transaction_from_reg_url_link($reg_url_link = '') { |
|
171 | + return $this->get_one(array( |
|
172 | 172 | array( |
173 | - 'Registration.REG_url_link' => ! empty( $reg_url_link ) ? $reg_url_link : EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ) |
|
173 | + 'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', '') |
|
174 | 174 | ) |
175 | 175 | )); |
176 | 176 | } |
@@ -190,15 +190,15 @@ discard block |
||
190 | 190 | * @param boolean $save_txn whether or not to save the transaction during this function call |
191 | 191 | * @return boolean |
192 | 192 | */ |
193 | - public function update_based_on_payments( $transaction_obj_or_id, $save_txn = TRUE ){ |
|
193 | + public function update_based_on_payments($transaction_obj_or_id, $save_txn = TRUE) { |
|
194 | 194 | EE_Error::doing_it_wrong( |
195 | - __CLASS__ . '::' . __FUNCTION__, |
|
196 | - sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ), |
|
195 | + __CLASS__.'::'.__FUNCTION__, |
|
196 | + sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'), |
|
197 | 197 | '4.6.0' |
198 | 198 | ); |
199 | 199 | /** @type EE_Transaction_Processor $transaction_processor */ |
200 | - $transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' ); |
|
201 | - return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $this->ensure_is_obj( $transaction_obj_or_id )); |
|
200 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
201 | + return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($this->ensure_is_obj($transaction_obj_or_id)); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | array( |
230 | 230 | 0 => array( |
231 | 231 | 'STS_ID' => EEM_Transaction::failed_status_code, |
232 | - 'TXN_timestamp' => array( '<', time() - $time_to_leave_alone ) |
|
232 | + 'TXN_timestamp' => array('<', time() - $time_to_leave_alone) |
|
233 | 233 | ) |
234 | 234 | ), |
235 | 235 | $time_to_leave_alone |
@@ -242,26 +242,26 @@ discard block |
||
242 | 242 | */ |
243 | 243 | $txn_ids = apply_filters( |
244 | 244 | 'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete', |
245 | - EEM_Transaction::instance()->get_col( $ids_query, 'TXN_ID' ), |
|
245 | + EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'), |
|
246 | 246 | $time_to_leave_alone |
247 | 247 | ); |
248 | 248 | |
249 | 249 | //now that we have the ids to delete, let's get deletin' |
250 | 250 | //Why no wpdb->prepare? Because the data is trusted. We got the ids from the original query to get them FROM |
251 | 251 | //the db (which is sanitized) so no need to prepare them again. |
252 | - if ( $txn_ids ) { |
|
253 | - $query = ' |
|
252 | + if ($txn_ids) { |
|
253 | + $query = ' |
|
254 | 254 | DELETE |
255 | - FROM ' . $this->table() . ' |
|
255 | + FROM ' . $this->table().' |
|
256 | 256 | WHERE |
257 | - TXN_ID IN ( ' . implode( ",", $txn_ids ) . ')'; |
|
258 | - $deleted = $wpdb->query( $query ); |
|
257 | + TXN_ID IN ( ' . implode(",", $txn_ids).')'; |
|
258 | + $deleted = $wpdb->query($query); |
|
259 | 259 | } |
260 | - if ( $deleted ) { |
|
260 | + if ($deleted) { |
|
261 | 261 | /** |
262 | 262 | * Allows code to do something after the transactions have been deleted. |
263 | 263 | */ |
264 | - do_action( 'AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids ); |
|
264 | + do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids); |
|
265 | 265 | } |
266 | 266 | return $deleted; |
267 | 267 | } |
@@ -3,18 +3,18 @@ |
||
3 | 3 | * Field to only allow tags that are normally allowed on post_content: |
4 | 4 | * address,a,abbr,acronym,area,article,aside,b,big,blockquote,br,button,caption,cite,code,col,del,dd,dfn,details,div,dl,dt,em,fieldset,figure,figcaption,font,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,img,ins,kbd,label,legend,li,map,mark,menu,nav,p,pre,q,s,samp,span,section,small,strike,strong,sub,summary,sup,table,tbody,td,textarea,tfoot,th,thead,title,tr,tt,u,ul,ol,var |
5 | 5 | */ |
6 | -class EE_Post_Content_Field extends EE_Full_HTML_Field{ |
|
6 | +class EE_Post_Content_Field extends EE_Full_HTML_Field { |
|
7 | 7 | /** |
8 | 8 | * removes all tags which a WP Post wouldn't allow in its content normally |
9 | 9 | * @param string $value_inputted_for_field_on_model_object |
10 | 10 | * @return string |
11 | 11 | */ |
12 | 12 | function prepare_for_set($value_inputted_for_field_on_model_object) { |
13 | - $value_with_select_tags = wp_kses("$value_inputted_for_field_on_model_object",wp_kses_allowed_html( 'post' )); |
|
13 | + $value_with_select_tags = wp_kses("$value_inputted_for_field_on_model_object", wp_kses_allowed_html('post')); |
|
14 | 14 | return parent::prepare_for_set($value_with_select_tags); |
15 | 15 | } |
16 | 16 | |
17 | - function prepare_for_set_from_db($value_found_in_db_for_model_object){ |
|
17 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) { |
|
18 | 18 | return $value_found_in_db_for_model_object; |
19 | 19 | } |
20 | 20 | } |
21 | 21 | \ No newline at end of file |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Class EE_Line_Item_Filter_Collection |
@@ -7,8 +7,8 @@ discard block |
||
7 | 7 | * @package Event Espresso |
8 | 8 | * @subpackage core, capabilities |
9 | 9 | */ |
10 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
11 | - exit( 'No direct script access allowed' ); |
|
10 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
11 | + exit('No direct script access allowed'); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public static function instance() { |
71 | 71 | //check if instantiated, and if not do so. |
72 | - if ( ! self::$_instance instanceof EE_Capabilities ) { |
|
72 | + if ( ! self::$_instance instanceof EE_Capabilities) { |
|
73 | 73 | self::$_instance = new self(); |
74 | 74 | } |
75 | 75 | return self::$_instance; |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | * @since 4.5.0 |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function init_caps( $reset = false ) { |
|
102 | - if ( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
101 | + public function init_caps($reset = false) { |
|
102 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
103 | 103 | $this->_caps_map = $this->_init_caps_map(); |
104 | - $this->init_role_caps( $reset ); |
|
104 | + $this->init_role_caps($reset); |
|
105 | 105 | $this->_set_meta_caps(); |
106 | 106 | } |
107 | 107 | } |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
121 | 121 | $this->_meta_caps = $this->_get_default_meta_caps_array(); |
122 | 122 | |
123 | - $this->_meta_caps = apply_filters( 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps ); |
|
123 | + $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
124 | 124 | |
125 | 125 | //add filter for map_meta_caps but only if models can query. |
126 | - if ( EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ) ) ) { |
|
127 | - add_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10, 4 ); |
|
126 | + if (EE_Maintenance_Mode::instance()->models_can_query() && ! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
127 | + add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | |
@@ -137,37 +137,37 @@ discard block |
||
137 | 137 | */ |
138 | 138 | private function _get_default_meta_caps_array() { |
139 | 139 | static $default_meta_caps = array(); |
140 | - if ( empty( $default_meta_caps ) ) { |
|
140 | + if (empty($default_meta_caps)) { |
|
141 | 141 | $default_meta_caps = array( |
142 | 142 | //edits |
143 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_event', array( 'Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events' ) ), |
|
144 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_venue', array( 'Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues' ) ), |
|
145 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_registration', array( 'Registration', '', 'ee_edit_others_registrations', '' ) ), |
|
146 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_checkin', array( 'Registration', '', 'ee_edit_others_checkins', '' ) ), |
|
147 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_edit_message', array( 'Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages' ) ), |
|
148 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_default_ticket', array( 'Ticket', '', 'ee_edit_others_default_tickets', '' ) ), |
|
149 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question', array( 'Question', '', '', 'ee_edit_system_questions' ) ), |
|
150 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_edit_question_group', array( 'Question_Group', '', '', 'ee_edit_system_question_groups' ) ), |
|
151 | - new EE_Meta_Capability_Map_Edit( 'ee_edit_payment_method', array( 'Payment_Method', '', 'ee_edit_others_payment_methods', '' ) ), |
|
143 | + new EE_Meta_Capability_Map_Edit('ee_edit_event', array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events')), |
|
144 | + new EE_Meta_Capability_Map_Edit('ee_edit_venue', array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues')), |
|
145 | + new EE_Meta_Capability_Map_Edit('ee_edit_registration', array('Registration', '', 'ee_edit_others_registrations', '')), |
|
146 | + new EE_Meta_Capability_Map_Edit('ee_edit_checkin', array('Registration', '', 'ee_edit_others_checkins', '')), |
|
147 | + new EE_Meta_Capability_Map_Messages_Cap('ee_edit_message', array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages')), |
|
148 | + new EE_Meta_Capability_Map_Edit('ee_edit_default_ticket', array('Ticket', '', 'ee_edit_others_default_tickets', '')), |
|
149 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question', array('Question', '', '', 'ee_edit_system_questions')), |
|
150 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_edit_question_group', array('Question_Group', '', '', 'ee_edit_system_question_groups')), |
|
151 | + new EE_Meta_Capability_Map_Edit('ee_edit_payment_method', array('Payment_Method', '', 'ee_edit_others_payment_methods', '')), |
|
152 | 152 | //reads |
153 | - new EE_Meta_Capability_Map_Read( 'ee_read_event', array( 'Event', '', 'ee_read_others_events', 'ee_read_private_events' ) ), |
|
154 | - new EE_Meta_Capability_Map_Read( 'ee_read_venue', array( 'Venue', '', 'ee_read_others_venues', 'ee_read_private_venues' ) ), |
|
155 | - new EE_Meta_Capability_Map_Read( 'ee_read_registration', array( 'Registration', '', '', 'ee_edit_others_registrations' ) ), |
|
156 | - new EE_Meta_Capability_Map_Read( 'ee_read_checkin', array( 'Registration', '', '', 'ee_read_others_checkins' ) ), |
|
157 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_read_message', array( 'Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages' ) ), |
|
158 | - new EE_Meta_Capability_Map_Read( 'ee_read_default_ticket', array( 'Ticket', '', '', 'ee_read_others_default_tickets' ) ), |
|
159 | - new EE_Meta_Capability_Map_Read( 'ee_read_payment_method', array( 'Payment_Method', '', '', 'ee_read_others_payment_methods' ) ), |
|
153 | + new EE_Meta_Capability_Map_Read('ee_read_event', array('Event', '', 'ee_read_others_events', 'ee_read_private_events')), |
|
154 | + new EE_Meta_Capability_Map_Read('ee_read_venue', array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues')), |
|
155 | + new EE_Meta_Capability_Map_Read('ee_read_registration', array('Registration', '', '', 'ee_edit_others_registrations')), |
|
156 | + new EE_Meta_Capability_Map_Read('ee_read_checkin', array('Registration', '', '', 'ee_read_others_checkins')), |
|
157 | + new EE_Meta_Capability_Map_Messages_Cap('ee_read_message', array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages')), |
|
158 | + new EE_Meta_Capability_Map_Read('ee_read_default_ticket', array('Ticket', '', '', 'ee_read_others_default_tickets')), |
|
159 | + new EE_Meta_Capability_Map_Read('ee_read_payment_method', array('Payment_Method', '', '', 'ee_read_others_payment_methods')), |
|
160 | 160 | |
161 | 161 | //deletes |
162 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_event', array( 'Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events' ) ), |
|
163 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_venue', array( 'Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues' ) ), |
|
164 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_registration', array( 'Registration', '', 'ee_delete_others_registrations', '' ) ), |
|
165 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_checkin', array( 'Registration', '', 'ee_delete_others_checkins', '' ) ), |
|
166 | - new EE_Meta_Capability_Map_Messages_Cap( 'ee_delete_message', array( 'Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages' ) ), |
|
167 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_default_ticket', array( 'Ticket', '', 'ee_delete_others_default_tickets', '' ) ), |
|
168 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question', array( 'Question', '', '', 'delete_system_questions' ) ), |
|
169 | - new EE_Meta_Capability_Map_Registration_Form_Cap( 'ee_delete_question_group', array( 'Question_Group', '', '', 'delete_system_question_groups' ) ), |
|
170 | - new EE_Meta_Capability_Map_Delete( 'ee_delete_payment_method', array( 'Payment_Method', '', 'ee_delete_others_payment_methods', '' ) ), |
|
162 | + new EE_Meta_Capability_Map_Delete('ee_delete_event', array('Event', 'ee_delete_published_events', 'ee_delete_others_events', 'ee_delete_private_events')), |
|
163 | + new EE_Meta_Capability_Map_Delete('ee_delete_venue', array('Venue', 'ee_delete_published_venues', 'ee_delete_others_venues', 'ee_delete_private_venues')), |
|
164 | + new EE_Meta_Capability_Map_Delete('ee_delete_registration', array('Registration', '', 'ee_delete_others_registrations', '')), |
|
165 | + new EE_Meta_Capability_Map_Delete('ee_delete_checkin', array('Registration', '', 'ee_delete_others_checkins', '')), |
|
166 | + new EE_Meta_Capability_Map_Messages_Cap('ee_delete_message', array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages')), |
|
167 | + new EE_Meta_Capability_Map_Delete('ee_delete_default_ticket', array('Ticket', '', 'ee_delete_others_default_tickets', '')), |
|
168 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question', array('Question', '', '', 'delete_system_questions')), |
|
169 | + new EE_Meta_Capability_Map_Registration_Form_Cap('ee_delete_question_group', array('Question_Group', '', '', 'delete_system_question_groups')), |
|
170 | + new EE_Meta_Capability_Map_Delete('ee_delete_payment_method', array('Payment_Method', '', 'ee_delete_others_payment_methods', '')), |
|
171 | 171 | ); |
172 | 172 | } |
173 | 173 | return $default_meta_caps; |
@@ -191,15 +191,15 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return array actual users capabilities |
193 | 193 | */ |
194 | - public function map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
194 | + public function map_meta_caps($caps, $cap, $user_id, $args) { |
|
195 | 195 | //loop through our _meta_caps array |
196 | - foreach ( $this->_meta_caps as $meta_map ) { |
|
197 | - if ( ! $meta_map instanceof EE_Meta_Capability_Map ) { |
|
196 | + foreach ($this->_meta_caps as $meta_map) { |
|
197 | + if ( ! $meta_map instanceof EE_Meta_Capability_Map) { |
|
198 | 198 | continue; |
199 | 199 | } |
200 | 200 | $meta_map->ensure_is_model(); |
201 | 201 | |
202 | - $caps = $meta_map->map_meta_caps( $caps, $cap, $user_id, $args ); |
|
202 | + $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
203 | 203 | } |
204 | 204 | return $caps; |
205 | 205 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | ) |
365 | 365 | ); |
366 | 366 | |
367 | - $caps = apply_filters( 'FHEE__EE_Capabilities__init_caps_map__caps', $caps ); |
|
367 | + $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
368 | 368 | return $caps; |
369 | 369 | } |
370 | 370 | |
@@ -381,26 +381,26 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @return void |
383 | 383 | */ |
384 | - public function init_role_caps( $reset = false, $custom_map = array() ) { |
|
384 | + public function init_role_caps($reset = false, $custom_map = array()) { |
|
385 | 385 | |
386 | - $caps_map = empty( $custom_map ) ? $this->_caps_map : $custom_map; |
|
386 | + $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
387 | 387 | |
388 | 388 | //first let's determine if these caps have already been set. |
389 | - $caps_set_before = get_option( self::option_name, array() ); |
|
389 | + $caps_set_before = get_option(self::option_name, array()); |
|
390 | 390 | //if not reset, see what caps are new for each role. if they're new, add them. |
391 | - foreach ( $caps_map as $role => $caps_for_role ) { |
|
392 | - foreach ( $caps_for_role as $cap ) { |
|
391 | + foreach ($caps_map as $role => $caps_for_role) { |
|
392 | + foreach ($caps_for_role as $cap) { |
|
393 | 393 | //first check we haven't already added this cap before, or it's a reset |
394 | - if ( $reset || ! isset( $caps_set_before[ $role ] ) || ! in_array( $cap, $caps_set_before[ $role ] ) ) { |
|
395 | - $this->add_cap_to_role( $role, $cap ); |
|
396 | - $caps_set_before[ $role ][] = $cap; |
|
394 | + if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) { |
|
395 | + $this->add_cap_to_role($role, $cap); |
|
396 | + $caps_set_before[$role][] = $cap; |
|
397 | 397 | } |
398 | 398 | } |
399 | 399 | } |
400 | 400 | |
401 | 401 | //now let's just save the cap that has been set. |
402 | - update_option( self::option_name, $caps_set_before ); |
|
403 | - do_action( 'AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before ); |
|
402 | + update_option(self::option_name, $caps_set_before); |
|
403 | + do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -419,10 +419,10 @@ discard block |
||
419 | 419 | * @param bool $grant Whether to grant access to this cap on this role. |
420 | 420 | * @return void |
421 | 421 | */ |
422 | - public function add_cap_to_role( $role, $cap, $grant = true ) { |
|
423 | - $role = get_role( $role ); |
|
424 | - if ( $role instanceof WP_Role ) { |
|
425 | - $role->add_cap( $cap, $grant ); |
|
422 | + public function add_cap_to_role($role, $cap, $grant = true) { |
|
423 | + $role = get_role($role); |
|
424 | + if ($role instanceof WP_Role) { |
|
425 | + $role->add_cap($cap, $grant); |
|
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
@@ -442,10 +442,10 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @return void |
444 | 444 | */ |
445 | - public function remove_cap_from_role( $role, $cap ) { |
|
446 | - $role = get_role( $role ); |
|
447 | - if ( $role instanceof WP_Role ) { |
|
448 | - $role->remove_cap( $cap ); |
|
445 | + public function remove_cap_from_role($role, $cap) { |
|
446 | + $role = get_role($role); |
|
447 | + if ($role instanceof WP_Role) { |
|
448 | + $role->remove_cap($cap); |
|
449 | 449 | } |
450 | 450 | } |
451 | 451 | |
@@ -466,11 +466,11 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @return bool Whether user can or not. |
468 | 468 | */ |
469 | - public function current_user_can( $cap, $context, $id = 0 ) { |
|
469 | + public function current_user_can($cap, $context, $id = 0) { |
|
470 | 470 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
471 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id ); |
|
472 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id ); |
|
473 | - return ! empty( $id ) ? current_user_can( $filtered_cap, $id ) : current_user_can( $filtered_cap ); |
|
471 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id); |
|
472 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, $id); |
|
473 | + return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -487,11 +487,11 @@ discard block |
||
487 | 487 | * |
488 | 488 | * @return bool Whether user can or not. |
489 | 489 | */ |
490 | - public function user_can( $user, $cap, $context, $id = 0 ) { |
|
490 | + public function user_can($user, $cap, $context, $id = 0) { |
|
491 | 491 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
492 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id ); |
|
493 | - $filtered_cap = apply_filters( 'FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, $id ); |
|
494 | - return ! empty( $id ) ? user_can( $user, $filtered_cap, $id ) : user_can( $user, $filtered_cap ); |
|
492 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id); |
|
493 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, $id); |
|
494 | + return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -511,12 +511,12 @@ discard block |
||
511 | 511 | * |
512 | 512 | * @return bool Whether user can or not. |
513 | 513 | */ |
514 | - public function current_user_can_for_blog( $blog_id, $cap, $context, $id = 0 ) { |
|
515 | - $user_can = ! empty( $id ) ? current_user_can_for_blog( $blog_id, $cap, $id ) : current_user_can( $blog_id, $cap ); |
|
514 | + public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) { |
|
515 | + $user_can = ! empty($id) ? current_user_can_for_blog($blog_id, $cap, $id) : current_user_can($blog_id, $cap); |
|
516 | 516 | |
517 | 517 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
518 | - $user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, $user_can, $blog_id, $cap, $id ); |
|
519 | - $user_can = apply_filters( 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id ); |
|
518 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, $user_can, $blog_id, $cap, $id); |
|
519 | + $user_can = apply_filters('FHEE__EE_Capabilities__current_user_can_for_blog__user_can', $user_can, $context, $blog_id, $cap, $id); |
|
520 | 520 | return $user_can; |
521 | 521 | } |
522 | 522 | |
@@ -532,12 +532,12 @@ discard block |
||
532 | 532 | * |
533 | 533 | * @return array |
534 | 534 | */ |
535 | - public function get_ee_capabilities( $role = 'administrator' ) { |
|
535 | + public function get_ee_capabilities($role = 'administrator') { |
|
536 | 536 | $capabilities = $this->_init_caps_map(); |
537 | - if ( empty( $role ) ) { |
|
537 | + if (empty($role)) { |
|
538 | 538 | return $capabilities; |
539 | 539 | } |
540 | - return isset( $capabilities[ $role ] ) ? $capabilities[ $role ] : array(); |
|
540 | + return isset($capabilities[$role]) ? $capabilities[$role] : array(); |
|
541 | 541 | } |
542 | 542 | } |
543 | 543 | |
@@ -585,11 +585,11 @@ discard block |
||
585 | 585 | * } |
586 | 586 | * @throws EE_Error |
587 | 587 | */ |
588 | - public function __construct( $meta_cap, $map_values ) { |
|
588 | + public function __construct($meta_cap, $map_values) { |
|
589 | 589 | $this->meta_cap = $meta_cap; |
590 | 590 | //verify there are four args in the $map_values array; |
591 | - if ( count( $map_values ) !== 4 ) { |
|
592 | - throw new EE_Error( sprintf( __( 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', 'event_espresso' ), '<br>' . print_r( $map_values, true ) ) ); |
|
591 | + if (count($map_values) !== 4) { |
|
592 | + throw new EE_Error(sprintf(__('Incoming $map_values array should have a count of four values in it. This is what was given: %s', 'event_espresso'), '<br>'.print_r($map_values, true))); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | //set properties |
@@ -603,8 +603,8 @@ discard block |
||
603 | 603 | /** |
604 | 604 | * Makes it so this object stops filtering caps |
605 | 605 | */ |
606 | - public function remove_filters(){ |
|
607 | - remove_filter( 'map_meta_cap', array( $this, 'map_meta_caps' ), 10 ); |
|
606 | + public function remove_filters() { |
|
607 | + remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | |
@@ -619,19 +619,19 @@ discard block |
||
619 | 619 | */ |
620 | 620 | public function ensure_is_model() { |
621 | 621 | //is it already instantiated? |
622 | - if ( $this->_model instanceof EEM_Base ) { |
|
622 | + if ($this->_model instanceof EEM_Base) { |
|
623 | 623 | return; |
624 | 624 | } |
625 | 625 | |
626 | 626 | //ensure model name is string |
627 | 627 | $this->_model_name = (string) $this->_model_name; |
628 | 628 | //error proof if the name has EEM in it |
629 | - $this->_model_name = str_replace( 'EEM', '', $this->_model_name ); |
|
629 | + $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
630 | 630 | |
631 | - $this->_model = EE_Registry::instance()->load_model( $this->_model_name ); |
|
631 | + $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
632 | 632 | |
633 | - if ( ! $this->_model instanceof EEM_Base ) { |
|
634 | - throw new EE_Error( sprintf( __( 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso' ), get_class( $this ), $this->_model ) ); |
|
633 | + if ( ! $this->_model instanceof EEM_Base) { |
|
634 | + throw new EE_Error(sprintf(__('This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', 'event_espresso'), get_class($this), $this->_model)); |
|
635 | 635 | } |
636 | 636 | } |
637 | 637 | |
@@ -647,8 +647,8 @@ discard block |
||
647 | 647 | * |
648 | 648 | * @return array |
649 | 649 | */ |
650 | - public function map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
651 | - return $this->_map_meta_caps( $caps, $cap, $user_id, $args ); |
|
650 | + public function map_meta_caps($caps, $cap, $user_id, $args) { |
|
651 | + return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | * |
667 | 667 | * @return array actual users capabilities |
668 | 668 | */ |
669 | - abstract protected function _map_meta_caps( $caps, $cap, $user_id, $args ); |
|
669 | + abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | |
@@ -698,28 +698,28 @@ discard block |
||
698 | 698 | * |
699 | 699 | * @return array actual users capabilities |
700 | 700 | */ |
701 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
701 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
702 | 702 | //only process if we're checking our mapped_cap |
703 | - if ( $cap !== $this->meta_cap ) { |
|
703 | + if ($cap !== $this->meta_cap) { |
|
704 | 704 | return $caps; |
705 | 705 | } |
706 | 706 | |
707 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
707 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
708 | 708 | |
709 | 709 | //if no obj then let's just do cap |
710 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
710 | + if ( ! $obj instanceof EE_Base_Class) { |
|
711 | 711 | $caps[] = $cap; |
712 | 712 | return $caps; |
713 | 713 | } |
714 | 714 | |
715 | - if ( $obj instanceof EE_CPT_Base ) { |
|
715 | + if ($obj instanceof EE_CPT_Base) { |
|
716 | 716 | //if the item author is set and the user is the author... |
717 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
718 | - if ( empty( $this->published_cap ) ) { |
|
717 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
718 | + if (empty($this->published_cap)) { |
|
719 | 719 | $caps[] = $cap; |
720 | 720 | } else { |
721 | 721 | //if obj is published... |
722 | - if ( $obj->status() == 'publish' ) { |
|
722 | + if ($obj->status() == 'publish') { |
|
723 | 723 | $caps[] = $this->published_cap; |
724 | 724 | } else { |
725 | 725 | $caps[] = $cap; |
@@ -727,21 +727,21 @@ discard block |
||
727 | 727 | } |
728 | 728 | } else { |
729 | 729 | //the user is trying to edit someone else's obj |
730 | - if ( ! empty( $this->others_cap ) ) { |
|
730 | + if ( ! empty($this->others_cap)) { |
|
731 | 731 | $caps[] = $this->others_cap; |
732 | 732 | } |
733 | - if ( ! empty( $this->published_cap ) && $obj->status() == 'publish' ) { |
|
733 | + if ( ! empty($this->published_cap) && $obj->status() == 'publish') { |
|
734 | 734 | $caps[] = $this->published_cap; |
735 | - } elseif ( ! empty( $this->private_cap ) && $obj->status() == 'private' ) { |
|
735 | + } elseif ( ! empty($this->private_cap) && $obj->status() == 'private') { |
|
736 | 736 | $caps[] = $this->private_cap; |
737 | 737 | } |
738 | 738 | } |
739 | 739 | } else { |
740 | 740 | //not a cpt object so handled differently |
741 | - if ( method_exists( $obj, 'wp_user' ) && $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
741 | + if (method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user()) { |
|
742 | 742 | $caps[] = $cap; |
743 | 743 | } else { |
744 | - if ( ! empty( $this->others_cap ) ) { |
|
744 | + if ( ! empty($this->others_cap)) { |
|
745 | 745 | $caps[] = $this->others_cap; |
746 | 746 | } |
747 | 747 | } |
@@ -778,8 +778,8 @@ discard block |
||
778 | 778 | * |
779 | 779 | * @return array actual users capabilities |
780 | 780 | */ |
781 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
782 | - return parent::_map_meta_caps( $caps, $cap, $user_id, $args ); |
|
781 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
782 | + return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
783 | 783 | } |
784 | 784 | } |
785 | 785 | |
@@ -811,45 +811,45 @@ discard block |
||
811 | 811 | * |
812 | 812 | * @return array actual users capabilities |
813 | 813 | */ |
814 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
814 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
815 | 815 | //only process if we're checking our mapped cap; |
816 | - if ( $cap !== $this->meta_cap ) { |
|
816 | + if ($cap !== $this->meta_cap) { |
|
817 | 817 | return $caps; |
818 | 818 | } |
819 | 819 | |
820 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
820 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
821 | 821 | |
822 | 822 | //if no obj then let's just do cap |
823 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
823 | + if ( ! $obj instanceof EE_Base_Class) { |
|
824 | 824 | $caps[] = $cap; |
825 | 825 | return $caps; |
826 | 826 | } |
827 | 827 | |
828 | - if ( $obj instanceof EE_CPT_Base ) { |
|
829 | - $status_obj = get_post_status_object( $obj->status() ); |
|
830 | - if ( $status_obj->public ) { |
|
828 | + if ($obj instanceof EE_CPT_Base) { |
|
829 | + $status_obj = get_post_status_object($obj->status()); |
|
830 | + if ($status_obj->public) { |
|
831 | 831 | $caps[] = $cap; |
832 | 832 | return $caps; |
833 | 833 | } |
834 | 834 | |
835 | 835 | //if the item author is set and the user is the author... |
836 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
836 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
837 | 837 | $caps[] = $cap; |
838 | - } elseif ( $status_obj->private && ! empty( $this->private_cap ) ) { |
|
838 | + } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
839 | 839 | //the user is trying to view someone else's obj |
840 | 840 | $caps[] = $this->private_cap; |
841 | - } elseif ( ! empty( $this->others_cap ) ) { |
|
841 | + } elseif ( ! empty($this->others_cap)) { |
|
842 | 842 | $caps[] = $this->others_cap; |
843 | 843 | } else { |
844 | 844 | $caps[] = $cap; |
845 | 845 | } |
846 | 846 | } else { |
847 | 847 | //not a cpt object so handled differently |
848 | - if ( method_exists( $obj, 'wp_user' ) && $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
848 | + if (method_exists($obj, 'wp_user') && $obj->wp_user() && $user_id == $obj->wp_user()) { |
|
849 | 849 | $caps[] = $cap; |
850 | - } elseif ( ! empty( $this->private_cap ) ) { |
|
850 | + } elseif ( ! empty($this->private_cap)) { |
|
851 | 851 | $caps[] = $this->private_cap; |
852 | - } elseif ( ! empty( $this->others_cap ) ) { |
|
852 | + } elseif ( ! empty($this->others_cap)) { |
|
853 | 853 | $caps[] = $this->others_cap; |
854 | 854 | } else { |
855 | 855 | $caps[] = $cap; |
@@ -886,30 +886,30 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @return array actual users capabilities |
888 | 888 | */ |
889 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
889 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
890 | 890 | //only process if we're checking our mapped_cap |
891 | - if ( $cap !== $this->meta_cap ) { |
|
891 | + if ($cap !== $this->meta_cap) { |
|
892 | 892 | return $caps; |
893 | 893 | } |
894 | 894 | |
895 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
895 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
896 | 896 | |
897 | 897 | //if no obj then let's just do cap |
898 | - if ( ! $obj instanceof EE_Message_Template_Group ) { |
|
898 | + if ( ! $obj instanceof EE_Message_Template_Group) { |
|
899 | 899 | $caps[] = $cap; |
900 | 900 | return $caps; |
901 | 901 | } |
902 | 902 | |
903 | 903 | $is_global = $obj->is_global(); |
904 | 904 | |
905 | - if ( $obj->wp_user() && $user_id == $obj->wp_user() ) { |
|
906 | - if ( $is_global ) { |
|
907 | - $caps[] = $this->private_cap; |
|
905 | + if ($obj->wp_user() && $user_id == $obj->wp_user()) { |
|
906 | + if ($is_global) { |
|
907 | + $caps[] = $this->private_cap; |
|
908 | 908 | } else { |
909 | 909 | $caps[] = $cap; |
910 | 910 | } |
911 | 911 | } else { |
912 | - if ( $is_global ) { |
|
912 | + if ($is_global) { |
|
913 | 913 | $caps[] = $this->private_cap; |
914 | 914 | } else { |
915 | 915 | $caps[] = $this->others_cap; |
@@ -947,16 +947,16 @@ discard block |
||
947 | 947 | * |
948 | 948 | * @return array actual users capabilities |
949 | 949 | */ |
950 | - protected function _map_meta_caps( $caps, $cap, $user_id, $args ) { |
|
950 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) { |
|
951 | 951 | //only process if we're checking our mapped_cap |
952 | - if ( $cap !== $this->meta_cap ) { |
|
952 | + if ($cap !== $this->meta_cap) { |
|
953 | 953 | return $caps; |
954 | 954 | } |
955 | 955 | |
956 | - $obj = ! empty( $args[0] ) ? $this->_model->get_one_by_ID( $args[0] ) : null; |
|
956 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
957 | 957 | |
958 | 958 | //if no obj then let's just do cap |
959 | - if ( ! $obj instanceof EE_Base_Class ) { |
|
959 | + if ( ! $obj instanceof EE_Base_Class) { |
|
960 | 960 | $caps[] = $cap; |
961 | 961 | return $caps; |
962 | 962 | } |
@@ -964,7 +964,7 @@ discard block |
||
964 | 964 | $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
965 | 965 | $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
966 | 966 | |
967 | - if ( $is_system ) { |
|
967 | + if ($is_system) { |
|
968 | 968 | $caps[] = $this->private_cap; |
969 | 969 | } else { |
970 | 970 | $caps[] = $cap; |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | -do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | +do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
3 | 3 | /** |
4 | 4 | * EE_Export class |
5 | 5 | * |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | * @access private |
40 | 40 | * @param array $request_data |
41 | 41 | */ |
42 | - private function __construct( $request_data = array() ) { |
|
42 | + private function __construct($request_data = array()) { |
|
43 | 43 | $this->_req_data = $request_data; |
44 | - $this->today = date("Y-m-d",time()); |
|
45 | - require_once( EE_CLASSES . 'EE_CSV.class.php' ); |
|
46 | - $this->EE_CSV= EE_CSV::instance(); |
|
44 | + $this->today = date("Y-m-d", time()); |
|
45 | + require_once(EE_CLASSES.'EE_CSV.class.php'); |
|
46 | + $this->EE_CSV = EE_CSV::instance(); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | * @param array $request_data |
56 | 56 | * @return \EE_Export |
57 | 57 | */ |
58 | - public static function instance( $request_data = array() ) { |
|
58 | + public static function instance($request_data = array()) { |
|
59 | 59 | // check if class object is instantiated |
60 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Export )) { |
|
61 | - self::$_instance = new self( $request_data ); |
|
60 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Export)) { |
|
61 | + self::$_instance = new self($request_data); |
|
62 | 62 | } |
63 | 63 | return self::$_instance; |
64 | 64 | } |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | public function export() { |
73 | 73 | |
74 | 74 | // in case of bulk exports, the "actual" action will be in action2, but first check regular action for "export" keyword |
75 | - if ( isset( $this->_req_data['action'] ) && strpos( $this->_req_data['action'], 'export' ) === FALSE ) { |
|
75 | + if (isset($this->_req_data['action']) && strpos($this->_req_data['action'], 'export') === FALSE) { |
|
76 | 76 | // check if action2 has export action |
77 | - if ( isset( $this->_req_data['action2'] ) && strpos( $this->_req_data['action2'], 'export' ) !== FALSE ) { |
|
77 | + if (isset($this->_req_data['action2']) && strpos($this->_req_data['action2'], 'export') !== FALSE) { |
|
78 | 78 | // whoop! there it is! |
79 | 79 | $this->_req_data['action'] = $this->_req_data['action2']; |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - $this->_req_data['export'] = isset( $this->_req_data['export'] ) ? $this->_req_data['export'] : ''; |
|
83 | + $this->_req_data['export'] = isset($this->_req_data['export']) ? $this->_req_data['export'] : ''; |
|
84 | 84 | |
85 | 85 | switch ($this->_req_data['export']) { |
86 | 86 | case 'report': |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | break; |
95 | 95 | |
96 | 96 | case 'registrations_report_for_event': |
97 | - $this->report_registrations_for_event( $this->_req_data['EVT_ID'] ); |
|
97 | + $this->report_registrations_for_event($this->_req_data['EVT_ID']); |
|
98 | 98 | break; |
99 | 99 | |
100 | 100 | case 'attendees': |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | break; |
107 | 107 | |
108 | 108 | default: |
109 | - EE_Error::add_error(__('An error occurred! The requested export report could not be found.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ) ; |
|
109 | + EE_Error::add_error(__('An error occurred! The requested export report could not be found.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
110 | 110 | return FALSE; |
111 | 111 | break; |
112 | 112 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * Downloads a CSV file with all the columns, but no data. This should be used for importing |
125 | 125 | * @return null kills execution |
126 | 126 | */ |
127 | - function export_sample(){ |
|
127 | + function export_sample() { |
|
128 | 128 | $event = EEM_Event::instance()->get_one(); |
129 | 129 | $this->_req_data['EVT_ID'] = $event->ID(); |
130 | 130 | $this->export_all_event_data(); |
@@ -151,23 +151,23 @@ discard block |
||
151 | 151 | $question_group_query_params = array(); |
152 | 152 | $question_query_params = array(); |
153 | 153 | $related_through_mtg_params = array(); |
154 | - if ( isset( $this->_req_data['EVT_ID'] )) { |
|
154 | + if (isset($this->_req_data['EVT_ID'])) { |
|
155 | 155 | // do we have an array of IDs ? |
156 | 156 | |
157 | - if ( is_array( $this->_req_data['EVT_ID'] )) { |
|
158 | - $EVT_IDs = array_map( 'sanitize_text_field', $this->_req_data['EVT_ID'] ); |
|
159 | - $value_to_equal = array('IN',$EVT_IDs); |
|
157 | + if (is_array($this->_req_data['EVT_ID'])) { |
|
158 | + $EVT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_ID']); |
|
159 | + $value_to_equal = array('IN', $EVT_IDs); |
|
160 | 160 | $filename = 'events'; |
161 | 161 | } else { |
162 | 162 | // generate regular where = clause |
163 | - $EVT_ID = absint( $this->_req_data['EVT_ID'] ); |
|
163 | + $EVT_ID = absint($this->_req_data['EVT_ID']); |
|
164 | 164 | $value_to_equal = $EVT_ID; |
165 | 165 | $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($EVT_ID); |
166 | 166 | |
167 | - $filename = 'event-' . ( $event instanceof EE_Event ? $event->slug() : __( 'unknown', 'event_espresso' ) ); |
|
167 | + $filename = 'event-'.($event instanceof EE_Event ? $event->slug() : __('unknown', 'event_espresso')); |
|
168 | 168 | |
169 | 169 | } |
170 | - $event_query_params[0]['EVT_ID'] =$value_to_equal; |
|
170 | + $event_query_params[0]['EVT_ID'] = $value_to_equal; |
|
171 | 171 | $related_models_query_params[0]['Event.EVT_ID'] = $value_to_equal; |
172 | 172 | $related_through_reg_query_params[0]['Registration.EVT_ID'] = $value_to_equal; |
173 | 173 | $datetime_ticket_query_params[0]['Datetime.EVT_ID'] = $value_to_equal; |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $state_country_query_params[0]['Venue.Event.EVT_ID'] = $value_to_equal; |
178 | 178 | $question_group_query_params[0]['Event.EVT_ID'] = $value_to_equal; |
179 | 179 | $question_query_params[0]['Question_Group.Event.EVT_ID'] = $value_to_equal; |
180 | - $related_through_mtg_params[0]['Message_Template_Group.Event.EVT_ID' ] = $value_to_equal; |
|
180 | + $related_through_mtg_params[0]['Message_Template_Group.Event.EVT_ID'] = $value_to_equal; |
|
181 | 181 | |
182 | 182 | } else { |
183 | 183 | $filename = 'all-events'; |
@@ -218,18 +218,18 @@ discard block |
||
218 | 218 | //and we want to specify what things we want to update (because some of that data we'd rather |
219 | 219 | //not update, just insert if it doesn't exist |
220 | 220 | $models_to_update = $models_to_export; |
221 | - unset( $models_to_update['Ticket_Template'] ); |
|
222 | - unset( $models_to_update['Price_Type'] ); |
|
223 | - unset( $models_to_update['Term'] ); |
|
224 | - unset( $models_to_update['Country'] ); |
|
225 | - unset( $models_to_update['State'] ); |
|
226 | - unset( $models_to_update['Question_Group'] ); |
|
227 | - unset( $models_to_update['Event_Question_Group'] ); |
|
228 | - unset( $models_to_update['Question'] ); |
|
229 | - unset( $models_to_update['Question_Group_Question'] ); |
|
230 | - unset( $models_to_update['Message_Template_Group'] ); |
|
231 | - unset( $models_to_update['Message_Template'] ); |
|
232 | - $models_to_update = array_keys( $models_to_update ); |
|
221 | + unset($models_to_update['Ticket_Template']); |
|
222 | + unset($models_to_update['Price_Type']); |
|
223 | + unset($models_to_update['Term']); |
|
224 | + unset($models_to_update['Country']); |
|
225 | + unset($models_to_update['State']); |
|
226 | + unset($models_to_update['Question_Group']); |
|
227 | + unset($models_to_update['Event_Question_Group']); |
|
228 | + unset($models_to_update['Question']); |
|
229 | + unset($models_to_update['Question_Group_Question']); |
|
230 | + unset($models_to_update['Message_Template_Group']); |
|
231 | + unset($models_to_update['Message_Template']); |
|
232 | + $models_to_update = array_keys($models_to_update); |
|
233 | 233 | |
234 | 234 | |
235 | 235 | |
@@ -238,37 +238,37 @@ discard block |
||
238 | 238 | //and won't get any non-events; also |
239 | 239 | //we can forego the default query params |
240 | 240 | |
241 | - $model_data = $this->_get_export_data_for_models( $models_to_export ); |
|
241 | + $model_data = $this->_get_export_data_for_models($models_to_export); |
|
242 | 242 | |
243 | - $filename = $this->generate_filename ( $filename ); |
|
243 | + $filename = $this->generate_filename($filename); |
|
244 | 244 | |
245 | - if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data, $models_to_update )) { |
|
246 | - EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ ); |
|
245 | + if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data, $models_to_update)) { |
|
246 | + EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
250 | - function report_attendees(){ |
|
251 | - $attendee_rows = EEM_Attendee::instance()->get_all_wpdb_results( array( 'force_join' => array( 'State', 'Country' ) ) ); |
|
250 | + function report_attendees() { |
|
251 | + $attendee_rows = EEM_Attendee::instance()->get_all_wpdb_results(array('force_join' => array('State', 'Country'))); |
|
252 | 252 | $csv_data = array(); |
253 | - foreach( $attendee_rows as $attendee_row ){ |
|
253 | + foreach ($attendee_rows as $attendee_row) { |
|
254 | 254 | $csv_row = array(); |
255 | - foreach( EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){ |
|
256 | - if( $field_name == 'STA_ID' ){ |
|
257 | - $state_name_field = EEM_State::instance()->field_settings_for( 'STA_name' ); |
|
258 | - $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
|
259 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
260 | - $country_name_field = EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
|
261 | - $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
|
262 | - }else{ |
|
263 | - $csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
|
255 | + foreach (EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) { |
|
256 | + if ($field_name == 'STA_ID') { |
|
257 | + $state_name_field = EEM_State::instance()->field_settings_for('STA_name'); |
|
258 | + $csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()]; |
|
259 | + }elseif ($field_name == 'CNT_ISO') { |
|
260 | + $country_name_field = EEM_Country::instance()->field_settings_for('CNT_name'); |
|
261 | + $csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()]; |
|
262 | + } else { |
|
263 | + $csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()]; |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | $csv_data[] = $csv_row; |
267 | 267 | } |
268 | 268 | |
269 | - $filename = $this->generate_filename ( 'contact-list-report' ); |
|
269 | + $filename = $this->generate_filename('contact-list-report'); |
|
270 | 270 | |
271 | - $handle = $this->EE_CSV->begin_sending_csv( $filename); |
|
271 | + $handle = $this->EE_CSV->begin_sending_csv($filename); |
|
272 | 272 | $this->EE_CSV->write_data_array_to_csv($handle, $csv_data); |
273 | 273 | $this->EE_CSV->end_sending_csv($handle); |
274 | 274 | } |
@@ -285,19 +285,19 @@ discard block |
||
285 | 285 | $countries_that_have_an_attendee = EEM_Country::instance()->get_all(array(0=>array('Attendee.ATT_ID'=>array('IS NOT NULL')))); |
286 | 286 | // $states_to_export_query_params |
287 | 287 | $models_to_export = array( |
288 | - 'Country'=>array(array('CNT_ISO'=>array('IN',array_keys($countries_that_have_an_attendee)))), |
|
289 | - 'State'=>array(array('STA_ID'=>array('IN',array_keys($states_that_have_an_attendee)))), |
|
288 | + 'Country'=>array(array('CNT_ISO'=>array('IN', array_keys($countries_that_have_an_attendee)))), |
|
289 | + 'State'=>array(array('STA_ID'=>array('IN', array_keys($states_that_have_an_attendee)))), |
|
290 | 290 | 'Attendee'=>array(), |
291 | 291 | ); |
292 | - $models_to_update = array( 'Attendee' ); |
|
292 | + $models_to_update = array('Attendee'); |
|
293 | 293 | |
294 | 294 | |
295 | 295 | |
296 | - $model_data = $this->_get_export_data_for_models( $models_to_export ); |
|
297 | - $filename = $this->generate_filename ( 'all-attendees' ); |
|
296 | + $model_data = $this->_get_export_data_for_models($models_to_export); |
|
297 | + $filename = $this->generate_filename('all-attendees'); |
|
298 | 298 | |
299 | - if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data, $models_to_update )) { |
|
300 | - EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
299 | + if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data, $models_to_update)) { |
|
300 | + EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
@@ -309,19 +309,19 @@ discard block |
||
309 | 309 | * @param boolean|string $pretty_schema true to display pretty, a string to use a specific "Schema", or false to NOT display pretty |
310 | 310 | * @return string |
311 | 311 | */ |
312 | - protected function _prepare_value_from_db_for_display( $model, $field_name, $raw_db_value, $pretty_schema = true ) { |
|
313 | - $field_obj = $model->field_settings_for( $field_name ); |
|
314 | - $value_on_model_obj = $field_obj->prepare_for_set_from_db( $raw_db_value ); |
|
315 | - if( $field_obj instanceof EE_Datetime_Field ) { |
|
316 | - $field_obj->set_date_format( EE_CSV::instance()->get_date_format_for_csv( $field_obj->get_date_format( $pretty_schema ) ), $pretty_schema ); |
|
317 | - $field_obj->set_time_format( EE_CSV::instance()->get_time_format_for_csv( $field_obj->get_time_format( $pretty_schema ) ), $pretty_schema ); |
|
312 | + protected function _prepare_value_from_db_for_display($model, $field_name, $raw_db_value, $pretty_schema = true) { |
|
313 | + $field_obj = $model->field_settings_for($field_name); |
|
314 | + $value_on_model_obj = $field_obj->prepare_for_set_from_db($raw_db_value); |
|
315 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
316 | + $field_obj->set_date_format(EE_CSV::instance()->get_date_format_for_csv($field_obj->get_date_format($pretty_schema)), $pretty_schema); |
|
317 | + $field_obj->set_time_format(EE_CSV::instance()->get_time_format_for_csv($field_obj->get_time_format($pretty_schema)), $pretty_schema); |
|
318 | 318 | } |
319 | - if( $pretty_schema === true){ |
|
320 | - return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj ); |
|
321 | - }elseif( is_string( $pretty_schema ) ) { |
|
322 | - return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema ); |
|
323 | - }else{ |
|
324 | - return $field_obj->prepare_for_get( $value_on_model_obj ); |
|
319 | + if ($pretty_schema === true) { |
|
320 | + return $field_obj->prepare_for_pretty_echoing($value_on_model_obj); |
|
321 | + }elseif (is_string($pretty_schema)) { |
|
322 | + return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema); |
|
323 | + } else { |
|
324 | + return $field_obj->prepare_for_get($value_on_model_obj); |
|
325 | 325 | } |
326 | 326 | } |
327 | 327 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * and the questions associated with the registrations |
331 | 331 | * @param int $event_id |
332 | 332 | */ |
333 | - function report_registrations_for_event( $event_id = NULL ){ |
|
333 | + function report_registrations_for_event($event_id = NULL) { |
|
334 | 334 | $reg_fields_to_include = array( |
335 | 335 | 'TXN_ID', |
336 | 336 | 'ATT_ID', |
@@ -362,125 +362,125 @@ discard block |
||
362 | 362 | array( |
363 | 363 | 'OR' => array( |
364 | 364 | //don't include registrations from failed or abandoned transactions... |
365 | - 'Transaction.STS_ID' => array( 'NOT IN', array( EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code ) ), |
|
365 | + 'Transaction.STS_ID' => array('NOT IN', array(EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code)), |
|
366 | 366 | //unless the registration is approved, in which case include it regardless of transaction status |
367 | 367 | 'STS_ID' => EEM_Registration::status_id_approved |
368 | 368 | ), |
369 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
369 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
370 | 370 | ), |
371 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
372 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ) |
|
371 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
372 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee') |
|
373 | 373 | ), |
374 | 374 | $event_id |
375 | 375 | ); |
376 | - if( $event_id ){ |
|
377 | - $query_params[0]['EVT_ID'] = $event_id; |
|
378 | - }else{ |
|
379 | - $query_params[ 'force_join' ][] = 'Event'; |
|
376 | + if ($event_id) { |
|
377 | + $query_params[0]['EVT_ID'] = $event_id; |
|
378 | + } else { |
|
379 | + $query_params['force_join'][] = 'Event'; |
|
380 | 380 | } |
381 | - $registration_rows = $reg_model->get_all_wpdb_results( $query_params ); |
|
381 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
382 | 382 | //get all questions which relate to someone in this group |
383 | 383 | $registration_ids = array(); |
384 | - foreach( $registration_rows as $reg_row ) { |
|
385 | - $registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] ); |
|
384 | + foreach ($registration_rows as $reg_row) { |
|
385 | + $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
386 | 386 | } |
387 | 387 | // EEM_Question::instance()->show_next_x_db_queries(); |
388 | - $questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN',$registration_ids)))); |
|
389 | - foreach($registration_rows as $reg_row){ |
|
390 | - if ( is_array( $reg_row ) ) { |
|
388 | + $questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN', $registration_ids)))); |
|
389 | + foreach ($registration_rows as $reg_row) { |
|
390 | + if (is_array($reg_row)) { |
|
391 | 391 | $reg_csv_array = array(); |
392 | - if( ! $event_id ){ |
|
392 | + if ( ! $event_id) { |
|
393 | 393 | //get the event's name and Id |
394 | - $reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), $this->_prepare_value_from_db_for_display( EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] ); |
|
394 | + $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), $this->_prepare_value_from_db_for_display(EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']); |
|
395 | 395 | } |
396 | - $is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false; |
|
396 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
397 | 397 | /*@var $reg_row EE_Registration */ |
398 | - foreach($reg_fields_to_include as $field_name){ |
|
398 | + foreach ($reg_fields_to_include as $field_name) { |
|
399 | 399 | $field = $reg_model->field_settings_for($field_name); |
400 | - if($field_name == 'REG_final_price'){ |
|
401 | - $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' ); |
|
402 | - }elseif( $field_name == 'REG_count' ){ |
|
403 | - $value = sprintf( __( '%s of %s', 'event_espresso' ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) ); |
|
404 | - }elseif( $field_name == 'REG_date' ) { |
|
405 | - $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' ); |
|
406 | - }else{ |
|
407 | - $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] ); |
|
400 | + if ($field_name == 'REG_final_price') { |
|
401 | + $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float'); |
|
402 | + }elseif ($field_name == 'REG_count') { |
|
403 | + $value = sprintf(__('%s of %s', 'event_espresso'), $this->_prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), $this->_prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size'])); |
|
404 | + }elseif ($field_name == 'REG_date') { |
|
405 | + $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html'); |
|
406 | + } else { |
|
407 | + $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]); |
|
408 | 408 | } |
409 | 409 | $reg_csv_array[$this->_get_column_name_for_field($field)] = $value; |
410 | - if($field_name == 'REG_final_price'){ |
|
410 | + if ($field_name == 'REG_final_price') { |
|
411 | 411 | //add a column named Currency after the final price |
412 | 412 | $reg_csv_array[__("Currency", "event_espresso")] = EE_Config::instance()->currency->code; |
413 | 413 | } |
414 | 414 | } |
415 | 415 | //get pretty status |
416 | - $stati = EEM_Status::instance()->localized_status( array( |
|
417 | - $reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ), |
|
418 | - $reg_row[ 'Transaction.STS_ID' ] => __( 'unknown', 'event_espresso' ) ), |
|
416 | + $stati = EEM_Status::instance()->localized_status(array( |
|
417 | + $reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), |
|
418 | + $reg_row['Transaction.STS_ID'] => __('unknown', 'event_espresso') ), |
|
419 | 419 | FALSE, |
420 | - 'sentence' ); |
|
421 | - $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ]; |
|
420 | + 'sentence'); |
|
421 | + $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
422 | 422 | //get pretty trnasaction status |
423 | - $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'Transaction.STS_ID' ] ]; |
|
424 | - $reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'Transaction.TXN_total' ], 'localized_float' ) : '0.00'; |
|
425 | - $reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'Transaction.TXN_paid' ], 'localized_float' ) : '0.00'; |
|
423 | + $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['Transaction.STS_ID']]; |
|
424 | + $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_total', $reg_row['Transaction.TXN_total'], 'localized_float') : '0.00'; |
|
425 | + $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_paid', $reg_row['Transaction.TXN_paid'], 'localized_float') : '0.00'; |
|
426 | 426 | $payment_methods = array(); |
427 | 427 | $gateway_txn_ids_etc = array(); |
428 | 428 | $payment_times = array(); |
429 | - if( $is_primary_reg && $reg_row[ 'Transaction.TXN_ID' ] ){ |
|
429 | + if ($is_primary_reg && $reg_row['Transaction.TXN_ID']) { |
|
430 | 430 | $payments_info = EEM_Payment::instance()->get_all_wpdb_results( |
431 | 431 | array( |
432 | 432 | array( |
433 | - 'TXN_ID' => $reg_row[ 'Transaction.TXN_ID' ], |
|
433 | + 'TXN_ID' => $reg_row['Transaction.TXN_ID'], |
|
434 | 434 | 'STS_ID' => EEM_Payment::status_id_approved |
435 | 435 | ), |
436 | - 'force_join' => array( 'Payment_Method' ), |
|
436 | + 'force_join' => array('Payment_Method'), |
|
437 | 437 | |
438 | 438 | ), |
439 | 439 | ARRAY_A, |
440 | 440 | 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' ); |
441 | 441 | |
442 | - foreach( $payments_info as $payment_method_and_gateway_txn_id ){ |
|
443 | - $payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' ); |
|
444 | - $gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : ''; |
|
445 | - $payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : ''; |
|
442 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
443 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso'); |
|
444 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
445 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | } |
449 | - $reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times ); |
|
450 | - $reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods ); |
|
451 | - $reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc ); |
|
449 | + $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
450 | + $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
451 | + $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc); |
|
452 | 452 | |
453 | 453 | //get whether or not the user has checked in |
454 | - $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' ); |
|
454 | + $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin'); |
|
455 | 455 | //get ticket of registration and its price |
456 | 456 | $ticket_model = EE_Registry::instance()->load_model('Ticket'); |
457 | - if( $reg_row[ 'Ticket.TKT_ID'] ) { |
|
458 | - $ticket_name = $this->_prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] ); |
|
457 | + if ($reg_row['Ticket.TKT_ID']) { |
|
458 | + $ticket_name = $this->_prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']); |
|
459 | 459 | $datetimes_strings = array(); |
460 | - foreach( EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){ |
|
461 | - $datetimes_strings[] = $this->_prepare_value_from_db_for_display( EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] ); |
|
460 | + foreach (EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) { |
|
461 | + $datetimes_strings[] = $this->_prepare_value_from_db_for_display(EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | } else { |
465 | - $ticket_name = __( 'Unknown', 'event_espresso' ); |
|
466 | - $datetimes_strings = array( __( 'Unknown', 'event_espresso' ) ); |
|
465 | + $ticket_name = __('Unknown', 'event_espresso'); |
|
466 | + $datetimes_strings = array(__('Unknown', 'event_espresso')); |
|
467 | 467 | } |
468 | 468 | $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
469 | 469 | $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
470 | 470 | //get datetime(s) of registration |
471 | 471 | |
472 | 472 | //add attendee columns |
473 | - foreach($att_fields_to_include as $att_field_name){ |
|
473 | + foreach ($att_fields_to_include as $att_field_name) { |
|
474 | 474 | $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name); |
475 | - if( $reg_row[ 'Attendee_CPT.ID' ]){ |
|
476 | - if($att_field_name == 'STA_ID'){ |
|
477 | - $value = EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' ); |
|
478 | - }elseif($att_field_name == 'CNT_ISO'){ |
|
479 | - $value = EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' ); |
|
480 | - }else{ |
|
481 | - $value = $this->_prepare_value_from_db_for_display( EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] ); |
|
475 | + if ($reg_row['Attendee_CPT.ID']) { |
|
476 | + if ($att_field_name == 'STA_ID') { |
|
477 | + $value = EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name'); |
|
478 | + }elseif ($att_field_name == 'CNT_ISO') { |
|
479 | + $value = EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name'); |
|
480 | + } else { |
|
481 | + $value = $this->_prepare_value_from_db_for_display(EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]); |
|
482 | 482 | } |
483 | - }else{ |
|
483 | + } else { |
|
484 | 484 | $value = ''; |
485 | 485 | } |
486 | 486 | |
@@ -488,56 +488,56 @@ discard block |
||
488 | 488 | } |
489 | 489 | |
490 | 490 | //make sure each registration has the same questions in the same order |
491 | - foreach($questions_for_these_regs_rows as $question_row){ |
|
492 | - if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){ |
|
493 | - $reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null; |
|
491 | + foreach ($questions_for_these_regs_rows as $question_row) { |
|
492 | + if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) { |
|
493 | + $reg_csv_array[$question_row['Question.QST_admin_label']] = null; |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | //now fill out the questions THEY answered |
497 | - foreach( EEM_Answer::instance()->get_all_wpdb_results( array( array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ), 'force_join' => array( 'Question' ) ) ) as $answer_row){ |
|
497 | + foreach (EEM_Answer::instance()->get_all_wpdb_results(array(array('REG_ID' => $reg_row['Registration.REG_ID']), 'force_join' => array('Question'))) as $answer_row) { |
|
498 | 498 | /* @var $answer EE_Answer */ |
499 | - if( $answer_row[ 'Question.QST_ID' ] ){ |
|
500 | - $question_label = $this->_prepare_value_from_db_for_display( EEM_Question::instance(), 'QST_admin_label', $answer_row[ 'Question.QST_admin_label' ] ); |
|
501 | - }else{ |
|
502 | - $question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] ); |
|
499 | + if ($answer_row['Question.QST_ID']) { |
|
500 | + $question_label = $this->_prepare_value_from_db_for_display(EEM_Question::instance(), 'QST_admin_label', $answer_row['Question.QST_admin_label']); |
|
501 | + } else { |
|
502 | + $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
503 | 503 | } |
504 | - if( isset( $answer_row[ 'Question.QST_type'] ) && $answer_row[ 'Question.QST_type' ] == EEM_Question::QST_type_state ) { |
|
505 | - $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( $answer_row[ 'Answer.ANS_value' ] ); |
|
504 | + if (isset($answer_row['Question.QST_type']) && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state) { |
|
505 | + $reg_csv_array[$question_label] = EEM_State::instance()->get_state_name_by_ID($answer_row['Answer.ANS_value']); |
|
506 | 506 | } else { |
507 | - $reg_csv_array[ $question_label ] = $this->_prepare_value_from_db_for_display( EEM_Answer::instance(), 'ANS_value', $answer_row[ 'Answer.ANS_value' ] ); |
|
507 | + $reg_csv_array[$question_label] = $this->_prepare_value_from_db_for_display(EEM_Answer::instance(), 'ANS_value', $answer_row['Answer.ANS_value']); |
|
508 | 508 | } |
509 | 509 | } |
510 | - $registrations_csv_ready_array[] = apply_filters( 'FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row ); |
|
510 | + $registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row); |
|
511 | 511 | } |
512 | 512 | } |
513 | 513 | |
514 | 514 | //if we couldn't export anything, we want to at least show the column headers |
515 | - if(empty($registrations_csv_ready_array)){ |
|
515 | + if (empty($registrations_csv_ready_array)) { |
|
516 | 516 | $reg_csv_array = array(); |
517 | 517 | $model_and_fields_to_include = array( |
518 | 518 | 'Registration' => $reg_fields_to_include, |
519 | 519 | 'Attendee' => $att_fields_to_include |
520 | 520 | ); |
521 | - foreach($model_and_fields_to_include as $model_name => $field_list){ |
|
521 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
522 | 522 | $model = EE_Registry::instance()->load_model($model_name); |
523 | - foreach($field_list as $field_name){ |
|
523 | + foreach ($field_list as $field_name) { |
|
524 | 524 | $field = $model->field_settings_for($field_name); |
525 | - $reg_csv_array[$this->_get_column_name_for_field($field)] = null;//$registration->get($field->get_name()); |
|
525 | + $reg_csv_array[$this->_get_column_name_for_field($field)] = null; //$registration->get($field->get_name()); |
|
526 | 526 | } |
527 | 527 | } |
528 | 528 | $registrations_csv_ready_array [] = $reg_csv_array; |
529 | 529 | } |
530 | - if( $event_id ){ |
|
531 | - $event_slug = EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' ); |
|
532 | - if( ! $event_slug ) { |
|
533 | - $event_slug = __( 'unknown', 'event_espresso' ); |
|
530 | + if ($event_id) { |
|
531 | + $event_slug = EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug'); |
|
532 | + if ( ! $event_slug) { |
|
533 | + $event_slug = __('unknown', 'event_espresso'); |
|
534 | 534 | } |
535 | - }else{ |
|
536 | - $event_slug = __( 'all', 'event_espresso' ); |
|
535 | + } else { |
|
536 | + $event_slug = __('all', 'event_espresso'); |
|
537 | 537 | } |
538 | - $filename = sprintf( "registrations-for-%s", $event_slug ); |
|
538 | + $filename = sprintf("registrations-for-%s", $event_slug); |
|
539 | 539 | |
540 | - $handle = $this->EE_CSV->begin_sending_csv( $filename); |
|
540 | + $handle = $this->EE_CSV->begin_sending_csv($filename); |
|
541 | 541 | $this->EE_CSV->write_data_array_to_csv($handle, $registrations_csv_ready_array); |
542 | 542 | $this->EE_CSV->end_sending_csv($handle); |
543 | 543 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | * @param EE_Model_Field_Base $field |
548 | 548 | * @return string |
549 | 549 | */ |
550 | - protected function _get_column_name_for_field(EE_Model_Field_Base $field){ |
|
550 | + protected function _get_column_name_for_field(EE_Model_Field_Base $field) { |
|
551 | 551 | return $field->get_nicename()."[".$field->get_name()."]"; |
552 | 552 | } |
553 | 553 | |
@@ -560,17 +560,17 @@ discard block |
||
560 | 560 | function export_categories() { |
561 | 561 | // are any Event IDs set? |
562 | 562 | $query_params = array(); |
563 | - if ( isset( $this->_req_data['EVT_CAT_ID'] )) { |
|
563 | + if (isset($this->_req_data['EVT_CAT_ID'])) { |
|
564 | 564 | // do we have an array of IDs ? |
565 | - if ( is_array( $this->_req_data['EVT_CAT_ID'] )) { |
|
565 | + if (is_array($this->_req_data['EVT_CAT_ID'])) { |
|
566 | 566 | // generate an "IN (CSV)" where clause |
567 | - $EVT_CAT_IDs = array_map( 'sanitize_text_field', $this->_req_data['EVT_CAT_ID'] ); |
|
567 | + $EVT_CAT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_CAT_ID']); |
|
568 | 568 | $filename = 'event-categories'; |
569 | - $query_params[0]['term_taxonomy_id'] = array('IN',$EVT_CAT_IDs); |
|
569 | + $query_params[0]['term_taxonomy_id'] = array('IN', $EVT_CAT_IDs); |
|
570 | 570 | } else { |
571 | 571 | // generate regular where = clause |
572 | - $EVT_CAT_ID = absint( $this->_req_data['EVT_CAT_ID'] ); |
|
573 | - $filename = 'event-category#' . $EVT_CAT_ID; |
|
572 | + $EVT_CAT_ID = absint($this->_req_data['EVT_CAT_ID']); |
|
573 | + $filename = 'event-category#'.$EVT_CAT_ID; |
|
574 | 574 | $query_params[0]['term_taxonomy_id'] = $EVT_CAT_ID; |
575 | 575 | } |
576 | 576 | } else { |
@@ -582,11 +582,11 @@ discard block |
||
582 | 582 | 'Term_Taxonomy' => $query_params |
583 | 583 | ); |
584 | 584 | |
585 | - $table_data = $this->_get_export_data_for_models( $tables_to_export ); |
|
586 | - $filename = $this->generate_filename ( $filename ); |
|
585 | + $table_data = $this->_get_export_data_for_models($tables_to_export); |
|
586 | + $filename = $this->generate_filename($filename); |
|
587 | 587 | |
588 | - if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $table_data )) { |
|
589 | - EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
588 | + if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $table_data)) { |
|
589 | + EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
590 | 590 | } |
591 | 591 | } |
592 | 592 | |
@@ -597,13 +597,13 @@ discard block |
||
597 | 597 | * @param string - export_name |
598 | 598 | * @return string on success, FALSE on fail |
599 | 599 | */ |
600 | - private function generate_filename ( $export_name = '' ) { |
|
601 | - if ( $export_name != '' ) { |
|
602 | - $filename = get_bloginfo('name') . '-' . $export_name; |
|
603 | - $filename = sanitize_key( $filename ) . '-' . $this->today; |
|
600 | + private function generate_filename($export_name = '') { |
|
601 | + if ($export_name != '') { |
|
602 | + $filename = get_bloginfo('name').'-'.$export_name; |
|
603 | + $filename = sanitize_key($filename).'-'.$this->today; |
|
604 | 604 | return $filename; |
605 | - } else { |
|
606 | - EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ ); |
|
605 | + } else { |
|
606 | + EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
607 | 607 | } |
608 | 608 | return false; |
609 | 609 | } |
@@ -616,37 +616,37 @@ discard block |
||
616 | 616 | * @param array $models_to_export keys are model names (eg 'Event', 'Attendee', etc.) and values are arrays of query params like on EEM_Base::get_all |
617 | 617 | * @return array on success, FALSE on fail |
618 | 618 | */ |
619 | - private function _get_export_data_for_models( $models_to_export = array() ) { |
|
619 | + private function _get_export_data_for_models($models_to_export = array()) { |
|
620 | 620 | $table_data = FALSE; |
621 | - if ( is_array( $models_to_export ) ) { |
|
622 | - foreach ( $models_to_export as $model_name => $query_params ) { |
|
621 | + if (is_array($models_to_export)) { |
|
622 | + foreach ($models_to_export as $model_name => $query_params) { |
|
623 | 623 | //check for a numerically-indexed array. in that case, $model_name is the value!! |
624 | - if(is_int($model_name)){ |
|
624 | + if (is_int($model_name)) { |
|
625 | 625 | $model_name = $query_params; |
626 | 626 | $query_params = array(); |
627 | 627 | } |
628 | - if( ! isset( $query_params[ 'default_where_conditions'] ) ) { |
|
629 | - $query_params[ 'default_where_conditions' ] = 'minimum'; |
|
628 | + if ( ! isset($query_params['default_where_conditions'])) { |
|
629 | + $query_params['default_where_conditions'] = 'minimum'; |
|
630 | 630 | } |
631 | 631 | $model = EE_Registry::instance()->load_model($model_name); |
632 | 632 | $model_objects = $model->get_all($query_params); |
633 | 633 | |
634 | 634 | |
635 | 635 | $table_data[$model_name] = array(); |
636 | - foreach($model_objects as $model_object){ |
|
636 | + foreach ($model_objects as $model_object) { |
|
637 | 637 | $model_data_array = array(); |
638 | 638 | $fields = $model->field_settings(); |
639 | - foreach($fields as $field){ |
|
639 | + foreach ($fields as $field) { |
|
640 | 640 | $column_name = $field->get_nicename()."[".$field->get_name()."]"; |
641 | - if($field instanceof EE_Datetime_Field){ |
|
641 | + if ($field instanceof EE_Datetime_Field) { |
|
642 | 642 | // $field->set_date_format('Y-m-d'); |
643 | 643 | // $field->set_time_format('H:i:s'); |
644 | - $model_data_array[$column_name] = $model_object->get_datetime($field->get_name(),'Y-m-d','H:i:s'); |
|
645 | - } elseif( $field instanceof EE_Infinite_Integer_Field && |
|
646 | - $model_object->get( $field->get_name() ) === EE_INF ) { |
|
644 | + $model_data_array[$column_name] = $model_object->get_datetime($field->get_name(), 'Y-m-d', 'H:i:s'); |
|
645 | + } elseif ($field instanceof EE_Infinite_Integer_Field && |
|
646 | + $model_object->get($field->get_name()) === EE_INF) { |
|
647 | 647 | $model_data_array[$column_name] = ""; |
648 | 648 | } |
649 | - else{ |
|
649 | + else { |
|
650 | 650 | $model_data_array[$column_name] = $model_object->get($field->get_name()); |
651 | 651 | } |
652 | 652 | } |
@@ -31,20 +31,20 @@ discard block |
||
31 | 31 | * |
32 | 32 | * ------------------------------------------------------------------------ |
33 | 33 | */ |
34 | -require_once ( EE_MODELS . 'EEM_Base.model.php' ); |
|
34 | +require_once (EE_MODELS.'EEM_Base.model.php'); |
|
35 | 35 | |
36 | 36 | class EEM_Post_Meta extends EEM_Base { |
37 | 37 | |
38 | 38 | // private instance of the EE_Post_Meta object |
39 | 39 | protected static $_instance = NULL; |
40 | 40 | |
41 | - protected function __construct( $timezone = NULL ) { |
|
42 | - $this->singular_item = __('Post Meta','event_espresso'); |
|
43 | - $this->plural_item = __('Post Metas','event_espresso'); |
|
41 | + protected function __construct($timezone = NULL) { |
|
42 | + $this->singular_item = __('Post Meta', 'event_espresso'); |
|
43 | + $this->plural_item = __('Post Metas', 'event_espresso'); |
|
44 | 44 | $this->_tables = array( |
45 | 45 | 'Post_Meta'=> new EE_Primary_Table('postmeta', 'meta_id') |
46 | 46 | ); |
47 | - $models_this_can_attach_to = apply_filters( 'FHEE__EEM_Post_Meta__construct__models_this_can_attach_to', array_keys( EE_Registry::instance()->cpt_models() ) ); |
|
47 | + $models_this_can_attach_to = apply_filters('FHEE__EEM_Post_Meta__construct__models_this_can_attach_to', array_keys(EE_Registry::instance()->cpt_models())); |
|
48 | 48 | $this->_fields = array( |
49 | 49 | 'Post_Meta'=>array( |
50 | 50 | 'meta_id'=>new EE_Primary_Key_Int_Field('meta_id', __("Meta ID", "event_espresso")), |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | 'meta_value'=>new EE_Maybe_Serialized_Text_Field('meta_value', __("Meta Value", "event_espresso"), true) |
54 | 54 | )); |
55 | 55 | $this->_model_relations = array(); |
56 | - foreach($models_this_can_attach_to as $model){ |
|
56 | + foreach ($models_this_can_attach_to as $model) { |
|
57 | 57 | $this->_model_relations[$model] = new EE_Belongs_To_Relation(); |
58 | 58 | } |
59 | - foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ) { |
|
60 | - $this->_cap_restriction_generators[ $cap_context ] = new EE_Restriction_Generator_Meta( 'meta_key', 'meta_value' ); |
|
59 | + foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) { |
|
60 | + $this->_cap_restriction_generators[$cap_context] = new EE_Restriction_Generator_Meta('meta_key', 'meta_value'); |
|
61 | 61 | } |
62 | - parent::__construct( $timezone ); |
|
62 | + parent::__construct($timezone); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 |