@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @param boolean $IPN |
34 | 34 | */ |
35 | - public static function set_IPN( $IPN ) { |
|
36 | - self::$IPN = filter_var( $IPN, FILTER_VALIDATE_BOOLEAN ); |
|
35 | + public static function set_IPN($IPN) { |
|
36 | + self::$IPN = filter_var($IPN, FILTER_VALIDATE_BOOLEAN); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | * @param bool $revisit |
45 | 45 | * @return void |
46 | 46 | */ |
47 | - public function set_revisit( $revisit = false ) { |
|
48 | - $this->_revisit = filter_var( $revisit, FILTER_VALIDATE_BOOLEAN ); |
|
47 | + public function set_revisit($revisit = false) { |
|
48 | + $this->_revisit = filter_var($revisit, FILTER_VALIDATE_BOOLEAN); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | * @param array $info |
61 | 61 | * @param bool $display_request |
62 | 62 | */ |
63 | - protected function log( $class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false ) { |
|
64 | - if ( WP_DEBUG && false ) { |
|
65 | - if ( $transaction instanceof EE_Transaction ) { |
|
63 | + protected function log($class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false) { |
|
64 | + if (WP_DEBUG && false) { |
|
65 | + if ($transaction instanceof EE_Transaction) { |
|
66 | 66 | // don't serialize objects |
67 | - $info = EEH_Debug_Tools::strip_objects( $info ); |
|
68 | - if ( $transaction->ID() ) { |
|
69 | - $info[ 'TXN_status' ] = $transaction->status_ID(); |
|
70 | - $info[ 'TXN_reg_steps' ] = $transaction->reg_steps(); |
|
71 | - $index = 'EE_Transaction: ' . $transaction->ID(); |
|
72 | - EEH_Debug_Tools::log( $class, $func, $line, $info, $display_request, $index ); |
|
67 | + $info = EEH_Debug_Tools::strip_objects($info); |
|
68 | + if ($transaction->ID()) { |
|
69 | + $info['TXN_status'] = $transaction->status_ID(); |
|
70 | + $info['TXN_reg_steps'] = $transaction->reg_steps(); |
|
71 | + $index = 'EE_Transaction: '.$transaction->ID(); |
|
72 | + EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | -EE_Registry::instance()->load_class( 'Processor_Base' ); |
|
2 | +EE_Registry::instance()->load_class('Processor_Base'); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Class EE_Registration_Processor |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public static function instance() { |
62 | 62 | // check if class object is instantiated |
63 | - if ( ! self::$_instance instanceof EE_Registration_Processor ) { |
|
63 | + if ( ! self::$_instance instanceof EE_Registration_Processor) { |
|
64 | 64 | self::$_instance = new self(); |
65 | 65 | } |
66 | 66 | return self::$_instance; |
@@ -96,37 +96,37 @@ discard block |
||
96 | 96 | * @return \EE_Registration | null |
97 | 97 | * @throws \EE_Error |
98 | 98 | */ |
99 | - public function generate_ONE_registration_from_line_item( EE_Line_Item $line_item, EE_Transaction $transaction, $att_nmbr = 1, $total_ticket_count = 1 ) { |
|
99 | + public function generate_ONE_registration_from_line_item(EE_Line_Item $line_item, EE_Transaction $transaction, $att_nmbr = 1, $total_ticket_count = 1) { |
|
100 | 100 | // grab the related ticket object for this line_item |
101 | 101 | $ticket = $line_item->ticket(); |
102 | - if ( ! $ticket instanceof EE_Ticket ) { |
|
103 | - EE_Error::add_error( sprintf( __( "Line item %s did not contain a valid ticket", "event_espresso" ), $line_item->ID() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
102 | + if ( ! $ticket instanceof EE_Ticket) { |
|
103 | + EE_Error::add_error(sprintf(__("Line item %s did not contain a valid ticket", "event_espresso"), $line_item->ID()), __FILE__, __FUNCTION__, __LINE__); |
|
104 | 104 | return null; |
105 | 105 | } |
106 | - $first_datetime = $ticket->get_first_related( 'Datetime' ); |
|
107 | - if ( ! $first_datetime instanceof EE_Datetime ) { |
|
108 | - EE_Error::add_error( sprintf( __( "The ticket (%s) is not associated with any valid datetimes.", "event_espresso" ), $ticket->name() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
106 | + $first_datetime = $ticket->get_first_related('Datetime'); |
|
107 | + if ( ! $first_datetime instanceof EE_Datetime) { |
|
108 | + EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with any valid datetimes.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__); |
|
109 | 109 | return null; |
110 | 110 | } |
111 | - $event = $first_datetime->get_first_related( 'Event' ); |
|
112 | - if ( ! $event instanceof EE_Event ) { |
|
113 | - EE_Error::add_error( sprintf( __( "The ticket (%s) is not associated with a valid event.", "event_espresso" ), $ticket->name() ), __FILE__, __FUNCTION__, __LINE__ ); |
|
111 | + $event = $first_datetime->get_first_related('Event'); |
|
112 | + if ( ! $event instanceof EE_Event) { |
|
113 | + EE_Error::add_error(sprintf(__("The ticket (%s) is not associated with a valid event.", "event_espresso"), $ticket->name()), __FILE__, __FUNCTION__, __LINE__); |
|
114 | 114 | return null; |
115 | 115 | } |
116 | - $reg_url_link = $this->generate_reg_url_link( $att_nmbr, $line_item ); |
|
116 | + $reg_url_link = $this->generate_reg_url_link($att_nmbr, $line_item); |
|
117 | 117 | |
118 | - if( $this->_reg_final_price_per_tkt_line_item === null ) { |
|
119 | - $this->_reg_final_price_per_tkt_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() ); |
|
118 | + if ($this->_reg_final_price_per_tkt_line_item === null) { |
|
119 | + $this->_reg_final_price_per_tkt_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item()); |
|
120 | 120 | } |
121 | 121 | //ok now find this new registration's final price |
122 | - if( isset( $this->_reg_final_price_per_tkt_line_item[ $line_item->ID() ] ) ) { |
|
123 | - $final_price = $this->_reg_final_price_per_tkt_line_item[ $line_item->ID() ] ; |
|
124 | - }else{ |
|
125 | - $message = sprintf( __( 'The ticket line item (ID:%1$d) had no entry in the reg_final_price_per_tkt_line_item array.', 'event_espresso' ), $line_item->ID() ); |
|
126 | - if( WP_DEBUG ){ |
|
127 | - throw new EE_Error( $message ); |
|
128 | - }else{ |
|
129 | - EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message ); |
|
122 | + if (isset($this->_reg_final_price_per_tkt_line_item[$line_item->ID()])) { |
|
123 | + $final_price = $this->_reg_final_price_per_tkt_line_item[$line_item->ID()]; |
|
124 | + } else { |
|
125 | + $message = sprintf(__('The ticket line item (ID:%1$d) had no entry in the reg_final_price_per_tkt_line_item array.', 'event_espresso'), $line_item->ID()); |
|
126 | + if (WP_DEBUG) { |
|
127 | + throw new EE_Error($message); |
|
128 | + } else { |
|
129 | + EE_Log::instance()->log(__CLASS__, __FUNCTION__, $message); |
|
130 | 130 | } |
131 | 131 | $final_price = $ticket->get_ticket_total_with_taxes(); |
132 | 132 | |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | 'REG_url_link' => $reg_url_link |
147 | 147 | ) |
148 | 148 | ); |
149 | - $registration->set_reg_code( $this->generate_reg_code( $registration ) ); |
|
149 | + $registration->set_reg_code($this->generate_reg_code($registration)); |
|
150 | 150 | $registration->save(); |
151 | - $registration->_add_relation_to( $event, 'Event', array(), $event->ID() ); |
|
152 | - $registration->_add_relation_to( $line_item->ticket(), 'Ticket', array(), $line_item->ticket()->ID() ); |
|
153 | - $transaction->_add_relation_to( $registration, 'Registration' ); |
|
151 | + $registration->_add_relation_to($event, 'Event', array(), $event->ID()); |
|
152 | + $registration->_add_relation_to($line_item->ticket(), 'Ticket', array(), $line_item->ticket()->ID()); |
|
153 | + $transaction->_add_relation_to($registration, 'Registration'); |
|
154 | 154 | return $registration; |
155 | 155 | } |
156 | 156 | |
@@ -163,9 +163,9 @@ discard block |
||
163 | 163 | * @param EE_Line_Item | string $item |
164 | 164 | * @return string |
165 | 165 | */ |
166 | - public function generate_reg_url_link( $att_nmbr, $item ) { |
|
166 | + public function generate_reg_url_link($att_nmbr, $item) { |
|
167 | 167 | $reg_url_link = $item instanceof EE_Line_Item ? $item->code() : $item; |
168 | - $reg_url_link = $att_nmbr . '-' . md5( $reg_url_link . microtime() ); |
|
168 | + $reg_url_link = $att_nmbr.'-'.md5($reg_url_link.microtime()); |
|
169 | 169 | return $reg_url_link; |
170 | 170 | } |
171 | 171 | |
@@ -177,18 +177,18 @@ discard block |
||
177 | 177 | * @param \EE_Registration $registration |
178 | 178 | * @return string |
179 | 179 | */ |
180 | - public function generate_reg_code( EE_Registration $registration ) { |
|
180 | + public function generate_reg_code(EE_Registration $registration) { |
|
181 | 181 | // figure out where to start parsing the reg code |
182 | - $chars = strpos( $registration->reg_url_link(), '-' ) + 5; |
|
182 | + $chars = strpos($registration->reg_url_link(), '-') + 5; |
|
183 | 183 | // TXN_ID + TKT_ID + first 3 and last 3 chars of reg_url_link |
184 | 184 | $new_reg_code = array( |
185 | 185 | $registration->transaction_ID(), |
186 | 186 | $registration->ticket_ID(), |
187 | - substr( $registration->reg_url_link(), 0, $chars ) |
|
187 | + substr($registration->reg_url_link(), 0, $chars) |
|
188 | 188 | ); |
189 | 189 | // now put it all together |
190 | - $new_reg_code = implode( '-', $new_reg_code ); |
|
191 | - return apply_filters( 'FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', $new_reg_code, $registration ); |
|
190 | + $new_reg_code = implode('-', $new_reg_code); |
|
191 | + return apply_filters('FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code', $new_reg_code, $registration); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * @param int $REG_ID |
198 | 198 | * @return string |
199 | 199 | */ |
200 | - public function old_reg_status( $REG_ID ) { |
|
201 | - return isset( $this->_old_reg_status[ $REG_ID ] ) ? $this->_old_reg_status[ $REG_ID ] : null; |
|
200 | + public function old_reg_status($REG_ID) { |
|
201 | + return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -207,10 +207,10 @@ discard block |
||
207 | 207 | * @param int $REG_ID |
208 | 208 | * @param string $old_reg_status |
209 | 209 | */ |
210 | - public function set_old_reg_status( $REG_ID, $old_reg_status ) { |
|
210 | + public function set_old_reg_status($REG_ID, $old_reg_status) { |
|
211 | 211 | // only set the first time |
212 | - if ( ! isset( $this->_old_reg_status[ $REG_ID ] ) ) { |
|
213 | - $this->_old_reg_status[ $REG_ID ] = $old_reg_status; |
|
212 | + if ( ! isset($this->_old_reg_status[$REG_ID])) { |
|
213 | + $this->_old_reg_status[$REG_ID] = $old_reg_status; |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | * @param int $REG_ID |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - public function new_reg_status( $REG_ID ) { |
|
224 | - return isset( $this->_new_reg_status[ $REG_ID ] ) ? $this->_new_reg_status[ $REG_ID ] : null; |
|
223 | + public function new_reg_status($REG_ID) { |
|
224 | + return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null; |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * @param int $REG_ID |
231 | 231 | * @param string $new_reg_status |
232 | 232 | */ |
233 | - public function set_new_reg_status( $REG_ID, $new_reg_status ) { |
|
234 | - $this->_new_reg_status[ $REG_ID ] = $new_reg_status; |
|
233 | + public function set_new_reg_status($REG_ID, $new_reg_status) { |
|
234 | + $this->_new_reg_status[$REG_ID] = $new_reg_status; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | * @param int $REG_ID |
243 | 243 | * @return bool |
244 | 244 | */ |
245 | - public function reg_status_updated( $REG_ID ) { |
|
246 | - return $this->new_reg_status( $REG_ID ) !== $this->old_reg_status( $REG_ID ) ? true : false; |
|
245 | + public function reg_status_updated($REG_ID) { |
|
246 | + return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID) ? true : false; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | |
@@ -257,19 +257,19 @@ discard block |
||
257 | 257 | * @param bool $save TRUE will save the registration if the status is updated, FALSE will leave that up to client code |
258 | 258 | * @return boolean |
259 | 259 | */ |
260 | - public function manually_update_registration_status( EE_Registration $registration, $new_reg_status = '', $save = true ) { |
|
260 | + public function manually_update_registration_status(EE_Registration $registration, $new_reg_status = '', $save = true) { |
|
261 | 261 | // set initial REG_Status |
262 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
262 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
263 | 263 | // set incoming REG_Status |
264 | - $this->set_new_reg_status( $registration->ID(), $new_reg_status ); |
|
264 | + $this->set_new_reg_status($registration->ID(), $new_reg_status); |
|
265 | 265 | // toggle reg status but only if it has changed and the user can do so |
266 | 266 | if ( |
267 | - $this->reg_status_updated( $registration->ID() ) && |
|
268 | - EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registration', 'toggle_registration_status', $registration->ID() ) |
|
267 | + $this->reg_status_updated($registration->ID()) && |
|
268 | + EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'toggle_registration_status', $registration->ID()) |
|
269 | 269 | ) { |
270 | 270 | // change status to new value |
271 | - if ( $registration->set_status( $this->new_reg_status( $registration->ID() ) )) { |
|
272 | - if ( $save ) { |
|
271 | + if ($registration->set_status($this->new_reg_status($registration->ID()))) { |
|
272 | + if ($save) { |
|
273 | 273 | $registration->save(); |
274 | 274 | } |
275 | 275 | } |
@@ -290,30 +290,30 @@ discard block |
||
290 | 290 | * @return void |
291 | 291 | * @throws \EE_Error |
292 | 292 | */ |
293 | - public function toggle_incomplete_registration_status_to_default( EE_Registration $registration, $save = TRUE ) { |
|
293 | + public function toggle_incomplete_registration_status_to_default(EE_Registration $registration, $save = TRUE) { |
|
294 | 294 | $existing_reg_status = $registration->status_ID(); |
295 | 295 | // set initial REG_Status |
296 | - $this->set_old_reg_status( $registration->ID(), $existing_reg_status ); |
|
296 | + $this->set_old_reg_status($registration->ID(), $existing_reg_status); |
|
297 | 297 | // is the registration currently incomplete ? |
298 | - if ( $registration->status_ID() === EEM_Registration::status_id_incomplete ) { |
|
298 | + if ($registration->status_ID() === EEM_Registration::status_id_incomplete) { |
|
299 | 299 | // grab default reg status for the event, if set |
300 | 300 | $event_default_registration_status = $registration->event()->default_registration_status(); |
301 | 301 | // if no default reg status is set for the event, then use the global value |
302 | - $STS_ID = ! empty( $event_default_registration_status ) |
|
302 | + $STS_ID = ! empty($event_default_registration_status) |
|
303 | 303 | ? $event_default_registration_status |
304 | 304 | : EE_Registry::instance()->CFG->registration->default_STS_ID; |
305 | 305 | // if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered |
306 | 306 | $STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment : $STS_ID; |
307 | 307 | // set incoming REG_Status |
308 | - $this->set_new_reg_status( $registration->ID(), $STS_ID ); |
|
309 | - $registration->set_status( $STS_ID ); |
|
310 | - if ( $save ) { |
|
308 | + $this->set_new_reg_status($registration->ID(), $STS_ID); |
|
309 | + $registration->set_status($STS_ID); |
|
310 | + if ($save) { |
|
311 | 311 | $registration->save(); |
312 | 312 | } |
313 | 313 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
314 | - if ( ! EE_Processor_Base::$IPN ) { |
|
314 | + if ( ! EE_Processor_Base::$IPN) { |
|
315 | 315 | // otherwise, send out notifications |
316 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
316 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
317 | 317 | } |
318 | 318 | // DEBUG LOG |
319 | 319 | //$this->log( |
@@ -337,25 +337,25 @@ discard block |
||
337 | 337 | * @param bool $save TRUE will save the registration if the status is updated, FALSE will leave that up to client code |
338 | 338 | * @return boolean |
339 | 339 | */ |
340 | - public function toggle_registration_status_for_default_approved_events( EE_Registration $registration, $save = TRUE ) { |
|
340 | + public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = TRUE) { |
|
341 | 341 | // set initial REG_Status |
342 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
342 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
343 | 343 | // if not already, toggle reg status to approved IF the event default reg status is approved |
344 | 344 | if ( |
345 | 345 | $registration->status_ID() !== EEM_Registration::status_id_approved && |
346 | 346 | $registration->event()->default_registration_status() == EEM_Registration::status_id_approved |
347 | 347 | ) { |
348 | 348 | // set incoming REG_Status |
349 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
349 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
350 | 350 | // toggle status to approved |
351 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
352 | - if ( $save ) { |
|
351 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
352 | + if ($save) { |
|
353 | 353 | $registration->save(); |
354 | 354 | } |
355 | 355 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
356 | - if ( ! EE_Processor_Base::$IPN ) { |
|
356 | + if ( ! EE_Processor_Base::$IPN) { |
|
357 | 357 | // otherwise, send out notifications |
358 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
358 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
359 | 359 | } |
360 | 360 | // DEBUG LOG |
361 | 361 | //$this->log( |
@@ -383,19 +383,19 @@ discard block |
||
383 | 383 | * @return bool |
384 | 384 | * @throws \EE_Error |
385 | 385 | */ |
386 | - public function toggle_registration_status_if_no_monies_owing( EE_Registration $registration, $save = TRUE, $additional_details = array() ) { |
|
386 | + public function toggle_registration_status_if_no_monies_owing(EE_Registration $registration, $save = TRUE, $additional_details = array()) { |
|
387 | 387 | // set initial REG_Status |
388 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
388 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
389 | 389 | //EEH_Debug_Tools::printr( $additional_details, '$additional_details', __FILE__, __LINE__ ); |
390 | 390 | // was a payment just made ? |
391 | 391 | if ( |
392 | - isset( $additional_details[ 'payment_updates' ], $additional_details[ 'last_payment' ] ) && |
|
393 | - $additional_details[ 'payment_updates' ] && |
|
394 | - $additional_details[ 'last_payment' ] instanceof EE_Payment |
|
392 | + isset($additional_details['payment_updates'], $additional_details['last_payment']) && |
|
393 | + $additional_details['payment_updates'] && |
|
394 | + $additional_details['last_payment'] instanceof EE_Payment |
|
395 | 395 | ) { |
396 | - $payment = $additional_details[ 'last_payment' ]; |
|
396 | + $payment = $additional_details['last_payment']; |
|
397 | 397 | $total_paid = 0; |
398 | - foreach ( self::$_amount_paid as $reg => $amount_paid ) { |
|
398 | + foreach (self::$_amount_paid as $reg => $amount_paid) { |
|
399 | 399 | $total_paid += $amount_paid; |
400 | 400 | } |
401 | 401 | } else { |
@@ -419,30 +419,30 @@ discard block |
||
419 | 419 | $registration->transaction()->is_completed() || |
420 | 420 | $registration->transaction()->is_overpaid() || |
421 | 421 | $registration->transaction()->is_free() || |
422 | - apply_filters( 'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration ) |
|
422 | + apply_filters('FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration) |
|
423 | 423 | ) || ( |
424 | 424 | $payment instanceof EE_Payment && |
425 | 425 | $payment->is_approved() && |
426 | 426 | // this specific registration has not yet been paid for |
427 | - ! isset( self::$_amount_paid[ $registration->ID() ] ) && |
|
427 | + ! isset(self::$_amount_paid[$registration->ID()]) && |
|
428 | 428 | // payment amount, less what we have already attributed to other registrations, is greater than this reg's final price |
429 | 429 | $payment->amount() - $total_paid >= $registration->final_price() |
430 | 430 | ) |
431 | 431 | ) |
432 | 432 | ) { |
433 | 433 | // mark as paid |
434 | - self::$_amount_paid[ $registration->ID() ] = $registration->final_price(); |
|
434 | + self::$_amount_paid[$registration->ID()] = $registration->final_price(); |
|
435 | 435 | // track new REG_Status |
436 | - $this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved ); |
|
436 | + $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved); |
|
437 | 437 | // toggle status to approved |
438 | - $registration->set_status( EEM_Registration::status_id_approved ); |
|
439 | - if ( $save ) { |
|
438 | + $registration->set_status(EEM_Registration::status_id_approved); |
|
439 | + if ($save) { |
|
440 | 440 | $registration->save(); |
441 | 441 | } |
442 | 442 | // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor |
443 | - if ( ! EE_Processor_Base::$IPN ) { |
|
443 | + if ( ! EE_Processor_Base::$IPN) { |
|
444 | 444 | // otherwise, send out notifications |
445 | - add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 ); |
|
445 | + add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10); |
|
446 | 446 | } |
447 | 447 | // DEBUG LOG |
448 | 448 | //$this->log( |
@@ -468,19 +468,19 @@ discard block |
||
468 | 468 | * @param array $additional_details |
469 | 469 | * @return void |
470 | 470 | */ |
471 | - public function trigger_registration_update_notifications( $registration, $additional_details = array() ) { |
|
471 | + public function trigger_registration_update_notifications($registration, $additional_details = array()) { |
|
472 | 472 | try { |
473 | - if ( ! $registration instanceof EE_Registration ) { |
|
474 | - throw new EE_Error( __( 'An invalid registration was received.', 'event_espresso' ) ); |
|
473 | + if ( ! $registration instanceof EE_Registration) { |
|
474 | + throw new EE_Error(__('An invalid registration was received.', 'event_espresso')); |
|
475 | 475 | } |
476 | - EEH_Debug_Tools::log( __CLASS__, __FUNCTION__, __LINE__, array( $registration->transaction(), $additional_details ), false, 'EE_Transaction: ' . $registration->transaction()->ID() ); |
|
476 | + EEH_Debug_Tools::log(__CLASS__, __FUNCTION__, __LINE__, array($registration->transaction(), $additional_details), false, 'EE_Transaction: '.$registration->transaction()->ID()); |
|
477 | 477 | do_action( |
478 | 478 | 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', |
479 | 479 | $registration, |
480 | 480 | $additional_details |
481 | 481 | ); |
482 | - } catch( Exception $e ) { |
|
483 | - EE_Error::add_error( $e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine() ); |
|
482 | + } catch (Exception $e) { |
|
483 | + EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine()); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
@@ -493,18 +493,18 @@ discard block |
||
493 | 493 | * @param array $additional_details |
494 | 494 | * @return bool |
495 | 495 | */ |
496 | - public function update_registration_after_checkout_or_payment( EE_Registration $registration, $additional_details = array() ) { |
|
496 | + public function update_registration_after_checkout_or_payment(EE_Registration $registration, $additional_details = array()) { |
|
497 | 497 | // set initial REG_Status |
498 | - $this->set_old_reg_status( $registration->ID(), $registration->status_ID() ); |
|
498 | + $this->set_old_reg_status($registration->ID(), $registration->status_ID()); |
|
499 | 499 | |
500 | 500 | // if the registration status gets updated, then save the registration |
501 | - if ( $this->toggle_registration_status_for_default_approved_events( $registration, false ) || $this->toggle_registration_status_if_no_monies_owing( $registration, false, $additional_details )) { |
|
501 | + if ($this->toggle_registration_status_for_default_approved_events($registration, false) || $this->toggle_registration_status_if_no_monies_owing($registration, false, $additional_details)) { |
|
502 | 502 | $registration->save(); |
503 | 503 | } |
504 | 504 | |
505 | 505 | // set new REG_Status |
506 | - $this->set_new_reg_status( $registration->ID(), $registration->status_ID() ); |
|
507 | - return $this->reg_status_updated( $registration->ID() ) && $this->new_reg_status( $registration->ID() ) == EEM_Registration::status_id_approved ? true : false; |
|
506 | + $this->set_new_reg_status($registration->ID(), $registration->status_ID()); |
|
507 | + return $this->reg_status_updated($registration->ID()) && $this->new_reg_status($registration->ID()) == EEM_Registration::status_id_approved ? true : false; |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -514,19 +514,19 @@ discard block |
||
514 | 514 | * @param boolean $save_regs whether to immediately save registrations in this function or not |
515 | 515 | * @return void |
516 | 516 | */ |
517 | - public function update_registration_final_prices( $transaction, $save_regs = true ) { |
|
518 | - $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() ); |
|
519 | - foreach( $transaction->registrations() as $registration ) { |
|
520 | - $line_item = EEM_Line_Item::instance()->get_line_item_for_registration( $registration ); |
|
521 | - if( isset( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ) ) { |
|
522 | - $registration->set_final_price( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ); |
|
523 | - if( $save_regs ) { |
|
517 | + public function update_registration_final_prices($transaction, $save_regs = true) { |
|
518 | + $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item()); |
|
519 | + foreach ($transaction->registrations() as $registration) { |
|
520 | + $line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration); |
|
521 | + if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) { |
|
522 | + $registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]); |
|
523 | + if ($save_regs) { |
|
524 | 524 | $registration->save(); |
525 | 525 | } |
526 | 526 | } |
527 | 527 | } |
528 | 528 | //and make sure there's no rounding problem |
529 | - $this->fix_reg_final_price_rounding_issue( $transaction ); |
|
529 | + $this->fix_reg_final_price_rounding_issue($transaction); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * @param EE_Transaction $transaction |
543 | 543 | * @return boolean success verifying that there is NO difference after this method is done |
544 | 544 | */ |
545 | - public function fix_reg_final_price_rounding_issue( $transaction ) { |
|
545 | + public function fix_reg_final_price_rounding_issue($transaction) { |
|
546 | 546 | $reg_final_price_sum = EEM_Registration::instance()->sum( |
547 | 547 | array( |
548 | 548 | array( |
@@ -551,9 +551,9 @@ discard block |
||
551 | 551 | ), |
552 | 552 | 'REG_final_price' |
553 | 553 | ); |
554 | - $diff = $transaction->total() - floatval( $reg_final_price_sum ); |
|
554 | + $diff = $transaction->total() - floatval($reg_final_price_sum); |
|
555 | 555 | //ok then, just grab one of the registrations |
556 | - if( $diff != 0 ) { |
|
556 | + if ($diff != 0) { |
|
557 | 557 | $a_reg = EEM_Registration::instance()->get_one( |
558 | 558 | array( |
559 | 559 | array( |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | )); |
563 | 563 | $success = $a_reg instanceof EE_Registration ? $a_reg->save( |
564 | 564 | array( |
565 | - 'REG_final_price' => ( $a_reg->final_price() + $diff ) |
|
565 | + 'REG_final_price' => ($a_reg->final_price() + $diff) |
|
566 | 566 | ) |
567 | 567 | ) : false; |
568 | 568 | return $success ? true : false; |
@@ -39,12 +39,12 @@ discard block |
||
39 | 39 | public static function load_textdomain() { |
40 | 40 | self::_maybe_get_langfile(); |
41 | 41 | //now load the textdomain |
42 | - if ( ! empty( self::$_lang ) && is_readable( EE_LANGUAGES_SAFE_DIR . 'event_espresso-' . self::$_lang . '.mo' ) ) { |
|
42 | + if ( ! empty(self::$_lang) && is_readable(EE_LANGUAGES_SAFE_DIR.'event_espresso-'.self::$_lang.'.mo')) { |
|
43 | 43 | load_plugin_textdomain('event_espresso', FALSE, EE_LANGUAGES_SAFE_LOC); |
44 | - } else if ( ! empty( self::$_lang ) && is_readable( EE_LANGUAGES_SAFE_DIR . 'event-espresso-4-' . self::$_lang . '.mo' ) ) { |
|
45 | - load_textdomain( 'event_espresso', EE_LANGUAGES_SAFE_DIR . 'event-espresso-4-' . self::$_lang . '.mo' ); |
|
44 | + } else if ( ! empty(self::$_lang) && is_readable(EE_LANGUAGES_SAFE_DIR.'event-espresso-4-'.self::$_lang.'.mo')) { |
|
45 | + load_textdomain('event_espresso', EE_LANGUAGES_SAFE_DIR.'event-espresso-4-'.self::$_lang.'.mo'); |
|
46 | 46 | } else { |
47 | - load_plugin_textdomain( 'event_espresso', FALSE, dirname( EE_PLUGIN_BASENAME ) . '/languages/'); |
|
47 | + load_plugin_textdomain('event_espresso', FALSE, dirname(EE_PLUGIN_BASENAME).'/languages/'); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | |
@@ -59,24 +59,24 @@ discard block |
||
59 | 59 | */ |
60 | 60 | private static function _maybe_get_langfile() { |
61 | 61 | self::$_lang = get_locale(); |
62 | - if ( $has_check = get_option( 'ee_lang_check_' . self::$_lang . '_' . EVENT_ESPRESSO_VERSION ) || empty( self::$_lang ) ) |
|
62 | + if ($has_check = get_option('ee_lang_check_'.self::$_lang.'_'.EVENT_ESPRESSO_VERSION) || empty(self::$_lang)) |
|
63 | 63 | return; |
64 | 64 | |
65 | 65 | //if lang is en_US or empty then lets just get out. (Event Espresso core is en_US) |
66 | - if ( empty( self::$_lang ) || self::$_lang == 'en_US' ) |
|
66 | + if (empty(self::$_lang) || self::$_lang == 'en_US') |
|
67 | 67 | return; |
68 | 68 | |
69 | 69 | //made it here so let's get the file from the github repo |
70 | 70 | $sideloader_args = array( |
71 | - '_upload_to' => EE_PLUGIN_DIR_PATH . 'languages/', |
|
72 | - '_upload_from' => 'https://github.com/eventespresso/languages-ee4/blob/master/event_espresso-' . self::$_lang . '.mo?raw=true', |
|
73 | - '_new_file_name' => 'event_espresso-' . self::$_lang . '.mo' |
|
71 | + '_upload_to' => EE_PLUGIN_DIR_PATH.'languages/', |
|
72 | + '_upload_from' => 'https://github.com/eventespresso/languages-ee4/blob/master/event_espresso-'.self::$_lang.'.mo?raw=true', |
|
73 | + '_new_file_name' => 'event_espresso-'.self::$_lang.'.mo' |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | |
77 | - $sideloader = EE_Registry::instance()->load_helper('Sideloader', $sideloader_args, FALSE ); |
|
77 | + $sideloader = EE_Registry::instance()->load_helper('Sideloader', $sideloader_args, FALSE); |
|
78 | 78 | |
79 | 79 | $sideloader->sideload(); |
80 | - update_option( 'ee_lang_check_' . self::$_lang . '_' . EVENT_ESPRESSO_VERSION, 1 ); |
|
80 | + update_option('ee_lang_check_'.self::$_lang.'_'.EVENT_ESPRESSO_VERSION, 1); |
|
81 | 81 | } |
82 | 82 | } //end EE_Load_Textdomain |
@@ -21,23 +21,23 @@ discard block |
||
21 | 21 | private $EE; |
22 | 22 | public function __construct($url_link = 0) { |
23 | 23 | |
24 | - if ( $this->registration = EE_Registry::instance()->load_model( 'Registration' )->get_registration_for_reg_url_link( $url_link)) { |
|
24 | + if ($this->registration = EE_Registry::instance()->load_model('Registration')->get_registration_for_reg_url_link($url_link)) { |
|
25 | 25 | $this->transaction = $this->registration->transaction(); |
26 | 26 | |
27 | - $payment_settings = EE_Config::instance()->gateway->payment_settings;//get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE); |
|
28 | - $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type( 'Invoice' ); |
|
27 | + $payment_settings = EE_Config::instance()->gateway->payment_settings; //get_user_meta(EE_Registry::instance()->CFG->wp_user, 'payment_settings', TRUE); |
|
28 | + $this->invoice_payment_method = EEM_Payment_Method::instance()->get_one_of_type('Invoice'); |
|
29 | 29 | } else { |
30 | - EE_Error::add_error( __( 'Your request appears to be missing some required data, and no information for your transaction could be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
30 | + EE_Error::add_error(__('Your request appears to be missing some required data, and no information for your transaction could be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | } |
34 | 34 | |
35 | - public function send_invoice( $download = FALSE ) { |
|
35 | + public function send_invoice($download = FALSE) { |
|
36 | 36 | $template_args = array(); |
37 | 37 | $EE = EE_Registry::instance(); |
38 | 38 | |
39 | 39 | //allow the request to override the default theme defined in the invoice settings |
40 | - $theme_requested = ( isset( $_REQUEST['theme'] ) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8 ) ? absint( $_REQUEST['theme'] ) : null; |
|
40 | + $theme_requested = (isset($_REQUEST['theme']) && $_REQUEST['theme'] > 0 && $_REQUEST['theme'] < 8) ? absint($_REQUEST['theme']) : null; |
|
41 | 41 | $themes = array( |
42 | 42 | 1 => "simple.css", |
43 | 43 | 2 => "bauhaus.css", |
@@ -48,26 +48,26 @@ discard block |
||
48 | 48 | 7 => "union.css" |
49 | 49 | ); |
50 | 50 | //Get the CSS file |
51 | - if( isset( $themes[ $theme_requested ] ) ) { |
|
52 | - $template_args['invoice_css'] = $themes[ $theme_requested ]; |
|
53 | - }else{ |
|
54 | - $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta( 'legacy_invoice_css', TRUE, 'simple.css' ); |
|
51 | + if (isset($themes[$theme_requested])) { |
|
52 | + $template_args['invoice_css'] = $themes[$theme_requested]; |
|
53 | + } else { |
|
54 | + $template_args['invoice_css'] = $this->invoice_payment_method->get_extra_meta('legacy_invoice_css', TRUE, 'simple.css'); |
|
55 | 55 | } |
56 | 56 | |
57 | - if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) { |
|
58 | - $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/'; |
|
57 | + if (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) { |
|
58 | + $template_args['base_url'] = EVENT_ESPRESSO_GATEWAY_URL.'Invoice/lib/templates/'; |
|
59 | 59 | } else { |
60 | - $template_args['base_url'] = EE_GATEWAYS . '/Invoice/lib/templates/'; |
|
60 | + $template_args['base_url'] = EE_GATEWAYS.'/Invoice/lib/templates/'; |
|
61 | 61 | } |
62 | 62 | $primary_attendee = $this->transaction->primary_registration()->attendee(); |
63 | 63 | |
64 | - $template_args['organization'] = $EE->CFG->organization->get_pretty( 'name' ); |
|
65 | - $template_args['street'] = empty( $EE->CFG->organization->address_2 ) ? $EE->CFG->organization->get_pretty( 'address_1' ) : $EE->CFG->organization->get_pretty( 'address_1' ) . '<br>' . $EE->CFG->organization->get_pretty( 'address_2' ); |
|
66 | - $template_args['city'] = $EE->CFG->organization->get_pretty( 'city' ); |
|
67 | - $template_args['state'] = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $EE->CFG->organization->STA_ID ); |
|
68 | - $template_args['country'] = EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $EE->CFG->organization->CNT_ISO ); |
|
69 | - $template_args['zip'] = $EE->CFG->organization->get_pretty( 'zip' ); |
|
70 | - $template_args['email'] = $EE->CFG->organization->get_pretty( 'email' ); |
|
64 | + $template_args['organization'] = $EE->CFG->organization->get_pretty('name'); |
|
65 | + $template_args['street'] = empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty('address_1') : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty('address_2'); |
|
66 | + $template_args['city'] = $EE->CFG->organization->get_pretty('city'); |
|
67 | + $template_args['state'] = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID); |
|
68 | + $template_args['country'] = EE_Registry::instance()->load_model('Country')->get_one_by_ID($EE->CFG->organization->CNT_ISO); |
|
69 | + $template_args['zip'] = $EE->CFG->organization->get_pretty('zip'); |
|
70 | + $template_args['email'] = $EE->CFG->organization->get_pretty('email'); |
|
71 | 71 | |
72 | 72 | $template_args['registration_code'] = $this->registration->reg_code(); |
73 | 73 | $template_args['registration_date'] = $this->registration->date(); |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | $template_args['attendee_address2'] = $primary_attendee->address2(); |
77 | 77 | $template_args['attendee_city'] = $primary_attendee->city(); |
78 | 78 | $attendee_state = $primary_attendee->state_obj(); |
79 | - if($attendee_state){ |
|
79 | + if ($attendee_state) { |
|
80 | 80 | $attendee_state_name = $attendee_state->name(); |
81 | - }else{ |
|
81 | + } else { |
|
82 | 82 | $attendee_state_name = ''; |
83 | 83 | } |
84 | 84 | $template_args['attendee_state'] = $attendee_state_name; |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | if ($template_args['amount_pd'] != $template_args['total_cost']) { |
103 | 103 | //$template_args['net_total'] = $this->espressoInvoiceTotals( __('SubTotal', 'event_espresso'), $this->transaction->total());//$this->session_data['cart']['REG']['sub_total']); |
104 | 104 | $tax_items = $this->transaction->tax_items(); |
105 | - if(!empty($tax_items) ){ |
|
105 | + if ( ! empty($tax_items)) { |
|
106 | 106 | foreach ($tax_items as $tax) { |
107 | - $template_args['net_total'] .= $this->espressoInvoiceTotals( $tax->name(), $tax->total()); |
|
107 | + $template_args['net_total'] .= $this->espressoInvoiceTotals($tax->name(), $tax->total()); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
@@ -114,30 +114,30 @@ discard block |
||
114 | 114 | } else { |
115 | 115 | $text = __('Extra', 'event_espresso'); |
116 | 116 | } |
117 | - $template_args['discount'] = $this->espressoInvoiceTotals( $text, $difference ); |
|
117 | + $template_args['discount'] = $this->espressoInvoiceTotals($text, $difference); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | $template_args['currency_symbol'] = $EE->CFG->currency->sign; |
121 | - $template_args['template_payment_instructions'] = wpautop(stripslashes_deep(html_entity_decode($this->invoice_payment_method->get_extra_meta( 'pdf_instructions', TRUE ), ENT_QUOTES))); |
|
122 | - $template_args['shameless_plug'] = apply_filters( 'FHEE_Invoice__send_invoice__shameless_plug',true ); |
|
123 | - if(isset($_GET['receipt'])){ |
|
121 | + $template_args['template_payment_instructions'] = wpautop(stripslashes_deep(html_entity_decode($this->invoice_payment_method->get_extra_meta('pdf_instructions', TRUE), ENT_QUOTES))); |
|
122 | + $template_args['shameless_plug'] = apply_filters('FHEE_Invoice__send_invoice__shameless_plug', true); |
|
123 | + if (isset($_GET['receipt'])) { |
|
124 | 124 | //receipt-specific stuff |
125 | 125 | $events_for_txn = EEM_Event::instance()->get_all(array(array('Registration.TXN_ID'=>$this->transaction->ID()))); |
126 | 126 | $ticket_line_items_per_event = array(); |
127 | 127 | $registrations_per_line_item = array(); |
128 | 128 | $venues_for_events = array(); |
129 | - foreach($events_for_txn as $event_id => $event){ |
|
130 | - $line_items_for_this_event = EEM_Line_Item::instance()->get_all(array(array('Ticket.Datetime.EVT_ID'=>$event_id,'TXN_ID'=>$this->transaction->ID()))); |
|
129 | + foreach ($events_for_txn as $event_id => $event) { |
|
130 | + $line_items_for_this_event = EEM_Line_Item::instance()->get_all(array(array('Ticket.Datetime.EVT_ID'=>$event_id, 'TXN_ID'=>$this->transaction->ID()))); |
|
131 | 131 | $ticket_line_items_per_event[$event_id] = $line_items_for_this_event; |
132 | - foreach($line_items_for_this_event as $line_item_id => $line_item){ |
|
132 | + foreach ($line_items_for_this_event as $line_item_id => $line_item) { |
|
133 | 133 | $ticket = $line_item->ticket(); |
134 | - $registrations_for_this_ticket = EEM_Registration::instance()->get_all(array(array('TKT_ID'=>$ticket->ID(),'TXN_ID'=>$this->transaction->ID()))); |
|
134 | + $registrations_for_this_ticket = EEM_Registration::instance()->get_all(array(array('TKT_ID'=>$ticket->ID(), 'TXN_ID'=>$this->transaction->ID()))); |
|
135 | 135 | $registrations_per_line_item[$line_item_id] = $registrations_for_this_ticket; |
136 | 136 | } |
137 | 137 | $venues_for_events = array_merge($venues_for_events, $event->venues()); |
138 | 138 | } |
139 | - $tax_total_line_item = EEM_Line_Item::instance()->get_one(array(array('TXN_ID'=>$this->transaction->ID(),'LIN_type'=> EEM_Line_Item::type_tax_sub_total))); |
|
140 | - $questions_to_skip = array(EEM_Attendee::system_question_fname,EEM_Attendee::system_question_lname, EEM_Attendee::system_question_email); |
|
139 | + $tax_total_line_item = EEM_Line_Item::instance()->get_one(array(array('TXN_ID'=>$this->transaction->ID(), 'LIN_type'=> EEM_Line_Item::type_tax_sub_total))); |
|
140 | + $questions_to_skip = array(EEM_Attendee::system_question_fname, EEM_Attendee::system_question_lname, EEM_Attendee::system_question_email); |
|
141 | 141 | |
142 | 142 | |
143 | 143 | $template_args['events_for_txn'] = $events_for_txn; |
@@ -148,53 +148,53 @@ discard block |
||
148 | 148 | $template_args['questions_to_skip'] = $questions_to_skip; |
149 | 149 | // d($template_args); |
150 | 150 | $template_args['download_link'] = $this->registration->receipt_url('download'); |
151 | - }else{ |
|
151 | + } else { |
|
152 | 152 | //it's just an invoice we're accessing |
153 | 153 | $template_args['download_link'] = $this->registration->invoice_url('download'); |
154 | 154 | } |
155 | 155 | |
156 | 156 | //Get the HTML as an object |
157 | 157 | $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
158 | - $template_header = EEH_Template::locate_template( $templates_relative_path . 'invoice_header.template.php', $template_args, TRUE, TRUE ); |
|
159 | - if(isset($_GET['receipt'])){ |
|
160 | - $template_body = EEH_Template::locate_template( $templates_relative_path . 'receipt_body.template.php', $template_args, TRUE, TRUE ); |
|
161 | - }else{ |
|
162 | - $template_body = EEH_Template::locate_template( $templates_relative_path . 'invoice_body.template.php', $template_args, TRUE, TRUE ); |
|
158 | + $template_header = EEH_Template::locate_template($templates_relative_path.'invoice_header.template.php', $template_args, TRUE, TRUE); |
|
159 | + if (isset($_GET['receipt'])) { |
|
160 | + $template_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', $template_args, TRUE, TRUE); |
|
161 | + } else { |
|
162 | + $template_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', $template_args, TRUE, TRUE); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
166 | - $template_footer = EEH_Template::locate_template( $templates_relative_path . 'invoice_footer.template.php', $template_args, TRUE, TRUE ); |
|
166 | + $template_footer = EEH_Template::locate_template($templates_relative_path.'invoice_footer.template.php', $template_args, TRUE, TRUE); |
|
167 | 167 | |
168 | - $copies = ! empty( $_REQUEST['copies'] ) ? $_REQUEST['copies'] : 1; |
|
168 | + $copies = ! empty($_REQUEST['copies']) ? $_REQUEST['copies'] : 1; |
|
169 | 169 | |
170 | 170 | $content = $this->espresso_replace_invoice_shortcodes($template_header); |
171 | - for( $x = 1; $x <= $copies; $x++ ) { |
|
171 | + for ($x = 1; $x <= $copies; $x++) { |
|
172 | 172 | $content .= $this->espresso_replace_invoice_shortcodes($template_body); |
173 | 173 | } |
174 | 174 | $content .= $this->espresso_replace_invoice_shortcodes($template_footer); |
175 | 175 | |
176 | 176 | //Check if debugging or mobile is set |
177 | - if (!empty($_REQUEST['html'])) { |
|
177 | + if ( ! empty($_REQUEST['html'])) { |
|
178 | 178 | echo $content; |
179 | 179 | exit(0); |
180 | 180 | } |
181 | - $invoice_name = $template_args['organization'] . ' ' . __('Invoice #', 'event_espresso') . $template_args['registration_code'] . __(' for ', 'event_espresso') . $template_args['name']; |
|
182 | - $invoice_name = str_replace( ' ', '_', $invoice_name ); |
|
181 | + $invoice_name = $template_args['organization'].' '.__('Invoice #', 'event_espresso').$template_args['registration_code'].__(' for ', 'event_espresso').$template_args['name']; |
|
182 | + $invoice_name = str_replace(' ', '_', $invoice_name); |
|
183 | 183 | //Create the PDF |
184 | - if(array_key_exists('html',$_GET)){ |
|
184 | + if (array_key_exists('html', $_GET)) { |
|
185 | 185 | echo $content; |
186 | - }else{ |
|
186 | + } else { |
|
187 | 187 | //only load dompdf if nobody else has yet... |
188 | - if( ! defined('DOMPDF_DIR')){ |
|
188 | + if ( ! defined('DOMPDF_DIR')) { |
|
189 | 189 | define('DOMPDF_ENABLE_REMOTE', TRUE); |
190 | 190 | define('DOMPDF_ENABLE_JAVASCRIPT', FALSE); |
191 | 191 | define('DOMPDF_ENABLE_CSS_FLOAT', TRUE); |
192 | - require_once(EE_THIRD_PARTY . 'dompdf/dompdf_config.inc.php'); |
|
192 | + require_once(EE_THIRD_PARTY.'dompdf/dompdf_config.inc.php'); |
|
193 | 193 | } |
194 | 194 | $dompdf = new DOMPDF(); |
195 | 195 | $dompdf->load_html($content); |
196 | 196 | $dompdf->render(); |
197 | - $dompdf->stream($invoice_name . ".pdf", array( 'Attachment' => $download )); |
|
197 | + $dompdf->stream($invoice_name.".pdf", array('Attachment' => $download)); |
|
198 | 198 | } |
199 | 199 | exit(0); |
200 | 200 | } |
@@ -204,12 +204,12 @@ discard block |
||
204 | 204 | * @param EE_Line_Item $line_item |
205 | 205 | * @return boolean |
206 | 206 | */ |
207 | - function check_if_any_line_items_have_a_description(EE_Line_Item $line_item){ |
|
208 | - if($line_item->desc()){ |
|
207 | + function check_if_any_line_items_have_a_description(EE_Line_Item $line_item) { |
|
208 | + if ($line_item->desc()) { |
|
209 | 209 | return true; |
210 | - }else{ |
|
211 | - foreach($line_item->children() as $child_line_item){ |
|
212 | - if($this->check_if_any_line_items_have_a_description($child_line_item)){ |
|
210 | + } else { |
|
211 | + foreach ($line_item->children() as $child_line_item) { |
|
212 | + if ($this->check_if_any_line_items_have_a_description($child_line_item)) { |
|
213 | 213 | return true; |
214 | 214 | } |
215 | 215 | } |
@@ -219,14 +219,14 @@ discard block |
||
219 | 219 | } |
220 | 220 | |
221 | 221 | //Perform the shortcode replacement |
222 | - function espresso_replace_invoice_shortcodes( $content ) { |
|
222 | + function espresso_replace_invoice_shortcodes($content) { |
|
223 | 223 | |
224 | 224 | $EE = EE_Registry::instance(); |
225 | 225 | //Create the logo |
226 | - $invoice_logo_url = $this->invoice_payment_method->get_extra_meta('pdf_logo_image', TRUE, $EE->CFG->organization->logo_url ); |
|
227 | - if (!empty($invoice_logo_url)) { |
|
226 | + $invoice_logo_url = $this->invoice_payment_method->get_extra_meta('pdf_logo_image', TRUE, $EE->CFG->organization->logo_url); |
|
227 | + if ( ! empty($invoice_logo_url)) { |
|
228 | 228 | $image_size = getimagesize($invoice_logo_url); |
229 | - $invoice_logo_image = '<img class="logo screen" src="' . $invoice_logo_url . '" ' . $image_size[3] . ' alt="logo" /> '; |
|
229 | + $invoice_logo_image = '<img class="logo screen" src="'.$invoice_logo_url.'" '.$image_size[3].' alt="logo" /> '; |
|
230 | 230 | } else { |
231 | 231 | $invoice_logo_image = ''; |
232 | 232 | } |
@@ -248,28 +248,28 @@ discard block |
||
248 | 248 | "[instructions]", |
249 | 249 | ); |
250 | 250 | $primary_attendee = $this->transaction->primary_registration()->attendee(); |
251 | - $org_state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $EE->CFG->organization->STA_ID ); |
|
252 | - if($org_state){ |
|
251 | + $org_state = EE_Registry::instance()->load_model('State')->get_one_by_ID($EE->CFG->organization->STA_ID); |
|
252 | + if ($org_state) { |
|
253 | 253 | $org_state_name = $org_state->name(); |
254 | - }else{ |
|
254 | + } else { |
|
255 | 255 | $org_state_name = ''; |
256 | 256 | } |
257 | 257 | $ReplaceValues = array( |
258 | - $EE->CFG->organization->get_pretty( 'name' ), |
|
258 | + $EE->CFG->organization->get_pretty('name'), |
|
259 | 259 | $this->registration->reg_code(), |
260 | 260 | $this->transaction->ID(), |
261 | 261 | $primary_attendee->full_name(), |
262 | - (is_dir(EVENT_ESPRESSO_GATEWAY_DIR . '/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL . 'Invoice/lib/templates/' : EE_GATEWAYS_URL . 'Invoice/lib/templates/', |
|
263 | - $this->registration->invoice_url(),//home_url() . '/?download_invoice=true&id=' . $this->registration->reg_url_link(), |
|
262 | + (is_dir(EVENT_ESPRESSO_GATEWAY_DIR.'/invoice')) ? EVENT_ESPRESSO_GATEWAY_URL.'Invoice/lib/templates/' : EE_GATEWAYS_URL.'Invoice/lib/templates/', |
|
263 | + $this->registration->invoice_url(), //home_url() . '/?download_invoice=true&id=' . $this->registration->reg_url_link(), |
|
264 | 264 | $invoice_logo_image, |
265 | - empty( $EE->CFG->organization->address_2 ) ? $EE->CFG->organization->get_pretty( 'address_1' ) : $EE->CFG->organization->get_pretty( 'address_1' ) . '<br>' . $EE->CFG->organization->get_pretty( 'address_2' ), |
|
266 | - $EE->CFG->organization->get_pretty( 'city' ), |
|
265 | + empty($EE->CFG->organization->address_2) ? $EE->CFG->organization->get_pretty('address_1') : $EE->CFG->organization->get_pretty('address_1').'<br>'.$EE->CFG->organization->get_pretty('address_2'), |
|
266 | + $EE->CFG->organization->get_pretty('city'), |
|
267 | 267 | $org_state_name, |
268 | - $EE->CFG->organization->get_pretty( 'zip' ), |
|
269 | - $EE->CFG->organization->get_pretty( 'email' ), |
|
268 | + $EE->CFG->organization->get_pretty('zip'), |
|
269 | + $EE->CFG->organization->get_pretty('email'), |
|
270 | 270 | $EE->CFG->organization->vat, |
271 | - $this->registration->get_i18n_datetime( 'REG_date', get_option( 'date_format' ) ), |
|
272 | - $this->invoice_payment_method->get_extra_meta( 'pdf_instructions', TRUE ), |
|
271 | + $this->registration->get_i18n_datetime('REG_date', get_option('date_format')), |
|
272 | + $this->invoice_payment_method->get_extra_meta('pdf_instructions', TRUE), |
|
273 | 273 | ); |
274 | 274 | |
275 | 275 | return str_replace($SearchValues, $ReplaceValues, $content); |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | if ($total_cost < 0) { |
293 | 293 | $total_cost = (-1) * $total_cost; |
294 | 294 | } |
295 | - $find = array( ' ' ); |
|
296 | - $replace = array( '-' ); |
|
297 | - $row_id = strtolower( str_replace( $find, $replace, $text )); |
|
295 | + $find = array(' '); |
|
296 | + $replace = array('-'); |
|
297 | + $row_id = strtolower(str_replace($find, $replace, $text)); |
|
298 | 298 | $html .= '<tr id="'.$row_id.'-tr"><td colspan="4"> </td>'; |
299 | - $html .= '<td class="item_r">' . $text . '</td>'; |
|
300 | - $html .= '<td class="item_r">' . $total_cost . '</td>'; |
|
299 | + $html .= '<td class="item_r">'.$text.'</td>'; |
|
300 | + $html .= '<td class="item_r">'.$total_cost.'</td>'; |
|
301 | 301 | $html .= '</tr>'; |
302 | 302 | return $html; |
303 | 303 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @return EED_Ical |
33 | 33 | */ |
34 | 34 | public static function instance() { |
35 | - return parent::get_instance( __CLASS__ ); |
|
35 | + return parent::get_instance(__CLASS__); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public static function set_hooks() { |
47 | 47 | // create download buttons |
48 | - add_filter( 'FHEE__espresso_list_of_event_dates__datetime_html', array( 'EED_Ical', 'generate_add_to_iCal_button' ), 10, 2 ); |
|
48 | + add_filter('FHEE__espresso_list_of_event_dates__datetime_html', array('EED_Ical', 'generate_add_to_iCal_button'), 10, 2); |
|
49 | 49 | // process ics download request |
50 | - EE_Config::register_route( 'download_ics_file', 'EED_Ical', 'download_ics_file' ); |
|
50 | + EE_Config::register_route('download_ics_file', 'EED_Ical', 'download_ics_file'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param WP $WP |
71 | 71 | * @return void |
72 | 72 | */ |
73 | - public function run( $WP ) {} |
|
73 | + public function run($WP) {} |
|
74 | 74 | |
75 | 75 | |
76 | 76 | |
@@ -82,30 +82,30 @@ discard block |
||
82 | 82 | * @param $datetime |
83 | 83 | * @return string |
84 | 84 | */ |
85 | - public static function generate_add_to_iCal_button( $html, $datetime ) { |
|
85 | + public static function generate_add_to_iCal_button($html, $datetime) { |
|
86 | 86 | // first verify a proper datetime object has been received |
87 | - if ( $datetime instanceof EE_Datetime ) { |
|
87 | + if ($datetime instanceof EE_Datetime) { |
|
88 | 88 | // set whether a link or submit button is shown |
89 | - $iCal_type = apply_filters( 'FHEE__EED_Ical__generate_add_to_iCal_button__iCal_type', 'submit' ); |
|
89 | + $iCal_type = apply_filters('FHEE__EED_Ical__generate_add_to_iCal_button__iCal_type', 'submit'); |
|
90 | 90 | // generate a link to the route we registered in set_hooks() |
91 | - $URL = add_query_arg( array( 'ee' => 'download_ics_file', 'ics_id' => $datetime->ID() ), site_url() ); |
|
91 | + $URL = add_query_arg(array('ee' => 'download_ics_file', 'ics_id' => $datetime->ID()), site_url()); |
|
92 | 92 | // what type ? |
93 | - switch ( $iCal_type ) { |
|
93 | + switch ($iCal_type) { |
|
94 | 94 | // submit buttons appear as buttons and are very compatible with a theme's style |
95 | 95 | case 'submit' : |
96 | - $html .= '<form id="download-iCal-frm-' . $datetime->ID() . '" class="download-iCal-frm" action="' . $URL . '" method="post" >'; |
|
97 | - $html .= '<input type="submit" class="ee-ical-sbmt" value="" title="' . __( 'Add to iCal Calendar', 'event_espresso' ) . '"/>'; |
|
96 | + $html .= '<form id="download-iCal-frm-'.$datetime->ID().'" class="download-iCal-frm" action="'.$URL.'" method="post" >'; |
|
97 | + $html .= '<input type="submit" class="ee-ical-sbmt" value="" title="'.__('Add to iCal Calendar', 'event_espresso').'"/>'; |
|
98 | 98 | $html .= '</form>'; |
99 | 99 | break; |
100 | 100 | // buttons are just links that have been styled to appear as buttons, but may not be blend with a theme as well as submit buttons |
101 | 101 | case 'button' : |
102 | - $html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="' . $URL . '" title="' . __( 'Add to iCal Calendar', 'event_espresso' ) . '">'; |
|
102 | + $html .= '<a class="ee-ical-btn small ee-button ee-roundish" href="'.$URL.'" title="'.__('Add to iCal Calendar', 'event_espresso').'">'; |
|
103 | 103 | $html .= ' <span class="dashicons dashicons-calendar"></span>'; |
104 | 104 | $html .= '</a>'; |
105 | 105 | break; |
106 | 106 | // links are just links that use the calendar dashicon |
107 | 107 | case 'icon' : |
108 | - $html .= '<a class="ee-ical-lnk" href="' . $URL . '" title="' . __( 'Add to iCal Calendar', 'event_espresso' ) . '">'; |
|
108 | + $html .= '<a class="ee-ical-lnk" href="'.$URL.'" title="'.__('Add to iCal Calendar', 'event_espresso').'">'; |
|
109 | 109 | $html .= ' <span class="dashicons dashicons-calendar"></span>'; |
110 | 110 | $html .= '</a>'; |
111 | 111 | break; |
@@ -123,72 +123,72 @@ discard block |
||
123 | 123 | * @return void |
124 | 124 | */ |
125 | 125 | public static function download_ics_file() { |
126 | - if ( EE_Registry::instance()->REQ->is_set( 'ics_id' )) { |
|
127 | - $DTT_ID = absint( EE_Registry::instance()->REQ->get( 'ics_id' )); |
|
128 | - $datetime = EE_Registry::instance()->load_model( 'Datetime' )->get_one_by_ID( $DTT_ID ); |
|
129 | - if ( $datetime instanceof EE_Datetime ) { |
|
126 | + if (EE_Registry::instance()->REQ->is_set('ics_id')) { |
|
127 | + $DTT_ID = absint(EE_Registry::instance()->REQ->get('ics_id')); |
|
128 | + $datetime = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($DTT_ID); |
|
129 | + if ($datetime instanceof EE_Datetime) { |
|
130 | 130 | // get related event, venues, and event categories |
131 | 131 | $event = $datetime->event(); |
132 | 132 | // get related category Term object and it's name |
133 | 133 | $category = $event->first_event_category(); |
134 | - if ( $category instanceof EE_Term ) { |
|
134 | + if ($category instanceof EE_Term) { |
|
135 | 135 | $category = $category->name(); |
136 | 136 | } |
137 | 137 | $location = ''; |
138 | 138 | // get first related venue and convert to CSV string |
139 | - $venue = $event->venues(array( 'limit'=>1 )); |
|
140 | - if ( is_array( $venue ) && ! empty( $venue )) { |
|
141 | - $venue = array_shift( $venue ); |
|
142 | - if ( $venue instanceof EE_Venue ) { |
|
143 | - $location = espresso_venue_raw_address( 'inline', $venue->ID(), FALSE ); |
|
139 | + $venue = $event->venues(array('limit'=>1)); |
|
140 | + if (is_array($venue) && ! empty($venue)) { |
|
141 | + $venue = array_shift($venue); |
|
142 | + if ($venue instanceof EE_Venue) { |
|
143 | + $location = espresso_venue_raw_address('inline', $venue->ID(), FALSE); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | // set variables, escape strings, convert timestamps to ics format, etc |
147 | - $filename = $event->slug() . '-' . $datetime->start_date( 'Y-m-d' ) . '.ics'; |
|
148 | - $organizer = EED_Ical::_escape_ICal_data( EE_Registry::instance()->CFG->organization->name ); |
|
149 | - $UID = EED_Ical::_escape_ICal_data( md5( $event->name() . $event->ID() . $datetime->ID() )); |
|
150 | - $org_email = EED_Ical::_escape_ICal_data( $datetime->ID() ); |
|
151 | - $timestamp = date( EED_Ical::iCal_datetime_format ); |
|
152 | - $location = EED_Ical::_escape_ICal_data( $location ); |
|
153 | - $summary = EED_Ical::_escape_ICal_data( $event->name() ); |
|
154 | - $description = EED_Ical::_escape_ICal_description( wp_strip_all_tags( $event->description() )); |
|
147 | + $filename = $event->slug().'-'.$datetime->start_date('Y-m-d').'.ics'; |
|
148 | + $organizer = EED_Ical::_escape_ICal_data(EE_Registry::instance()->CFG->organization->name); |
|
149 | + $UID = EED_Ical::_escape_ICal_data(md5($event->name().$event->ID().$datetime->ID())); |
|
150 | + $org_email = EED_Ical::_escape_ICal_data($datetime->ID()); |
|
151 | + $timestamp = date(EED_Ical::iCal_datetime_format); |
|
152 | + $location = EED_Ical::_escape_ICal_data($location); |
|
153 | + $summary = EED_Ical::_escape_ICal_data($event->name()); |
|
154 | + $description = EED_Ical::_escape_ICal_description(wp_strip_all_tags($event->description())); |
|
155 | 155 | $status = $datetime->get_active_status(); |
156 | 156 | $status = $status == EE_Datetime::cancelled ? 'Cancelled' : 'Confirmed'; |
157 | - $status = EED_Ical::_escape_ICal_data( $status ); |
|
158 | - $categories = EED_Ical::_escape_ICal_data( $category ); |
|
159 | - $url = EED_Ical::_escape_ICal_data( get_permalink( $event->ID() )); |
|
160 | - $dtt_start = EED_Ical::_escape_ICal_data( date( EED_Ical::iCal_datetime_format, $datetime->start() )); |
|
161 | - $dtt_end = EED_Ical::_escape_ICal_data( date( EED_Ical::iCal_datetime_format, $datetime->end() )); |
|
157 | + $status = EED_Ical::_escape_ICal_data($status); |
|
158 | + $categories = EED_Ical::_escape_ICal_data($category); |
|
159 | + $url = EED_Ical::_escape_ICal_data(get_permalink($event->ID())); |
|
160 | + $dtt_start = EED_Ical::_escape_ICal_data(date(EED_Ical::iCal_datetime_format, $datetime->start())); |
|
161 | + $dtt_end = EED_Ical::_escape_ICal_data(date(EED_Ical::iCal_datetime_format, $datetime->end())); |
|
162 | 162 | // set headers |
163 | - header( 'Content-type: text/calendar; charset=utf-8' ); |
|
164 | - header( 'Content-Disposition: attachment; filename="' . $filename . '"' ); |
|
165 | - header( 'Cache-Control: private, max-age=0, must-revalidate' ); |
|
166 | - header( 'Pragma: public' ); |
|
167 | - header( 'Content-Type: application/octet-stream' ); |
|
168 | - header( 'Content-Type: application/force-download' ); |
|
169 | - header( 'Cache-Control: no-cache, must-revalidate' ); |
|
170 | - header( 'Content-Transfer-Encoding: binary' ); |
|
171 | - header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); // past date |
|
172 | - ini_set( 'zlib.output_compression', '0' ); |
|
163 | + header('Content-type: text/calendar; charset=utf-8'); |
|
164 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
165 | + header('Cache-Control: private, max-age=0, must-revalidate'); |
|
166 | + header('Pragma: public'); |
|
167 | + header('Content-Type: application/octet-stream'); |
|
168 | + header('Content-Type: application/force-download'); |
|
169 | + header('Cache-Control: no-cache, must-revalidate'); |
|
170 | + header('Content-Transfer-Encoding: binary'); |
|
171 | + header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // past date |
|
172 | + ini_set('zlib.output_compression', '0'); |
|
173 | 173 | // echo the output |
174 | - echo "BEGIN:VCALENDAR" . PHP_EOL; |
|
175 | - echo "VERSION:2.0" . PHP_EOL; |
|
176 | - echo "PRODID:-//{$organizer}//NONSGML PDA Calendar Version 1.0//EN" . PHP_EOL; |
|
177 | - echo "CALSCALE:GREGORIAN" . PHP_EOL; |
|
178 | - echo "BEGIN:VEVENT" . PHP_EOL; |
|
179 | - echo "UID:{$UID}" . PHP_EOL; |
|
180 | - echo "ORGANIZER:MAILTO:{$org_email}" . PHP_EOL; |
|
181 | - echo "DTSTAMP:{$timestamp}" . PHP_EOL; |
|
182 | - echo "LOCATION:{$location}" . PHP_EOL; |
|
183 | - echo "SUMMARY:{$summary}" . PHP_EOL; |
|
184 | - echo "DESCRIPTION:{$description}" . PHP_EOL; |
|
185 | - echo "STATUS:{$status}" . PHP_EOL; |
|
186 | - echo "CATEGORIES:{$categories}" . PHP_EOL; |
|
187 | - echo "URL;VALUE=URI:{$url}" . PHP_EOL; |
|
188 | - echo "DTSTART:{$dtt_start}" . PHP_EOL; |
|
189 | - echo "DTEND:{$dtt_end}" . PHP_EOL; |
|
190 | - echo "END:VEVENT" . PHP_EOL; |
|
191 | - echo "END:VCALENDAR" . PHP_EOL; |
|
174 | + echo "BEGIN:VCALENDAR".PHP_EOL; |
|
175 | + echo "VERSION:2.0".PHP_EOL; |
|
176 | + echo "PRODID:-//{$organizer}//NONSGML PDA Calendar Version 1.0//EN".PHP_EOL; |
|
177 | + echo "CALSCALE:GREGORIAN".PHP_EOL; |
|
178 | + echo "BEGIN:VEVENT".PHP_EOL; |
|
179 | + echo "UID:{$UID}".PHP_EOL; |
|
180 | + echo "ORGANIZER:MAILTO:{$org_email}".PHP_EOL; |
|
181 | + echo "DTSTAMP:{$timestamp}".PHP_EOL; |
|
182 | + echo "LOCATION:{$location}".PHP_EOL; |
|
183 | + echo "SUMMARY:{$summary}".PHP_EOL; |
|
184 | + echo "DESCRIPTION:{$description}".PHP_EOL; |
|
185 | + echo "STATUS:{$status}".PHP_EOL; |
|
186 | + echo "CATEGORIES:{$categories}".PHP_EOL; |
|
187 | + echo "URL;VALUE=URI:{$url}".PHP_EOL; |
|
188 | + echo "DTSTART:{$dtt_start}".PHP_EOL; |
|
189 | + echo "DTEND:{$dtt_end}".PHP_EOL; |
|
190 | + echo "END:VEVENT".PHP_EOL; |
|
191 | + echo "END:VCALENDAR".PHP_EOL; |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | die(); |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | * @param string $string |
204 | 204 | * @return string |
205 | 205 | */ |
206 | - private static function _escape_ICal_data( $string = '' ) { |
|
207 | - return preg_replace( '/([\,;])/', '\\\$1', $string ); |
|
206 | + private static function _escape_ICal_data($string = '') { |
|
207 | + return preg_replace('/([\,;])/', '\\\$1', $string); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | * @param string $description |
215 | 215 | * @return string |
216 | 216 | */ |
217 | - private static function _escape_ICal_description( $description = '' ) { |
|
217 | + private static function _escape_ICal_description($description = '') { |
|
218 | 218 | |
219 | 219 | //Escape spcial chars within the decription |
220 | - $description = EED_Ical::_escape_ICal_data( $description ); |
|
220 | + $description = EED_Ical::_escape_ICal_data($description); |
|
221 | 221 | |
222 | 222 | //Remove line breaks and output in iCal format |
223 | - $description = str_replace( array( "\r\n", "\n"), '\n', $description ); |
|
223 | + $description = str_replace(array("\r\n", "\n"), '\n', $description); |
|
224 | 224 | |
225 | 225 | return $description; |
226 | 226 | } |
@@ -57,15 +57,15 @@ discard block |
||
57 | 57 | * @return EED_Ticket_Selector |
58 | 58 | */ |
59 | 59 | public static function instance() { |
60 | - return parent::get_instance( __CLASS__ ); |
|
60 | + return parent::get_instance(__CLASS__); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | |
65 | - protected function set_config(){ |
|
66 | - $this->set_config_section( 'template_settings' ); |
|
67 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
68 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
65 | + protected function set_config() { |
|
66 | + $this->set_config_section('template_settings'); |
|
67 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
68 | + $this->set_config_name('EED_Ticket_Selector'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function set_hooks() { |
82 | 82 | // routing |
83 | - EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
|
84 | - EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
|
85 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
83 | + EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector'); |
|
84 | + EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections'); |
|
85 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
86 | 86 | //add_action( 'AHEE_event_details_before_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_open' ), 10, 1 ); |
87 | - add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
|
87 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
88 | 88 | //add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', array( 'EED_Ticket_Selector', 'display_ticket_selector_submit' ), 10, 1 ); |
89 | 89 | //add_action( 'AHEE_event_details_after_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_close' ), 10 ); |
90 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
90 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | * @return void |
100 | 100 | */ |
101 | 101 | public static function set_hooks_admin() { |
102 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
102 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
103 | 103 | //add button for iframe code to event editor. |
104 | - add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 ); |
|
105 | - add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 ); |
|
104 | + add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 4); |
|
105 | + add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | * @return void |
115 | 115 | */ |
116 | 116 | public static function set_definitions() { |
117 | - define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
118 | - define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
117 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
118 | + define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
119 | 119 | |
120 | 120 | //if config is not set, initialize |
121 | 121 | //If config is not set, set it. |
122 | - if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) { |
|
122 | + if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) { |
|
123 | 123 | EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config(); |
124 | 124 | } |
125 | - EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' ); |
|
125 | + EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso'); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @param object $WP |
134 | 134 | * @return void |
135 | 135 | */ |
136 | - public function run( $WP ) {} |
|
136 | + public function run($WP) {} |
|
137 | 137 | |
138 | 138 | |
139 | 139 | /** |
@@ -145,23 +145,23 @@ discard block |
||
145 | 145 | public function ticket_selector_iframe() { |
146 | 146 | self::$_in_iframe = true; |
147 | 147 | /** @type EEM_Event $EEM_Event */ |
148 | - $EEM_Event = EE_Registry::instance()->load_model( 'Event' ); |
|
148 | + $EEM_Event = EE_Registry::instance()->load_model('Event'); |
|
149 | 149 | $event = $EEM_Event->get_one_by_ID( |
150 | - EE_Registry::instance()->REQ->get( 'event', 0 ) |
|
150 | + EE_Registry::instance()->REQ->get('event', 0) |
|
151 | 151 | ); |
152 | - EE_Registry::instance()->REQ->set_espresso_page( true ); |
|
153 | - $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event ); |
|
152 | + EE_Registry::instance()->REQ->set_espresso_page(true); |
|
153 | + $template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event); |
|
154 | 154 | $template_args['css'] = apply_filters( |
155 | 155 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
156 | 156 | array( |
157 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
158 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION, |
|
159 | - includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ), |
|
160 | - EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION |
|
157 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION, |
|
158 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION, |
|
159 | + includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']), |
|
160 | + EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION |
|
161 | 161 | ) |
162 | 162 | ); |
163 | - EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true; |
|
164 | - EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = __( 'Please choose at least one ticket before continuing.', 'event_espresso' ); |
|
163 | + EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true; |
|
164 | + EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = __('Please choose at least one ticket before continuing.', 'event_espresso'); |
|
165 | 165 | $template_args['eei18n'] = apply_filters( |
166 | 166 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings', |
167 | 167 | EE_Registry::localize_i18n_js_strings() |
@@ -169,18 +169,18 @@ discard block |
||
169 | 169 | $template_args['js'] = apply_filters( |
170 | 170 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
171 | 171 | array( |
172 | - includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ), |
|
173 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION, |
|
174 | - TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION |
|
172 | + includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']), |
|
173 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION, |
|
174 | + TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION |
|
175 | 175 | ) |
176 | 176 | ); |
177 | - $template_args[ 'notices' ] = EEH_Template::display_template( |
|
178 | - EE_TEMPLATES . 'espresso-ajax-notices.template.php', |
|
177 | + $template_args['notices'] = EEH_Template::display_template( |
|
178 | + EE_TEMPLATES.'espresso-ajax-notices.template.php', |
|
179 | 179 | array(), |
180 | 180 | true |
181 | 181 | ); |
182 | 182 | EEH_Template::display_template( |
183 | - TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php', |
|
183 | + TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php', |
|
184 | 184 | $template_args |
185 | 185 | ); |
186 | 186 | exit; |
@@ -199,23 +199,23 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @return string The new html string for the permalink area. |
201 | 201 | */ |
202 | - public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) { |
|
202 | + public static function iframe_code_button($permalink_string, $id, $new_title, $new_slug) { |
|
203 | 203 | //make sure this is ONLY when editing and the event id has been set. |
204 | - if ( ! empty( $id ) ) { |
|
205 | - $post = get_post( $id ); |
|
204 | + if ( ! empty($id)) { |
|
205 | + $post = get_post($id); |
|
206 | 206 | |
207 | 207 | //if NOT event then let's get out. |
208 | - if ( $post->post_type !== 'espresso_events' ) { |
|
208 | + if ($post->post_type !== 'espresso_events') { |
|
209 | 209 | return $permalink_string; |
210 | 210 | } |
211 | 211 | |
212 | - $ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() ); |
|
212 | + $ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url()); |
|
213 | 213 | |
214 | - $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">' . __('Embed', 'event_espresso') . '</a> '; |
|
214 | + $permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#" tabindex="-1">'.__('Embed', 'event_espresso').'</a> '; |
|
215 | 215 | $permalink_string .= ' |
216 | 216 | <div id="js-ts-iframe" style="display:none"> |
217 | 217 | <div style="width:100%; height: 500px;"> |
218 | - <iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe> |
|
218 | + <iframe src="' . $ticket_selector_url.'" width="100%" height="100%"></iframe> |
|
219 | 219 | </div> |
220 | 220 | </div>'; |
221 | 221 | } |
@@ -234,22 +234,22 @@ discard block |
||
234 | 234 | * @param mixed $event |
235 | 235 | * @return bool |
236 | 236 | */ |
237 | - protected static function set_event( $event = null ) { |
|
238 | - if( $event === null ) { |
|
237 | + protected static function set_event($event = null) { |
|
238 | + if ($event === null) { |
|
239 | 239 | global $post; |
240 | 240 | $event = $post; |
241 | 241 | } |
242 | - if ( $event instanceof EE_Event ) { |
|
242 | + if ($event instanceof EE_Event) { |
|
243 | 243 | self::$_event = $event; |
244 | - } else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) { |
|
244 | + } else if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) { |
|
245 | 245 | self::$_event = $event->EE_Event; |
246 | - } else if ( $event instanceof WP_Post && $event->post_type == 'espresso_events' ) { |
|
247 | - $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
246 | + } else if ($event instanceof WP_Post && $event->post_type == 'espresso_events') { |
|
247 | + $event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event); |
|
248 | 248 | self::$_event = $event->EE_Event; |
249 | 249 | } else { |
250 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
251 | - $dev_msg = $user_msg . __( 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso' ); |
|
252 | - EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
250 | + $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
|
251 | + $dev_msg = $user_msg.__('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso'); |
|
252 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
253 | 253 | return false; |
254 | 254 | } |
255 | 255 | return true; |
@@ -268,11 +268,11 @@ discard block |
||
268 | 268 | * @param bool $view_details |
269 | 269 | * @return string |
270 | 270 | */ |
271 | - public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
|
271 | + public static function display_ticket_selector($event = NULL, $view_details = FALSE) { |
|
272 | 272 | // reset filter for displaying submit button |
273 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
273 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
274 | 274 | // poke and prod incoming event till it tells us what it is |
275 | - if ( ! EED_Ticket_Selector::set_event( $event )) { |
|
275 | + if ( ! EED_Ticket_Selector::set_event($event)) { |
|
276 | 276 | return false; |
277 | 277 | } |
278 | 278 | $event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event; |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | && ( |
284 | 284 | ! self::$_event->display_ticket_selector() |
285 | 285 | || $view_details |
286 | - || post_password_required( $event_post ) |
|
286 | + || post_password_required($event_post) |
|
287 | 287 | || ( |
288 | 288 | $_event_active_status != EE_Datetime::active |
289 | 289 | && $_event_active_status != EE_Datetime::upcoming |
@@ -301,68 +301,68 @@ discard block |
||
301 | 301 | $template_args = array(); |
302 | 302 | $template_args['event_status'] = $_event_active_status; |
303 | 303 | |
304 | - $template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) ); |
|
305 | - $template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) ); |
|
304 | + $template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format')); |
|
305 | + $template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format')); |
|
306 | 306 | |
307 | 307 | $template_args['EVT_ID'] = self::$_event->ID(); |
308 | 308 | $template_args['event'] = self::$_event; |
309 | 309 | |
310 | 310 | // is the event expired ? |
311 | 311 | $template_args['event_is_expired'] = self::$_event->is_expired(); |
312 | - if ( $template_args['event_is_expired'] ) { |
|
313 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso' ) . '</span></div>'; |
|
312 | + if ($template_args['event_is_expired']) { |
|
313 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso').'</span></div>'; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | $ticket_query_args = array( |
317 | - array( 'Datetime.EVT_ID' => self::$_event->ID() ), |
|
318 | - 'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' ) |
|
317 | + array('Datetime.EVT_ID' => self::$_event->ID()), |
|
318 | + 'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC') |
|
319 | 319 | ); |
320 | 320 | |
321 | - if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) { |
|
321 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
322 | 322 | //use the correct applicable time query depending on what version of core is being run. |
323 | - $current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp'); |
|
324 | - $ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time ); |
|
323 | + $current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp'); |
|
324 | + $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | // get all tickets for this event ordered by the datetime |
328 | - $template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args ); |
|
328 | + $template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args); |
|
329 | 329 | |
330 | - if ( count( $template_args['tickets'] ) < 1 ) { |
|
331 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>'; |
|
330 | + if (count($template_args['tickets']) < 1) { |
|
331 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all ticket sales have ended.', 'event_espresso').'</span></div>'; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
335 | - $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit() ); |
|
336 | - if ( $template_args['max_atndz'] < 1 ) { |
|
337 | - $sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' ); |
|
338 | - if ( current_user_can( 'edit_post', self::$_event->ID() )) { |
|
339 | - $sales_closed_msg .= sprintf( |
|
340 | - __( '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso' ), |
|
335 | + $template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit()); |
|
336 | + if ($template_args['max_atndz'] < 1) { |
|
337 | + $sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso'); |
|
338 | + if (current_user_can('edit_post', self::$_event->ID())) { |
|
339 | + $sales_closed_msg .= sprintf( |
|
340 | + __('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso'), |
|
341 | 341 | '<div class="ee-attention" style="text-align: left;"><b>', |
342 | 342 | '</b><br />', |
343 | - $link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">', |
|
343 | + $link = '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link(self::$_event->ID()).'">', |
|
344 | 344 | '</a></span></div>' |
345 | 345 | ); |
346 | 346 | } |
347 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
347 | + return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>'; |
|
348 | 348 | } |
349 | 349 | |
350 | - $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php'; |
|
351 | - $templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event ); |
|
350 | + $templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php'; |
|
351 | + $templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event); |
|
352 | 352 | |
353 | 353 | // redirecting to another site for registration ?? |
354 | 354 | $external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE; |
355 | 355 | // set up the form (but not for the admin) |
356 | - $ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open( self::$_event->ID(), $external_url ) : ''; |
|
356 | + $ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open(self::$_event->ID(), $external_url) : ''; |
|
357 | 357 | // if not redirecting to another site for registration |
358 | - if ( ! $external_url ) { |
|
358 | + if ( ! $external_url) { |
|
359 | 359 | // then display the ticket selector |
360 | - $ticket_selector .= EEH_Template::locate_template( $templates['ticket_selector'], $template_args ); |
|
360 | + $ticket_selector .= EEH_Template::locate_template($templates['ticket_selector'], $template_args); |
|
361 | 361 | } else { |
362 | 362 | // if not we still need to trigger the display of the submit button |
363 | - add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
363 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
364 | 364 | //display notice to admin that registration is external |
365 | - $ticket_selector .= ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' ); |
|
365 | + $ticket_selector .= ! is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso'); |
|
366 | 366 | } |
367 | 367 | // submit button and form close tag |
368 | 368 | $ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : ''; |
@@ -382,25 +382,25 @@ discard block |
||
382 | 382 | * @param string $external_url |
383 | 383 | * @return string |
384 | 384 | */ |
385 | - public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) { |
|
385 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') { |
|
386 | 386 | // if redirecting, we don't need any anything else |
387 | - if ( $external_url ) { |
|
388 | - $html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">'; |
|
389 | - $query_args = EEH_URL::get_query_string( $external_url ); |
|
390 | - foreach ( $query_args as $query_arg => $value ) { |
|
391 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
387 | + if ($external_url) { |
|
388 | + $html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">'; |
|
389 | + $query_args = EEH_URL::get_query_string($external_url); |
|
390 | + foreach ($query_args as $query_arg => $value) { |
|
391 | + $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">'; |
|
392 | 392 | } |
393 | 393 | return $html; |
394 | 394 | } |
395 | - $checkout_url = EEH_Event_View::event_link_url( $ID ); |
|
396 | - if ( ! $checkout_url ) { |
|
397 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
395 | + $checkout_url = EEH_Event_View::event_link_url($ID); |
|
396 | + if ( ! $checkout_url) { |
|
397 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
398 | 398 | } |
399 | 399 | $extra_params = self::$_in_iframe ? ' target="_blank"' : ''; |
400 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
401 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE ); |
|
400 | + $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>'; |
|
401 | + $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE); |
|
402 | 402 | $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
403 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event ); |
|
403 | + $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event); |
|
404 | 404 | return $html; |
405 | 405 | } |
406 | 406 | |
@@ -415,23 +415,23 @@ discard block |
||
415 | 415 | * @return string |
416 | 416 | */ |
417 | 417 | public static function display_ticket_selector_submit() { |
418 | - if ( ! is_admin() ) { |
|
419 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE ) ) { |
|
418 | + if ( ! is_admin()) { |
|
419 | + if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE)) { |
|
420 | 420 | $btn_text = apply_filters( |
421 | 421 | 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
422 | - __('Register Now', 'event_espresso' ), |
|
422 | + __('Register Now', 'event_espresso'), |
|
423 | 423 | self::$_event |
424 | 424 | ); |
425 | 425 | $external_url = self::$_event->external_url(); |
426 | - $html = '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn"'; |
|
426 | + $html = '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn"'; |
|
427 | 427 | $html .= ' class="ticket-selector-submit-btn '; |
428 | - $html .= empty( $external_url ) ? 'ticket-selector-submit-ajax"' : '"'; |
|
429 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
430 | - $html .= apply_filters( 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event ); |
|
428 | + $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
429 | + $html .= ' type="submit" value="'.$btn_text.'" />'; |
|
430 | + $html .= apply_filters('FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event); |
|
431 | 431 | $html .= '<div class="clear"><br/></div></form>'; |
432 | 432 | return $html; |
433 | - } else if ( is_archive() ) { |
|
434 | - return EED_Ticket_Selector::ticket_selector_form_close() . EED_Ticket_Selector::display_view_details_btn(); |
|
433 | + } else if (is_archive()) { |
|
434 | + return EED_Ticket_Selector::ticket_selector_form_close().EED_Ticket_Selector::display_view_details_btn(); |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | return ''; |
@@ -463,13 +463,13 @@ discard block |
||
463 | 463 | * @return string |
464 | 464 | */ |
465 | 465 | public static function display_view_details_btn() { |
466 | - if ( ! self::$_event->get_permalink() ) { |
|
467 | - EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
466 | + if ( ! self::$_event->get_permalink()) { |
|
467 | + EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
468 | 468 | } |
469 | - $view_details_btn = '<form method="POST" action="' . self::$_event->get_permalink() . '">'; |
|
470 | - $btn_text = apply_filters( 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __( 'View Details', 'event_espresso' ), self::$_event ); |
|
471 | - $view_details_btn .= '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' . $btn_text . '" />'; |
|
472 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event ); |
|
469 | + $view_details_btn = '<form method="POST" action="'.self::$_event->get_permalink().'">'; |
|
470 | + $btn_text = apply_filters('FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __('View Details', 'event_espresso'), self::$_event); |
|
471 | + $view_details_btn .= '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'.$btn_text.'" />'; |
|
472 | + $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event); |
|
473 | 473 | $view_details_btn .= '<div class="clear"><br/></div>'; |
474 | 474 | $view_details_btn .= '</form>'; |
475 | 475 | return $view_details_btn; |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | * @return array or FALSE |
489 | 489 | */ |
490 | 490 | public function process_ticket_selections() { |
491 | - do_action( 'EED_Ticket_Selector__process_ticket_selections__before' ); |
|
491 | + do_action('EED_Ticket_Selector__process_ticket_selections__before'); |
|
492 | 492 | // check nonce |
493 | - if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set( 'process_ticket_selections_nonce' ) || ! wp_verify_nonce( EE_Registry::instance()->REQ->get( 'process_ticket_selections_nonce' ), 'process_ticket_selections' ))) { |
|
493 | + if ( ! is_admin() && ( ! EE_Registry::instance()->REQ->is_set('process_ticket_selections_nonce') || ! wp_verify_nonce(EE_Registry::instance()->REQ->get('process_ticket_selections_nonce'), 'process_ticket_selections'))) { |
|
494 | 494 | EE_Error::add_error( |
495 | - sprintf( __( 'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
495 | + sprintf(__('We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
496 | 496 | __FILE__, __FUNCTION__, __LINE__ |
497 | 497 | ); |
498 | 498 | return FALSE; |
@@ -506,16 +506,16 @@ discard block |
||
506 | 506 | |
507 | 507 | //we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart. |
508 | 508 | // When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc. |
509 | - EE_Registry::instance()->load_core( 'Session' ); |
|
509 | + EE_Registry::instance()->load_core('Session'); |
|
510 | 510 | // unless otherwise requested, clear the session |
511 | - if ( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE )) { |
|
512 | - EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ ); |
|
511 | + if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) { |
|
512 | + EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__); |
|
513 | 513 | } |
514 | 514 | //d( EE_Registry::instance()->SSN ); |
515 | 515 | |
516 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
516 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
517 | 517 | // do we have an event id? |
518 | - if ( EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) { |
|
518 | + if (EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) { |
|
519 | 519 | // validate/sanitize data |
520 | 520 | $valid = self::_validate_post_data(); |
521 | 521 | |
@@ -525,43 +525,43 @@ discard block |
||
525 | 525 | //EEH_Debug_Tools::printr( $valid[ 'max_atndz' ], 'max_atndz', __FILE__, __LINE__ ); |
526 | 526 | |
527 | 527 | //check total tickets ordered vs max number of attendees that can register |
528 | - if ( $valid['total_tickets'] > $valid['max_atndz'] ) { |
|
528 | + if ($valid['total_tickets'] > $valid['max_atndz']) { |
|
529 | 529 | |
530 | 530 | // ordering too many tickets !!! |
531 | 531 | $singular = 'You have attempted to purchase %s ticket.'; |
532 | 532 | $plural = 'You have attempted to purchase %s tickets.'; |
533 | - $limit_error_1 = sprintf( _n( $singular, $plural, $valid['total_tickets'], 'event_espresso' ), $valid['total_tickets'], $valid['total_tickets'] ); |
|
533 | + $limit_error_1 = sprintf(_n($singular, $plural, $valid['total_tickets'], 'event_espresso'), $valid['total_tickets'], $valid['total_tickets']); |
|
534 | 534 | // dev only message |
535 | 535 | $singular = 'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.'; |
536 | 536 | $plural = 'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.'; |
537 | - $limit_error_2 = sprintf( _n( $singular, $plural, $valid['max_atndz'], 'event_espresso' ), $valid['max_atndz'], $valid['max_atndz'] ); |
|
538 | - EE_Error::add_error( $limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__ ); |
|
537 | + $limit_error_2 = sprintf(_n($singular, $plural, $valid['max_atndz'], 'event_espresso'), $valid['max_atndz'], $valid['max_atndz']); |
|
538 | + EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__); |
|
539 | 539 | } else { |
540 | 540 | |
541 | 541 | // all data appears to be valid |
542 | 542 | $tckts_slctd = FALSE; |
543 | 543 | $success = TRUE; |
544 | 544 | // load cart |
545 | - EE_Registry::instance()->load_core( 'Cart' ); |
|
545 | + EE_Registry::instance()->load_core('Cart'); |
|
546 | 546 | |
547 | 547 | // cycle thru the number of data rows sent from the event listing |
548 | - for ( $x = 0; $x < $valid['rows']; $x++ ) { |
|
548 | + for ($x = 0; $x < $valid['rows']; $x++) { |
|
549 | 549 | // does this row actually contain a ticket quantity? |
550 | - if ( isset( $valid['qty'][$x] ) && $valid['qty'][$x] > 0 ) { |
|
550 | + if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) { |
|
551 | 551 | // YES we have a ticket quantity |
552 | 552 | $tckts_slctd = TRUE; |
553 | 553 | // d( $valid['ticket_obj'][$x] ); |
554 | - if ( $valid['ticket_obj'][$x] instanceof EE_Ticket ) { |
|
554 | + if ($valid['ticket_obj'][$x] instanceof EE_Ticket) { |
|
555 | 555 | // then add ticket to cart |
556 | - $ticket_added = self::_add_ticket_to_cart( $valid['ticket_obj'][$x], $valid['qty'][$x] ); |
|
556 | + $ticket_added = self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]); |
|
557 | 557 | $success = ! $ticket_added ? FALSE : $success; |
558 | - if ( EE_Error::has_error() ) { |
|
558 | + if (EE_Error::has_error()) { |
|
559 | 559 | break; |
560 | 560 | } |
561 | 561 | } else { |
562 | 562 | // nothing added to cart retrieved |
563 | 563 | EE_Error::add_error( |
564 | - sprintf( __( 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
564 | + sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
565 | 565 | __FILE__, __FUNCTION__, __LINE__ |
566 | 566 | ); |
567 | 567 | } |
@@ -570,45 +570,45 @@ discard block |
||
570 | 570 | //d( EE_Registry::instance()->CART ); |
571 | 571 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE |
572 | 572 | |
573 | - if ( $tckts_slctd ) { |
|
574 | - if ( $success ) { |
|
575 | - do_action( 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this ); |
|
573 | + if ($tckts_slctd) { |
|
574 | + if ($success) { |
|
575 | + do_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this); |
|
576 | 576 | EE_Registry::instance()->CART->recalculate_all_cart_totals(); |
577 | - EE_Registry::instance()->CART->save_cart( FALSE ); |
|
577 | + EE_Registry::instance()->CART->save_cart(FALSE); |
|
578 | 578 | EE_Registry::instance()->SSN->update(); |
579 | 579 | //d( EE_Registry::instance()->CART ); |
580 | 580 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE |
581 | 581 | // just return TRUE for registrations being made from admin |
582 | - if ( is_admin() ) { |
|
582 | + if (is_admin()) { |
|
583 | 583 | return TRUE; |
584 | 584 | } |
585 | - wp_safe_redirect( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url() )); |
|
585 | + wp_safe_redirect(apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url())); |
|
586 | 586 | exit(); |
587 | 587 | |
588 | 588 | } else { |
589 | - if ( ! EE_Error::has_error() ) { |
|
589 | + if ( ! EE_Error::has_error()) { |
|
590 | 590 | // nothing added to cart |
591 | - EE_Error::add_attention( __( 'No tickets were added for the event', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
591 | + EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | 595 | } else { |
596 | 596 | // no ticket quantities were selected |
597 | - EE_Error::add_error( __( 'You need to select a ticket quantity before you can proceed.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
597 | + EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
598 | 598 | } |
599 | 599 | } |
600 | 600 | //die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT |
601 | 601 | // at this point, just return if registration is being made from admin |
602 | - if ( is_admin() ) { |
|
602 | + if (is_admin()) { |
|
603 | 603 | return FALSE; |
604 | 604 | } |
605 | - if ( $valid['return_url'] ) { |
|
606 | - EE_Error::get_notices( FALSE, TRUE ); |
|
607 | - wp_safe_redirect( $valid['return_url'] ); |
|
605 | + if ($valid['return_url']) { |
|
606 | + EE_Error::get_notices(FALSE, TRUE); |
|
607 | + wp_safe_redirect($valid['return_url']); |
|
608 | 608 | exit(); |
609 | - } elseif ( isset( $event_to_add['id'] )) { |
|
610 | - EE_Error::get_notices( FALSE, TRUE ); |
|
611 | - wp_safe_redirect( get_permalink( $event_to_add['id'] )); |
|
609 | + } elseif (isset($event_to_add['id'])) { |
|
610 | + EE_Error::get_notices(FALSE, TRUE); |
|
611 | + wp_safe_redirect(get_permalink($event_to_add['id'])); |
|
612 | 612 | exit(); |
613 | 613 | } else { |
614 | 614 | echo EE_Error::get_notices(); |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | } else { |
618 | 618 | // $_POST['tkt-slctr-event-id'] was not set ?!?!?!? |
619 | 619 | EE_Error::add_error( |
620 | - sprintf( __( 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ), |
|
620 | + sprintf(__('An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'), |
|
621 | 621 | __FILE__, __FUNCTION__, __LINE__ |
622 | 622 | ); |
623 | 623 | } |
@@ -635,18 +635,18 @@ discard block |
||
635 | 635 | * @return array or FALSE |
636 | 636 | */ |
637 | 637 | private static function _validate_post_data() { |
638 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
638 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
639 | 639 | |
640 | 640 | // start with an empty array() |
641 | 641 | $valid_data = array(); |
642 | 642 | // d( $_POST ); |
643 | 643 | //if event id is valid |
644 | - $id = absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-event-id' )); |
|
645 | - if ( $id ) { |
|
644 | + $id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id')); |
|
645 | + if ($id) { |
|
646 | 646 | // grab valid id |
647 | 647 | $valid_data['id'] = $id; |
648 | 648 | // grab and sanitize return-url |
649 | - $valid_data['return_url'] = esc_url_raw( EE_Registry::instance()->REQ->get( 'tkt-slctr-return-url-' . $id )); |
|
649 | + $valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id)); |
|
650 | 650 | // array of other form names |
651 | 651 | $inputs_to_clean = array( |
652 | 652 | 'event_id' => 'tkt-slctr-event-id', |
@@ -659,22 +659,22 @@ discard block |
||
659 | 659 | // let's track the total number of tickets ordered.' |
660 | 660 | $valid_data['total_tickets'] = 0; |
661 | 661 | // cycle through $inputs_to_clean array |
662 | - foreach ( $inputs_to_clean as $what => $input_to_clean ) { |
|
662 | + foreach ($inputs_to_clean as $what => $input_to_clean) { |
|
663 | 663 | // check for POST data |
664 | - if ( EE_Registry::instance()->REQ->is_set( $input_to_clean . $id )) { |
|
664 | + if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) { |
|
665 | 665 | // grab value |
666 | - $input_value = EE_Registry::instance()->REQ->get( $input_to_clean . $id ); |
|
666 | + $input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id); |
|
667 | 667 | switch ($what) { |
668 | 668 | |
669 | 669 | // integers |
670 | 670 | case 'event_id': |
671 | - $valid_data[$what] = absint( $input_value ); |
|
671 | + $valid_data[$what] = absint($input_value); |
|
672 | 672 | // get event via the event id we put in the form |
673 | - $valid_data['event'] = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $valid_data['event_id'] ); |
|
673 | + $valid_data['event'] = EE_Registry::instance()->load_model('Event')->get_one_by_ID($valid_data['event_id']); |
|
674 | 674 | break; |
675 | 675 | case 'rows': |
676 | 676 | case 'max_atndz': |
677 | - $valid_data[$what] = absint( $input_value ); |
|
677 | + $valid_data[$what] = absint($input_value); |
|
678 | 678 | break; |
679 | 679 | |
680 | 680 | // arrays of integers |
@@ -682,27 +682,27 @@ discard block |
||
682 | 682 | // d( $input_value ); |
683 | 683 | $row_qty = $input_value; |
684 | 684 | // if qty is coming from a radio button input, then we need to assemble an array of rows |
685 | - if( ! is_array( $row_qty )) { |
|
685 | + if ( ! is_array($row_qty)) { |
|
686 | 686 | // get number of rows |
687 | - $rows = EE_Registry::instance()->REQ->is_set( 'tkt-slctr-rows-' . $id ) ? absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-rows-' . $id )) : 1; |
|
687 | + $rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id) ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id)) : 1; |
|
688 | 688 | // d( $rows ); |
689 | 689 | // explode ints by the dash |
690 | - $row_qty = explode( '-', $row_qty ); |
|
691 | - $row = isset( $row_qty[0] ) ? ( absint( $row_qty[0] )) : 1; |
|
692 | - $qty = isset( $row_qty[1] ) ? absint( $row_qty[1] ) : 0; |
|
693 | - $row_qty = array( $row => $qty ); |
|
690 | + $row_qty = explode('-', $row_qty); |
|
691 | + $row = isset($row_qty[0]) ? (absint($row_qty[0])) : 1; |
|
692 | + $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0; |
|
693 | + $row_qty = array($row => $qty); |
|
694 | 694 | // d( $row_qty ); |
695 | - for( $x = 1; $x <= $rows; $x++ ) { |
|
696 | - if ( ! isset( $row_qty[$x] )) { |
|
695 | + for ($x = 1; $x <= $rows; $x++) { |
|
696 | + if ( ! isset($row_qty[$x])) { |
|
697 | 697 | $row_qty[$x] = 0; |
698 | 698 | } |
699 | 699 | } |
700 | 700 | } |
701 | - ksort( $row_qty ); |
|
701 | + ksort($row_qty); |
|
702 | 702 | // d( $row_qty ); |
703 | 703 | // cycle thru values |
704 | - foreach ( $row_qty as $qty ) { |
|
705 | - $qty = absint( $qty ); |
|
704 | + foreach ($row_qty as $qty) { |
|
705 | + $qty = absint($qty); |
|
706 | 706 | // sanitize as integers |
707 | 707 | $valid_data[$what][] = $qty; |
708 | 708 | $valid_data['total_tickets'] += $qty; |
@@ -713,19 +713,19 @@ discard block |
||
713 | 713 | case 'ticket_id': |
714 | 714 | $value_array = array(); |
715 | 715 | // cycle thru values |
716 | - foreach ( $input_value as $key=>$value ) { |
|
716 | + foreach ($input_value as $key=>$value) { |
|
717 | 717 | // allow only numbers, letters, spaces, commas and dashes |
718 | - $value_array[ $key ] = wp_strip_all_tags( $value ); |
|
718 | + $value_array[$key] = wp_strip_all_tags($value); |
|
719 | 719 | // get ticket via the ticket id we put in the form |
720 | - $ticket_obj = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $value ); |
|
721 | - $valid_data['ticket_obj'][ $key ] = $ticket_obj; |
|
720 | + $ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value); |
|
721 | + $valid_data['ticket_obj'][$key] = $ticket_obj; |
|
722 | 722 | } |
723 | - $valid_data[ $what ] = $value_array; |
|
723 | + $valid_data[$what] = $value_array; |
|
724 | 724 | break; |
725 | 725 | |
726 | 726 | case 'return_url' : |
727 | 727 | // grab and sanitize return-url |
728 | - $valid_data[$what] = esc_url_raw( $input_value ); |
|
728 | + $valid_data[$what] = esc_url_raw($input_value); |
|
729 | 729 | break; |
730 | 730 | |
731 | 731 | } // end switch $what |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | } // end foreach $inputs_to_clean |
734 | 734 | |
735 | 735 | } else { |
736 | - EE_Error::add_error( __('The event id provided was not valid.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
736 | + EE_Error::add_error(__('The event id provided was not valid.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
737 | 737 | return FALSE; |
738 | 738 | } |
739 | 739 | |
@@ -751,28 +751,28 @@ discard block |
||
751 | 751 | * @param int $qty |
752 | 752 | * @return TRUE on success, FALSE on fail |
753 | 753 | */ |
754 | - private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) { |
|
755 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
754 | + private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1) { |
|
755 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
756 | 756 | // get the number of spaces left for this datetime ticket |
757 | - $available_spaces = self::_ticket_datetime_availability( $ticket ); |
|
757 | + $available_spaces = self::_ticket_datetime_availability($ticket); |
|
758 | 758 | // compare available spaces against the number of tickets being purchased |
759 | - if ( $available_spaces >= $qty ) { |
|
759 | + if ($available_spaces >= $qty) { |
|
760 | 760 | // allow addons to prevent a ticket from being added to cart |
761 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces ) ) { |
|
761 | + if ( ! apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart', true, $ticket, $qty, $available_spaces)) { |
|
762 | 762 | return false; |
763 | 763 | } |
764 | 764 | // add event to cart |
765 | - if( EE_Registry::instance()->CART->add_ticket_to_cart( $ticket, $qty )) { |
|
766 | - self::_recalculate_ticket_datetime_availability( $ticket, $qty ); |
|
765 | + if (EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) { |
|
766 | + self::_recalculate_ticket_datetime_availability($ticket, $qty); |
|
767 | 767 | return true; |
768 | 768 | } else { |
769 | 769 | return false; |
770 | 770 | } |
771 | 771 | } else { |
772 | 772 | // tickets can not be purchased but let's find the exact number left for the last ticket selected PRIOR to subtracting tickets |
773 | - $available_spaces = self::_ticket_datetime_availability( $ticket, true ); |
|
773 | + $available_spaces = self::_ticket_datetime_availability($ticket, true); |
|
774 | 774 | // greedy greedy greedy eh? |
775 | - if ( $available_spaces > 0 ) { |
|
775 | + if ($available_spaces > 0) { |
|
776 | 776 | // add error messaging - we're using the _n function that will generate the appropriate singular or plural message based on the number of $available_spaces |
777 | 777 | EE_Error::add_error( |
778 | 778 | sprintf( |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | __FILE__, __FUNCTION__, __LINE__ |
789 | 789 | ); |
790 | 790 | } else { |
791 | - EE_Error::add_error( __('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
791 | + EE_Error::add_error(__('We\'re sorry, but there are no available spaces left for this event at this particular date and time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
792 | 792 | } |
793 | 793 | return false; |
794 | 794 | } |
@@ -806,22 +806,22 @@ discard block |
||
806 | 806 | * @param bool $get_original_ticket_spaces |
807 | 807 | * @return int |
808 | 808 | */ |
809 | - private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) { |
|
809 | + private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = FALSE) { |
|
810 | 810 | // if the $_available_spaces array has not been set up yet... |
811 | - if ( ! isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
812 | - self::_set_initial_ticket_datetime_availability( $ticket ); |
|
811 | + if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
812 | + self::_set_initial_ticket_datetime_availability($ticket); |
|
813 | 813 | } |
814 | 814 | $available_spaces = $ticket->qty() - $ticket->sold(); |
815 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
815 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
816 | 816 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
817 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
817 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
818 | 818 | // if we want the original datetime availability BEFORE we started subtracting tickets ? |
819 | - if ( $get_original_ticket_spaces ) { |
|
819 | + if ($get_original_ticket_spaces) { |
|
820 | 820 | // then grab the available spaces from the "tickets" array and compare with the above to get the lowest number |
821 | - $available_spaces = min( $available_spaces, self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] ); |
|
821 | + $available_spaces = min($available_spaces, self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]); |
|
822 | 822 | } else { |
823 | 823 | // we want the updated ticket availability as stored in the "datetimes" array |
824 | - $available_spaces = min( $available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ] ); |
|
824 | + $available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]); |
|
825 | 825 | } |
826 | 826 | } |
827 | 827 | } |
@@ -837,23 +837,23 @@ discard block |
||
837 | 837 | * @param EE_Ticket $ticket |
838 | 838 | * @return int |
839 | 839 | */ |
840 | - private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) { |
|
840 | + private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket) { |
|
841 | 841 | // first, get all of the datetimes that are available to this ticket |
842 | 842 | $datetimes = $ticket->get_many_related( |
843 | 843 | 'Datetime', |
844 | - array( array( 'DTT_EVT_end' => array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' )) |
|
844 | + array(array('DTT_EVT_end' => array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))), 'order_by' => array('DTT_EVT_start' => 'ASC')) |
|
845 | 845 | ); |
846 | - if ( ! empty( $datetimes )) { |
|
846 | + if ( ! empty($datetimes)) { |
|
847 | 847 | // now loop thru all of the datetimes |
848 | - foreach ( $datetimes as $datetime ) { |
|
849 | - if ( $datetime instanceof EE_Datetime ) { |
|
848 | + foreach ($datetimes as $datetime) { |
|
849 | + if ($datetime instanceof EE_Datetime) { |
|
850 | 850 | // the number of spaces available for the datetime without considering individual ticket quantities |
851 | 851 | $spaces_remaining = $datetime->spaces_remaining(); |
852 | 852 | // save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold or the datetime spaces remaining) to this ticket using the datetime ID as the key |
853 | - self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(( $ticket->qty() - $ticket->sold() ), $spaces_remaining ); |
|
853 | + self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(($ticket->qty() - $ticket->sold()), $spaces_remaining); |
|
854 | 854 | // if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number, |
855 | 855 | // else just take the datetime spaces remaining, and assign to the datetimes array |
856 | - self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset( self::$_available_spaces['datetimes'][ $datetime->ID() ] ) ? min( self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining ) : $spaces_remaining; |
|
856 | + self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()]) ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) : $spaces_remaining; |
|
857 | 857 | } |
858 | 858 | } |
859 | 859 | } |
@@ -869,12 +869,12 @@ discard block |
||
869 | 869 | * @param int $qty |
870 | 870 | * @return int |
871 | 871 | */ |
872 | - private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) { |
|
873 | - if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) { |
|
872 | + private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0) { |
|
873 | + if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) { |
|
874 | 874 | // loop thru tickets, which will ALSO include individual ticket records AND a total |
875 | - foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces ) { |
|
875 | + foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) { |
|
876 | 876 | // subtract the qty of selected tickets from each datetime's available spaces this ticket has access to, |
877 | - self::$_available_spaces['datetimes'][ $DTD_ID ] = self::$_available_spaces['datetimes'][ $DTD_ID ] - $qty; |
|
877 | + self::$_available_spaces['datetimes'][$DTD_ID] = self::$_available_spaces['datetimes'][$DTD_ID] - $qty; |
|
878 | 878 | } |
879 | 879 | } |
880 | 880 | } |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | */ |
892 | 892 | public static function load_tckt_slctr_assets() { |
893 | 893 | // add some style |
894 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
|
895 | - wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'); |
|
894 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) { |
|
895 | + wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'); |
|
896 | 896 | wp_enqueue_style('ticket_selector'); |
897 | 897 | // make it dance |
898 | 898 | // wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE); |
@@ -906,9 +906,9 @@ discard block |
||
906 | 906 | |
907 | 907 | public static function load_tckt_slctr_assets_admin() { |
908 | 908 | //iframe button js on admin event editor page |
909 | - if ( EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit' ) { |
|
910 | - wp_register_script( 'ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, true ); |
|
911 | - wp_enqueue_script( 'ticket_selector_embed' ); |
|
909 | + if (EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit') { |
|
910 | + wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
911 | + wp_enqueue_script('ticket_selector_embed'); |
|
912 | 912 | } |
913 | 913 | } |
914 | 914 |
@@ -107,71 +107,71 @@ discard block |
||
107 | 107 | public function __toString() { |
108 | 108 | $JSON_response = array(); |
109 | 109 | // grab notices |
110 | - $notices = EE_Error::get_notices( FALSE ); |
|
111 | - $this->set_attention( isset( $notices['attention'] ) ? $notices['attention'] : '' ); |
|
112 | - $this->set_errors( isset( $notices['errors'] ) ? $notices['errors'] : '' ); |
|
113 | - $this->set_success( isset( $notices['success'] ) ? $notices['success'] : '' ); |
|
110 | + $notices = EE_Error::get_notices(FALSE); |
|
111 | + $this->set_attention(isset($notices['attention']) ? $notices['attention'] : ''); |
|
112 | + $this->set_errors(isset($notices['errors']) ? $notices['errors'] : ''); |
|
113 | + $this->set_success(isset($notices['success']) ? $notices['success'] : ''); |
|
114 | 114 | // add notices to JSON response, but only if they exist |
115 | - if ( $this->attention() ) { |
|
115 | + if ($this->attention()) { |
|
116 | 116 | $JSON_response['attention'] = $this->attention(); |
117 | 117 | } |
118 | - if ( $this->errors() ) { |
|
118 | + if ($this->errors()) { |
|
119 | 119 | $JSON_response['errors'] = $this->errors(); |
120 | 120 | } |
121 | - if ( $this->unexpected_errors() ) { |
|
121 | + if ($this->unexpected_errors()) { |
|
122 | 122 | $JSON_response['unexpected_errors'] = $this->unexpected_errors(); |
123 | 123 | } |
124 | - if ( $this->success() ) { |
|
124 | + if ($this->success()) { |
|
125 | 125 | $JSON_response['success'] = $this->success(); |
126 | 126 | } |
127 | 127 | // but if NO notices are set... at least set the "success" as a key so that the JS knows everything worked |
128 | - if ( ! isset( $JSON_response[ 'attention' ] ) && ! isset( $JSON_response[ 'errors' ] ) && ! isset( $JSON_response[ 'success' ] ) ) { |
|
128 | + if ( ! isset($JSON_response['attention']) && ! isset($JSON_response['errors']) && ! isset($JSON_response['success'])) { |
|
129 | 129 | $JSON_response['success'] = null; |
130 | 130 | } |
131 | 131 | // set redirect_url, IF it exists |
132 | - if ( $this->redirect_url() ) { |
|
132 | + if ($this->redirect_url()) { |
|
133 | 133 | $JSON_response['redirect_url'] = $this->redirect_url(); |
134 | 134 | } |
135 | 135 | // set registration_time_limit, IF it exists |
136 | - if ( $this->registration_time_limit() ) { |
|
136 | + if ($this->registration_time_limit()) { |
|
137 | 137 | $JSON_response['registration_time_limit'] = $this->registration_time_limit(); |
138 | 138 | } |
139 | 139 | // set payment_amount, IF it exists |
140 | - if ( $this->payment_amount() !== null ) { |
|
141 | - $JSON_response[ 'payment_amount' ] = $this->payment_amount(); |
|
140 | + if ($this->payment_amount() !== null) { |
|
141 | + $JSON_response['payment_amount'] = $this->payment_amount(); |
|
142 | 142 | } |
143 | 143 | // grab generic return data |
144 | 144 | $return_data = $this->return_data(); |
145 | 145 | // add billing form validation rules |
146 | - if ( $this->validation_rules() ) { |
|
146 | + if ($this->validation_rules()) { |
|
147 | 147 | $return_data['validation_rules'] = $this->validation_rules(); |
148 | 148 | } |
149 | 149 | // set reg_step_html, IF it exists |
150 | - if ( $this->reg_step_html() ) { |
|
150 | + if ($this->reg_step_html()) { |
|
151 | 151 | $return_data['reg_step_html'] = $this->reg_step_html(); |
152 | 152 | } |
153 | 153 | // set method of payment, IF it exists |
154 | - if ( $this->method_of_payment() ) { |
|
154 | + if ($this->method_of_payment()) { |
|
155 | 155 | $return_data['method_of_payment'] = $this->method_of_payment(); |
156 | 156 | } |
157 | 157 | // set "plz_select_method_of_payment" message, IF it exists |
158 | - if ( $this->plz_select_method_of_payment() ) { |
|
158 | + if ($this->plz_select_method_of_payment()) { |
|
159 | 159 | $return_data['plz_select_method_of_payment'] = $this->plz_select_method_of_payment(); |
160 | 160 | } |
161 | 161 | // set redirect_form, IF it exists |
162 | - if ( $this->redirect_form() ) { |
|
162 | + if ($this->redirect_form()) { |
|
163 | 163 | $return_data['redirect_form'] = $this->redirect_form(); |
164 | 164 | } |
165 | 165 | // and finally, add return_data array to main JSON response array, IF it contains anything |
166 | 166 | // why did we add some of the above properties to the return data array? |
167 | 167 | // because it is easier and cleaner in the Javascript to deal with this way |
168 | - if ( ! empty( $return_data )) { |
|
168 | + if ( ! empty($return_data)) { |
|
169 | 169 | $JSON_response['return_data'] = $return_data; |
170 | 170 | } |
171 | 171 | // filter final array |
172 | - $JSON_response = apply_filters( 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response ); |
|
172 | + $JSON_response = apply_filters('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', $JSON_response); |
|
173 | 173 | // return encoded array |
174 | - return json_encode( $JSON_response ); |
|
174 | + return json_encode($JSON_response); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | /** |
180 | 180 | * @param string $attention |
181 | 181 | */ |
182 | - public function set_attention( $attention ) { |
|
182 | + public function set_attention($attention) { |
|
183 | 183 | $this->_attention = $attention; |
184 | 184 | } |
185 | 185 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | /** |
198 | 198 | * @param string $errors |
199 | 199 | */ |
200 | - public function set_errors( $errors ) { |
|
200 | + public function set_errors($errors) { |
|
201 | 201 | $this->_errors = $errors; |
202 | 202 | } |
203 | 203 | |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | /** |
225 | 225 | * @param string $unexpected_errors |
226 | 226 | */ |
227 | - public function set_unexpected_errors( $unexpected_errors ) { |
|
227 | + public function set_unexpected_errors($unexpected_errors) { |
|
228 | 228 | $this->_unexpected_errors = $unexpected_errors; |
229 | 229 | } |
230 | 230 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | /** |
234 | 234 | * @param string $success |
235 | 235 | */ |
236 | - public function set_success( $success ) { |
|
236 | + public function set_success($success) { |
|
237 | 237 | $this->_success = $success; |
238 | 238 | } |
239 | 239 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | /** |
252 | 252 | * @param string $method_of_payment |
253 | 253 | */ |
254 | - public function set_method_of_payment( $method_of_payment ) { |
|
254 | + public function set_method_of_payment($method_of_payment) { |
|
255 | 255 | $this->_method_of_payment = $method_of_payment; |
256 | 256 | } |
257 | 257 | |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | /** |
279 | 279 | * @param float $payment_amount |
280 | 280 | */ |
281 | - public function set_payment_amount( $payment_amount ) { |
|
282 | - $this->_payment_amount = EEH_Money::convert_to_float_from_localized_money( $payment_amount ); |
|
281 | + public function set_payment_amount($payment_amount) { |
|
282 | + $this->_payment_amount = EEH_Money::convert_to_float_from_localized_money($payment_amount); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | /** |
288 | 288 | * @param string $next_step_html |
289 | 289 | */ |
290 | - public function set_reg_step_html( $next_step_html ) { |
|
290 | + public function set_reg_step_html($next_step_html) { |
|
291 | 291 | $this->_reg_step_html = $next_step_html; |
292 | 292 | } |
293 | 293 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | /** |
306 | 306 | * @param string $redirect_form |
307 | 307 | */ |
308 | - public function set_redirect_form( $redirect_form ) { |
|
308 | + public function set_redirect_form($redirect_form) { |
|
309 | 309 | $this->_redirect_form = $redirect_form; |
310 | 310 | } |
311 | 311 | |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @return string |
316 | 316 | */ |
317 | 317 | public function redirect_form() { |
318 | - return ! empty( $this->_redirect_form ) ? $this->_redirect_form : FALSE; |
|
318 | + return ! empty($this->_redirect_form) ? $this->_redirect_form : FALSE; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | /** |
324 | 324 | * @param string $plz_select_method_of_payment |
325 | 325 | */ |
326 | - public function set_plz_select_method_of_payment( $plz_select_method_of_payment ) { |
|
326 | + public function set_plz_select_method_of_payment($plz_select_method_of_payment) { |
|
327 | 327 | $this->_plz_select_method_of_payment = $plz_select_method_of_payment; |
328 | 328 | } |
329 | 329 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | /** |
342 | 342 | * @param string $redirect_url |
343 | 343 | */ |
344 | - public function set_redirect_url( $redirect_url ) { |
|
344 | + public function set_redirect_url($redirect_url) { |
|
345 | 345 | $this->_redirect_url = $redirect_url; |
346 | 346 | } |
347 | 347 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | /** |
369 | 369 | * @param string $registration_time_limit |
370 | 370 | */ |
371 | - public function set_registration_time_limit( $registration_time_limit ) { |
|
371 | + public function set_registration_time_limit($registration_time_limit) { |
|
372 | 372 | $this->_registration_time_limit = $registration_time_limit; |
373 | 373 | } |
374 | 374 | |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | /** |
378 | 378 | * @param array $return_data |
379 | 379 | */ |
380 | - public function set_return_data( $return_data ) { |
|
381 | - $this->_return_data = array_merge( $this->_return_data, $return_data ); |
|
380 | + public function set_return_data($return_data) { |
|
381 | + $this->_return_data = array_merge($this->_return_data, $return_data); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | |
@@ -395,9 +395,9 @@ discard block |
||
395 | 395 | /** |
396 | 396 | * @param array $validation_rules |
397 | 397 | */ |
398 | - public function add_validation_rules( $validation_rules = array() ) { |
|
399 | - if ( is_array( $validation_rules ) && ! empty( $validation_rules )) { |
|
400 | - $this->_validation_rules = array_merge( $this->_validation_rules, $validation_rules ); |
|
398 | + public function add_validation_rules($validation_rules = array()) { |
|
399 | + if (is_array($validation_rules) && ! empty($validation_rules)) { |
|
400 | + $this->_validation_rules = array_merge($this->_validation_rules, $validation_rules); |
|
401 | 401 | } |
402 | 402 | } |
403 | 403 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * @return array | bool |
408 | 408 | */ |
409 | 409 | public function validation_rules() { |
410 | - return ! empty( $this->_validation_rules ) ? $this->_validation_rules : FALSE; |
|
410 | + return ! empty($this->_validation_rules) ? $this->_validation_rules : FALSE; |
|
411 | 411 | } |
412 | 412 | |
413 | 413 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields; |
3 | 3 | |
4 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | /** |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function instance() { |
37 | 37 | self::$_field_calculator = new Calculated_Model_Fields(); |
38 | - return parent::get_instance( __CLASS__ ); |
|
38 | + return parent::get_instance(__CLASS__); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | |
66 | 66 | |
67 | 67 | public static function set_hooks_both() { |
68 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
69 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
70 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
71 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
68 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
69 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
70 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
71 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
72 | 72 | EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change(); |
73 | 73 | } |
74 | 74 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * Loads all the hooks which make requests to old versions of the API |
87 | 87 | * appear the same as they always did |
88 | 88 | */ |
89 | - public static function set_hooks_for_changes(){ |
|
89 | + public static function set_hooks_for_changes() { |
|
90 | 90 | self::_set_hooks_for_changes(); |
91 | 91 | } |
92 | 92 | /** |
@@ -94,16 +94,16 @@ discard block |
||
94 | 94 | * appear the same as they always did |
95 | 95 | */ |
96 | 96 | protected static function _set_hooks_for_changes() { |
97 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
98 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
97 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
98 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
99 | 99 | //ignore the base parent class |
100 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
100 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
101 | 101 | continue; |
102 | 102 | } |
103 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
104 | - if ( class_exists( $full_classname )) { |
|
103 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
104 | + if (class_exists($full_classname)) { |
|
105 | 105 | $instance_of_class = new $full_classname; |
106 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
106 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
107 | 107 | $instance_of_class->set_hooks(); |
108 | 108 | } |
109 | 109 | } |
@@ -116,16 +116,16 @@ discard block |
||
116 | 116 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
117 | 117 | */ |
118 | 118 | public static function register_routes() { |
119 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
120 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
121 | - foreach( $routes as $route ) { |
|
119 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
120 | + foreach ($relative_urls as $endpoint => $routes) { |
|
121 | + foreach ($routes as $route) { |
|
122 | 122 | register_rest_route( |
123 | 123 | $namespace, |
124 | 124 | $endpoint, |
125 | 125 | array( |
126 | - 'callback' => $route[ 'callback' ], |
|
127 | - 'methods' => $route[ 'methods' ], |
|
128 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
126 | + 'callback' => $route['callback'], |
|
127 | + 'methods' => $route['methods'], |
|
128 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
129 | 129 | ) |
130 | 130 | ); |
131 | 131 | } |
@@ -139,11 +139,11 @@ discard block |
||
139 | 139 | * next time the WP API is used |
140 | 140 | */ |
141 | 141 | public static function invalidate_cached_route_data_on_version_change() { |
142 | - if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) { |
|
142 | + if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) { |
|
143 | 143 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
144 | 144 | } |
145 | - foreach( EE_Registry::instance()->addons as $addon ){ |
|
146 | - if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) { |
|
145 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
146 | + if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) { |
|
147 | 147 | EED_Core_Rest_Api::invalidate_cached_route_data(); |
148 | 148 | } |
149 | 149 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public static function invalidate_cached_route_data() { |
156 | 156 | //delete the saved EE REST API routes |
157 | - delete_option( EED_Core_Rest_Api::saved_routes_option_names ); |
|
157 | + delete_option(EED_Core_Rest_Api::saved_routes_option_names); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -166,10 +166,10 @@ discard block |
||
166 | 166 | * } |
167 | 167 | */ |
168 | 168 | public static function get_ee_route_data() { |
169 | - $ee_routes = get_option( self::saved_routes_option_names, null ); |
|
170 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
169 | + $ee_routes = get_option(self::saved_routes_option_names, null); |
|
170 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
171 | 171 | self::save_ee_routes(); |
172 | - $ee_routes = get_option( self::saved_routes_option_names, array() ); |
|
172 | + $ee_routes = get_option(self::saved_routes_option_names, array()); |
|
173 | 173 | } |
174 | 174 | return $ee_routes; |
175 | 175 | } |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @return void |
181 | 181 | */ |
182 | 182 | public static function save_ee_routes() { |
183 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
183 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
184 | 184 | $instance = self::instance(); |
185 | 185 | $routes = apply_filters( |
186 | 186 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $instance->_register_rpc_routes() |
192 | 192 | ) |
193 | 193 | ); |
194 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
194 | + update_option(self::saved_routes_option_names, $routes, true); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -208,24 +208,24 @@ discard block |
||
208 | 208 | unset($models_to_register['Extra_Meta']); |
209 | 209 | unset($models_to_register['Extra_Join']); |
210 | 210 | $model_routes = array( ); |
211 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
211 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
212 | 212 | |
213 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
214 | - $model = \EE_Registry::instance()->load_model( $model_name ); |
|
213 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
214 | + $model = \EE_Registry::instance()->load_model($model_name); |
|
215 | 215 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
216 | - $ee_namespace = self::ee_api_namespace . $version; |
|
217 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
218 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
219 | - $model_routes[ $ee_namespace ][ $plural_model_route ] = array( |
|
216 | + $ee_namespace = self::ee_api_namespace.$version; |
|
217 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
218 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
219 | + $model_routes[$ee_namespace][$plural_model_route] = array( |
|
220 | 220 | array( |
221 | 221 | 'callback' => array( |
222 | 222 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
223 | 223 | 'handle_request_get_all' ), |
224 | 224 | 'methods' => WP_REST_Server::READABLE, |
225 | 225 | 'hidden_endpoint' => $hidden_endpoint, |
226 | - 'args' => $this->_get_read_query_params( $model, $version ), |
|
226 | + 'args' => $this->_get_read_query_params($model, $version), |
|
227 | 227 | '_links' => array( |
228 | - 'self' => rest_url( $ee_namespace . $singular_model_route ), |
|
228 | + 'self' => rest_url($ee_namespace.$singular_model_route), |
|
229 | 229 | ) |
230 | 230 | ), |
231 | 231 | // array( |
@@ -236,14 +236,14 @@ discard block |
||
236 | 236 | // 'hidden_endpoint' => $hidden_endpoint |
237 | 237 | // ) |
238 | 238 | ); |
239 | - $model_routes[ $ee_namespace ][ $singular_model_route ] = array( |
|
239 | + $model_routes[$ee_namespace][$singular_model_route] = array( |
|
240 | 240 | array( |
241 | 241 | 'callback' => array( |
242 | 242 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
243 | 243 | 'handle_request_get_one' ), |
244 | 244 | 'methods' => WP_REST_Server::READABLE, |
245 | 245 | 'hidden_endpoint' => $hidden_endpoint, |
246 | - 'args' => $this->_get_response_selection_query_params( $model, $version) |
|
246 | + 'args' => $this->_get_response_selection_query_params($model, $version) |
|
247 | 247 | ), |
248 | 248 | // array( |
249 | 249 | // 'callback' => array( |
@@ -254,19 +254,19 @@ discard block |
||
254 | 254 | // ), |
255 | 255 | ); |
256 | 256 | //@todo: also handle DELETE for a single item |
257 | - foreach ( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
257 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
258 | 258 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
259 | 259 | $relation_name, |
260 | 260 | $relation_obj |
261 | 261 | ); |
262 | - $model_routes[ $ee_namespace ][ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
262 | + $model_routes[$ee_namespace][$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
263 | 263 | array( |
264 | 264 | 'callback' => array( |
265 | 265 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
266 | 266 | 'handle_request_get_related' ), |
267 | 267 | 'methods' => WP_REST_Server::READABLE, |
268 | 268 | 'hidden_endpoint' => $hidden_endpoint, |
269 | - 'args' => $this->_get_read_query_params( $relation_obj->get_other_model(), $version ), |
|
269 | + 'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version), |
|
270 | 270 | ), |
271 | 271 | // array( |
272 | 272 | // 'callback' => array( |
@@ -290,11 +290,11 @@ discard block |
||
290 | 290 | */ |
291 | 291 | protected function _register_rpc_routes() { |
292 | 292 | $routes = array(); |
293 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
294 | - $ee_namespace = self::ee_api_namespace . $version; |
|
293 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
294 | + $ee_namespace = self::ee_api_namespace.$version; |
|
295 | 295 | $this_versions_routes = array(); |
296 | 296 | //checkin endpoint |
297 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
297 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
298 | 298 | array( |
299 | 299 | 'callback' => array( |
300 | 300 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | 'force' => array( |
306 | 306 | 'required' => false, |
307 | 307 | 'default' => false, |
308 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
308 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
309 | 309 | ) |
310 | 310 | ) |
311 | 311 | ) |
312 | 312 | ); |
313 | - $routes[ $ee_namespace ] = apply_filters( |
|
313 | + $routes[$ee_namespace] = apply_filters( |
|
314 | 314 | 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
315 | 315 | $this_versions_routes, |
316 | 316 | $version, |
@@ -326,19 +326,19 @@ discard block |
||
326 | 326 | * @param string $version |
327 | 327 | * @return array |
328 | 328 | */ |
329 | - protected function _get_response_selection_query_params( \EEM_Base $model, $version ) { |
|
329 | + protected function _get_response_selection_query_params(\EEM_Base $model, $version) { |
|
330 | 330 | return apply_filters( |
331 | 331 | 'FHEE__EED_Core_Rest_Api___get_response_selection_query_params', |
332 | 332 | array( |
333 | 333 | 'include' => array( |
334 | 334 | 'required' => false, |
335 | 335 | 'default' => '*', |
336 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ), |
|
336 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'), |
|
337 | 337 | ), |
338 | 338 | 'calculate' => array( |
339 | 339 | 'required' => false, |
340 | 340 | 'default' => '', |
341 | - 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model( $model ) |
|
341 | + 'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model) |
|
342 | 342 | ) |
343 | 343 | ), |
344 | 344 | $model, |
@@ -356,43 +356,43 @@ discard block |
||
356 | 356 | * @return array describing the args acceptable when querying this model |
357 | 357 | * @throws \EE_Error |
358 | 358 | */ |
359 | - protected function _get_read_query_params( \EEM_Base $model, $version ) { |
|
359 | + protected function _get_read_query_params(\EEM_Base $model, $version) { |
|
360 | 360 | $default_orderby = array(); |
361 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
362 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
361 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
362 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
363 | 363 | } |
364 | 364 | return array_merge( |
365 | - $this->_get_response_selection_query_params( $model, $version ), |
|
365 | + $this->_get_response_selection_query_params($model, $version), |
|
366 | 366 | array( |
367 | 367 | 'where' => array( |
368 | 368 | 'required' => false, |
369 | 369 | 'default' => array(), |
370 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso' ), |
|
370 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso'), |
|
371 | 371 | ), |
372 | 372 | 'limit' => array( |
373 | 373 | 'required' => false, |
374 | 374 | 'default' => EED_Core_Rest_Api::get_default_query_limit(), |
375 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso' ) |
|
375 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso') |
|
376 | 376 | ), |
377 | 377 | 'order_by' => array( |
378 | 378 | 'required' => false, |
379 | 379 | 'default' => $default_orderby, |
380 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso' ) |
|
380 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso') |
|
381 | 381 | ), |
382 | 382 | 'group_by' => array( |
383 | 383 | 'required' => false, |
384 | 384 | 'default' => null, |
385 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso' ) |
|
385 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso') |
|
386 | 386 | ), |
387 | 387 | 'having' => array( |
388 | 388 | 'required' => false, |
389 | 389 | 'default' => null, |
390 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso' ) |
|
390 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso') |
|
391 | 391 | ), |
392 | 392 | 'caps' => array( |
393 | 393 | 'required' => false, |
394 | 394 | 'default' => EEM_Base::caps_read, |
395 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso' ) |
|
395 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso') |
|
396 | 396 | ), |
397 | 397 | ) |
398 | 398 | ); |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | */ |
405 | 405 | protected function _register_config_routes() { |
406 | 406 | $config_routes = array(); |
407 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
408 | - $config_routes[ self::ee_api_namespace . $version ][ 'config' ] = array( |
|
407 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
408 | + $config_routes[self::ee_api_namespace.$version]['config'] = array( |
|
409 | 409 | array( |
410 | 410 | 'callback' => array( |
411 | 411 | 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | */ |
425 | 425 | protected function _register_meta_routes() { |
426 | 426 | $meta_routes = array(); |
427 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
428 | - $meta_routes[ self::ee_api_namespace . $version ][ '/resources' ] = array( |
|
427 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
428 | + $meta_routes[self::ee_api_namespace.$version]['/resources'] = array( |
|
429 | 429 | array( |
430 | 430 | 'callback' => array( |
431 | 431 | 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', |
@@ -446,13 +446,13 @@ discard block |
||
446 | 446 | * @param array $route_data |
447 | 447 | * @return array |
448 | 448 | */ |
449 | - public static function hide_old_endpoints( $route_data ) { |
|
450 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
451 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
452 | - foreach( $routes as $route ) { |
|
453 | - if( $route[ 'hidden_endpoint' ] ) { |
|
454 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
455 | - unset( $route_data[ $full_route ] ); |
|
449 | + public static function hide_old_endpoints($route_data) { |
|
450 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
451 | + foreach ($relative_urls as $endpoint => $routes) { |
|
452 | + foreach ($routes as $route) { |
|
453 | + if ($route['hidden_endpoint']) { |
|
454 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
455 | + unset($route_data[$full_route]); |
|
456 | 456 | } |
457 | 457 | } |
458 | 458 | } |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | */ |
492 | 492 | public static function latest_rest_api_version() { |
493 | 493 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
494 | - return end( array_keys( $versions_served ) ); |
|
494 | + return end(array_keys($versions_served)); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | /** |
@@ -505,32 +505,32 @@ discard block |
||
505 | 505 | public static function versions_served() { |
506 | 506 | $versions_served = array(); |
507 | 507 | $possibly_served_versions = EED_Core_Rest_Api::version_compatibilities(); |
508 | - $lowest_compatible_version = end( $possibly_served_versions); |
|
509 | - reset( $possibly_served_versions ); |
|
510 | - $versions_served_historically = array_keys( $possibly_served_versions ); |
|
511 | - $latest_version = end( $versions_served_historically ); |
|
512 | - reset( $versions_served_historically ); |
|
508 | + $lowest_compatible_version = end($possibly_served_versions); |
|
509 | + reset($possibly_served_versions); |
|
510 | + $versions_served_historically = array_keys($possibly_served_versions); |
|
511 | + $latest_version = end($versions_served_historically); |
|
512 | + reset($versions_served_historically); |
|
513 | 513 | //for each version of core we have ever served: |
514 | - foreach ( $versions_served_historically as $key_versioned_endpoint ) { |
|
514 | + foreach ($versions_served_historically as $key_versioned_endpoint) { |
|
515 | 515 | //if it's not above the current core version, and it's compatible with the current version of core |
516 | - if( $key_versioned_endpoint == $latest_version ) { |
|
516 | + if ($key_versioned_endpoint == $latest_version) { |
|
517 | 517 | //don't hide the latest version in the index |
518 | - $versions_served[ $key_versioned_endpoint ] = false; |
|
519 | - } else if( |
|
518 | + $versions_served[$key_versioned_endpoint] = false; |
|
519 | + } else if ( |
|
520 | 520 | $key_versioned_endpoint < EED_Core_Rest_Api::core_version() |
521 | 521 | && $key_versioned_endpoint >= $lowest_compatible_version |
522 | 522 | ) { |
523 | 523 | //include, but hide, previous versions which are still supported |
524 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
525 | - } elseif( |
|
524 | + $versions_served[$key_versioned_endpoint] = true; |
|
525 | + } elseif ( |
|
526 | 526 | apply_filters( |
527 | 527 | 'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions', |
528 | 528 | false, |
529 | 529 | $possibly_served_versions |
530 | 530 | ) |
531 | - ){ |
|
531 | + ) { |
|
532 | 532 | //if a version is no longer supported, don't include it in index or list of versions served |
533 | - $versions_served[ $key_versioned_endpoint ] = true; |
|
533 | + $versions_served[$key_versioned_endpoint] = true; |
|
534 | 534 | } |
535 | 535 | } |
536 | 536 | return $versions_served; |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | * @return string |
544 | 544 | */ |
545 | 545 | public static function core_version() { |
546 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
546 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
547 | 547 | } |
548 | 548 | |
549 | 549 | /** |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @param WP $WP |
569 | 569 | * @return void |
570 | 570 | */ |
571 | - public function run( $WP ) { |
|
571 | + public function run($WP) { |
|
572 | 572 | |
573 | 573 | } |
574 | 574 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @return EED_Feeds |
30 | 30 | */ |
31 | 31 | public static function instance() { |
32 | - return parent::get_instance( __CLASS__ ); |
|
32 | + return parent::get_instance(__CLASS__); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | * @return void |
42 | 42 | */ |
43 | 43 | public static function set_hooks() { |
44 | - add_action( 'parse_request', array( 'EED_Feeds', 'parse_request' ), 10 ); |
|
45 | - add_filter( 'default_feed', array( 'EED_Feeds', 'default_feed' ), 10, 1 ); |
|
46 | - add_filter( 'comment_feed_join', array( 'EED_Feeds', 'comment_feed_join' ), 10, 2 ); |
|
47 | - add_filter( 'comment_feed_where', array( 'EED_Feeds', 'comment_feed_where' ), 10, 2 ); |
|
44 | + add_action('parse_request', array('EED_Feeds', 'parse_request'), 10); |
|
45 | + add_filter('default_feed', array('EED_Feeds', 'default_feed'), 10, 1); |
|
46 | + add_filter('comment_feed_join', array('EED_Feeds', 'comment_feed_join'), 10, 2); |
|
47 | + add_filter('comment_feed_where', array('EED_Feeds', 'comment_feed_where'), 10, 2); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @access public |
65 | 65 | * @return void |
66 | 66 | */ |
67 | - public function run( $WP ) { |
|
67 | + public function run($WP) { |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param type rss2, atom, rss, rdf, rssjs |
77 | 77 | * @return string |
78 | 78 | */ |
79 | - public static function default_feed( $type = 'rss2' ) { |
|
79 | + public static function default_feed($type = 'rss2') { |
|
80 | 80 | //rss2, atom, rss, rdf, rssjs |
81 | 81 | $type = 'rss2'; |
82 | 82 | return $type; |
@@ -92,24 +92,24 @@ discard block |
||
92 | 92 | * @return void |
93 | 93 | */ |
94 | 94 | public static function parse_request() { |
95 | - if ( EE_Registry::instance()->REQ->is_set( 'post_type' )) { |
|
95 | + if (EE_Registry::instance()->REQ->is_set('post_type')) { |
|
96 | 96 | // define path to templates |
97 | - define( 'RSS_FEEDS_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
97 | + define('RSS_FEEDS_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
98 | 98 | // what kinda post_type are we dealing with ? |
99 | - switch( EE_Registry::instance()->REQ->get( 'post_type' )) { |
|
99 | + switch (EE_Registry::instance()->REQ->get('post_type')) { |
|
100 | 100 | case 'espresso_events' : |
101 | 101 | // for rss2, atom, rss, rdf |
102 | - add_filter( 'the_excerpt_rss', array( 'EED_Feeds', 'the_event_feed' ), 10, 1 ); |
|
103 | - add_filter( 'the_content_feed', array( 'EED_Feeds', 'the_event_feed' ), 10, 1 ); |
|
102 | + add_filter('the_excerpt_rss', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
103 | + add_filter('the_content_feed', array('EED_Feeds', 'the_event_feed'), 10, 1); |
|
104 | 104 | // for json ( also uses the above filter ) |
105 | - add_filter( 'rssjs_feed_item', array( 'EED_Feeds', 'the_event_rssjs_feed' ), 10, 1 ); |
|
105 | + add_filter('rssjs_feed_item', array('EED_Feeds', 'the_event_rssjs_feed'), 10, 1); |
|
106 | 106 | break; |
107 | 107 | case 'espresso_venues' : |
108 | 108 | // for rss2, atom, rss, rdf |
109 | - add_filter( 'the_excerpt_rss', array( 'EED_Feeds', 'the_venue_feed' ), 10, 1 ); |
|
110 | - add_filter( 'the_content_feed', array( 'EED_Feeds', 'the_venue_feed' ), 10, 1 ); |
|
109 | + add_filter('the_excerpt_rss', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
110 | + add_filter('the_content_feed', array('EED_Feeds', 'the_venue_feed'), 10, 1); |
|
111 | 111 | // for json ( also uses the above filter ) |
112 | - add_filter( 'rssjs_feed_item', array( 'EED_Feeds', 'the_venue_rssjs_feed' ), 10, 1 ); |
|
112 | + add_filter('rssjs_feed_item', array('EED_Feeds', 'the_venue_rssjs_feed'), 10, 1); |
|
113 | 113 | break; |
114 | 114 | } |
115 | 115 | } |
@@ -127,11 +127,11 @@ discard block |
||
127 | 127 | * @param string $SQL the JOIN clause for the comment feed query |
128 | 128 | * @return void |
129 | 129 | */ |
130 | - public static function comment_feed_join( $SQL ) { |
|
130 | + public static function comment_feed_join($SQL) { |
|
131 | 131 | global $wpdb; |
132 | 132 | // check for wp_posts table in JOIN clause |
133 | - if ( strpos( $SQL, $wpdb->posts ) !== FALSE ) { |
|
134 | - add_filter( 'EED_Feeds__comment_feed_where__espresso_attendees', '__return_true' ); |
|
133 | + if (strpos($SQL, $wpdb->posts) !== FALSE) { |
|
134 | + add_filter('EED_Feeds__comment_feed_where__espresso_attendees', '__return_true'); |
|
135 | 135 | } |
136 | 136 | return $SQL; |
137 | 137 | } |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | * @param string $SQL the WHERE clause for the comment feed query |
149 | 149 | * @return void |
150 | 150 | */ |
151 | - public static function comment_feed_where( $SQL ) { |
|
151 | + public static function comment_feed_where($SQL) { |
|
152 | 152 | global $wp_query, $wpdb; |
153 | - if ( $wp_query->is_comment_feed && apply_filters( 'EED_Feeds__comment_feed_where__espresso_attendees', FALSE )) { |
|
153 | + if ($wp_query->is_comment_feed && apply_filters('EED_Feeds__comment_feed_where__espresso_attendees', FALSE)) { |
|
154 | 154 | $SQL .= " AND $wpdb->posts.post_type != 'espresso_attendees'"; |
155 | 155 | } |
156 | 156 | return $SQL; |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | * @param string $content |
167 | 167 | * @return void |
168 | 168 | */ |
169 | - public static function the_event_feed( $content ) { |
|
170 | - if ( is_feed() && is_readable( RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php' )) { |
|
169 | + public static function the_event_feed($content) { |
|
170 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php')) { |
|
171 | 171 | global $post; |
172 | 172 | $template_args = array( |
173 | 173 | 'EVT_ID' => $post->ID, |
174 | 174 | 'event_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content |
175 | 175 | ); |
176 | - $content = EEH_Template::display_template( RSS_FEEDS_TEMPLATES_PATH . 'espresso_events_feed.template.php', $template_args, TRUE ); |
|
176 | + $content = EEH_Template::display_template(RSS_FEEDS_TEMPLATES_PATH.'espresso_events_feed.template.php', $template_args, TRUE); |
|
177 | 177 | } |
178 | 178 | return $content; |
179 | 179 | } |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | * @param object $item |
189 | 189 | * @return void |
190 | 190 | */ |
191 | - public static function the_event_rssjs_feed( $item ) { |
|
192 | - if ( is_feed() && isset( $item->description )) { |
|
193 | - $item->description = EED_Feeds::the_event_feed( $item->description ); |
|
191 | + public static function the_event_rssjs_feed($item) { |
|
192 | + if (is_feed() && isset($item->description)) { |
|
193 | + $item->description = EED_Feeds::the_event_feed($item->description); |
|
194 | 194 | } |
195 | 195 | return $item; |
196 | 196 | } |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | * @param string $content |
206 | 206 | * @return void |
207 | 207 | */ |
208 | - public static function the_venue_feed( $content ) { |
|
209 | - if ( is_feed() && is_readable( RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php' )) { |
|
208 | + public static function the_venue_feed($content) { |
|
209 | + if (is_feed() && is_readable(RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php')) { |
|
210 | 210 | global $post; |
211 | 211 | $template_args = array( |
212 | 212 | 'VNU_ID' => $post->ID, |
213 | 213 | 'venue_description' => get_option('rss_use_excerpt') ? $post->post_excerpt : $post->post_content |
214 | 214 | ); |
215 | - $content = EEH_Template::display_template( RSS_FEEDS_TEMPLATES_PATH . 'espresso_venues_feed.template.php', $template_args, TRUE ); |
|
215 | + $content = EEH_Template::display_template(RSS_FEEDS_TEMPLATES_PATH.'espresso_venues_feed.template.php', $template_args, TRUE); |
|
216 | 216 | } |
217 | 217 | return $content; |
218 | 218 | } |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | * @param object $item |
228 | 228 | * @return void |
229 | 229 | */ |
230 | - public static function the_venue_rssjs_feed( $item ) { |
|
231 | - if ( is_feed() && isset( $item->description )) { |
|
232 | - $item->description = EED_Feeds::the_venue_feed( $item->description ); |
|
230 | + public static function the_venue_rssjs_feed($item) { |
|
231 | + if (is_feed() && isset($item->description)) { |
|
232 | + $item->description = EED_Feeds::the_venue_feed($item->description); |
|
233 | 233 | } |
234 | 234 | return $item; |
235 | 235 | } |