@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @param bool $preview indicate whether a preview is being generated or not. |
272 | 272 | * @return void |
273 | 273 | */ |
274 | - public function set_messages($data, EE_messenger $active_messenger, $context = '', $preview = FALSE ) { |
|
274 | + public function set_messages($data, EE_messenger $active_messenger, $context = '', $preview = FALSE) { |
|
275 | 275 | |
276 | 276 | $this->_active_messenger = $active_messenger; |
277 | 277 | |
@@ -280,10 +280,10 @@ discard block |
||
280 | 280 | |
281 | 281 | //this is a special method that allows child message types to trigger an exit from generating messages early (in cases where there may be a delay on send). |
282 | 282 | $exit = $this->_trigger_exit(); |
283 | - if ( $exit && ! $this->_preview ) return FALSE; |
|
283 | + if ($exit && ! $this->_preview) return FALSE; |
|
284 | 284 | |
285 | 285 | //todo: need to move require into registration hook but for now we'll require here. |
286 | - EE_Registry::instance()->load_helper( 'Parse_Shortcodes' ); |
|
286 | + EE_Registry::instance()->load_helper('Parse_Shortcodes'); |
|
287 | 287 | //get shortcode_replace instance- set when _get_messages is called in child... |
288 | 288 | $this->_shortcode_replace = new EEH_Parse_Shortcodes(); |
289 | 289 | |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | $this->_data_handler = ! $this->_preview ? $this->_data_handler : 'Preview'; |
295 | 295 | |
296 | 296 | //if there is an incoming context then this is a preview so let's ONLY show the given context! |
297 | - if ( !empty( $context ) ) { |
|
298 | - $cntxt = ! empty( $this->_contexts[$context] ) ? $this->_contexts[$context] : ''; |
|
299 | - if ( ! empty( $cntxt ) ) { |
|
297 | + if ( ! empty($context)) { |
|
298 | + $cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : ''; |
|
299 | + if ( ! empty($cntxt)) { |
|
300 | 300 | $this->_contexts = array(); |
301 | 301 | $this->_contexts[$context] = $cntxt; |
302 | 302 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $exit = $this->_init_data(); |
306 | 306 | |
307 | 307 | //final check for if we exit or not cause child objects may have run conditionals that cleared out data so no addresees generated. |
308 | - if ( $exit ) return FALSE; |
|
308 | + if ($exit) return FALSE; |
|
309 | 309 | |
310 | 310 | $this->_get_templates(); //get the templates that have been set with this type and for the given messenger that have been saved in the database. |
311 | 311 | $this->_assemble_messages(); |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * @param int $id Optional. Integer corresponding to the value for the primary key of a EE_Base_Class_Object |
342 | 342 | * @return mixed ( EE_Base_Class||EE_Base_Class[] ) |
343 | 343 | */ |
344 | - abstract protected function _get_data_for_context( $context, EE_Registration $registration, $id ); |
|
344 | + abstract protected function _get_data_for_context($context, EE_Registration $registration, $id); |
|
345 | 345 | |
346 | 346 | |
347 | 347 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | * |
374 | 374 | * @return int |
375 | 375 | */ |
376 | - protected function _get_id_for_msg_url( $context, EE_Registration $registration ) { |
|
376 | + protected function _get_id_for_msg_url($context, EE_Registration $registration) { |
|
377 | 377 | return 0; |
378 | 378 | } |
379 | 379 | |
@@ -406,28 +406,28 @@ discard block |
||
406 | 406 | * |
407 | 407 | * @return string generated url |
408 | 408 | */ |
409 | - public function get_url_trigger( $context, $sending_messenger, EE_Registration $registration ) { |
|
409 | + public function get_url_trigger($context, $sending_messenger, EE_Registration $registration) { |
|
410 | 410 | |
411 | 411 | //validate context |
412 | 412 | //valid context? |
413 | - if ( !isset( $this->_contexts[$context] ) ) { |
|
414 | - throw new EE_Error( sprintf( __('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class( $this ) ) ); |
|
413 | + if ( ! isset($this->_contexts[$context])) { |
|
414 | + throw new EE_Error(sprintf(__('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class($this))); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | //valid sending_messenger? |
418 | 418 | $not_valid_msgr = FALSE; |
419 | - foreach ( $this->_with_messengers as $generating => $sendings ) { |
|
420 | - if ( empty( $sendings ) || array_search( $sending_messenger, $sendings ) === FALSE ) { |
|
419 | + foreach ($this->_with_messengers as $generating => $sendings) { |
|
420 | + if (empty($sendings) || array_search($sending_messenger, $sendings) === FALSE) { |
|
421 | 421 | $not_valid_msgr = TRUE; |
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | - if ( $not_valid_msgr ) { |
|
426 | - throw new EE_Error( sprintf( __('The given sending messenger string (%s) does not match a valid sending messenger with the %s. If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class( $this ) ) ); |
|
425 | + if ($not_valid_msgr) { |
|
426 | + throw new EE_Error(sprintf(__('The given sending messenger string (%s) does not match a valid sending messenger with the %s. If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class($this))); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | EE_Registry::instance()->load_helper('MSG_Template'); |
430 | - return EEH_MSG_Template::generate_url_trigger( $sending_messenger, $this->_active_messenger->name, $context, $this->name, $registration, $this->_GRP_ID, $this->_get_id_for_msg_url( $context, $registration ) ); |
|
430 | + return EEH_MSG_Template::generate_url_trigger($sending_messenger, $this->_active_messenger->name, $context, $this->name, $registration, $this->_GRP_ID, $this->_get_id_for_msg_url($context, $registration)); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | |
@@ -448,19 +448,19 @@ discard block |
||
448 | 448 | * |
449 | 449 | * @return mixed (EE_Base_Class||EE_Base_Class[]) |
450 | 450 | */ |
451 | - public function get_data_for_context( $context, EE_Registration $registration, $id = 0 ) { |
|
451 | + public function get_data_for_context($context, EE_Registration $registration, $id = 0) { |
|
452 | 452 | //valid context? |
453 | - if ( !isset( $this->_contexts[$context] ) ) { |
|
454 | - throw new EE_Error( sprintf( __('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class( $this ) ) ); |
|
453 | + if ( ! isset($this->_contexts[$context])) { |
|
454 | + throw new EE_Error(sprintf(__('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class($this))); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | //get data and apply global and class specific filters on it. |
458 | - $data = apply_filters( 'FHEE__EE_message_type__get_data_for_context__data', $this->_get_data_for_context( $context, $registration, $id ), $this ); |
|
459 | - $data = apply_filters( 'FHEE__' . get_class( $this ) . '__get_data_for_context__data', $data, $this ); |
|
458 | + $data = apply_filters('FHEE__EE_message_type__get_data_for_context__data', $this->_get_data_for_context($context, $registration, $id), $this); |
|
459 | + $data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this); |
|
460 | 460 | |
461 | 461 | //if empty then something went wrong! |
462 | - if ( empty( $data ) ) { |
|
463 | - throw new EE_Error( sprintf( __('There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', 'event_espresso'), $id, $this->name ) ); |
|
462 | + if (empty($data)) { |
|
463 | + throw new EE_Error(sprintf(__('There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', 'event_espresso'), $id, $this->name)); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | return $data; |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | */ |
496 | 496 | public function with_messengers() { |
497 | 497 | |
498 | - return apply_filters( 'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class( $this ), $this->_with_messengers); |
|
498 | + return apply_filters('FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this), $this->_with_messengers); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | |
@@ -513,9 +513,9 @@ discard block |
||
513 | 513 | * @access public |
514 | 514 | * @return void |
515 | 515 | */ |
516 | - public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array() ) { |
|
516 | + public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array()) { |
|
517 | 517 | //we can also further refine the context by action (if present). |
518 | - return $this->_get_admin_page_content( $page, $action, $extra, $messengers ); |
|
518 | + return $this->_get_admin_page_content($page, $action, $extra, $messengers); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | */ |
560 | 560 | public function get_master_templates() { |
561 | 561 | //first class specific filter then filter that by the global filter. |
562 | - $master_templates = apply_filters( 'FHEE__' . get_class( $this ) . '__get_master_templates', $this->_master_templates ); |
|
563 | - return apply_filters( 'FHEE__EE_message_type__get_master_templates', $master_templates, $this ); |
|
562 | + $master_templates = apply_filters('FHEE__'.get_class($this).'__get_master_templates', $this->_master_templates); |
|
563 | + return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | |
@@ -579,31 +579,31 @@ discard block |
||
579 | 579 | /** |
580 | 580 | * first let's make sure that incoming data isn't empty! |
581 | 581 | */ |
582 | - if ( is_array($this->_data) && empty($this->_data) && !$this->_preview ) { |
|
583 | - $msg = sprintf( __( '"%s" message type incoming data is empty. There is nothing to work with so why are you bugging me?', 'event_espresso'), $this->label['singular'] ); |
|
584 | - throw new EE_Error( $msg ); |
|
582 | + if (is_array($this->_data) && empty($this->_data) && ! $this->_preview) { |
|
583 | + $msg = sprintf(__('"%s" message type incoming data is empty. There is nothing to work with so why are you bugging me?', 'event_espresso'), $this->label['singular']); |
|
584 | + throw new EE_Error($msg); |
|
585 | 585 | } |
586 | 586 | |
587 | - if ( empty( $this->_data_handler) ) { |
|
588 | - $msg = sprintf( __('Hey %s hasn\'t declared a handler for the incoming data, so I\'m stuck', 'event_espresso'), __CLASS__ ); |
|
589 | - throw new EE_Error( $msg ); |
|
587 | + if (empty($this->_data_handler)) { |
|
588 | + $msg = sprintf(__('Hey %s hasn\'t declared a handler for the incoming data, so I\'m stuck', 'event_espresso'), __CLASS__); |
|
589 | + throw new EE_Error($msg); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | |
593 | 593 | //setup class name for the data handler |
594 | - $classname = 'EE_Messages_' . $this->_data_handler . '_incoming_data'; |
|
594 | + $classname = 'EE_Messages_'.$this->_data_handler.'_incoming_data'; |
|
595 | 595 | |
596 | 596 | //check that the class exists |
597 | - if ( !class_exists( $classname ) ) { |
|
597 | + if ( ! class_exists($classname)) { |
|
598 | 598 | |
599 | 599 | $msg[] = __('uhoh, Something went wrong and no data handler is found', 'event_espresso'); |
600 | - $msg[] = sprintf( __('The %s class has set the "$_data_handler" property but the string included (%s) does not match any existing "EE_Messages_incoming_data" classes (found in "/includes/core/messages/data_class"). Looking for %s.', 'event_espresso'), __CLASS__, $this->_data_handler, $classname ); |
|
601 | - throw new EE_error( implode('||', $msg) ); |
|
600 | + $msg[] = sprintf(__('The %s class has set the "$_data_handler" property but the string included (%s) does not match any existing "EE_Messages_incoming_data" classes (found in "/includes/core/messages/data_class"). Looking for %s.', 'event_espresso'), __CLASS__, $this->_data_handler, $classname); |
|
601 | + throw new EE_error(implode('||', $msg)); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | //k lets get the prepared data object and replace existing data property with it. |
605 | - $a = new ReflectionClass( $classname ); |
|
606 | - $this->_data = $a->newInstance( $this->_data ); |
|
605 | + $a = new ReflectionClass($classname); |
|
606 | + $this->_data = $a->newInstance($this->_data); |
|
607 | 607 | |
608 | 608 | $this->_set_default_addressee_data(); |
609 | 609 | return $this->_process_data(); |
@@ -619,15 +619,15 @@ discard block |
||
619 | 619 | protected function _process_data() { |
620 | 620 | //at a minimum, we NEED EE_Attendee objects. |
621 | 621 | |
622 | - if ( empty( $this->_data->attendees ) ) |
|
623 | - return TRUE; //EXIT! |
|
622 | + if (empty($this->_data->attendees)) |
|
623 | + return TRUE; //EXIT! |
|
624 | 624 | |
625 | 625 | //process addressees for each context. Child classes will have to have methods for each context defined to handle the processing of the data object within them |
626 | - foreach ( $this->_contexts as $context => $details ) { |
|
627 | - $xpctd_method = '_' . $context . '_addressees'; |
|
628 | - if ( !method_exists( $this, $xpctd_method ) ) |
|
629 | - throw new EE_Error( sprintf( __('The data for %1$s message type cannot be prepared because there is no set method for doing so. The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method) ); |
|
630 | - $this->_addressees[$context] = call_user_func( array( $this, $xpctd_method ) ); |
|
626 | + foreach ($this->_contexts as $context => $details) { |
|
627 | + $xpctd_method = '_'.$context.'_addressees'; |
|
628 | + if ( ! method_exists($this, $xpctd_method)) |
|
629 | + throw new EE_Error(sprintf(__('The data for %1$s message type cannot be prepared because there is no set method for doing so. The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method)); |
|
630 | + $this->_addressees[$context] = call_user_func(array($this, $xpctd_method)); |
|
631 | 631 | } |
632 | 632 | return FALSE; //DON'T EXIT |
633 | 633 | } |
@@ -662,8 +662,8 @@ discard block |
||
662 | 662 | 'total_ticket_count' => $this->_data->total_ticket_count |
663 | 663 | ); |
664 | 664 | |
665 | - if ( is_array( $this->_data->primary_attendee_data ) ) { |
|
666 | - $this->_default_addressee_data = array_merge( $this->_default_addressee_data, $this->_data->primary_attendee_data ); |
|
665 | + if (is_array($this->_data->primary_attendee_data)) { |
|
666 | + $this->_default_addressee_data = array_merge($this->_default_addressee_data, $this->_data->primary_attendee_data); |
|
667 | 667 | $this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj']; |
668 | 668 | $this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj']; |
669 | 669 | } |
@@ -681,26 +681,26 @@ discard block |
||
681 | 681 | * see abstract declaration in parent class for details, children message types can override these valid shortcodes if desired (we include all for all contexts by default). |
682 | 682 | */ |
683 | 683 | protected function _set_valid_shortcodes() { |
684 | - $all_shortcodes = array( 'attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event_meta', 'event', 'organization', 'recipient_details', 'recipient_list', 'ticket_list', 'ticket', 'transaction', 'venue', 'primary_registration_details', 'primary_registration_list', 'event_author', 'email', 'messenger' ); |
|
684 | + $all_shortcodes = array('attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event_meta', 'event', 'organization', 'recipient_details', 'recipient_list', 'ticket_list', 'ticket', 'transaction', 'venue', 'primary_registration_details', 'primary_registration_list', 'event_author', 'email', 'messenger'); |
|
685 | 685 | $contexts = $this->get_contexts(); |
686 | - foreach ( $contexts as $context => $details ) { |
|
686 | + foreach ($contexts as $context => $details) { |
|
687 | 687 | $this->_valid_shortcodes[$context] = $all_shortcodes; |
688 | 688 | |
689 | 689 | //make sure non admin context does not include the event_author shortcodes |
690 | - if ( $context != 'admin' ) { |
|
691 | - if( ($key = array_search('event_author', $this->_valid_shortcodes[$context] ) ) !== false) { |
|
690 | + if ($context != 'admin') { |
|
691 | + if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) { |
|
692 | 692 | unset($this->_valid_shortcodes[$context][$key]); |
693 | 693 | } |
694 | 694 | } |
695 | 695 | } |
696 | 696 | |
697 | 697 | //make sure admin context does not include the recipient_details shortcodes IF we have admin context hooked in message types might not have that context. |
698 | - if ( !empty( $this->_valid_shortcodes['admin'] ) ) { |
|
699 | - if( ($key = array_search('recipient_details', $this->_valid_shortcodes['admin'] ) ) !== false) { |
|
698 | + if ( ! empty($this->_valid_shortcodes['admin'])) { |
|
699 | + if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) { |
|
700 | 700 | unset($this->_valid_shortcodes['admin'][$key]); |
701 | 701 | } |
702 | 702 | //make sure admin context does not include the recipient_details shortcodes |
703 | - if( ($key = array_search('recipient_list', $this->_valid_shortcodes['admin'] ) ) !== false) { |
|
703 | + if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) { |
|
704 | 704 | unset($this->_valid_shortcodes['admin'][$key]); |
705 | 705 | } |
706 | 706 | } |
@@ -713,8 +713,8 @@ discard block |
||
713 | 713 | * @param array $new_config array of valid shortcodes (by context) |
714 | 714 | * @return void sets valid_shortcodes property |
715 | 715 | */ |
716 | - public function reset_valid_shortcodes_config( $new_config ) { |
|
717 | - foreach ( $new_config as $context => $shortcodes ) { |
|
716 | + public function reset_valid_shortcodes_config($new_config) { |
|
717 | + foreach ($new_config as $context => $shortcodes) { |
|
718 | 718 | $this->_valid_shortcodes[$context] = $shortcodes; |
719 | 719 | } |
720 | 720 | } |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | $addressees = array(); |
735 | 735 | |
736 | 736 | //first we need to get the event admin user id for all the events and setup an addressee object for each unique admin user. |
737 | - foreach ( $this->_data->events as $line_ref => $event ) { |
|
737 | + foreach ($this->_data->events as $line_ref => $event) { |
|
738 | 738 | $admin_id = $this->_get_event_admin_id($event['ID']); |
739 | 739 | //get the user_id for the event |
740 | 740 | $admin_ids[] = $admin_id; |
@@ -746,14 +746,14 @@ discard block |
||
746 | 746 | $admin_ids = array_unique($admin_ids); |
747 | 747 | |
748 | 748 | //k now we can loop through the event_admins and setup the addressee data. |
749 | - foreach ( $admin_ids as $event_admin ) { |
|
749 | + foreach ($admin_ids as $event_admin) { |
|
750 | 750 | $aee = array( |
751 | 751 | 'user_id' => $event_admin, |
752 | 752 | 'events' => $admin_events[$event_admin], |
753 | 753 | 'attendees' => $this->_data->attendees |
754 | 754 | ); |
755 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
756 | - $addressees[] = new EE_Messages_Addressee( $aee ); |
|
755 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
756 | + $addressees[] = new EE_Messages_Addressee($aee); |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | return $addressees; |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | $aee['attendees'] = $this->_data->attendees; |
774 | 774 | |
775 | 775 | //great now we can instantiate the $addressee object and return (as an array); |
776 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
776 | + $add[] = new EE_Messages_Addressee($aee); |
|
777 | 777 | return $add; |
778 | 778 | } |
779 | 779 | |
@@ -792,34 +792,34 @@ discard block |
||
792 | 792 | //use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we? |
793 | 793 | $already_processed = array(); |
794 | 794 | |
795 | - foreach ( $this->_data->attendees as $att_id => $details ) { |
|
795 | + foreach ($this->_data->attendees as $att_id => $details) { |
|
796 | 796 | //set the attendee array to blank on each loop; |
797 | 797 | $aee = array(); |
798 | 798 | |
799 | - if ( isset( $this->_data->reg_obj ) && ( $this->_data->reg_obj->attendee_ID() != $att_id ) && $this->_single_message ) continue; |
|
799 | + if (isset($this->_data->reg_obj) && ($this->_data->reg_obj->attendee_ID() != $att_id) && $this->_single_message) continue; |
|
800 | 800 | |
801 | 801 | //is $this->_regs_for_sending present? If so, let's make sure we ONLY generate addressee for registrations in that array. |
802 | - if ( ! empty( $this->_regs_for_sending ) && is_array( $this->_regs_for_sending ) ) { |
|
803 | - $regs_allowed = array_intersect_key( array_flip( $this->_regs_for_sending ), $details['reg_objs'] ); |
|
804 | - if ( empty( $regs_allowed ) ) { |
|
802 | + if ( ! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) { |
|
803 | + $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']); |
|
804 | + if (empty($regs_allowed)) { |
|
805 | 805 | continue; |
806 | 806 | } |
807 | 807 | } |
808 | 808 | |
809 | - if ( in_array( $details['attendee_email'], $already_processed ) ) |
|
809 | + if (in_array($details['attendee_email'], $already_processed)) |
|
810 | 810 | continue; |
811 | 811 | |
812 | 812 | $already_processed[] = $details['attendee_email']; |
813 | 813 | |
814 | - foreach ( $details as $item => $value ) { |
|
814 | + foreach ($details as $item => $value) { |
|
815 | 815 | $aee[$item] = $value; |
816 | - if ( $item == 'line_ref' ) { |
|
817 | - foreach ( $value as $event_id ) { |
|
816 | + if ($item == 'line_ref') { |
|
817 | + foreach ($value as $event_id) { |
|
818 | 818 | $aee['events'][$event_id] = $this->_data->events[$event_id]; |
819 | 819 | } |
820 | 820 | } |
821 | 821 | |
822 | - if ( $item == 'attendee_email' ) { |
|
822 | + if ($item == 'attendee_email') { |
|
823 | 823 | $aee['attendee_email'] = $value; |
824 | 824 | } |
825 | 825 | |
@@ -834,8 +834,8 @@ discard block |
||
834 | 834 | $aee['attendees'] = $this->_data->attendees; |
835 | 835 | |
836 | 836 | //merge in the primary attendee data |
837 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
838 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
837 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
838 | + $add[] = new EE_Messages_Addressee($aee); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | return $add; |
@@ -860,46 +860,46 @@ discard block |
||
860 | 860 | ); |
861 | 861 | |
862 | 862 | //in vanilla EE we're assuming there's only one event. However, if there are multiple events then we'll just use the default templates instead of different templates per event (which could create problems). |
863 | - if ( count($this->_data->events) === 1 ) { |
|
864 | - foreach ( $this->_data->events as $event ) { |
|
863 | + if (count($this->_data->events) === 1) { |
|
864 | + foreach ($this->_data->events as $event) { |
|
865 | 865 | $EVT_ID = $event['ID']; |
866 | 866 | } |
867 | 867 | } |
868 | 868 | // is there a Group ID in the incoming request? |
869 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
869 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
870 | 870 | // if not, set a default value of false |
871 | - $GRP_ID = EE_Registry::instance()->REQ->get( 'GRP_ID', false ); |
|
871 | + $GRP_ID = EE_Registry::instance()->REQ->get('GRP_ID', false); |
|
872 | 872 | //if this is a preview then we just get whatever message group is for the preview and skip this part! |
873 | - if ( $this->_preview && $GRP_ID ) { |
|
874 | - $mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
873 | + if ($this->_preview && $GRP_ID) { |
|
874 | + $mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
875 | 875 | } else { |
876 | 876 | //not a preview or test send so lets continue on our way! |
877 | 877 | //is there an evt_id? If so let's get that. template. |
878 | - if ( !empty( $EVT_ID ) ) { |
|
878 | + if ( ! empty($EVT_ID)) { |
|
879 | 879 | $evt_qa = array( |
880 | 880 | 'Event.EVT_ID' => $EVT_ID |
881 | 881 | ); |
882 | - $qa = array_merge( $template_qa, $evt_qa ); |
|
883 | - $mtpg = EEM_Message_Template_Group::instance()->get_one( array( $qa ) ); |
|
882 | + $qa = array_merge($template_qa, $evt_qa); |
|
883 | + $mtpg = EEM_Message_Template_Group::instance()->get_one(array($qa)); |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | //is there a 'GRP_ID' ? if so let's get that. |
887 | 887 | |
888 | 888 | //if global template is NOT an override, and there is a 'GRP_ID' in the request, then we'll assume a specific template has ben requested. |
889 | - if ( $GRP_ID ) { |
|
890 | - $mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID ); |
|
889 | + if ($GRP_ID) { |
|
890 | + $mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID); |
|
891 | 891 | } |
892 | 892 | |
893 | 893 | |
894 | 894 | $template_qa['MTP_is_global'] = TRUE; |
895 | 895 | |
896 | 896 | //this gets the current global template (message template group) for the active messenger and message type. |
897 | - $global_mtpg = EEM_Message_Template_Group::instance()->get_one( array( $template_qa ) ); |
|
897 | + $global_mtpg = EEM_Message_Template_Group::instance()->get_one(array($template_qa)); |
|
898 | 898 | |
899 | - $mtpg = $mtpg instanceof EE_Message_Template_Group && ! $global_mtpg->get( 'MTP_is_override' ) ? $mtpg : $global_mtpg; |
|
899 | + $mtpg = $mtpg instanceof EE_Message_Template_Group && ! $global_mtpg->get('MTP_is_override') ? $mtpg : $global_mtpg; |
|
900 | 900 | } |
901 | 901 | |
902 | - if ( ! $mtpg instanceof EE_Message_Template_Group ) { |
|
902 | + if ( ! $mtpg instanceof EE_Message_Template_Group) { |
|
903 | 903 | //get out because we can't process anything, there are no message template groups |
904 | 904 | // and thus some sort of bad setup issues. |
905 | 905 | return false; |
@@ -915,8 +915,8 @@ discard block |
||
915 | 915 | |
916 | 916 | |
917 | 917 | |
918 | - foreach ( $templates as $context => $template_fields ) { |
|
919 | - foreach( $template_fields as $template_field=> $template_obj ) { |
|
918 | + foreach ($templates as $context => $template_fields) { |
|
919 | + foreach ($template_fields as $template_field=> $template_obj) { |
|
920 | 920 | $this->_templates[$template_field][$context] = $template_obj->get('MTP_content'); |
921 | 921 | } |
922 | 922 | } |
@@ -931,11 +931,11 @@ discard block |
||
931 | 931 | protected function _assemble_messages() { |
932 | 932 | //make sure any set messages object is cleared |
933 | 933 | $this->messages = array(); |
934 | - foreach ( $this->_addressees as $context => $addressees ) { |
|
935 | - foreach ( $addressees as $addressee ) { |
|
934 | + foreach ($this->_addressees as $context => $addressees) { |
|
935 | + foreach ($addressees as $addressee) { |
|
936 | 936 | $message = $this->_setup_message_object($context, $addressee); |
937 | 937 | //only assign message if everything went okay |
938 | - if ( $message ) { |
|
938 | + if ($message) { |
|
939 | 939 | $message->template_pack = $this->_template_pack; |
940 | 940 | $message->variation = $this->_variation; |
941 | 941 | $this->messages[] = $message; |
@@ -959,22 +959,22 @@ discard block |
||
959 | 959 | $m_shortcodes = $this->_active_messenger->get_valid_shortcodes(); |
960 | 960 | |
961 | 961 | //if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because this context is turned off) EXCEPT if we're previewing |
962 | - if ( ( isset( $this->_templates['to'][$context] ) && empty( $this->_templates['to'][$context] ) ) && !$this->_preview ) |
|
962 | + if ((isset($this->_templates['to'][$context]) && empty($this->_templates['to'][$context])) && ! $this->_preview) |
|
963 | 963 | return false; |
964 | 964 | |
965 | - if ( empty( $this->_templates ) ) { |
|
965 | + if (empty($this->_templates)) { |
|
966 | 966 | //unable to setup any messages because there are no templates. Some sort of catastrophic setup |
967 | 967 | //issue exists |
968 | 968 | return false; |
969 | 969 | } |
970 | 970 | |
971 | - foreach ( $this->_templates as $field => $ctxt ) { |
|
971 | + foreach ($this->_templates as $field => $ctxt) { |
|
972 | 972 | //let's setup the valid shortcodes for the incoming context. |
973 | 973 | $valid_shortcodes = $mt_shortcodes[$context]; |
974 | 974 | //merge in valid shortcodes for the field. |
975 | 975 | $shortcodes = isset($m_shortcodes[$field]) ? $m_shortcodes[$field] : $valid_shortcodes; |
976 | - if ( isset( $this->_templates[$field][$context] ) ) { |
|
977 | - $message->{$field} = $this->_shortcode_replace->parse_message_template($this->_templates[$field][$context], $addressee, $shortcodes, $this, $this->_active_messenger, $context, $this->_GRP_ID ); |
|
976 | + if (isset($this->_templates[$field][$context])) { |
|
977 | + $message->{$field} = $this->_shortcode_replace->parse_message_template($this->_templates[$field][$context], $addressee, $shortcodes, $this, $this->_active_messenger, $context, $this->_GRP_ID); |
|
978 | 978 | } |
979 | 979 | } |
980 | 980 | return $message; |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @return EED_Single_Page_Checkout |
39 | 39 | */ |
40 | 40 | public static function instance() { |
41 | - add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' ); |
|
42 | - return parent::get_instance( __CLASS__ ); |
|
41 | + add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true'); |
|
42 | + return parent::get_instance(__CLASS__); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
@@ -84,22 +84,22 @@ discard block |
||
84 | 84 | */ |
85 | 85 | public static function set_hooks_admin() { |
86 | 86 | EED_Single_Page_Checkout::set_definitions(); |
87 | - if ( defined( 'DOING_AJAX' )) { |
|
87 | + if (defined('DOING_AJAX')) { |
|
88 | 88 | // going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response |
89 | 89 | ob_start(); |
90 | 90 | EED_Single_Page_Checkout::load_request_handler(); |
91 | 91 | EED_Single_Page_Checkout::load_reg_steps(); |
92 | 92 | } else { |
93 | 93 | // hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called |
94 | - add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 ); |
|
94 | + add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1); |
|
95 | 95 | } |
96 | 96 | // set ajax hooks |
97 | - add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
98 | - add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' )); |
|
99 | - add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
100 | - add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' )); |
|
101 | - add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
102 | - add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' )); |
|
97 | + add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
98 | + add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step')); |
|
99 | + add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
100 | + add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step')); |
|
101 | + add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
102 | + add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step')); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * process ajax request |
109 | 109 | * @param string $ajax_action |
110 | 110 | */ |
111 | - public static function process_ajax_request( $ajax_action ) { |
|
112 | - EE_Registry::instance()->REQ->set( 'action', $ajax_action ); |
|
111 | + public static function process_ajax_request($ajax_action) { |
|
112 | + EE_Registry::instance()->REQ->set('action', $ajax_action); |
|
113 | 113 | EED_Single_Page_Checkout::instance()->_initialize(); |
114 | 114 | } |
115 | 115 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * ajax display registration step |
120 | 120 | */ |
121 | 121 | public static function display_reg_step() { |
122 | - EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' ); |
|
122 | + EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * ajax process registration step |
129 | 129 | */ |
130 | 130 | public static function process_reg_step() { |
131 | - EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' ); |
|
131 | + EED_Single_Page_Checkout::process_ajax_request('process_reg_step'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * ajax process registration step |
138 | 138 | */ |
139 | 139 | public static function update_reg_step() { |
140 | - EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' ); |
|
140 | + EED_Single_Page_Checkout::process_ajax_request('update_reg_step'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return void |
150 | 150 | */ |
151 | 151 | public static function update_checkout() { |
152 | - EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' ); |
|
152 | + EED_Single_Page_Checkout::process_ajax_request('update_checkout'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public static function load_request_handler() { |
164 | 164 | // load core Request_Handler class |
165 | - if ( ! isset( EE_Registry::instance()->REQ )) { |
|
166 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
165 | + if ( ! isset(EE_Registry::instance()->REQ)) { |
|
166 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
@@ -176,14 +176,14 @@ discard block |
||
176 | 176 | * @return void |
177 | 177 | */ |
178 | 178 | public static function set_definitions() { |
179 | - define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS ); |
|
180 | - define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS ); |
|
181 | - define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS ); |
|
182 | - define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS ); |
|
183 | - define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS ); |
|
184 | - define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS ); |
|
185 | - define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS ); |
|
186 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE ); |
|
179 | + define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS); |
|
180 | + define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS); |
|
181 | + define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS); |
|
182 | + define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS); |
|
183 | + define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS); |
|
184 | + define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS); |
|
185 | + define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS); |
|
186 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public static function load_reg_steps() { |
200 | 200 | static $reg_steps_loaded = FALSE; |
201 | - if ( $reg_steps_loaded ) { |
|
201 | + if ($reg_steps_loaded) { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | // filter list of reg_steps |
@@ -207,24 +207,24 @@ discard block |
||
207 | 207 | EED_Single_Page_Checkout::get_reg_steps() |
208 | 208 | ); |
209 | 209 | // sort by key (order) |
210 | - ksort( $reg_steps_to_load ); |
|
210 | + ksort($reg_steps_to_load); |
|
211 | 211 | // loop through folders |
212 | - foreach ( $reg_steps_to_load as $order => $reg_step ) { |
|
212 | + foreach ($reg_steps_to_load as $order => $reg_step) { |
|
213 | 213 | // we need a |
214 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
214 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
215 | 215 | // copy over to the reg_steps_array |
216 | - EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step; |
|
216 | + EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step; |
|
217 | 217 | // register custom key route for each reg step |
218 | 218 | // ie: step=>"slug" - this is the entire reason we load the reg steps array now |
219 | - EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' ); |
|
219 | + EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step'); |
|
220 | 220 | // add AJAX or other hooks |
221 | - if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) { |
|
221 | + if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) { |
|
222 | 222 | // setup autoloaders if necessary |
223 | - if ( ! class_exists( $reg_step['class_name'] )) { |
|
224 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE ); |
|
223 | + if ( ! class_exists($reg_step['class_name'])) { |
|
224 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE); |
|
225 | 225 | } |
226 | - if ( is_callable( $reg_step['class_name'], 'set_hooks' )) { |
|
227 | - call_user_func( array( $reg_step['class_name'], 'set_hooks' )); |
|
226 | + if (is_callable($reg_step['class_name'], 'set_hooks')) { |
|
227 | + call_user_func(array($reg_step['class_name'], 'set_hooks')); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | } |
@@ -243,28 +243,28 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public static function get_reg_steps() { |
245 | 245 | $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps; |
246 | - if ( empty( $reg_steps )) { |
|
246 | + if (empty($reg_steps)) { |
|
247 | 247 | $reg_steps = array( |
248 | 248 | 10 => array( |
249 | - 'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information', |
|
249 | + 'file_path' => SPCO_REG_STEPS_PATH.'attendee_information', |
|
250 | 250 | 'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information', |
251 | 251 | 'slug' => 'attendee_information', |
252 | 252 | 'has_hooks' => FALSE |
253 | 253 | ), |
254 | 254 | 20 => array( |
255 | - 'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation', |
|
255 | + 'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation', |
|
256 | 256 | 'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation', |
257 | 257 | 'slug' => 'registration_confirmation', |
258 | 258 | 'has_hooks' => FALSE |
259 | 259 | ), |
260 | 260 | 30 => array( |
261 | - 'file_path' => SPCO_REG_STEPS_PATH . 'payment_options', |
|
261 | + 'file_path' => SPCO_REG_STEPS_PATH.'payment_options', |
|
262 | 262 | 'class_name' => 'EE_SPCO_Reg_Step_Payment_Options', |
263 | 263 | 'slug' => 'payment_options', |
264 | 264 | 'has_hooks' => TRUE |
265 | 265 | ), |
266 | 266 | 999 => array( |
267 | - 'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration', |
|
267 | + 'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration', |
|
268 | 268 | 'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration', |
269 | 269 | 'slug' => 'finalize_registration', |
270 | 270 | 'has_hooks' => FALSE |
@@ -284,9 +284,9 @@ discard block |
||
284 | 284 | */ |
285 | 285 | public static function registration_checkout_for_admin() { |
286 | 286 | EED_Single_Page_Checkout::load_reg_steps(); |
287 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
288 | - EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' ); |
|
289 | - EE_Registry::instance()->REQ->set( 'process_form_submission', false ); |
|
287 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
288 | + EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step'); |
|
289 | + EE_Registry::instance()->REQ->set('process_form_submission', false); |
|
290 | 290 | EED_Single_Page_Checkout::instance()->_initialize(); |
291 | 291 | EED_Single_Page_Checkout::instance()->_display_spco_reg_form(); |
292 | 292 | return EE_Registry::instance()->REQ->get_output(); |
@@ -302,14 +302,14 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public static function process_registration_from_admin() { |
304 | 304 | EED_Single_Page_Checkout::load_reg_steps(); |
305 | - EE_Registry::instance()->REQ->set( 'step', 'attendee_information' ); |
|
306 | - EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' ); |
|
307 | - EE_Registry::instance()->REQ->set( 'process_form_submission', true ); |
|
305 | + EE_Registry::instance()->REQ->set('step', 'attendee_information'); |
|
306 | + EE_Registry::instance()->REQ->set('action', 'process_reg_step'); |
|
307 | + EE_Registry::instance()->REQ->set('process_form_submission', true); |
|
308 | 308 | EED_Single_Page_Checkout::instance()->_initialize(); |
309 | - if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) { |
|
310 | - $final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps ); |
|
311 | - if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) { |
|
312 | - if ( $final_reg_step->process_reg_step() ) { |
|
309 | + if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) { |
|
310 | + $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps); |
|
311 | + if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) { |
|
312 | + if ($final_reg_step->process_reg_step()) { |
|
313 | 313 | return EED_Single_Page_Checkout::instance()->checkout->transaction; |
314 | 314 | } |
315 | 315 | } |
@@ -326,11 +326,11 @@ discard block |
||
326 | 326 | * @param WP_Query $WP_Query |
327 | 327 | * @return void |
328 | 328 | */ |
329 | - public function run( $WP_Query ) { |
|
329 | + public function run($WP_Query) { |
|
330 | 330 | if ( |
331 | 331 | $WP_Query instanceof WP_Query |
332 | 332 | && $WP_Query->is_main_query() |
333 | - && apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true ) |
|
333 | + && apply_filters('FHEE__EED_Single_Page_Checkout__run', true) |
|
334 | 334 | ) { |
335 | 335 | $this->_initialize(); |
336 | 336 | } |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | * @param WP_Query $WP_Query |
347 | 347 | * @return void |
348 | 348 | */ |
349 | - public static function init( $WP_Query ) { |
|
350 | - EED_Single_Page_Checkout::instance()->run( $WP_Query ); |
|
349 | + public static function init($WP_Query) { |
|
350 | + EED_Single_Page_Checkout::instance()->run($WP_Query); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | |
@@ -361,35 +361,35 @@ discard block |
||
361 | 361 | */ |
362 | 362 | private function _initialize() { |
363 | 363 | // ensure SPCO doesn't run twice |
364 | - if ( EED_Single_Page_Checkout::$_initialized ) { |
|
364 | + if (EED_Single_Page_Checkout::$_initialized) { |
|
365 | 365 | return; |
366 | 366 | } |
367 | 367 | // setup the EE_Checkout object |
368 | 368 | $this->checkout = $this->_initialize_checkout(); |
369 | 369 | // filter checkout |
370 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout ); |
|
370 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout); |
|
371 | 371 | // get the $_GET |
372 | 372 | $this->_get_request_vars(); |
373 | 373 | // filter continue_reg |
374 | - $this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout ); |
|
374 | + $this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout); |
|
375 | 375 | // load the reg steps array |
376 | - if ( ! $this->_load_and_instantiate_reg_steps() ) { |
|
376 | + if ( ! $this->_load_and_instantiate_reg_steps()) { |
|
377 | 377 | EED_Single_Page_Checkout::$_initialized = true; |
378 | 378 | return; |
379 | 379 | } |
380 | 380 | // set the current step |
381 | - $this->checkout->set_current_step( $this->checkout->step ); |
|
381 | + $this->checkout->set_current_step($this->checkout->step); |
|
382 | 382 | // and the next step |
383 | 383 | $this->checkout->set_next_step(); |
384 | 384 | // was there already a valid transaction in the checkout from the session ? |
385 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
385 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
386 | 386 | // get transaction from db or session |
387 | 387 | $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin() |
388 | 388 | ? $this->_get_transaction_and_cart_for_previous_visit() |
389 | 389 | : $this->_get_cart_for_current_session_and_setup_new_transaction(); |
390 | - if ( ! $this->checkout->transaction instanceof EE_Transaction ) { |
|
390 | + if ( ! $this->checkout->transaction instanceof EE_Transaction) { |
|
391 | 391 | EE_Error::add_error( |
392 | - __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), |
|
392 | + __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), |
|
393 | 393 | __FILE__, __FUNCTION__, __LINE__ |
394 | 394 | ); |
395 | 395 | // add some style and make it dance |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | return; |
400 | 400 | } |
401 | 401 | // and the registrations for the transaction |
402 | - $this->_get_registrations( $this->checkout->transaction ); |
|
402 | + $this->_get_registrations($this->checkout->transaction); |
|
403 | 403 | } |
404 | 404 | // verify that everything has been setup correctly |
405 | - if ( ! $this->_final_verifications() ) { |
|
405 | + if ( ! $this->_final_verifications()) { |
|
406 | 406 | EED_Single_Page_Checkout::$_initialized = true; |
407 | 407 | return; |
408 | 408 | } |
@@ -427,9 +427,9 @@ discard block |
||
427 | 427 | // set no cache headers and constants |
428 | 428 | EE_System::do_not_cache(); |
429 | 429 | // add anchor |
430 | - add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 ); |
|
430 | + add_action('loop_start', array($this, 'set_checkout_anchor'), 1); |
|
431 | 431 | // remove transaction lock |
432 | - add_action( 'shutdown', array( $this, 'unlock_transaction' ), 1 ); |
|
432 | + add_action('shutdown', array($this, 'unlock_transaction'), 1); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -446,20 +446,20 @@ discard block |
||
446 | 446 | // look in session for existing checkout |
447 | 447 | $checkout = EE_Registry::instance()->SSN->checkout(); |
448 | 448 | // verify |
449 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
449 | + if ( ! $checkout instanceof EE_Checkout) { |
|
450 | 450 | // instantiate EE_Checkout object for handling the properties of the current checkout process |
451 | - $checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE ); |
|
451 | + $checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE); |
|
452 | 452 | // verify again |
453 | - if ( ! $checkout instanceof EE_Checkout ) { |
|
454 | - throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) ); |
|
453 | + if ( ! $checkout instanceof EE_Checkout) { |
|
454 | + throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso')); |
|
455 | 455 | } |
456 | 456 | } else { |
457 | - if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true ) { |
|
458 | - wp_safe_redirect( $checkout->redirect_url ); |
|
457 | + if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) { |
|
458 | + wp_safe_redirect($checkout->redirect_url); |
|
459 | 459 | exit(); |
460 | 460 | } |
461 | 461 | } |
462 | - $checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout ); |
|
462 | + $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout); |
|
463 | 463 | // reset anything that needs a clean slate for each request |
464 | 464 | $checkout->reset_for_current_request(); |
465 | 465 | return $checkout; |
@@ -477,24 +477,24 @@ discard block |
||
477 | 477 | // load classes |
478 | 478 | EED_Single_Page_Checkout::load_request_handler(); |
479 | 479 | //make sure this request is marked as belonging to EE |
480 | - EE_Registry::instance()->REQ->set_espresso_page( TRUE ); |
|
480 | + EE_Registry::instance()->REQ->set_espresso_page(TRUE); |
|
481 | 481 | // which step is being requested ? |
482 | - $this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() ); |
|
482 | + $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step()); |
|
483 | 483 | // which step is being edited ? |
484 | - $this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' ); |
|
484 | + $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', ''); |
|
485 | 485 | // and what we're doing on the current step |
486 | - $this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ); |
|
486 | + $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step'); |
|
487 | 487 | // returning to edit ? |
488 | - $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' ); |
|
488 | + $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', ''); |
|
489 | 489 | // or some other kind of revisit ? |
490 | - $this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE ); |
|
490 | + $this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE); |
|
491 | 491 | // and whether or not to generate a reg form for this request |
492 | - $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); // TRUE FALSE |
|
492 | + $this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE FALSE |
|
493 | 493 | // and whether or not to process a reg form submission for this request |
494 | - $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); // TRUE FALSE |
|
494 | + $this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE FALSE |
|
495 | 495 | $this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step' |
496 | 496 | ? $this->checkout->process_form_submission |
497 | - : FALSE; // TRUE FALSE |
|
497 | + : FALSE; // TRUE FALSE |
|
498 | 498 | //$this->_display_request_vars(); |
499 | 499 | } |
500 | 500 | |
@@ -507,17 +507,17 @@ discard block |
||
507 | 507 | * @return void |
508 | 508 | */ |
509 | 509 | protected function _display_request_vars() { |
510 | - if ( ! WP_DEBUG ) { |
|
510 | + if ( ! WP_DEBUG) { |
|
511 | 511 | return; |
512 | 512 | } |
513 | - EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ ); |
|
514 | - EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ ); |
|
515 | - EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ ); |
|
516 | - EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ ); |
|
517 | - EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ ); |
|
518 | - EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ ); |
|
519 | - EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ ); |
|
520 | - EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ ); |
|
513 | + EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__); |
|
514 | + EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__); |
|
515 | + EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__); |
|
516 | + EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__); |
|
517 | + EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__); |
|
518 | + EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__); |
|
519 | + EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__); |
|
520 | + EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -531,8 +531,8 @@ discard block |
||
531 | 531 | * @return array |
532 | 532 | */ |
533 | 533 | private function _get_first_step() { |
534 | - $first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array ); |
|
535 | - return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information'; |
|
534 | + $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array); |
|
535 | + return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information'; |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | |
@@ -548,27 +548,27 @@ discard block |
||
548 | 548 | private function _load_and_instantiate_reg_steps() { |
549 | 549 | // have reg_steps already been instantiated ? |
550 | 550 | if ( |
551 | - empty( $this->checkout->reg_steps ) || |
|
552 | - apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout ) |
|
551 | + empty($this->checkout->reg_steps) || |
|
552 | + apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout) |
|
553 | 553 | ) { |
554 | 554 | // if not, then loop through raw reg steps array |
555 | - foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) { |
|
556 | - if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) { |
|
555 | + foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) { |
|
556 | + if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) { |
|
557 | 557 | return false; |
558 | 558 | } |
559 | 559 | } |
560 | 560 | EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE; |
561 | 561 | EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE; |
562 | 562 | // skip the registration_confirmation page ? |
563 | - if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) { |
|
563 | + if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) { |
|
564 | 564 | // just remove it from the reg steps array |
565 | - $this->checkout->remove_reg_step( 'registration_confirmation', false ); |
|
565 | + $this->checkout->remove_reg_step('registration_confirmation', false); |
|
566 | 566 | } else if ( |
567 | 567 | EE_Registry::instance()->CFG->registration->reg_confirmation_last |
568 | - && isset( $this->checkout->reg_steps['registration_confirmation'] ) |
|
568 | + && isset($this->checkout->reg_steps['registration_confirmation']) |
|
569 | 569 | ) { |
570 | 570 | // set the order to something big like 100 |
571 | - $this->checkout->set_reg_step_order( 'registration_confirmation', 100 ); |
|
571 | + $this->checkout->set_reg_step_order('registration_confirmation', 100); |
|
572 | 572 | } |
573 | 573 | // filter the array for good luck |
574 | 574 | $this->checkout->reg_steps = apply_filters( |
@@ -578,13 +578,13 @@ discard block |
||
578 | 578 | // finally re-sort based on the reg step class order properties |
579 | 579 | $this->checkout->sort_reg_steps(); |
580 | 580 | } else { |
581 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
581 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
582 | 582 | // set all current step stati to FALSE |
583 | - $reg_step->set_is_current_step( FALSE ); |
|
583 | + $reg_step->set_is_current_step(FALSE); |
|
584 | 584 | } |
585 | 585 | } |
586 | - if ( empty( $this->checkout->reg_steps )) { |
|
587 | - EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
586 | + if (empty($this->checkout->reg_steps)) { |
|
587 | + EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
588 | 588 | return false; |
589 | 589 | } |
590 | 590 | // make reg step details available to JS |
@@ -602,10 +602,10 @@ discard block |
||
602 | 602 | * @param int $order |
603 | 603 | * @return bool |
604 | 604 | */ |
605 | - private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) { |
|
605 | + private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) { |
|
606 | 606 | |
607 | 607 | // we need a file_path, class_name, and slug to add a reg step |
608 | - if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) { |
|
608 | + if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) { |
|
609 | 609 | // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step) |
610 | 610 | if ( |
611 | 611 | $this->checkout->reg_url_link |
@@ -623,26 +623,26 @@ discard block |
||
623 | 623 | FALSE |
624 | 624 | ); |
625 | 625 | // did we gets the goods ? |
626 | - if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) { |
|
626 | + if ($reg_step_obj instanceof EE_SPCO_Reg_Step) { |
|
627 | 627 | // set reg step order based on config |
628 | - $reg_step_obj->set_order( $order ); |
|
628 | + $reg_step_obj->set_order($order); |
|
629 | 629 | // add instantiated reg step object to the master reg steps array |
630 | - $this->checkout->add_reg_step( $reg_step_obj ); |
|
630 | + $this->checkout->add_reg_step($reg_step_obj); |
|
631 | 631 | } else { |
632 | 632 | EE_Error::add_error( |
633 | - __( 'The current step could not be set.', 'event_espresso' ), |
|
633 | + __('The current step could not be set.', 'event_espresso'), |
|
634 | 634 | __FILE__, __FUNCTION__, __LINE__ |
635 | 635 | ); |
636 | 636 | return false; |
637 | 637 | } |
638 | 638 | } else { |
639 | - if ( WP_DEBUG ) { |
|
639 | + if (WP_DEBUG) { |
|
640 | 640 | EE_Error::add_error( |
641 | 641 | sprintf( |
642 | - __( 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso' ), |
|
643 | - isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '', |
|
644 | - isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '', |
|
645 | - isset( $reg_step['slug'] ) ? $reg_step['slug'] : '', |
|
642 | + __('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'), |
|
643 | + isset($reg_step['file_path']) ? $reg_step['file_path'] : '', |
|
644 | + isset($reg_step['class_name']) ? $reg_step['class_name'] : '', |
|
645 | + isset($reg_step['slug']) ? $reg_step['slug'] : '', |
|
646 | 646 | '<ul>', |
647 | 647 | '<li>', |
648 | 648 | '</li>', |
@@ -666,16 +666,16 @@ discard block |
||
666 | 666 | */ |
667 | 667 | private function _get_transaction_and_cart_for_previous_visit() { |
668 | 668 | /** @var $TXN_model EEM_Transaction */ |
669 | - $TXN_model = EE_Registry::instance()->load_model( 'Transaction' ); |
|
669 | + $TXN_model = EE_Registry::instance()->load_model('Transaction'); |
|
670 | 670 | // because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db |
671 | - $transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link ); |
|
671 | + $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link); |
|
672 | 672 | // verify transaction |
673 | - if ( $transaction instanceof EE_Transaction ) { |
|
673 | + if ($transaction instanceof EE_Transaction) { |
|
674 | 674 | // and get the cart that was used for that transaction |
675 | - $this->checkout->cart = $this->_get_cart_for_transaction( $transaction ); |
|
675 | + $this->checkout->cart = $this->_get_cart_for_transaction($transaction); |
|
676 | 676 | return $transaction; |
677 | 677 | } else { |
678 | - EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__); |
|
678 | + EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
679 | 679 | return NULL; |
680 | 680 | } |
681 | 681 | } |
@@ -689,11 +689,11 @@ discard block |
||
689 | 689 | * @param EE_Transaction $transaction |
690 | 690 | * @return EE_Cart |
691 | 691 | */ |
692 | - private function _get_cart_for_transaction( $transaction ) { |
|
693 | - $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn( $transaction ) : NULL; |
|
692 | + private function _get_cart_for_transaction($transaction) { |
|
693 | + $cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction) : NULL; |
|
694 | 694 | // verify cart |
695 | - if ( ! $cart instanceof EE_Cart ) { |
|
696 | - $cart = EE_Registry::instance()->load_core( 'Cart' ); |
|
695 | + if ( ! $cart instanceof EE_Cart) { |
|
696 | + $cart = EE_Registry::instance()->load_core('Cart'); |
|
697 | 697 | } |
698 | 698 | return $cart; |
699 | 699 | } |
@@ -708,8 +708,8 @@ discard block |
||
708 | 708 | * @param EE_Transaction $transaction |
709 | 709 | * @return EE_Cart |
710 | 710 | */ |
711 | - public function get_cart_for_transaction( EE_Transaction $transaction ) { |
|
712 | - return EE_Cart::get_cart_from_txn( $transaction ); |
|
711 | + public function get_cart_for_transaction(EE_Transaction $transaction) { |
|
712 | + return EE_Cart::get_cart_from_txn($transaction); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | |
@@ -724,17 +724,17 @@ discard block |
||
724 | 724 | private function _get_cart_for_current_session_and_setup_new_transaction() { |
725 | 725 | // if there's no transaction, then this is the FIRST visit to SPCO |
726 | 726 | // so load up the cart ( passing nothing for the TXN because it doesn't exist yet ) |
727 | - $this->checkout->cart = $this->_get_cart_for_transaction( NULL ); |
|
727 | + $this->checkout->cart = $this->_get_cart_for_transaction(NULL); |
|
728 | 728 | // and then create a new transaction |
729 | 729 | $transaction = $this->_initialize_transaction(); |
730 | 730 | // verify transaction |
731 | - if ( $transaction instanceof EE_Transaction ) { |
|
731 | + if ($transaction instanceof EE_Transaction) { |
|
732 | 732 | // save it so that we have an ID for other objects to use |
733 | 733 | $transaction->save(); |
734 | 734 | // and save TXN data to the cart |
735 | - $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() ); |
|
735 | + $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID()); |
|
736 | 736 | } else { |
737 | - EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
737 | + EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
738 | 738 | } |
739 | 739 | return $transaction; |
740 | 740 | } |
@@ -754,15 +754,15 @@ discard block |
||
754 | 754 | // grab the cart grand total |
755 | 755 | $cart_total = $this->checkout->cart->get_cart_grand_total(); |
756 | 756 | // create new TXN |
757 | - return EE_Transaction::new_instance( array( |
|
757 | + return EE_Transaction::new_instance(array( |
|
758 | 758 | 'TXN_timestamp' => time(), |
759 | 759 | 'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(), |
760 | 760 | 'TXN_total' => $cart_total > 0 ? $cart_total : 0, |
761 | 761 | 'TXN_paid' => 0, |
762 | 762 | 'STS_ID' => EEM_Transaction::failed_status_code, |
763 | 763 | )); |
764 | - } catch( Exception $e ) { |
|
765 | - EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
764 | + } catch (Exception $e) { |
|
765 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
766 | 766 | } |
767 | 767 | return NULL; |
768 | 768 | } |
@@ -776,34 +776,34 @@ discard block |
||
776 | 776 | * @param EE_Transaction $transaction |
777 | 777 | * @return EE_Cart |
778 | 778 | */ |
779 | - private function _get_registrations( EE_Transaction $transaction ) { |
|
779 | + private function _get_registrations(EE_Transaction $transaction) { |
|
780 | 780 | // first step: grab the registrants { : o |
781 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true ); |
|
781 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true); |
|
782 | 782 | // verify registrations have been set |
783 | - if ( empty( $registrations )) { |
|
783 | + if (empty($registrations)) { |
|
784 | 784 | // if no cached registrations, then check the db |
785 | - $registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false ); |
|
785 | + $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false); |
|
786 | 786 | // still nothing ? well as long as this isn't a revisit |
787 | - if ( empty( $registrations ) && ! $this->checkout->revisit ) { |
|
787 | + if (empty($registrations) && ! $this->checkout->revisit) { |
|
788 | 788 | // generate new registrations from scratch |
789 | - $registrations = $this->_initialize_registrations( $transaction ); |
|
789 | + $registrations = $this->_initialize_registrations($transaction); |
|
790 | 790 | } |
791 | 791 | } |
792 | 792 | // sort by their original registration order |
793 | - usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' )); |
|
793 | + usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count')); |
|
794 | 794 | // then loop thru the array |
795 | - foreach ( $registrations as $registration ) { |
|
795 | + foreach ($registrations as $registration) { |
|
796 | 796 | // verify each registration |
797 | - if ( $registration instanceof EE_Registration ) { |
|
797 | + if ($registration instanceof EE_Registration) { |
|
798 | 798 | // we display all attendee info for the primary registrant |
799 | - if ( $this->checkout->reg_url_link == $registration->reg_url_link() && $registration->is_primary_registrant() ) { |
|
799 | + if ($this->checkout->reg_url_link == $registration->reg_url_link() && $registration->is_primary_registrant()) { |
|
800 | 800 | $this->checkout->primary_revisit = TRUE; |
801 | 801 | break; |
802 | - } else if ( $this->checkout->revisit && $this->checkout->reg_url_link != $registration->reg_url_link() ) { |
|
802 | + } else if ($this->checkout->revisit && $this->checkout->reg_url_link != $registration->reg_url_link()) { |
|
803 | 803 | // but hide info if it doesn't belong to you |
804 | - $transaction->clear_cache( 'Registration', $registration->ID() ); |
|
804 | + $transaction->clear_cache('Registration', $registration->ID()); |
|
805 | 805 | } |
806 | - $this->checkout->set_reg_status_updated( $registration->ID(), false ); |
|
806 | + $this->checkout->set_reg_status_updated($registration->ID(), false); |
|
807 | 807 | } |
808 | 808 | } |
809 | 809 | } |
@@ -817,17 +817,17 @@ discard block |
||
817 | 817 | * @param EE_Transaction $transaction |
818 | 818 | * @return array |
819 | 819 | */ |
820 | - private function _initialize_registrations( EE_Transaction $transaction ) { |
|
820 | + private function _initialize_registrations(EE_Transaction $transaction) { |
|
821 | 821 | $att_nmbr = 0; |
822 | 822 | $registrations = array(); |
823 | - if ( $transaction instanceof EE_Transaction ) { |
|
823 | + if ($transaction instanceof EE_Transaction) { |
|
824 | 824 | /** @type EE_Registration_Processor $registration_processor */ |
825 | - $registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' ); |
|
825 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
826 | 826 | $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count(); |
827 | 827 | // now let's add the cart items to the $transaction |
828 | - foreach ( $this->checkout->cart->get_tickets() as $line_item ) { |
|
828 | + foreach ($this->checkout->cart->get_tickets() as $line_item) { |
|
829 | 829 | //do the following for each ticket of this type they selected |
830 | - for ( $x = 1; $x <= $line_item->quantity(); $x++ ) { |
|
830 | + for ($x = 1; $x <= $line_item->quantity(); $x++) { |
|
831 | 831 | $att_nmbr++; |
832 | 832 | $registration = $registration_processor->generate_ONE_registration_from_line_item( |
833 | 833 | $line_item, |
@@ -835,12 +835,12 @@ discard block |
||
835 | 835 | $att_nmbr, |
836 | 836 | $this->checkout->total_ticket_count |
837 | 837 | ); |
838 | - if ( $registration instanceof EE_Registration ) { |
|
839 | - $registrations[ $registration->ID() ] = $registration; |
|
838 | + if ($registration instanceof EE_Registration) { |
|
839 | + $registrations[$registration->ID()] = $registration; |
|
840 | 840 | } |
841 | 841 | } |
842 | 842 | } |
843 | - $registration_processor->fix_reg_final_price_rounding_issue( $transaction ); |
|
843 | + $registration_processor->fix_reg_final_price_rounding_issue($transaction); |
|
844 | 844 | } |
845 | 845 | return $registrations; |
846 | 846 | } |
@@ -855,12 +855,12 @@ discard block |
||
855 | 855 | * @param EE_Registration $reg_B |
856 | 856 | * @return array() |
857 | 857 | */ |
858 | - public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) { |
|
858 | + public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) { |
|
859 | 859 | // this shouldn't ever happen within the same TXN, but oh well |
860 | - if ( $reg_A->count() == $reg_B->count() ) { |
|
860 | + if ($reg_A->count() == $reg_B->count()) { |
|
861 | 861 | return 0; |
862 | 862 | } |
863 | - return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1; |
|
863 | + return ($reg_A->count() > $reg_B->count()) ? 1 : -1; |
|
864 | 864 | } |
865 | 865 | |
866 | 866 | |
@@ -875,35 +875,35 @@ discard block |
||
875 | 875 | */ |
876 | 876 | private function _final_verifications() { |
877 | 877 | // filter checkout |
878 | - $this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout ); |
|
878 | + $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout); |
|
879 | 879 | //verify that current step is still set correctly |
880 | - if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) { |
|
881 | - EE_Error::add_error( __( 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
880 | + if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) { |
|
881 | + EE_Error::add_error(__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
882 | 882 | return false; |
883 | 883 | } |
884 | 884 | // if returning to SPCO, then verify that primary registrant is set |
885 | - if ( ! empty( $this->checkout->reg_url_link )) { |
|
885 | + if ( ! empty($this->checkout->reg_url_link)) { |
|
886 | 886 | $valid_registrant = $this->checkout->transaction->primary_registration(); |
887 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
888 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
887 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
888 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
889 | 889 | return false; |
890 | 890 | } |
891 | 891 | $valid_registrant = null; |
892 | - foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) { |
|
893 | - if ( $registration instanceof EE_Registration ) { |
|
894 | - if ( $registration->reg_url_link() == $this->checkout->reg_url_link ) { |
|
892 | + foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) { |
|
893 | + if ($registration instanceof EE_Registration) { |
|
894 | + if ($registration->reg_url_link() == $this->checkout->reg_url_link) { |
|
895 | 895 | $valid_registrant = $registration; |
896 | 896 | } |
897 | 897 | } |
898 | 898 | } |
899 | - if ( ! $valid_registrant instanceof EE_Registration ) { |
|
900 | - EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
899 | + if ( ! $valid_registrant instanceof EE_Registration) { |
|
900 | + EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
901 | 901 | return false; |
902 | 902 | } |
903 | 903 | } |
904 | 904 | // now that things have been kinda sufficiently verified, |
905 | 905 | // let's add the checkout to the session so that's available other systems |
906 | - EE_Registry::instance()->SSN->set_checkout( $this->checkout ); |
|
906 | + EE_Registry::instance()->SSN->set_checkout($this->checkout); |
|
907 | 907 | return true; |
908 | 908 | } |
909 | 909 | |
@@ -919,28 +919,28 @@ discard block |
||
919 | 919 | * @access private |
920 | 920 | * @param bool $reinitializing |
921 | 921 | */ |
922 | - private function _initialize_reg_steps( $reinitializing = false ) { |
|
923 | - $this->checkout->set_reg_step_initiated( $this->checkout->current_step ); |
|
922 | + private function _initialize_reg_steps($reinitializing = false) { |
|
923 | + $this->checkout->set_reg_step_initiated($this->checkout->current_step); |
|
924 | 924 | // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS |
925 | - foreach ( $this->checkout->reg_steps as $reg_step ) { |
|
926 | - if ( ! $reg_step->initialize_reg_step() ) { |
|
925 | + foreach ($this->checkout->reg_steps as $reg_step) { |
|
926 | + if ( ! $reg_step->initialize_reg_step()) { |
|
927 | 927 | // if not initialized then maybe this step is being removed... |
928 | - if ( $reg_step->is_current_step() && ! $reinitializing ) { |
|
928 | + if ($reg_step->is_current_step() && ! $reinitializing) { |
|
929 | 929 | // if it was the current step, then we need to start over here |
930 | - $this->_initialize_reg_steps( true ); |
|
930 | + $this->_initialize_reg_steps(true); |
|
931 | 931 | return; |
932 | 932 | } |
933 | 933 | continue; |
934 | 934 | } |
935 | 935 | // i18n |
936 | 936 | $reg_step->translate_js_strings(); |
937 | - if ( $reg_step->is_current_step() ) { |
|
937 | + if ($reg_step->is_current_step()) { |
|
938 | 938 | // the text that appears on the reg step form submit button |
939 | 939 | $reg_step->set_submit_button_text(); |
940 | 940 | } |
941 | 941 | } |
942 | 942 | // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information |
943 | - do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step ); |
|
943 | + do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step); |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | |
@@ -953,39 +953,39 @@ discard block |
||
953 | 953 | */ |
954 | 954 | private function _check_form_submission() { |
955 | 955 | //does this request require the reg form to be generated ? |
956 | - if ( $this->checkout->generate_reg_form ) { |
|
956 | + if ($this->checkout->generate_reg_form) { |
|
957 | 957 | // ever heard that song by Blue Rodeo ? |
958 | 958 | try { |
959 | 959 | $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form(); |
960 | 960 | // if not displaying a form, then check for form submission |
961 | - if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) { |
|
961 | + if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) { |
|
962 | 962 | // clear out any old data in case this step is being run again |
963 | - $this->checkout->current_step->set_valid_data( array() ); |
|
963 | + $this->checkout->current_step->set_valid_data(array()); |
|
964 | 964 | // capture submitted form data |
965 | 965 | $this->checkout->current_step->reg_form->receive_form_submission( |
966 | - apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout ) |
|
966 | + apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout) |
|
967 | 967 | ); |
968 | 968 | // validate submitted form data |
969 | - if ( ! $this->checkout->current_step->reg_form->is_valid() || ! $this->checkout->continue_reg ) { |
|
969 | + if ( ! $this->checkout->current_step->reg_form->is_valid() || ! $this->checkout->continue_reg) { |
|
970 | 970 | // thou shall not pass !!! |
971 | 971 | $this->checkout->continue_reg = FALSE; |
972 | 972 | // any form validation errors? |
973 | - if ( $this->checkout->current_step->reg_form->submission_error_message() != '' ) { |
|
973 | + if ($this->checkout->current_step->reg_form->submission_error_message() != '') { |
|
974 | 974 | $submission_error_messages = array(); |
975 | 975 | // bad, bad, bad registrant |
976 | - foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){ |
|
977 | - if ( $validation_error instanceof EE_Validation_Error ) { |
|
978 | - $submission_error_messages[] = sprintf( __( '%s : %s', 'event_espresso' ), $validation_error->get_form_section()->html_label_text(), $validation_error->getMessage() ); |
|
976 | + foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) { |
|
977 | + if ($validation_error instanceof EE_Validation_Error) { |
|
978 | + $submission_error_messages[] = sprintf(__('%s : %s', 'event_espresso'), $validation_error->get_form_section()->html_label_text(), $validation_error->getMessage()); |
|
979 | 979 | } |
980 | 980 | } |
981 | - EE_Error::add_error( join( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ ); |
|
981 | + EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__); |
|
982 | 982 | } |
983 | 983 | // well not really... what will happen is we'll just get redirected back to redo the current step |
984 | 984 | $this->go_to_next_step(); |
985 | 985 | return; |
986 | 986 | } |
987 | 987 | } |
988 | - } catch( EE_Error $e ) { |
|
988 | + } catch (EE_Error $e) { |
|
989 | 989 | $e->get_error(); |
990 | 990 | } |
991 | 991 | } |
@@ -1001,38 +1001,38 @@ discard block |
||
1001 | 1001 | */ |
1002 | 1002 | private function _process_form_action() { |
1003 | 1003 | // what cha wanna do? |
1004 | - switch( $this->checkout->action ) { |
|
1004 | + switch ($this->checkout->action) { |
|
1005 | 1005 | // AJAX next step reg form |
1006 | 1006 | case 'display_spco_reg_step' : |
1007 | 1007 | $this->checkout->redirect = FALSE; |
1008 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1009 | - $this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() ); |
|
1008 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1009 | + $this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form()); |
|
1010 | 1010 | } |
1011 | 1011 | break; |
1012 | 1012 | |
1013 | 1013 | default : |
1014 | 1014 | // meh... do one of those other steps first |
1015 | - if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) { |
|
1015 | + if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) { |
|
1016 | 1016 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step |
1017 | - do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1017 | + do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1018 | 1018 | // call action on current step |
1019 | - if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) { |
|
1019 | + if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) { |
|
1020 | 1020 | // good registrant, you get to proceed |
1021 | - if ( $this->checkout->current_step->success_message() != '' ) { |
|
1022 | - if ( apply_filters( 'FHEE__Single_Page_Checkout___process_form_action__display_success', false ) ) { |
|
1023 | - EE_Error::add_success( $this->checkout->current_step->success_message() . '<br />' . $this->checkout->next_step->_instructions() ); |
|
1021 | + if ($this->checkout->current_step->success_message() != '') { |
|
1022 | + if (apply_filters('FHEE__Single_Page_Checkout___process_form_action__display_success', false)) { |
|
1023 | + EE_Error::add_success($this->checkout->current_step->success_message().'<br />'.$this->checkout->next_step->_instructions()); |
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | // pack it up, pack it in... |
1027 | 1027 | $this->_setup_redirect(); |
1028 | 1028 | } |
1029 | 1029 | // dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step |
1030 | - do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step ); |
|
1030 | + do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step); |
|
1031 | 1031 | |
1032 | 1032 | } else { |
1033 | 1033 | EE_Error::add_error( |
1034 | 1034 | sprintf( |
1035 | - __( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ), |
|
1035 | + __('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'), |
|
1036 | 1036 | $this->checkout->action, |
1037 | 1037 | $this->checkout->current_step->name() |
1038 | 1038 | ), |
@@ -1058,10 +1058,10 @@ discard block |
||
1058 | 1058 | public function add_styles_and_scripts() { |
1059 | 1059 | // i18n |
1060 | 1060 | $this->translate_js_strings(); |
1061 | - if ( $this->checkout->admin_request ) { |
|
1062 | - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 ); |
|
1061 | + if ($this->checkout->admin_request) { |
|
1062 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1063 | 1063 | } else { |
1064 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 ); |
|
1064 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10); |
|
1065 | 1065 | } |
1066 | 1066 | } |
1067 | 1067 | |
@@ -1077,42 +1077,42 @@ discard block |
||
1077 | 1077 | EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit; |
1078 | 1078 | EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link; |
1079 | 1079 | EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
1080 | - EE_Registry::$i18n_js_strings['invalid_json_response'] = __( 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1081 | - EE_Registry::$i18n_js_strings['validation_error'] = __( 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso' ); |
|
1082 | - EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso' ); |
|
1080 | + EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1081 | + EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso'); |
|
1082 | + EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso'); |
|
1083 | 1083 | EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso'); |
1084 | 1084 | EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso'); |
1085 | - EE_Registry::$i18n_js_strings['process_registration'] = sprintf( __( 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso' ), '<br/>', '<br/>' ); |
|
1086 | - EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' ); |
|
1085 | + EE_Registry::$i18n_js_strings['process_registration'] = sprintf(__('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), '<br/>', '<br/>'); |
|
1086 | + EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language'); |
|
1087 | 1087 | EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id(); |
1088 | 1088 | EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency; |
1089 | 1089 | EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20'; |
1090 | - EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' ); |
|
1091 | - EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' ); |
|
1092 | - EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' ); |
|
1093 | - EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' ); |
|
1094 | - EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' ); |
|
1095 | - EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' ); |
|
1096 | - EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' ); |
|
1097 | - EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' ); |
|
1098 | - EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' ); |
|
1099 | - EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' ); |
|
1100 | - EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' ); |
|
1101 | - EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' ); |
|
1102 | - EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' ); |
|
1103 | - EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' ); |
|
1090 | + EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso'); |
|
1091 | + EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso'); |
|
1092 | + EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso'); |
|
1093 | + EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso'); |
|
1094 | + EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso'); |
|
1095 | + EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso'); |
|
1096 | + EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso'); |
|
1097 | + EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso'); |
|
1098 | + EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso'); |
|
1099 | + EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso'); |
|
1100 | + EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso'); |
|
1101 | + EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso'); |
|
1102 | + EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso'); |
|
1103 | + EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso'); |
|
1104 | 1104 | EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf( |
1105 | - __( '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ), |
|
1105 | + __('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'), |
|
1106 | 1106 | '<h4 class="important-notice">', |
1107 | 1107 | '</h4>', |
1108 | 1108 | '<br />', |
1109 | 1109 | '<p>', |
1110 | - '<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1110 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1111 | 1111 | '">', |
1112 | 1112 | '</a>', |
1113 | 1113 | '</p>' |
1114 | 1114 | ); |
1115 | - EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true ); |
|
1115 | + EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true); |
|
1116 | 1116 | } |
1117 | 1117 | |
1118 | 1118 | |
@@ -1125,25 +1125,25 @@ discard block |
||
1125 | 1125 | */ |
1126 | 1126 | public function enqueue_styles_and_scripts() { |
1127 | 1127 | // load css |
1128 | - wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION ); |
|
1129 | - wp_enqueue_style( 'single_page_checkout' ); |
|
1128 | + wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION); |
|
1129 | + wp_enqueue_style('single_page_checkout'); |
|
1130 | 1130 | // load JS |
1131 | - wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery .plugin.min.js', array( 'jquery' ), '1.0.1', TRUE ); |
|
1132 | - wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery .countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE ); |
|
1133 | - wp_register_script( 'single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array( 'espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown' ), EVENT_ESPRESSO_VERSION, TRUE ); |
|
1134 | - wp_enqueue_script( 'single_page_checkout' ); |
|
1131 | + wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery .plugin.min.js', array('jquery'), '1.0.1', TRUE); |
|
1132 | + wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery .countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE); |
|
1133 | + wp_register_script('single_page_checkout', SPCO_JS_URL.'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, TRUE); |
|
1134 | + wp_enqueue_script('single_page_checkout'); |
|
1135 | 1135 | |
1136 | 1136 | /** |
1137 | 1137 | * global action hook for enqueueing styles and scripts with |
1138 | 1138 | * spco calls. |
1139 | 1139 | */ |
1140 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this ); |
|
1140 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this); |
|
1141 | 1141 | |
1142 | 1142 | /** |
1143 | 1143 | * dynamic action hook for enqueueing styles and scripts with spco calls. |
1144 | 1144 | * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information |
1145 | 1145 | */ |
1146 | - do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this ); |
|
1146 | + do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this); |
|
1147 | 1147 | |
1148 | 1148 | // add css and JS for current step |
1149 | 1149 | $this->checkout->current_step->enqueue_styles_and_scripts(); |
@@ -1159,20 +1159,20 @@ discard block |
||
1159 | 1159 | */ |
1160 | 1160 | private function _display_spco_reg_form() { |
1161 | 1161 | // if registering via the admin, just display the reg form for the current step |
1162 | - if ( $this->checkout->admin_request ) { |
|
1163 | - EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() ); |
|
1162 | + if ($this->checkout->admin_request) { |
|
1163 | + EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form()); |
|
1164 | 1164 | } else { |
1165 | 1165 | // add powered by EE msg |
1166 | - add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' )); |
|
1166 | + add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer')); |
|
1167 | 1167 | |
1168 | - $empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false; |
|
1168 | + $empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false; |
|
1169 | 1169 | $cookies_not_set_msg = ''; |
1170 | - if ( $empty_cart ) { |
|
1171 | - if ( ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) { |
|
1170 | + if ($empty_cart) { |
|
1171 | + if ( ! isset($_COOKIE['ee_cookie_test'])) { |
|
1172 | 1172 | $cookies_not_set_msg = apply_filters( |
1173 | 1173 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg', |
1174 | 1174 | sprintf( |
1175 | - __( '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso' ), |
|
1175 | + __('%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso'), |
|
1176 | 1176 | '<div class="ee-attention">', |
1177 | 1177 | '</div>', |
1178 | 1178 | '<h6 class="important-notice">', |
@@ -1193,7 +1193,7 @@ discard block |
||
1193 | 1193 | 'layout_strategy' => |
1194 | 1194 | new EE_Template_Layout( |
1195 | 1195 | array( |
1196 | - 'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php', |
|
1196 | + 'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php', |
|
1197 | 1197 | 'template_args' => array( |
1198 | 1198 | 'empty_cart' => $empty_cart, |
1199 | 1199 | 'revisit' => $this->checkout->revisit, |
@@ -1202,8 +1202,8 @@ discard block |
||
1202 | 1202 | 'empty_msg' => apply_filters( |
1203 | 1203 | 'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg', |
1204 | 1204 | sprintf( |
1205 | - __( 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso' ), |
|
1206 | - '<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="', |
|
1205 | + __('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso'), |
|
1206 | + '<a href="'.get_post_type_archive_link('espresso_events').'" title="', |
|
1207 | 1207 | '">', |
1208 | 1208 | '</a>' |
1209 | 1209 | ) |
@@ -1211,14 +1211,14 @@ discard block |
||
1211 | 1211 | 'cookies_not_set_msg' => $cookies_not_set_msg, |
1212 | 1212 | 'registration_time_limit' => $this->checkout->get_registration_time_limit(), |
1213 | 1213 | 'session_expiration' => |
1214 | - gmdate( 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) |
|
1214 | + gmdate('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)) |
|
1215 | 1215 | ) |
1216 | 1216 | ) |
1217 | 1217 | ) |
1218 | 1218 | ) |
1219 | 1219 | ); |
1220 | 1220 | // load template and add to output sent that gets filtered into the_content() |
1221 | - EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() ); |
|
1221 | + EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js()); |
|
1222 | 1222 | } |
1223 | 1223 | } |
1224 | 1224 | |
@@ -1232,8 +1232,8 @@ discard block |
||
1232 | 1232 | * @internal param string $label |
1233 | 1233 | * @return string |
1234 | 1234 | */ |
1235 | - public function add_extra_finalize_registration_inputs( $next_step ) { |
|
1236 | - if ( $next_step == 'finalize_registration' ) { |
|
1235 | + public function add_extra_finalize_registration_inputs($next_step) { |
|
1236 | + if ($next_step == 'finalize_registration') { |
|
1237 | 1237 | echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>'; |
1238 | 1238 | } |
1239 | 1239 | } |
@@ -1247,18 +1247,18 @@ discard block |
||
1247 | 1247 | * @return string |
1248 | 1248 | */ |
1249 | 1249 | public static function display_registration_footer() { |
1250 | - if ( apply_filters( 'FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer ) ) { |
|
1251 | - EE_Registry::instance()->CFG->admin->affiliate_id = ! empty( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1252 | - $url = add_query_arg( array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id ), 'https://eventespresso.com/' ); |
|
1253 | - $url = apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url ); |
|
1250 | + if (apply_filters('FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer)) { |
|
1251 | + EE_Registry::instance()->CFG->admin->affiliate_id = ! empty(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default'; |
|
1252 | + $url = add_query_arg(array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id), 'https://eventespresso.com/'); |
|
1253 | + $url = apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url); |
|
1254 | 1254 | echo apply_filters( |
1255 | 1255 | 'FHEE__EE_Front_Controller__display_registration_footer', |
1256 | 1256 | sprintf( |
1257 | - __( '%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso' ), |
|
1258 | - '<div id="espresso-registration-footer-dv"><a href="' . $url . '" title="', |
|
1257 | + __('%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso'), |
|
1258 | + '<div id="espresso-registration-footer-dv"><a href="'.$url.'" title="', |
|
1259 | 1259 | '" target="_blank">', |
1260 | 1260 | '</a>', |
1261 | - '<a href="' . $url . '" title="', |
|
1261 | + '<a href="'.$url.'" title="', |
|
1262 | 1262 | '" target="_blank">', |
1263 | 1263 | '</a></div>' |
1264 | 1264 | ) |
@@ -1289,12 +1289,12 @@ discard block |
||
1289 | 1289 | * @return array |
1290 | 1290 | */ |
1291 | 1291 | private function _setup_redirect() { |
1292 | - if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
1292 | + if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
1293 | 1293 | $this->checkout->redirect = TRUE; |
1294 | - if ( empty( $this->checkout->redirect_url )) { |
|
1294 | + if (empty($this->checkout->redirect_url)) { |
|
1295 | 1295 | $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url(); |
1296 | 1296 | } |
1297 | - $this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout ); |
|
1297 | + $this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout); |
|
1298 | 1298 | } |
1299 | 1299 | } |
1300 | 1300 | |
@@ -1307,12 +1307,12 @@ discard block |
||
1307 | 1307 | * @return void |
1308 | 1308 | */ |
1309 | 1309 | public function go_to_next_step() { |
1310 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1310 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1311 | 1311 | // capture contents of output buffer we started earlier in the request, and insert into JSON response |
1312 | - $this->checkout->json_response->set_unexpected_errors( ob_get_clean() ); |
|
1312 | + $this->checkout->json_response->set_unexpected_errors(ob_get_clean()); |
|
1313 | 1313 | } |
1314 | 1314 | // just return for these conditions |
1315 | - if ( $this->checkout->admin_request || $this->checkout->action == 'redirect_form' || $this->checkout->action == 'update_checkout' ) { |
|
1315 | + if ($this->checkout->admin_request || $this->checkout->action == 'redirect_form' || $this->checkout->action == 'update_checkout') { |
|
1316 | 1316 | return; |
1317 | 1317 | } |
1318 | 1318 | // AJAX response |
@@ -1333,7 +1333,7 @@ discard block |
||
1333 | 1333 | */ |
1334 | 1334 | protected function _handle_json_response() { |
1335 | 1335 | // if this is an ajax request |
1336 | - if ( EE_Registry::instance()->REQ->ajax ) { |
|
1336 | + if (EE_Registry::instance()->REQ->ajax) { |
|
1337 | 1337 | // DEBUG LOG |
1338 | 1338 | //$this->checkout->log( |
1339 | 1339 | // __CLASS__, __FUNCTION__, __LINE__, |
@@ -1343,10 +1343,10 @@ discard block |
||
1343 | 1343 | // 'continue_reg' => $this->checkout->continue_reg, |
1344 | 1344 | // ) |
1345 | 1345 | //); |
1346 | - $this->checkout->json_response->set_registration_time_limit( $this->checkout->get_registration_time_limit() ); |
|
1347 | - $this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing ); |
|
1346 | + $this->checkout->json_response->set_registration_time_limit($this->checkout->get_registration_time_limit()); |
|
1347 | + $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing); |
|
1348 | 1348 | // just send the ajax ( |
1349 | - $json_response = apply_filters( 'FHEE__EE_Single_Page_Checkout__JSON_response', $this->checkout->json_response ); |
|
1349 | + $json_response = apply_filters('FHEE__EE_Single_Page_Checkout__JSON_response', $this->checkout->json_response); |
|
1350 | 1350 | $this->unlock_transaction(); |
1351 | 1351 | echo $json_response; |
1352 | 1352 | exit(); |
@@ -1363,9 +1363,9 @@ discard block |
||
1363 | 1363 | */ |
1364 | 1364 | protected function _handle_html_redirects() { |
1365 | 1365 | // going somewhere ? |
1366 | - if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) { |
|
1366 | + if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) { |
|
1367 | 1367 | // store notices in a transient |
1368 | - EE_Error::get_notices( false, true, true ); |
|
1368 | + EE_Error::get_notices(false, true, true); |
|
1369 | 1369 | $this->unlock_transaction(); |
1370 | 1370 | // DEBUG LOG |
1371 | 1371 | //$this->checkout->log( |
@@ -1376,7 +1376,7 @@ discard block |
||
1376 | 1376 | // 'headers_list' => headers_list(), |
1377 | 1377 | // ) |
1378 | 1378 | //); |
1379 | - wp_safe_redirect( $this->checkout->redirect_url ); |
|
1379 | + wp_safe_redirect($this->checkout->redirect_url); |
|
1380 | 1380 | exit(); |
1381 | 1381 | } |
1382 | 1382 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public static function instance() { |
63 | 63 | // check if class object is instantiated, and instantiated properly |
64 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Front_Controller )) { |
|
64 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Front_Controller)) { |
|
65 | 65 | self::$_instance = new self(); |
66 | 66 | } |
67 | 67 | return self::$_instance; |
@@ -79,37 +79,37 @@ discard block |
||
79 | 79 | */ |
80 | 80 | private function __construct() { |
81 | 81 | // make sure template tags are loaded immediately so that themes don't break |
82 | - add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'load_espresso_template_tags' ), 10 ); |
|
82 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'load_espresso_template_tags'), 10); |
|
83 | 83 | // determine how to integrate WP_Query with the EE models |
84 | - add_action( 'AHEE__EE_System__initialize', array( $this, 'employ_CPT_Strategy' )); |
|
84 | + add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
85 | 85 | // load other resources and begin to actually run shortcodes and modules |
86 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 5 ); |
|
86 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
87 | 87 | // analyse the incoming WP request |
88 | - add_action( 'parse_request', array( $this, 'get_request' ), 1, 1 ); |
|
88 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
89 | 89 | // process any content shortcodes |
90 | - add_action( 'parse_request', array( $this, '_initialize_shortcodes' ), 5 ); |
|
90 | + add_action('parse_request', array($this, '_initialize_shortcodes'), 5); |
|
91 | 91 | // process request with module factory |
92 | - add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 10, 1 ); |
|
92 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
93 | 93 | // before headers sent |
94 | - add_action( 'wp', array( $this, 'wp' ), 5 ); |
|
94 | + add_action('wp', array($this, 'wp'), 5); |
|
95 | 95 | // load css and js |
96 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 1 ); |
|
96 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 1); |
|
97 | 97 | // header |
98 | - add_action('wp_head', array( $this, 'header_meta_tag' ), 5 ); |
|
99 | - add_filter( 'template_include', array( $this, 'template_include' ), 1 ); |
|
98 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
99 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
100 | 100 | // display errors |
101 | - add_action('loop_start', array( $this, 'display_errors' ), 2 ); |
|
101 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
102 | 102 | // the content |
103 | - add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
103 | + add_filter('the_content', array($this, 'the_content'), 5, 1); |
|
104 | 104 | //exclude our private cpt comments |
105 | - add_filter( 'comments_clauses', array( $this, 'filter_wp_comments'), 10, 1 ); |
|
105 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
106 | 106 | //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
107 | - add_filter( 'admin_url', array( $this, 'maybe_force_admin_ajax_ssl' ), 200, 1 ); |
|
107 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
108 | 108 | // action hook EE |
109 | - do_action( 'AHEE__EE_Front_Controller__construct__done',$this ); |
|
109 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
110 | 110 | // for checking that browser cookies are enabled |
111 | - if ( apply_filters( 'FHEE__EE_Front_Controller____construct__set_test_cookie', true )) { |
|
112 | - setcookie( 'ee_cookie_test', uniqid(), time() + 24 * HOUR_IN_SECONDS, '/' ); |
|
111 | + if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
112 | + setcookie('ee_cookie_test', uniqid(), time() + 24 * HOUR_IN_SECONDS, '/'); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * @return void |
130 | 130 | */ |
131 | 131 | public function load_espresso_template_tags() { |
132 | - if ( is_readable( EE_PUBLIC . 'template_tags.php' )) { |
|
133 | - require_once( EE_PUBLIC . 'template_tags.php' ); |
|
132 | + if (is_readable(EE_PUBLIC.'template_tags.php')) { |
|
133 | + require_once(EE_PUBLIC.'template_tags.php'); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | * @param array $clauses array of comment clauses setup by WP_Comment_Query |
146 | 146 | * @return array array of comment clauses with modifications. |
147 | 147 | */ |
148 | - public function filter_wp_comments( $clauses ) { |
|
148 | + public function filter_wp_comments($clauses) { |
|
149 | 149 | global $wpdb; |
150 | - if ( strpos( $clauses['join'], $wpdb->posts ) !== FALSE ) { |
|
150 | + if (strpos($clauses['join'], $wpdb->posts) !== FALSE) { |
|
151 | 151 | $cpts = EE_Register_CPTs::get_private_CPTs(); |
152 | - foreach ( $cpts as $cpt => $details ) { |
|
153 | - $clauses['where'] .= $wpdb->prepare( " AND $wpdb->posts.post_type != %s", $cpt ); |
|
152 | + foreach ($cpts as $cpt => $details) { |
|
153 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | return $clauses; |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @return void |
168 | 168 | */ |
169 | 169 | public function employ_CPT_Strategy() { |
170 | - if ( apply_filters( 'FHEE__EE_Front_Controller__employ_CPT_Strategy',true) ){ |
|
171 | - EE_Registry::instance()->load_core( 'CPT_Strategy' ); |
|
170 | + if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
171 | + EE_Registry::instance()->load_core('CPT_Strategy'); |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | * @param string $url incoming url |
181 | 181 | * @return string final assembled url |
182 | 182 | */ |
183 | - public function maybe_force_admin_ajax_ssl( $url ) { |
|
184 | - if ( is_ssl() && preg_match( '/admin-ajax.php/', $url )) { |
|
185 | - $url = str_replace( 'http://', 'https://', $url ); |
|
183 | + public function maybe_force_admin_ajax_ssl($url) { |
|
184 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
185 | + $url = str_replace('http://', 'https://', $url); |
|
186 | 186 | } |
187 | 187 | return $url; |
188 | 188 | } |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | * @param WP $WP |
220 | 220 | * @return void |
221 | 221 | */ |
222 | - public function get_request( WP $WP ) { |
|
223 | - do_action( 'AHEE__EE_Front_Controller__get_request__start' ); |
|
224 | - EE_Registry::instance()->load_core( 'Request_Handler', $WP ); |
|
225 | - do_action( 'AHEE__EE_Front_Controller__get_request__complete' ); |
|
222 | + public function get_request(WP $WP) { |
|
223 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
224 | + EE_Registry::instance()->load_core('Request_Handler', $WP); |
|
225 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -234,22 +234,22 @@ discard block |
||
234 | 234 | * @param WP $WP |
235 | 235 | * @return void |
236 | 236 | */ |
237 | - public function _initialize_shortcodes( WP $WP ) { |
|
238 | - do_action( 'AHEE__EE_Front_Controller__initialize_shortcodes__begin', $WP, $this ); |
|
237 | + public function _initialize_shortcodes(WP $WP) { |
|
238 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $WP, $this); |
|
239 | 239 | // grab post_name from request |
240 | - $current_post = apply_filters( 'FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', EE_Registry::instance()->REQ->get( 'post_name' )); |
|
240 | + $current_post = apply_filters('FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', EE_Registry::instance()->REQ->get('post_name')); |
|
241 | 241 | // if it's not set, then check if frontpage is blog |
242 | - if ( empty( $current_post ) && get_option( 'show_on_front' ) == 'posts' ) { |
|
242 | + if (empty($current_post) && get_option('show_on_front') == 'posts') { |
|
243 | 243 | // yup.. this is the posts page, prepare to load all shortcode modules |
244 | 244 | $current_post = 'posts'; |
245 | - } else if ( empty( $current_post ) && get_option( 'show_on_front' ) == 'page' ) { |
|
245 | + } else if (empty($current_post) && get_option('show_on_front') == 'page') { |
|
246 | 246 | // some other page is set as the homepage |
247 | - $page_on_front = get_option( 'page_on_front' ); |
|
248 | - if ( $page_on_front ) { |
|
247 | + $page_on_front = get_option('page_on_front'); |
|
248 | + if ($page_on_front) { |
|
249 | 249 | // k now we need to find the post_name for this page |
250 | 250 | global $wpdb; |
251 | 251 | $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='page' AND post_status='publish' AND ID=%d"; |
252 | - $page_on_front = $wpdb->get_var( $wpdb->prepare( $SQL, $page_on_front )); |
|
252 | + $page_on_front = $wpdb->get_var($wpdb->prepare($SQL, $page_on_front)); |
|
253 | 253 | // set the current post slug to what it actually is |
254 | 254 | $current_post = $page_on_front ? $page_on_front : $current_post; |
255 | 255 | } |
@@ -257,58 +257,58 @@ discard block |
||
257 | 257 | // where are posts being displayed ? |
258 | 258 | $page_for_posts = EE_Config::get_page_for_posts(); |
259 | 259 | // in case $current_post is hierarchical like: /parent-page/current-page |
260 | - $current_post = basename( $current_post ); |
|
260 | + $current_post = basename($current_post); |
|
261 | 261 | // are we on a category page? |
262 | - $term_exists = is_array( term_exists( $current_post, 'category' )) || array_key_exists( 'category_name', $WP->query_vars ); |
|
262 | + $term_exists = is_array(term_exists($current_post, 'category')) || array_key_exists('category_name', $WP->query_vars); |
|
263 | 263 | // make sure shortcodes are set |
264 | - if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes )) { |
|
264 | + if (isset(EE_Registry::instance()->CFG->core->post_shortcodes)) { |
|
265 | 265 | // d( EE_Registry::instance()->CFG->core->post_shortcodes ); |
266 | 266 | // cycle thru all posts with shortcodes set |
267 | - foreach ( EE_Registry::instance()->CFG->core->post_shortcodes as $post_name => $post_shortcodes ) { |
|
267 | + foreach (EE_Registry::instance()->CFG->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
268 | 268 | // filter shortcodes so |
269 | - $post_shortcodes = apply_filters( 'FHEE__Front_Controller__initialize_shortcodes__post_shortcodes', $post_shortcodes ); |
|
269 | + $post_shortcodes = apply_filters('FHEE__Front_Controller__initialize_shortcodes__post_shortcodes', $post_shortcodes); |
|
270 | 270 | // now cycle thru shortcodes |
271 | - foreach ( $post_shortcodes as $shortcode_class => $post_id ) { |
|
271 | + foreach ($post_shortcodes as $shortcode_class => $post_id) { |
|
272 | 272 | // are we on this page, or on the blog page, or an EE CPT category page ? |
273 | - if ( $current_post == $post_name || $term_exists ) { |
|
273 | + if ($current_post == $post_name || $term_exists) { |
|
274 | 274 | // verify shortcode is in list of registered shortcodes |
275 | - if ( ! isset( EE_Registry::instance()->shortcodes->{$shortcode_class} )) { |
|
276 | - if ( $current_post != $page_for_posts && current_user_can( 'edit_post', $post_id )) { |
|
277 | - $msg = sprintf( __( 'The [%s] shortcode has not been properly registered or the corresponding addon/module is not active for some reason. Either fix/remove the shortcode from the post, or activate the addon/module the shortcode is associated with.', 'event_espresso' ), $shortcode_class ); |
|
278 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
279 | - add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
275 | + if ( ! isset(EE_Registry::instance()->shortcodes->{$shortcode_class} )) { |
|
276 | + if ($current_post != $page_for_posts && current_user_can('edit_post', $post_id)) { |
|
277 | + $msg = sprintf(__('The [%s] shortcode has not been properly registered or the corresponding addon/module is not active for some reason. Either fix/remove the shortcode from the post, or activate the addon/module the shortcode is associated with.', 'event_espresso'), $shortcode_class); |
|
278 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
279 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
280 | 280 | } |
281 | - add_shortcode( $shortcode_class, array( 'EES_Shortcode', 'invalid_shortcode_processor' )); |
|
281 | + add_shortcode($shortcode_class, array('EES_Shortcode', 'invalid_shortcode_processor')); |
|
282 | 282 | continue; |
283 | 283 | } |
284 | 284 | // is this : a shortcodes set exclusively for this post, or for the home page, or a category, or a taxonomy ? |
285 | - if ( isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $current_post ] ) || $term_exists || $current_post == $page_for_posts ) { |
|
285 | + if (isset(EE_Registry::instance()->CFG->core->post_shortcodes[$current_post]) || $term_exists || $current_post == $page_for_posts) { |
|
286 | 286 | // let's pause to reflect on this... |
287 | - $sc_reflector = new ReflectionClass( 'EES_' . $shortcode_class ); |
|
287 | + $sc_reflector = new ReflectionClass('EES_'.$shortcode_class); |
|
288 | 288 | // ensure that class is actually a shortcode |
289 | - if ( ! $sc_reflector->isSubclassOf( 'EES_Shortcode' ) && defined( 'WP_DEBUG' ) && WP_DEBUG === TRUE ) { |
|
290 | - $msg = sprintf( __( 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', 'event_espresso' ), $shortcode_class ); |
|
291 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
292 | - add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
289 | + if ( ! $sc_reflector->isSubclassOf('EES_Shortcode') && defined('WP_DEBUG') && WP_DEBUG === TRUE) { |
|
290 | + $msg = sprintf(__('The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', 'event_espresso'), $shortcode_class); |
|
291 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
292 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
293 | 293 | continue; |
294 | 294 | } |
295 | 295 | // and pass the request object to the run method |
296 | 296 | EE_Registry::instance()->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
297 | 297 | // fire the shortcode class's run method, so that it can activate resources |
298 | - EE_Registry::instance()->shortcodes->{$shortcode_class}->run( $WP ); |
|
298 | + EE_Registry::instance()->shortcodes->{$shortcode_class}->run($WP); |
|
299 | 299 | } |
300 | 300 | // if this is NOT the "Posts page" and we have a valid entry for the "Posts page" in our tracked post_shortcodes array |
301 | - } else if ( $post_name != $page_for_posts && isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ] )) { |
|
301 | + } else if ($post_name != $page_for_posts && isset(EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts])) { |
|
302 | 302 | // and the shortcode is not being tracked for this page |
303 | - if ( ! isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ][ $shortcode_class ] )) { |
|
303 | + if ( ! isset(EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts][$shortcode_class])) { |
|
304 | 304 | // then remove the "fallback" shortcode processor |
305 | - remove_shortcode( $shortcode_class ); |
|
305 | + remove_shortcode($shortcode_class); |
|
306 | 306 | } |
307 | 307 | } |
308 | 308 | } |
309 | 309 | } |
310 | 310 | } |
311 | - do_action( 'AHEE__EE_Front_Controller__initialize_shortcodes__end', $this ); |
|
311 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $this); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -320,20 +320,20 @@ discard block |
||
320 | 320 | * @param WP_Query $WP_Query |
321 | 321 | * @return void |
322 | 322 | */ |
323 | - public function pre_get_posts( $WP_Query ) { |
|
323 | + public function pre_get_posts($WP_Query) { |
|
324 | 324 | // only load Module_Request_Router if this is the main query |
325 | - if ( $WP_Query->is_main_query() ) { |
|
325 | + if ($WP_Query->is_main_query()) { |
|
326 | 326 | // load module request router |
327 | - $Module_Request_Router = EE_Registry::instance()->load_core( 'Module_Request_Router' ); |
|
327 | + $Module_Request_Router = EE_Registry::instance()->load_core('Module_Request_Router'); |
|
328 | 328 | // verify object |
329 | - if ( $Module_Request_Router instanceof EE_Module_Request_Router ) { |
|
329 | + if ($Module_Request_Router instanceof EE_Module_Request_Router) { |
|
330 | 330 | // cycle thru module routes |
331 | - while ( $route = $Module_Request_Router->get_route( $WP_Query )) { |
|
331 | + while ($route = $Module_Request_Router->get_route($WP_Query)) { |
|
332 | 332 | // determine module and method for route |
333 | - $module = $Module_Request_Router->resolve_route( $route[0], $route[1] ); |
|
334 | - if( $module instanceof EED_Module ) { |
|
333 | + $module = $Module_Request_Router->resolve_route($route[0], $route[1]); |
|
334 | + if ($module instanceof EED_Module) { |
|
335 | 335 | // get registered view for route |
336 | - $this->_template_path = $Module_Request_Router->get_view( $route ); |
|
336 | + $this->_template_path = $Module_Request_Router->get_view($route); |
|
337 | 337 | // grab module name |
338 | 338 | $module_name = $module->module_name(); |
339 | 339 | // map the module to the module objects |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return void |
361 | 361 | */ |
362 | 362 | public function wp() { |
363 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
363 | + EE_Registry::instance()->load_helper('Template'); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | |
@@ -378,30 +378,30 @@ discard block |
||
378 | 378 | public function wp_enqueue_scripts() { |
379 | 379 | |
380 | 380 | // css is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_css', '__return_false' ); |
381 | - if ( apply_filters( 'FHEE_load_css', TRUE ) ) { |
|
381 | + if (apply_filters('FHEE_load_css', TRUE)) { |
|
382 | 382 | |
383 | 383 | EE_Registry::instance()->CFG->template_settings->enable_default_style = TRUE; |
384 | 384 | //Load the ThemeRoller styles if enabled |
385 | - if ( isset( EE_Registry::instance()->CFG->template_settings->enable_default_style ) && EE_Registry::instance()->CFG->template_settings->enable_default_style ) { |
|
385 | + if (isset(EE_Registry::instance()->CFG->template_settings->enable_default_style) && EE_Registry::instance()->CFG->template_settings->enable_default_style) { |
|
386 | 386 | |
387 | 387 | //Load custom style sheet if available |
388 | - if ( isset( EE_Registry::instance()->CFG->template_settings->custom_style_sheet )) { |
|
389 | - wp_register_style('espresso_custom_css', EVENT_ESPRESSO_UPLOAD_URL . 'css/' . EE_Registry::instance()->CFG->template_settings->custom_style_sheet, EVENT_ESPRESSO_VERSION ); |
|
388 | + if (isset(EE_Registry::instance()->CFG->template_settings->custom_style_sheet)) { |
|
389 | + wp_register_style('espresso_custom_css', EVENT_ESPRESSO_UPLOAD_URL.'css/'.EE_Registry::instance()->CFG->template_settings->custom_style_sheet, EVENT_ESPRESSO_VERSION); |
|
390 | 390 | wp_enqueue_style('espresso_custom_css'); |
391 | 391 | } |
392 | 392 | |
393 | - EE_Registry::instance()->load_helper( 'File' ); |
|
394 | - if ( is_readable( EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css' )) { |
|
395 | - wp_register_style( 'espresso_default', EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION ); |
|
393 | + EE_Registry::instance()->load_helper('File'); |
|
394 | + if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')) { |
|
395 | + wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
396 | 396 | } else { |
397 | - wp_register_style( 'espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', array( 'dashicons' ), EVENT_ESPRESSO_VERSION ); |
|
397 | + wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
398 | 398 | } |
399 | 399 | wp_enqueue_style('espresso_default'); |
400 | 400 | |
401 | - if ( is_readable( get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'style.css' )) { |
|
402 | - wp_register_style( 'espresso_style', get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'style.css', array( 'dashicons', 'espresso_default' ) ); |
|
401 | + if (is_readable(get_stylesheet_directory().EE_Config::get_current_theme().DS.'style.css')) { |
|
402 | + wp_register_style('espresso_style', get_stylesheet_directory_uri().EE_Config::get_current_theme().DS.'style.css', array('dashicons', 'espresso_default')); |
|
403 | 403 | } else { |
404 | - wp_register_style( 'espresso_style', EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'style.css', array( 'dashicons', 'espresso_default' ) ); |
|
404 | + wp_register_style('espresso_style', EE_TEMPLATES_URL.EE_Config::get_current_theme().DS.'style.css', array('dashicons', 'espresso_default')); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | } |
@@ -409,29 +409,29 @@ discard block |
||
409 | 409 | } |
410 | 410 | |
411 | 411 | // js is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_js', '__return_false' ); |
412 | - if ( apply_filters( 'FHEE_load_js', TRUE ) ) { |
|
412 | + if (apply_filters('FHEE_load_js', TRUE)) { |
|
413 | 413 | |
414 | - wp_enqueue_script( 'jquery' ); |
|
414 | + wp_enqueue_script('jquery'); |
|
415 | 415 | //let's make sure that all required scripts have been setup |
416 | - if ( function_exists( 'wp_script_is' )) { |
|
417 | - if ( ! wp_script_is( 'jquery' )) { |
|
416 | + if (function_exists('wp_script_is')) { |
|
417 | + if ( ! wp_script_is('jquery')) { |
|
418 | 418 | $msg = sprintf( |
419 | - __( '%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', 'event_espresso' ), |
|
419 | + __('%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', 'event_espresso'), |
|
420 | 420 | '<em><br />', |
421 | 421 | '</em>' |
422 | 422 | ); |
423 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
423 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
424 | 424 | } |
425 | 425 | } |
426 | 426 | // load core js |
427 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
428 | - wp_enqueue_script( 'espresso_core' ); |
|
429 | - wp_localize_script( 'espresso_core', 'eei18n', EE_Registry::$i18n_js_strings ); |
|
427 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
428 | + wp_enqueue_script('espresso_core'); |
|
429 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
430 | 430 | |
431 | 431 | } |
432 | 432 | |
433 | 433 | //qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
434 | - if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) { |
|
434 | + if (apply_filters('FHEE_load_qtip', FALSE)) { |
|
435 | 435 | EE_Registry::instance()->load_helper('Qtip_Loader'); |
436 | 436 | EEH_Qtip_Loader::instance()->register_and_enqueue(); |
437 | 437 | } |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | |
440 | 440 | //accounting.js library |
441 | 441 | // @link http://josscrowcroft.github.io/accounting.js/ |
442 | - if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) { |
|
443 | - $acct_js = EE_THIRD_PARTY_URL . 'accounting/accounting.js'; |
|
444 | - wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
445 | - wp_register_script( 'ee-accounting-core', $acct_js, array('underscore'), '0.3.2', TRUE ); |
|
446 | - wp_enqueue_script( 'ee-accounting' ); |
|
442 | + if (apply_filters('FHEE_load_accounting_js', FALSE)) { |
|
443 | + $acct_js = EE_THIRD_PARTY_URL.'accounting/accounting.js'; |
|
444 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
445 | + wp_register_script('ee-accounting-core', $acct_js, array('underscore'), '0.3.2', TRUE); |
|
446 | + wp_enqueue_script('ee-accounting'); |
|
447 | 447 | |
448 | 448 | $currency_config = array( |
449 | 449 | 'currency' => array( |
@@ -466,21 +466,21 @@ discard block |
||
466 | 466 | wp_localize_script('ee-accounting', 'EE_ACCOUNTING_CFG', $currency_config); |
467 | 467 | } |
468 | 468 | |
469 | - if ( ! function_exists( 'wp_head' )) { |
|
469 | + if ( ! function_exists('wp_head')) { |
|
470 | 470 | $msg = sprintf( |
471 | - __( '%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso' ), |
|
471 | + __('%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso'), |
|
472 | 472 | '<em><br />', |
473 | 473 | '</em>' |
474 | 474 | ); |
475 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
475 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
476 | 476 | } |
477 | - if ( ! function_exists( 'wp_footer' )) { |
|
477 | + if ( ! function_exists('wp_footer')) { |
|
478 | 478 | $msg = sprintf( |
479 | - __( '%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso' ), |
|
479 | + __('%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', 'event_espresso'), |
|
480 | 480 | '<em><br />', |
481 | 481 | '</em>' |
482 | 482 | ); |
483 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
483 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | * @return void |
495 | 495 | */ |
496 | 496 | public function header_meta_tag() { |
497 | - print( apply_filters("FHEE__EE_Front_Controller__header_meta_tag","<meta name='generator' content='Event Espresso Version " . EVENT_ESPRESSO_VERSION . "' />")); |
|
497 | + print(apply_filters("FHEE__EE_Front_Controller__header_meta_tag", "<meta name='generator' content='Event Espresso Version ".EVENT_ESPRESSO_VERSION."' />")); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | |
@@ -508,9 +508,9 @@ discard block |
||
508 | 508 | * @param $the_content |
509 | 509 | * @return string |
510 | 510 | */ |
511 | - public function the_content( $the_content ) { |
|
511 | + public function the_content($the_content) { |
|
512 | 512 | // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
513 | - if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
513 | + if (apply_filters('FHEE_run_EE_the_content', FALSE)) { |
|
514 | 514 | } |
515 | 515 | return $the_content; |
516 | 516 | } |
@@ -535,9 +535,9 @@ discard block |
||
535 | 535 | */ |
536 | 536 | public function display_errors() { |
537 | 537 | static $shown_already = FALSE; |
538 | - do_action( 'AHEE__EE_Front_Controller__display_errors__begin' ); |
|
538 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
539 | 539 | if ( |
540 | - apply_filters( 'FHEE__EE_Front_Controller__display_errors', TRUE ) |
|
540 | + apply_filters('FHEE__EE_Front_Controller__display_errors', TRUE) |
|
541 | 541 | && ! $shown_already |
542 | 542 | && is_main_query() |
543 | 543 | && ! is_feed() |
@@ -546,10 +546,10 @@ discard block |
||
546 | 546 | ) { |
547 | 547 | echo EE_Error::get_notices(); |
548 | 548 | $shown_already = TRUE; |
549 | - EE_Registry::instance()->load_helper( 'Template' ); |
|
550 | - EEH_Template::display_template( EE_TEMPLATES . 'espresso-ajax-notices.template.php' ); |
|
549 | + EE_Registry::instance()->load_helper('Template'); |
|
550 | + EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php'); |
|
551 | 551 | } |
552 | - do_action( 'AHEE__EE_Front_Controller__display_errors__end' ); |
|
552 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | |
@@ -564,12 +564,12 @@ discard block |
||
564 | 564 | * @param string $template_include_path |
565 | 565 | * @return string |
566 | 566 | */ |
567 | - public function template_include( $template_include_path = NULL ) { |
|
568 | - if ( EE_Registry::instance()->REQ->is_espresso_page() ) { |
|
569 | - $this->_template_path = ! empty( $this->_template_path ) ? basename( $this->_template_path ) : basename( $template_include_path ); |
|
570 | - $template_path = EEH_Template::locate_template( $this->_template_path, array(), false ); |
|
571 | - $this->_template_path = ! empty( $template_path ) ? $template_path : $template_include_path; |
|
572 | - $this->_template = basename( $this->_template_path ); |
|
567 | + public function template_include($template_include_path = NULL) { |
|
568 | + if (EE_Registry::instance()->REQ->is_espresso_page()) { |
|
569 | + $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
570 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
571 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
572 | + $this->_template = basename($this->_template_path); |
|
573 | 573 | return $this->_template_path; |
574 | 574 | } |
575 | 575 | return $template_include_path; |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | * @param bool $with_path |
585 | 585 | * @return string |
586 | 586 | */ |
587 | - public function get_selected_template( $with_path = FALSE ) { |
|
587 | + public function get_selected_template($with_path = FALSE) { |
|
588 | 588 | return $with_path ? $this->_template_path : $this->_template; |
589 | 589 | } |
590 | 590 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('No direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @return EED_Core_Rest_Api |
28 | 28 | */ |
29 | 29 | public static function instance() { |
30 | - return parent::get_instance( __CLASS__ ); |
|
30 | + return parent::get_instance(__CLASS__); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | |
58 | 58 | |
59 | 59 | public static function set_hooks_both() { |
60 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 ); |
|
61 | - add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 ); |
|
62 | - add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 ); |
|
63 | - add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) ); |
|
60 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10); |
|
61 | + add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5); |
|
62 | + add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2); |
|
63 | + add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index')); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | protected static function _set_hooks_for_changes() { |
76 | - $folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false ); |
|
77 | - foreach( $folder_contents as $classname_in_namespace => $filepath ) { |
|
76 | + $folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false); |
|
77 | + foreach ($folder_contents as $classname_in_namespace => $filepath) { |
|
78 | 78 | //ignore the base parent class |
79 | - if( $classname_in_namespace === 'Changes_In_Base' ) { |
|
79 | + if ($classname_in_namespace === 'Changes_In_Base') { |
|
80 | 80 | continue; |
81 | 81 | } |
82 | - $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace; |
|
83 | - if ( class_exists( $full_classname )) { |
|
82 | + $full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace; |
|
83 | + if (class_exists($full_classname)) { |
|
84 | 84 | $instance_of_class = new $full_classname; |
85 | - if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) { |
|
85 | + if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) { |
|
86 | 86 | $instance_of_class->set_hooks(); |
87 | 87 | } |
88 | 88 | } |
@@ -95,16 +95,16 @@ discard block |
||
95 | 95 | * so we actually prefer to only do it when an EE plugin is activated or upgraded |
96 | 96 | */ |
97 | 97 | public static function register_routes() { |
98 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
99 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
100 | - foreach( $routes as $route ) { |
|
98 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
99 | + foreach ($relative_urls as $endpoint => $routes) { |
|
100 | + foreach ($routes as $route) { |
|
101 | 101 | register_rest_route( |
102 | 102 | $namespace, |
103 | 103 | $endpoint, |
104 | 104 | array( |
105 | - 'callback' => $route[ 'callback' ], |
|
106 | - 'methods' => $route[ 'methods' ], |
|
107 | - 'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(), |
|
105 | + 'callback' => $route['callback'], |
|
106 | + 'methods' => $route['methods'], |
|
107 | + 'args' => isset($route['args']) ? $route['args'] : array(), |
|
108 | 108 | ) |
109 | 109 | ); |
110 | 110 | } |
@@ -121,10 +121,10 @@ discard block |
||
121 | 121 | * } |
122 | 122 | */ |
123 | 123 | public static function get_ee_route_data() { |
124 | - $ee_routes = get_option( self::saved_routes_option_names, null ); |
|
125 | - if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){ |
|
124 | + $ee_routes = get_option(self::saved_routes_option_names, null); |
|
125 | + if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) { |
|
126 | 126 | self::save_ee_routes(); |
127 | - $ee_routes = get_option( self::saved_routes_option_names, array() ); |
|
127 | + $ee_routes = get_option(self::saved_routes_option_names, array()); |
|
128 | 128 | } |
129 | 129 | return $ee_routes; |
130 | 130 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @return void |
136 | 136 | */ |
137 | 137 | public static function save_ee_routes() { |
138 | - if( EE_Maintenance_Mode::instance()->models_can_query() ){ |
|
138 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
139 | 139 | $instance = self::instance(); |
140 | 140 | $routes = apply_filters( |
141 | 141 | 'EED_Core_Rest_Api__save_ee_routes__routes', |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $instance->_register_rpc_routes() |
147 | 147 | ) |
148 | 148 | ); |
149 | - update_option( self::saved_routes_option_names, $routes, true ); |
|
149 | + update_option(self::saved_routes_option_names, $routes, true); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @return array @see get_ee_route_data |
156 | 156 | */ |
157 | 157 | protected function _register_model_routes() { |
158 | - EE_Registry::instance()->load_helper( 'Inflector' ); |
|
158 | + EE_Registry::instance()->load_helper('Inflector'); |
|
159 | 159 | $models_to_register = apply_filters( |
160 | 160 | 'FHEE__EED_Core_REST_API___register_model_routes', |
161 | 161 | EE_Registry::instance()->non_abstract_db_models |
@@ -164,23 +164,23 @@ discard block |
||
164 | 164 | unset($models_to_register['Extra_Meta']); |
165 | 165 | unset($models_to_register['Extra_Join']); |
166 | 166 | $model_routes = array( ); |
167 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
167 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
168 | 168 | |
169 | - foreach ( $models_to_register as $model_name => $model_classname ) { |
|
169 | + foreach ($models_to_register as $model_name => $model_classname) { |
|
170 | 170 | //yes we could just register one route for ALL models, but then they wouldn't show up in the index |
171 | - $ee_namespace = self::ee_api_namespace . $version; |
|
172 | - $plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name ); |
|
173 | - $singular_model_route = $plural_model_route . '/(?P<id>\d+)' ; |
|
174 | - $model_routes[ $ee_namespace ][ $plural_model_route ] = array( |
|
171 | + $ee_namespace = self::ee_api_namespace.$version; |
|
172 | + $plural_model_route = EEH_Inflector::pluralize_and_lower($model_name); |
|
173 | + $singular_model_route = $plural_model_route.'/(?P<id>\d+)'; |
|
174 | + $model_routes[$ee_namespace][$plural_model_route] = array( |
|
175 | 175 | array( |
176 | 176 | 'callback' => array( |
177 | 177 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
178 | 178 | 'handle_request_get_all' ), |
179 | 179 | 'methods' => WP_REST_Server::READABLE, |
180 | 180 | 'hidden_endpoint' => $hidden_endpoint, |
181 | - 'args' => $this->_get_read_query_params( $model_name ), |
|
181 | + 'args' => $this->_get_read_query_params($model_name), |
|
182 | 182 | '_links' => array( |
183 | - 'self' => rest_url( $ee_namespace . $singular_model_route ), |
|
183 | + 'self' => rest_url($ee_namespace.$singular_model_route), |
|
184 | 184 | ) |
185 | 185 | ), |
186 | 186 | // array( |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | // 'hidden_endpoint' => $hidden_endpoint |
192 | 192 | // ) |
193 | 193 | ); |
194 | - $model_routes[ $ee_namespace ][ $singular_model_route ] = array( |
|
194 | + $model_routes[$ee_namespace][$singular_model_route] = array( |
|
195 | 195 | array( |
196 | 196 | 'callback' => array( |
197 | 197 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | 'include' => array( |
203 | 203 | 'required' => false, |
204 | 204 | 'default' => '*', |
205 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ), |
|
205 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'), |
|
206 | 206 | ), |
207 | 207 | ) |
208 | 208 | ), |
@@ -215,20 +215,20 @@ discard block |
||
215 | 215 | // ), |
216 | 216 | ); |
217 | 217 | //@todo: also handle DELETE for a single item |
218 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
219 | - foreach ( $model->relation_settings() as $relation_name => $relation_obj ) { |
|
218 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
219 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
220 | 220 | $related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name( |
221 | 221 | $relation_name, |
222 | 222 | $relation_obj |
223 | 223 | ); |
224 | - $model_routes[ $ee_namespace ][ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array( |
|
224 | + $model_routes[$ee_namespace][$singular_model_route.'/'.$related_model_name_endpoint_part] = array( |
|
225 | 225 | array( |
226 | 226 | 'callback' => array( |
227 | 227 | 'EventEspresso\core\libraries\rest_api\controllers\model\Read', |
228 | 228 | 'handle_request_get_related' ), |
229 | 229 | 'methods' => WP_REST_Server::READABLE, |
230 | 230 | 'hidden_endpoint' => $hidden_endpoint, |
231 | - 'args' => $this->_get_read_query_params( $relation_name ), |
|
231 | + 'args' => $this->_get_read_query_params($relation_name), |
|
232 | 232 | ), |
233 | 233 | // array( |
234 | 234 | // 'callback' => array( |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | */ |
253 | 253 | protected function _register_rpc_routes() { |
254 | 254 | $routes = array(); |
255 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
256 | - $ee_namespace = self::ee_api_namespace . $version; |
|
255 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
256 | + $ee_namespace = self::ee_api_namespace.$version; |
|
257 | 257 | $this_versions_routes = array(); |
258 | 258 | //checkin endpoint |
259 | - $this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array( |
|
259 | + $this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array( |
|
260 | 260 | array( |
261 | 261 | 'callback' => array( |
262 | 262 | 'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin', |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | 'force' => array( |
268 | 268 | 'required' => false, |
269 | 269 | 'default' => false, |
270 | - 'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' ) |
|
270 | + 'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso') |
|
271 | 271 | ) |
272 | 272 | ) |
273 | 273 | ) |
274 | 274 | ); |
275 | - $routes[ $ee_namespace ] = apply_filters( |
|
275 | + $routes[$ee_namespace] = apply_filters( |
|
276 | 276 | 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
277 | 277 | $this_versions_routes, |
278 | 278 | $version, |
@@ -287,47 +287,47 @@ discard block |
||
287 | 287 | * @param string $model_name eg 'Event' or 'Venue' |
288 | 288 | * @return array describing the args acceptable when querying this model |
289 | 289 | */ |
290 | - protected function _get_read_query_params( $model_name ) { |
|
291 | - $model = EE_Registry::instance()->load_model( $model_name ); |
|
290 | + protected function _get_read_query_params($model_name) { |
|
291 | + $model = EE_Registry::instance()->load_model($model_name); |
|
292 | 292 | $default_orderby = array(); |
293 | - foreach( $model->get_combined_primary_key_fields() as $key_field ) { |
|
294 | - $default_orderby[ $key_field->get_name() ] = 'ASC'; |
|
293 | + foreach ($model->get_combined_primary_key_fields() as $key_field) { |
|
294 | + $default_orderby[$key_field->get_name()] = 'ASC'; |
|
295 | 295 | } |
296 | 296 | return array( |
297 | 297 | 'where' => array( |
298 | 298 | 'required' => false, |
299 | 299 | 'default' => array(), |
300 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso' ), |
|
300 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso'), |
|
301 | 301 | ), |
302 | 302 | 'limit' => array( |
303 | 303 | 'required' => false, |
304 | 304 | 'default' => 50, |
305 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso' ) |
|
305 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso') |
|
306 | 306 | ), |
307 | 307 | 'order_by' => array( |
308 | 308 | 'required' => false, |
309 | 309 | 'default' => $default_orderby, |
310 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso' ) |
|
310 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso') |
|
311 | 311 | ), |
312 | 312 | 'group_by' => array( |
313 | 313 | 'required' => false, |
314 | 314 | 'default' => null, |
315 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso' ) |
|
315 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso') |
|
316 | 316 | ), |
317 | 317 | 'having' => array( |
318 | 318 | 'required' => false, |
319 | 319 | 'default' => null, |
320 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso' ) |
|
320 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso') |
|
321 | 321 | ), |
322 | 322 | 'caps' => array( |
323 | 323 | 'required' => false, |
324 | 324 | 'default' => EEM_Base::caps_read, |
325 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso' ) |
|
325 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso') |
|
326 | 326 | ), |
327 | 327 | 'include' => array( |
328 | 328 | 'required' => false, |
329 | 329 | 'default' => '*', |
330 | - 'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ), |
|
330 | + 'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'), |
|
331 | 331 | ), |
332 | 332 | ); |
333 | 333 | } |
@@ -338,8 +338,8 @@ discard block |
||
338 | 338 | */ |
339 | 339 | protected function _register_config_routes() { |
340 | 340 | $config_routes = array(); |
341 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
342 | - $config_routes[ self::ee_api_namespace . $version ][ 'config' ] = array( |
|
341 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
342 | + $config_routes[self::ee_api_namespace.$version]['config'] = array( |
|
343 | 343 | array( |
344 | 344 | 'callback' => array( |
345 | 345 | 'EventEspresso\core\libraries\rest_api\controllers\config\Read', |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | */ |
359 | 359 | protected function _register_meta_routes() { |
360 | 360 | $meta_routes = array(); |
361 | - foreach( self::versions_served() as $version => $hidden_endpoint ) { |
|
362 | - $meta_routes[ self::ee_api_namespace . $version ][ '/resources' ] = array( |
|
361 | + foreach (self::versions_served() as $version => $hidden_endpoint) { |
|
362 | + $meta_routes[self::ee_api_namespace.$version]['/resources'] = array( |
|
363 | 363 | array( |
364 | 364 | 'callback' => array( |
365 | 365 | 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', |
@@ -380,13 +380,13 @@ discard block |
||
380 | 380 | * @param array $route_data |
381 | 381 | * @return array |
382 | 382 | */ |
383 | - public static function hide_old_endpoints( $route_data ) { |
|
384 | - foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) { |
|
385 | - foreach( $relative_urls as $endpoint => $routes ) { |
|
386 | - foreach( $routes as $route ) { |
|
387 | - if( $route[ 'hidden_endpoint' ] ) { |
|
388 | - $full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' ); |
|
389 | - unset( $route_data[ $full_route ] ); |
|
383 | + public static function hide_old_endpoints($route_data) { |
|
384 | + foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) { |
|
385 | + foreach ($relative_urls as $endpoint => $routes) { |
|
386 | + foreach ($routes as $route) { |
|
387 | + if ($route['hidden_endpoint']) { |
|
388 | + $full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/'); |
|
389 | + unset($route_data[$full_route]); |
|
390 | 390 | } |
391 | 391 | } |
392 | 392 | } |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | */ |
424 | 424 | public static function latest_rest_api_version() { |
425 | 425 | $versions_served = \EED_Core_Rest_Api::versions_served(); |
426 | - return end( array_keys( $versions_served ) ); |
|
426 | + return end(array_keys($versions_served)); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -437,17 +437,17 @@ discard block |
||
437 | 437 | public static function versions_served() { |
438 | 438 | $version_compatibilities = EED_Core_Rest_Api::version_compatibilities(); |
439 | 439 | $versions_served = array(); |
440 | - $lowest_compatible_version = $version_compatibilities[ EED_Core_Rest_Api::core_version() ]; |
|
440 | + $lowest_compatible_version = $version_compatibilities[EED_Core_Rest_Api::core_version()]; |
|
441 | 441 | //for each version of core we have ever served: |
442 | - foreach( array_keys( EED_Core_Rest_Api::version_compatibilities() ) as $possibly_served_version ) { |
|
442 | + foreach (array_keys(EED_Core_Rest_Api::version_compatibilities()) as $possibly_served_version) { |
|
443 | 443 | //if it's not above the current core version, and it's compatible with the current version of core |
444 | - if( |
|
444 | + if ( |
|
445 | 445 | $possibly_served_version < EED_Core_Rest_Api::core_version() |
446 | 446 | && $possibly_served_version >= $lowest_compatible_version |
447 | 447 | ) { |
448 | - $versions_served[ $possibly_served_version ] = true; |
|
449 | - }else { |
|
450 | - $versions_served[ $possibly_served_version ] = false; |
|
448 | + $versions_served[$possibly_served_version] = true; |
|
449 | + } else { |
|
450 | + $versions_served[$possibly_served_version] = false; |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | return $versions_served; |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @return string |
461 | 461 | */ |
462 | 462 | public static function core_version() { |
463 | - return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) ); |
|
463 | + return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3))); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | * @param WP $WP |
473 | 473 | * @return void |
474 | 474 | */ |
475 | - public function run( $WP ) { |
|
475 | + public function run($WP) { |
|
476 | 476 | |
477 | 477 | } |
478 | 478 |
@@ -357,7 +357,7 @@ |
||
357 | 357 | && $possibly_served_version >= $lowest_compatible_version |
358 | 358 | ) { |
359 | 359 | $versions_served[ $possibly_served_version ] = true; |
360 | - }else { |
|
360 | + } else { |
|
361 | 361 | $versions_served[ $possibly_served_version ] = false; |
362 | 362 | } |
363 | 363 | } |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | * @access protected |
513 | 513 | * @param string $fieldname the property item the corresponding value is for. |
514 | 514 | * @param mixed $value The value we are caching. |
515 | - * @param null $cache_type |
|
515 | + * @param string $cache_type |
|
516 | 516 | * @return void |
517 | 517 | */ |
518 | 518 | protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) { |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | * |
826 | 826 | * @param null $field_to_order_by What field is being used as the reference point. |
827 | 827 | * @param array $query_params Any additional conditions on the query. |
828 | - * @param null $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
828 | + * @param string $columns_to_select If left null, then an array of EE_Base_Class objects is returned, otherwise |
|
829 | 829 | * you can indicate just the columns you want returned |
830 | 830 | * |
831 | 831 | * @return array|EE_Base_Class |
@@ -850,7 +850,7 @@ discard block |
||
850 | 850 | * |
851 | 851 | * @param null $field_to_order_by What field is being used as the reference point. |
852 | 852 | * @param array $query_params Any additional conditions on the query. |
853 | - * @param null $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
853 | + * @param string $columns_to_select If left null, then an EE_Base_Class object is returned, otherwise |
|
854 | 854 | * you can indicate just the column you want returned |
855 | 855 | * |
856 | 856 | * @return array|EE_Base_Class |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | /** |
914 | 914 | * This method simply returns the RAW unprocessed value for the given property in this class |
915 | 915 | * @param string $field_name A valid fieldname |
916 | - * @return mixed Whatever the raw value stored on the property is. |
|
916 | + * @return integer|null Whatever the raw value stored on the property is. |
|
917 | 917 | * @throws EE_Error if fieldSettings is misconfigured or the field doesn't exist. |
918 | 918 | */ |
919 | 919 | public function get_raw($field_name) { |
@@ -987,11 +987,11 @@ discard block |
||
987 | 987 | * |
988 | 988 | * @access protected |
989 | 989 | * @param string $field_name Field on the instantiated EE_Base_Class child object |
990 | - * @param null $dt_frmt valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format) |
|
991 | - * @param null $tm_frmt Same as above except this is for time format |
|
990 | + * @param string|null $dt_frmt valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format) |
|
991 | + * @param null|string $tm_frmt Same as above except this is for time format |
|
992 | 992 | * @param string $date_or_time if NULL then both are returned, otherwise "D" = only date and "T" = only time. |
993 | 993 | * @param boolean $echo Whether the dtt is echoing using pretty echoing or just returned using vanilla get |
994 | - * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
|
994 | + * @return string|boolean | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
|
995 | 995 | */ |
996 | 996 | protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) { |
997 | 997 | |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | * sets the time on a datetime property |
1165 | 1165 | * |
1166 | 1166 | * @access protected |
1167 | - * @param string|Datetime $time a valid time string for php datetime functions (or DateTime object) |
|
1167 | + * @param string $time a valid time string for php datetime functions (or DateTime object) |
|
1168 | 1168 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1169 | 1169 | */ |
1170 | 1170 | protected function _set_time_for( $time, $fieldname ) { |
@@ -1179,7 +1179,7 @@ discard block |
||
1179 | 1179 | * sets the date on a datetime property |
1180 | 1180 | * |
1181 | 1181 | * @access protected |
1182 | - * @param string|DateTime $date a valid date string for php datetime functions ( or DateTime object) |
|
1182 | + * @param string $date a valid date string for php datetime functions ( or DateTime object) |
|
1183 | 1183 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1184 | 1184 | */ |
1185 | 1185 | protected function _set_date_for( $date, $fieldname ) { |
@@ -1233,6 +1233,7 @@ discard block |
||
1233 | 1233 | * @param mixed (array|string) $args This is the arguments that will be passed to the callback. |
1234 | 1234 | * @param string $prepend You can include something to prepend on the timestamp |
1235 | 1235 | * @param string $append You can include something to append on the timestamp |
1236 | + * @param string $args |
|
1236 | 1237 | * @throws EE_Error |
1237 | 1238 | * @return string timestamp |
1238 | 1239 | */ |
@@ -1537,7 +1538,7 @@ discard block |
||
1537 | 1538 | |
1538 | 1539 | /** |
1539 | 1540 | * for getting a model while instantiated. |
1540 | - * @return \EEM_Base | \EEM_CPT_Base |
|
1541 | + * @return boolean | \EEM_CPT_Base |
|
1541 | 1542 | */ |
1542 | 1543 | public function get_model() { |
1543 | 1544 | $modelName = self::_get_model_classname( get_class($this) ); |
@@ -1568,7 +1569,7 @@ discard block |
||
1568 | 1569 | * If there is a key in the incoming array that matches the primary key for the model AND it is not null, then we check the db. If there's a an object we return it. If not we return false. |
1569 | 1570 | * @param array $props_n_values incoming array of properties and their values |
1570 | 1571 | * @param string $classname the classname of the child class |
1571 | - * @param null $timezone |
|
1572 | + * @param string|null $timezone |
|
1572 | 1573 | * @param array $date_formats incoming date_formats in an array where the first value is the |
1573 | 1574 | * date_format and the second value is the time format |
1574 | 1575 | * @return mixed (EE_Base_Class|bool) |
@@ -1617,7 +1618,7 @@ discard block |
||
1617 | 1618 | * @param $classname |
1618 | 1619 | * @param null $timezone |
1619 | 1620 | * @throws EE_Error |
1620 | - * @return EEM_Base |
|
1621 | + * @return boolean |
|
1621 | 1622 | */ |
1622 | 1623 | protected static function _get_model( $classname, $timezone = NULL ){ |
1623 | 1624 | //find model for this class |
@@ -1633,8 +1634,8 @@ discard block |
||
1633 | 1634 | /** |
1634 | 1635 | * Gets the model instance (eg instance of EEM_Attendee) given its classname (eg EE_Attendee) |
1635 | 1636 | * @param string $model_classname |
1636 | - * @param null $timezone |
|
1637 | - * @return EEM_Base |
|
1637 | + * @param string|null $timezone |
|
1638 | + * @return boolean |
|
1638 | 1639 | */ |
1639 | 1640 | protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
1640 | 1641 | $model_classname = str_replace( 'EEM_', '', $model_classname ); |
@@ -47,25 +47,25 @@ discard block |
||
47 | 47 | |
48 | 48 | |
49 | 49 | /** |
50 | - * date format |
|
51 | - * |
|
52 | - * pattern or format for displaying dates |
|
53 | - * |
|
54 | - * @access protected |
|
55 | - * @var string |
|
56 | - */ |
|
50 | + * date format |
|
51 | + * |
|
52 | + * pattern or format for displaying dates |
|
53 | + * |
|
54 | + * @access protected |
|
55 | + * @var string |
|
56 | + */ |
|
57 | 57 | protected $_dt_frmt; |
58 | 58 | |
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * time format |
|
63 | - * |
|
64 | - * pattern or format for displaying time |
|
65 | - * |
|
66 | - * @access protected |
|
67 | - * @var string |
|
68 | - */ |
|
61 | + /** |
|
62 | + * time format |
|
63 | + * |
|
64 | + * pattern or format for displaying time |
|
65 | + * |
|
66 | + * @access protected |
|
67 | + * @var string |
|
68 | + */ |
|
69 | 69 | protected $_tm_frmt; |
70 | 70 | |
71 | 71 | |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | |
206 | 206 | |
207 | 207 | /** |
208 | - * Gets the field's original value when this object was constructed during this request. |
|
209 | - * This can be helpful when determining if a model object has changed or not |
|
210 | - * |
|
211 | - * @param string $field_name |
|
212 | - * @return mixed|null |
|
213 | - */ |
|
208 | + * Gets the field's original value when this object was constructed during this request. |
|
209 | + * This can be helpful when determining if a model object has changed or not |
|
210 | + * |
|
211 | + * @param string $field_name |
|
212 | + * @return mixed|null |
|
213 | + */ |
|
214 | 214 | public function get_original( $field_name ){ |
215 | 215 | if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
216 | 216 | $field_settings = $this->get_Model()->field_settings_for( $field_name )){ |
@@ -1329,28 +1329,28 @@ discard block |
||
1329 | 1329 | return $result; |
1330 | 1330 | } |
1331 | 1331 | |
1332 | - /** |
|
1333 | - * When this model object is deleted, it may still be cached on related model objects. This clears the cache of |
|
1334 | - * related model objects |
|
1335 | - */ |
|
1336 | - public function refresh_cache_of_related_objects() { |
|
1337 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1338 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1339 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1340 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1341 | - //this relation only stores a single model object, not an array |
|
1342 | - //but let's make it consistent |
|
1343 | - $related_objects = array( $related_objects ); |
|
1344 | - } |
|
1345 | - foreach( $related_objects as $related_object ) { |
|
1346 | - //only refresh their cache if they're in memory |
|
1347 | - if( $related_object instanceof EE_Base_Class ) { |
|
1332 | + /** |
|
1333 | + * When this model object is deleted, it may still be cached on related model objects. This clears the cache of |
|
1334 | + * related model objects |
|
1335 | + */ |
|
1336 | + public function refresh_cache_of_related_objects() { |
|
1337 | + foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1338 | + if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1339 | + $related_objects = $this->_model_relations[ $relation_name ]; |
|
1340 | + if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1341 | + //this relation only stores a single model object, not an array |
|
1342 | + //but let's make it consistent |
|
1343 | + $related_objects = array( $related_objects ); |
|
1344 | + } |
|
1345 | + foreach( $related_objects as $related_object ) { |
|
1346 | + //only refresh their cache if they're in memory |
|
1347 | + if( $related_object instanceof EE_Base_Class ) { |
|
1348 | 1348 | $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
1349 | - } |
|
1350 | - } |
|
1351 | - } |
|
1352 | - } |
|
1353 | - } |
|
1349 | + } |
|
1350 | + } |
|
1351 | + } |
|
1352 | + } |
|
1353 | + } |
|
1354 | 1354 | |
1355 | 1355 | |
1356 | 1356 | |
@@ -1713,9 +1713,9 @@ discard block |
||
1713 | 1713 | $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
1714 | 1714 | //clear cache so future get_many_related and get_first_related() return new results. |
1715 | 1715 | $this->clear_cache( $relationName, $otherObject, TRUE ); |
1716 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1717 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1718 | - } |
|
1716 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1717 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1718 | + } |
|
1719 | 1719 | } else { |
1720 | 1720 | //this thing doesn't exist in the DB, so just cache it |
1721 | 1721 | if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
@@ -1729,18 +1729,18 @@ discard block |
||
1729 | 1729 | } |
1730 | 1730 | $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
1731 | 1731 | } |
1732 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1733 | - //fix the reciprocal relation too |
|
1734 | - if( $otherObject->ID() ) { |
|
1735 | - //its saved so assumed relations exist in the DB, so we can just |
|
1736 | - //clear the cache so future queries use the updated info in the DB |
|
1737 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1738 | - } else { |
|
1739 | - |
|
1740 | - //it's not saved, so it caches relations like this |
|
1741 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1742 | - } |
|
1743 | - } |
|
1732 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1733 | + //fix the reciprocal relation too |
|
1734 | + if( $otherObject->ID() ) { |
|
1735 | + //its saved so assumed relations exist in the DB, so we can just |
|
1736 | + //clear the cache so future queries use the updated info in the DB |
|
1737 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1738 | + } else { |
|
1739 | + |
|
1740 | + //it's not saved, so it caches relations like this |
|
1741 | + $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1742 | + } |
|
1743 | + } |
|
1744 | 1744 | return $otherObject; |
1745 | 1745 | } |
1746 | 1746 | |
@@ -1770,9 +1770,9 @@ discard block |
||
1770 | 1770 | //this doesn't exist in the DB, just remove it from the cache |
1771 | 1771 | $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
1772 | 1772 | } |
1773 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1774 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1775 | - } |
|
1773 | + if( $otherObject instanceof EE_Base_Class ) { |
|
1774 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1775 | + } |
|
1776 | 1776 | return $otherObject; |
1777 | 1777 | } |
1778 | 1778 | |
@@ -1791,11 +1791,11 @@ discard block |
||
1791 | 1791 | //this doesn't exist in the DB, just remove it from the cache |
1792 | 1792 | $otherObjects = $this->clear_cache( $relationName, null, true ); |
1793 | 1793 | } |
1794 | - if( is_array( $otherObjects ) ) { |
|
1795 | - foreach ( $otherObjects as $otherObject ) { |
|
1796 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1797 | - } |
|
1798 | - } |
|
1794 | + if( is_array( $otherObjects ) ) { |
|
1795 | + foreach ( $otherObjects as $otherObject ) { |
|
1796 | + $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1797 | + } |
|
1798 | + } |
|
1799 | 1799 | return $otherObjects; |
1800 | 1800 | } |
1801 | 1801 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | -do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | +do_action('AHEE_log', __FILE__, ' FILE LOADED', ''); |
|
3 | 3 | /** |
4 | 4 | * |
5 | 5 | * Event Espresso |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * ------------------------------------------------------------------------ |
25 | 25 | */ |
26 | 26 | |
27 | -abstract class EE_Base_Class{ |
|
27 | +abstract class EE_Base_Class { |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * This is an array of the original properties and values provided during construction |
@@ -117,60 +117,60 @@ discard block |
||
117 | 117 | * @throws EE_Error |
118 | 118 | * @return \EE_Base_Class |
119 | 119 | */ |
120 | - protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){ |
|
120 | + protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) { |
|
121 | 121 | |
122 | - $className=get_class($this); |
|
122 | + $className = get_class($this); |
|
123 | 123 | |
124 | - do_action("AHEE__{$className}__construct",$this,$fieldValues); |
|
125 | - $model=$this->get_model(); |
|
126 | - $model_fields = $model->field_settings( FALSE ); |
|
124 | + do_action("AHEE__{$className}__construct", $this, $fieldValues); |
|
125 | + $model = $this->get_model(); |
|
126 | + $model_fields = $model->field_settings(FALSE); |
|
127 | 127 | // ensure $fieldValues is an array |
128 | - $fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues ); |
|
128 | + $fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues); |
|
129 | 129 | // EEH_Debug_Tools::printr( $fieldValues, '$fieldValues <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
130 | 130 | // verify client code has not passed any invalid field names |
131 | - foreach($fieldValues as $field_name=> $field_value){ |
|
132 | - if( ! isset( $model_fields[ $field_name] ) ){ |
|
133 | - throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields)))); |
|
131 | + foreach ($fieldValues as $field_name=> $field_value) { |
|
132 | + if ( ! isset($model_fields[$field_name])) { |
|
133 | + throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields)))); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | // EEH_Debug_Tools::printr( $model_fields, '$model_fields <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
137 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
138 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
137 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
138 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
139 | 139 | |
140 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
140 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
141 | 141 | $this->_dt_frmt = $date_formats[0]; |
142 | 142 | $this->_tm_frmt = $date_formats[1]; |
143 | 143 | } else { |
144 | 144 | //set default formats for date and time |
145 | - $this->_dt_frmt = get_option( 'date_format' ); |
|
146 | - $this->_tm_frmt = get_option( 'time_format' ); |
|
145 | + $this->_dt_frmt = get_option('date_format'); |
|
146 | + $this->_tm_frmt = get_option('time_format'); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | //if db model is instantiating |
150 | - if ( $bydb ){ |
|
150 | + if ($bydb) { |
|
151 | 151 | //client code has indicated these field values are from the database |
152 | - foreach( $model_fields as $fieldName => $field ){ |
|
153 | - $this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null ); |
|
152 | + foreach ($model_fields as $fieldName => $field) { |
|
153 | + $this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null); |
|
154 | 154 | } |
155 | 155 | } else { |
156 | 156 | //we're constructing a brand |
157 | 157 | //new instance of the model object. Generally, this means we'll need to do more field validation |
158 | - foreach( $model_fields as $fieldName => $field ){ |
|
159 | - $this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true ); |
|
158 | + foreach ($model_fields as $fieldName => $field) { |
|
159 | + $this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | 163 | //remember what values were passed to this constructor |
164 | 164 | $this->_props_n_values_provided_in_constructor = $fieldValues; |
165 | 165 | //remember in entity mapper |
166 | - if($model->has_primary_key_field() && $this->ID() && ! $bydb ){ |
|
166 | + if ($model->has_primary_key_field() && $this->ID() && ! $bydb) { |
|
167 | 167 | $model->add_to_entity_map($this); |
168 | 168 | } |
169 | 169 | //setup all the relations |
170 | - foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
|
171 | - if($relation_obj instanceof EE_Belongs_To_Relation){ |
|
170 | + foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) { |
|
171 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
172 | 172 | $this->_model_relations[$relation_name] = NULL; |
173 | - }else{ |
|
173 | + } else { |
|
174 | 174 | $this->_model_relations[$relation_name] = array(); |
175 | 175 | } |
176 | 176 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * Action done at the end of each model object construction |
179 | 179 | * @param EE_Base_Class $this the model object just created |
180 | 180 | */ |
181 | - do_action( 'AHEE__EE_Base_Class__construct__finished', $this ); |
|
181 | + do_action('AHEE__EE_Base_Class__construct__finished', $this); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param boolean $allow_persist |
199 | 199 | * @return boolean |
200 | 200 | */ |
201 | - function set_allow_persist( $allow_persist ) { |
|
201 | + function set_allow_persist($allow_persist) { |
|
202 | 202 | return $this->_allow_persist = $allow_persist; |
203 | 203 | } |
204 | 204 | |
@@ -211,11 +211,11 @@ discard block |
||
211 | 211 | * @param string $field_name |
212 | 212 | * @return mixed|null |
213 | 213 | */ |
214 | - public function get_original( $field_name ){ |
|
215 | - if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
|
216 | - $field_settings = $this->get_Model()->field_settings_for( $field_name )){ |
|
217 | - return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
|
218 | - }else{ |
|
214 | + public function get_original($field_name) { |
|
215 | + if (isset($this->_props_n_values_provided_in_constructor[$field_name]) && |
|
216 | + $field_settings = $this->get_Model()->field_settings_for($field_name)) { |
|
217 | + return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]); |
|
218 | + } else { |
|
219 | 219 | return NULL; |
220 | 220 | } |
221 | 221 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param EE_Base_Class $obj |
226 | 226 | * @return string |
227 | 227 | */ |
228 | - public function get_class($obj){ |
|
228 | + public function get_class($obj) { |
|
229 | 229 | return get_class($obj); |
230 | 230 | } |
231 | 231 | |
@@ -238,19 +238,19 @@ discard block |
||
238 | 238 | * @param mixed $field_value |
239 | 239 | * @param bool $use_default |
240 | 240 | */ |
241 | - public function set( $field_name, $field_value, $use_default = FALSE ){ |
|
242 | - $field_obj = $this->get_model()->field_settings_for( $field_name ); |
|
243 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
241 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
242 | + $field_obj = $this->get_model()->field_settings_for($field_name); |
|
243 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
244 | 244 | // if ( method_exists( $field_obj, 'set_timezone' )) { |
245 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
246 | - $field_obj->set_timezone( $this->_timezone ); |
|
247 | - $field_obj->set_date_format( $this->_dt_frmt ); |
|
248 | - $field_obj->set_time_format( $this->_tm_frmt ); |
|
245 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
246 | + $field_obj->set_timezone($this->_timezone); |
|
247 | + $field_obj->set_date_format($this->_dt_frmt); |
|
248 | + $field_obj->set_time_format($this->_tm_frmt); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | $holder_of_value = $field_obj->prepare_for_set($field_value); |
252 | 252 | //should the value be null? |
253 | - if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){ |
|
253 | + if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) { |
|
254 | 254 | $this->_fields[$field_name] = $field_obj->get_default_value(); |
255 | 255 | |
256 | 256 | /** |
@@ -260,19 +260,19 @@ discard block |
||
260 | 260 | * object. |
261 | 261 | * @since 4.6.10+ |
262 | 262 | */ |
263 | - if ( $field_obj instanceof EE_Datetime_Field && ! is_null( $this->_fields[$field_name] ) && ! $this->_fields[$field_name] instanceof DateTime ) { |
|
264 | - empty( $this->_fields[$field_name] ) ? $this->set( $field_name, time() ) : $this->set( $field_name, $this->_fields[$field_name] ); |
|
263 | + if ($field_obj instanceof EE_Datetime_Field && ! is_null($this->_fields[$field_name]) && ! $this->_fields[$field_name] instanceof DateTime) { |
|
264 | + empty($this->_fields[$field_name]) ? $this->set($field_name, time()) : $this->set($field_name, $this->_fields[$field_name]); |
|
265 | 265 | } |
266 | 266 | |
267 | - }else{ |
|
267 | + } else { |
|
268 | 268 | $this->_fields[$field_name] = $holder_of_value; |
269 | 269 | } |
270 | 270 | |
271 | 271 | //if we're not in the constructor... |
272 | 272 | //now check if what we set was a primary key |
273 | - if($this->_props_n_values_provided_in_constructor && //note: props_n_values_provided_in_constructor is only set at the END of the constructor |
|
273 | + if ($this->_props_n_values_provided_in_constructor && //note: props_n_values_provided_in_constructor is only set at the END of the constructor |
|
274 | 274 | $field_name == $this->_get_primary_key_name(get_class($this)) && |
275 | - $field_value){ |
|
275 | + $field_value) { |
|
276 | 276 | //if so, we want all this object's fields to be filled either with |
277 | 277 | //what we've explicitly set on this model |
278 | 278 | //or what we have in the db |
@@ -280,20 +280,20 @@ discard block |
||
280 | 280 | $fields_on_model = $this->_get_model(get_class($this))->field_settings(); |
281 | 281 | |
282 | 282 | $obj_in_db = $this->_get_model(get_class($this))->get_one_by_ID($field_value); |
283 | - foreach($fields_on_model as $field_obj){ |
|
284 | - if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
285 | - && $field_obj->get_name() != $field_name ){ |
|
283 | + foreach ($fields_on_model as $field_obj) { |
|
284 | + if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor) |
|
285 | + && $field_obj->get_name() != $field_name) { |
|
286 | 286 | |
287 | - $this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name())); |
|
287 | + $this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name())); |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | //oh this model object has an ID? well make sure its in the entity mapper |
291 | 291 | $this->get_model()->add_to_entity_map($this); |
292 | 292 | } |
293 | 293 | //let's unset any cache for this field_name from the $_cached_properties property. |
294 | - $this->_clear_cached_property( $field_name ); |
|
295 | - }else{ |
|
296 | - throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name ) ); |
|
294 | + $this->_clear_cached_property($field_name); |
|
295 | + } else { |
|
296 | + throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name)); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | } |
@@ -312,14 +312,14 @@ discard block |
||
312 | 312 | * @param mixed $field_value The value to set. |
313 | 313 | * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs. |
314 | 314 | */ |
315 | - public function set_field_or_extra_meta( $field_name, $field_value ) { |
|
316 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
317 | - $this->set( $field_name, $field_value ); |
|
315 | + public function set_field_or_extra_meta($field_name, $field_value) { |
|
316 | + if ($this->get_model()->has_field($field_name)) { |
|
317 | + $this->set($field_name, $field_value); |
|
318 | 318 | return true; |
319 | 319 | } else { |
320 | 320 | //ensure this object is saved first so that extra meta can be properly related. |
321 | 321 | $this->save(); |
322 | - return $this->update_extra_meta( $field_name, $field_value ); |
|
322 | + return $this->update_extra_meta($field_name, $field_value); |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
@@ -343,12 +343,12 @@ discard block |
||
343 | 343 | * @param string $field_name expecting the fully qualified field name. |
344 | 344 | * @return mixed|null value for the field if found. null if not found. |
345 | 345 | */ |
346 | - public function get_field_or_extra_meta( $field_name ) { |
|
347 | - if ( $this->get_model()->has_field( $field_name ) ) { |
|
348 | - $column_value = $this->get( $field_name ); |
|
346 | + public function get_field_or_extra_meta($field_name) { |
|
347 | + if ($this->get_model()->has_field($field_name)) { |
|
348 | + $column_value = $this->get($field_name); |
|
349 | 349 | } else { |
350 | 350 | //This isn't a column in the main table, let's see if it is in the extra meta. |
351 | - $column_value = $this->get_extra_meta( $field_name, true, null ); |
|
351 | + $column_value = $this->get_extra_meta($field_name, true, null); |
|
352 | 352 | } |
353 | 353 | return $column_value; |
354 | 354 | } |
@@ -367,19 +367,19 @@ discard block |
||
367 | 367 | * @param string $timezone A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php |
368 | 368 | * @return void |
369 | 369 | */ |
370 | - public function set_timezone( $timezone = '' ) { |
|
370 | + public function set_timezone($timezone = '') { |
|
371 | 371 | EE_Registry::instance()->load_helper('DTT_Helper'); |
372 | - $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone ); |
|
372 | + $this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone); |
|
373 | 373 | //make sure we clear all cached properties because they won't be relevant now |
374 | 374 | $this->_clear_cached_properties(); |
375 | 375 | |
376 | 376 | //make sure we update field settings and the date for all EE_Datetime_Fields |
377 | - $model_fields = $this->get_model()->field_settings( false ); |
|
378 | - foreach ( $model_fields as $field_name => $field_obj ) { |
|
379 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
380 | - $field_obj->set_timezone( $this->_timezone ); |
|
381 | - if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) { |
|
382 | - $this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) ); |
|
377 | + $model_fields = $this->get_model()->field_settings(false); |
|
378 | + foreach ($model_fields as $field_name => $field_obj) { |
|
379 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
380 | + $field_obj->set_timezone($this->_timezone); |
|
381 | + if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) { |
|
382 | + $this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone)); |
|
383 | 383 | } |
384 | 384 | } |
385 | 385 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @param string $format should be a format recognizable by PHP date() functions. |
410 | 410 | */ |
411 | - public function set_date_format( $format ) { |
|
411 | + public function set_date_format($format) { |
|
412 | 412 | $this->_dt_frmt = $format; |
413 | 413 | //clear cached_properties because they won't be relevant now. |
414 | 414 | $this->_clear_cached_properties(); |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @since 4.6 |
425 | 425 | * @param string $format should be a format recognizable by PHP date() functions. |
426 | 426 | */ |
427 | - public function set_time_format( $format ) { |
|
427 | + public function set_time_format($format) { |
|
428 | 428 | $this->_tm_frmt = $format; |
429 | 429 | //clear cached_properties because they won't be relevant now. |
430 | 430 | $this->_clear_cached_properties(); |
@@ -441,8 +441,8 @@ discard block |
||
441 | 441 | * |
442 | 442 | * @return mixed string|array |
443 | 443 | */ |
444 | - public function get_format( $full = true ) { |
|
445 | - return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt ); |
|
444 | + public function get_format($full = true) { |
|
445 | + return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt); |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
@@ -460,17 +460,17 @@ discard block |
||
460 | 460 | * @throws EE_Error |
461 | 461 | * @return mixed index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array) |
462 | 462 | */ |
463 | - public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){ |
|
463 | + public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) { |
|
464 | 464 | // its entirely possible that there IS no related object yet in which case there is nothing to cache. |
465 | - if ( ! $object_to_cache instanceof EE_Base_Class ) { |
|
465 | + if ( ! $object_to_cache instanceof EE_Base_Class) { |
|
466 | 466 | return FALSE; |
467 | 467 | } |
468 | 468 | // also get "how" the object is related, or throw an error |
469 | - if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) { |
|
470 | - throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this ))); |
|
469 | + if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) { |
|
470 | + throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this))); |
|
471 | 471 | } |
472 | 472 | // how many things are related ? |
473 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ){ |
|
473 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
474 | 474 | // if it's a "belongs to" relationship, then there's only one related model object eg, if this is a registration, there's only 1 attendee for it |
475 | 475 | // so for these model objects just set it to be cached |
476 | 476 | $this->_model_relations[$relationName] = $object_to_cache; |
@@ -478,26 +478,26 @@ discard block |
||
478 | 478 | } else { |
479 | 479 | // otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type. |
480 | 480 | // eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array |
481 | - if( ! is_array( $this->_model_relations[$relationName] )) { |
|
481 | + if ( ! is_array($this->_model_relations[$relationName])) { |
|
482 | 482 | // if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array |
483 | - $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array(); |
|
483 | + $this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array(); |
|
484 | 484 | } |
485 | 485 | // first check for a cache_id which is normally empty |
486 | - if ( ! empty( $cache_id )) { |
|
486 | + if ( ! empty($cache_id)) { |
|
487 | 487 | // if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on |
488 | - $this->_model_relations[$relationName][ $cache_id ] = $object_to_cache; |
|
488 | + $this->_model_relations[$relationName][$cache_id] = $object_to_cache; |
|
489 | 489 | $return = $cache_id; |
490 | - } elseif ( $object_to_cache->ID() ) { |
|
490 | + } elseif ($object_to_cache->ID()) { |
|
491 | 491 | // OR the cached object originally came from the db, so let's just use it's PK for an ID |
492 | - $this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache; |
|
492 | + $this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache; |
|
493 | 493 | $return = $object_to_cache->ID(); |
494 | 494 | } else { |
495 | 495 | // OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID |
496 | 496 | $this->_model_relations[$relationName][] = $object_to_cache; |
497 | 497 | // move the internal pointer to the end of the array |
498 | - end( $this->_model_relations[$relationName] ); |
|
498 | + end($this->_model_relations[$relationName]); |
|
499 | 499 | // and grab the key so that we can return it |
500 | - $return = key( $this->_model_relations[$relationName] ); |
|
500 | + $return = key($this->_model_relations[$relationName]); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | } |
@@ -515,11 +515,11 @@ discard block |
||
515 | 515 | * @param null $cache_type |
516 | 516 | * @return void |
517 | 517 | */ |
518 | - protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) { |
|
518 | + protected function _set_cached_property($fieldname, $value, $cache_type = NULL) { |
|
519 | 519 | //first make sure this property exists |
520 | 520 | $this->get_model()->field_settings_for($fieldname); |
521 | 521 | |
522 | - $cache_type = empty( $cache_type ) ? 'standard' : $cache_type; |
|
522 | + $cache_type = empty($cache_type) ? 'standard' : $cache_type; |
|
523 | 523 | $this->_cached_properties[$fieldname][$cache_type] = $value; |
524 | 524 | } |
525 | 525 | |
@@ -534,34 +534,34 @@ discard block |
||
534 | 534 | * It can also accept certain pre-defined "schema" strings to define how to output the property. see the field's prepare_for_pretty_echoing for what strings can be used |
535 | 535 | * @return mixed whatever the value for the property is we're retrieving |
536 | 536 | */ |
537 | - protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) { |
|
537 | + protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) { |
|
538 | 538 | //verify the field exists |
539 | 539 | $this->get_model()->field_settings_for($fieldname); |
540 | 540 | |
541 | 541 | $cache_type = $pretty ? 'pretty' : 'standard'; |
542 | - $cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : ''; |
|
542 | + $cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : ''; |
|
543 | 543 | |
544 | - if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) { |
|
544 | + if (isset($this->_cached_properties[$fieldname][$cache_type])) { |
|
545 | 545 | return $this->_cached_properties[$fieldname][$cache_type]; |
546 | 546 | } |
547 | 547 | |
548 | 548 | $field_obj = $this->get_model()->field_settings_for($fieldname); |
549 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
549 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
550 | 550 | /** |
551 | 551 | * maybe this is EE_Datetime_Field. If so we need to make sure timezone and |
552 | 552 | * formats are correct. |
553 | 553 | */ |
554 | - if ( $field_obj instanceof EE_Datetime_Field ) { |
|
555 | - $field_obj->set_timezone( $this->_timezone ); |
|
556 | - $field_obj->set_date_format( $this->_dt_frmt, $pretty ); |
|
557 | - $field_obj->set_time_format( $this->_tm_frmt, $pretty ); |
|
554 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
555 | + $field_obj->set_timezone($this->_timezone); |
|
556 | + $field_obj->set_date_format($this->_dt_frmt, $pretty); |
|
557 | + $field_obj->set_time_format($this->_tm_frmt, $pretty); |
|
558 | 558 | } |
559 | 559 | |
560 | - if( ! isset($this->_fields[$fieldname])){ |
|
560 | + if ( ! isset($this->_fields[$fieldname])) { |
|
561 | 561 | $this->_fields[$fieldname] = NULL; |
562 | 562 | } |
563 | - $value = $pretty ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) : $field_obj->prepare_for_get($this->_fields[$fieldname] ); |
|
564 | - $this->_set_cached_property( $fieldname, $value, $cache_type ); |
|
563 | + $value = $pretty ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) : $field_obj->prepare_for_get($this->_fields[$fieldname]); |
|
564 | + $this->_set_cached_property($fieldname, $value, $cache_type); |
|
565 | 565 | return $value; |
566 | 566 | } |
567 | 567 | return FALSE; |
@@ -587,9 +587,9 @@ discard block |
||
587 | 587 | * @param string $property_name the property to remove if it exists (from the _cached_properties array) |
588 | 588 | * @return void |
589 | 589 | */ |
590 | - protected function _clear_cached_property( $property_name ) { |
|
591 | - if ( isset( $this->_cached_properties[ $property_name ] ) ) |
|
592 | - unset( $this->_cached_properties[ $property_name ] ); |
|
590 | + protected function _clear_cached_property($property_name) { |
|
591 | + if (isset($this->_cached_properties[$property_name])) |
|
592 | + unset($this->_cached_properties[$property_name]); |
|
593 | 593 | } |
594 | 594 | |
595 | 595 | |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * @param string $model_name name of the related thing, eg 'Attendee', |
601 | 601 | * @return EE_Base_Class |
602 | 602 | */ |
603 | - protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){ |
|
603 | + protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) { |
|
604 | 604 | $other_model_instance = self::_get_model_instance_with_name(self::_get_model_classname($model_name), $this->_timezone); |
605 | 605 | $model_obj = $other_model_instance->ensure_is_obj($object_or_id); |
606 | 606 | return $model_obj; |
@@ -620,55 +620,55 @@ discard block |
||
620 | 620 | * @throws EE_Error |
621 | 621 | * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all |
622 | 622 | */ |
623 | - public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){ |
|
623 | + public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) { |
|
624 | 624 | $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
625 | 625 | $index_in_cache = ''; |
626 | - if( ! $relationship_to_model){ |
|
627 | - throw new EE_Error(sprintf(__("There is no relationship to %s on a %s. Cannot clear that cache",'event_espresso'),$relationName,get_class($this))); |
|
626 | + if ( ! $relationship_to_model) { |
|
627 | + throw new EE_Error(sprintf(__("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'), $relationName, get_class($this))); |
|
628 | 628 | } |
629 | - if($clear_all){ |
|
629 | + if ($clear_all) { |
|
630 | 630 | $obj_removed = true; |
631 | 631 | $this->_model_relations[$relationName] = null; |
632 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
632 | + }elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
633 | 633 | $obj_removed = $this->_model_relations[$relationName]; |
634 | 634 | $this->_model_relations[$relationName] = null; |
635 | - }else{ |
|
636 | - if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
|
635 | + } else { |
|
636 | + if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) { |
|
637 | 637 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
638 | - if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
|
638 | + if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) { |
|
639 | 639 | $index_found_at = NULL; |
640 | 640 | //find this object in the array even though it has a different key |
641 | - foreach($this->_model_relations[$relationName] as $index=>$obj){ |
|
642 | - if( $obj instanceof EE_Base_Class && ( $obj == $object_to_remove_or_index_into_array || $obj->ID() == $object_to_remove_or_index_into_array->ID() )) { |
|
641 | + foreach ($this->_model_relations[$relationName] as $index=>$obj) { |
|
642 | + if ($obj instanceof EE_Base_Class && ($obj == $object_to_remove_or_index_into_array || $obj->ID() == $object_to_remove_or_index_into_array->ID())) { |
|
643 | 643 | $index_found_at = $index; |
644 | 644 | break; |
645 | 645 | } |
646 | 646 | } |
647 | - if($index_found_at){ |
|
647 | + if ($index_found_at) { |
|
648 | 648 | $index_in_cache = $index_found_at; |
649 | - }else{ |
|
649 | + } else { |
|
650 | 650 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
651 | 651 | //if it wasn't in it to begin with. So we're done |
652 | 652 | return $object_to_remove_or_index_into_array; |
653 | 653 | } |
654 | 654 | } |
655 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
655 | + }elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) { |
|
656 | 656 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
657 | - foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
|
658 | - if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
|
657 | + foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) { |
|
658 | + if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) { |
|
659 | 659 | $index_in_cache = $index; |
660 | 660 | } |
661 | 661 | } |
662 | - }else{ |
|
662 | + } else { |
|
663 | 663 | $index_in_cache = $object_to_remove_or_index_into_array; |
664 | 664 | } |
665 | 665 | //supposedly we've found it. But it could just be that the client code |
666 | 666 | //provided a bad index/object |
667 | - if(isset( $this->_model_relations[$relationName]) && |
|
668 | - isset( $this->_model_relations[$relationName][$index_in_cache])){ |
|
667 | + if (isset($this->_model_relations[$relationName]) && |
|
668 | + isset($this->_model_relations[$relationName][$index_in_cache])) { |
|
669 | 669 | $obj_removed = $this->_model_relations[$relationName][$index_in_cache]; |
670 | 670 | unset($this->_model_relations[$relationName][$index_in_cache]); |
671 | - }else{ |
|
671 | + } else { |
|
672 | 672 | //that thing was never cached anyways. |
673 | 673 | $obj_removed = NULL; |
674 | 674 | } |
@@ -687,24 +687,24 @@ discard block |
||
687 | 687 | * @param string $current_cache_id - the ID that was used when originally caching the object |
688 | 688 | * @return boolean TRUE on success, FALSE on fail |
689 | 689 | */ |
690 | - public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
690 | + public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') { |
|
691 | 691 | // verify that incoming object is of the correct type |
692 | - $obj_class = 'EE_' . $relationName; |
|
693 | - if ( $newly_saved_object instanceof $obj_class ) { |
|
692 | + $obj_class = 'EE_'.$relationName; |
|
693 | + if ($newly_saved_object instanceof $obj_class) { |
|
694 | 694 | /* @type EE_Base_Class $newly_saved_object*/ |
695 | 695 | // now get the type of relation |
696 | - $relationship_to_model = $this->get_model()->related_settings_for( $relationName ); |
|
696 | + $relationship_to_model = $this->get_model()->related_settings_for($relationName); |
|
697 | 697 | // if this is a 1:1 relationship |
698 | - if( $relationship_to_model instanceof EE_Belongs_To_Relation ) { |
|
698 | + if ($relationship_to_model instanceof EE_Belongs_To_Relation) { |
|
699 | 699 | // then just replace the cached object with the newly saved object |
700 | 700 | $this->_model_relations[$relationName] = $newly_saved_object; |
701 | 701 | return TRUE; |
702 | 702 | // or if it's some kind of sordid feral polyamorous relationship... |
703 | - } elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) { |
|
703 | + } elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) { |
|
704 | 704 | // then remove the current cached item |
705 | - unset( $this->_model_relations[$relationName][ $current_cache_id ] ); |
|
705 | + unset($this->_model_relations[$relationName][$current_cache_id]); |
|
706 | 706 | // and cache the newly saved object using it's new ID |
707 | - $this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object; |
|
707 | + $this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object; |
|
708 | 708 | return TRUE; |
709 | 709 | } |
710 | 710 | } |
@@ -720,11 +720,11 @@ discard block |
||
720 | 720 | * @param string $relationName |
721 | 721 | * @return EE_Base_Class |
722 | 722 | */ |
723 | - public function get_one_from_cache($relationName){ |
|
724 | - $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null; |
|
725 | - if(is_array($cached_array_or_object)){ |
|
723 | + public function get_one_from_cache($relationName) { |
|
724 | + $cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null; |
|
725 | + if (is_array($cached_array_or_object)) { |
|
726 | 726 | return array_shift($cached_array_or_object); |
727 | - }else{ |
|
727 | + } else { |
|
728 | 728 | return $cached_array_or_object; |
729 | 729 | } |
730 | 730 | } |
@@ -739,14 +739,14 @@ discard block |
||
739 | 739 | * @throws \EE_Error |
740 | 740 | * @return EE_Base_Class[] NOT necessarily indexed by primary keys |
741 | 741 | */ |
742 | - public function get_all_from_cache($relationName){ |
|
743 | - $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array(); |
|
744 | - if(is_array($cached_array_or_object)){ |
|
742 | + public function get_all_from_cache($relationName) { |
|
743 | + $cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array(); |
|
744 | + if (is_array($cached_array_or_object)) { |
|
745 | 745 | $objects = $cached_array_or_object; |
746 | - }elseif($cached_array_or_object){ |
|
746 | + }elseif ($cached_array_or_object) { |
|
747 | 747 | //if the result is not an array, but exists, make it an array |
748 | 748 | $objects = array($cached_array_or_object); |
749 | - }else{ |
|
749 | + } else { |
|
750 | 750 | //if nothing was found, return an empty array |
751 | 751 | $objects = array(); |
752 | 752 | } |
@@ -754,15 +754,15 @@ discard block |
||
754 | 754 | //basically, if this model object was stored in the session, and these cached model objects |
755 | 755 | //already have IDs, let's make sure they're in their model's entity mapper |
756 | 756 | //otherwise we will have duplicates next time we call EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() ); |
757 | - foreach( $objects as $model_object ){ |
|
758 | - $model = EE_Registry::instance()->load_model( $relationName ); |
|
759 | - if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){ |
|
757 | + foreach ($objects as $model_object) { |
|
758 | + $model = EE_Registry::instance()->load_model($relationName); |
|
759 | + if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) { |
|
760 | 760 | //ensure its in the map if it has an ID; otherwise it will be added to the map when its saved |
761 | - if( $model_object->ID() ){ |
|
762 | - $model->add_to_entity_map( $model_object ); |
|
761 | + if ($model_object->ID()) { |
|
762 | + $model->add_to_entity_map($model_object); |
|
763 | 763 | } |
764 | - }else{ |
|
765 | - throw new EE_Error( sprintf( __( 'Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso' ), $relationName, gettype( $model_object ))); |
|
764 | + } else { |
|
765 | + throw new EE_Error(sprintf(__('Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso'), $relationName, gettype($model_object))); |
|
766 | 766 | } |
767 | 767 | } |
768 | 768 | return $objects; |
@@ -781,13 +781,13 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @return array|EE_Base_Class[] |
783 | 783 | */ |
784 | - public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
785 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
786 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
787 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
784 | + public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
785 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
786 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
787 | + if (empty($field) || empty($current_value)) { |
|
788 | 788 | return array(); |
789 | 789 | } |
790 | - return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
790 | + return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | |
@@ -806,13 +806,13 @@ discard block |
||
806 | 806 | * |
807 | 807 | * @return array|EE_Base_Class[] |
808 | 808 | */ |
809 | - public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) { |
|
810 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
811 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
812 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
809 | + public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) { |
|
810 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
811 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
812 | + if (empty($field) || empty($current_value)) { |
|
813 | 813 | return array(); |
814 | 814 | } |
815 | - return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select ); |
|
815 | + return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select); |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | |
@@ -830,13 +830,13 @@ discard block |
||
830 | 830 | * |
831 | 831 | * @return array|EE_Base_Class |
832 | 832 | */ |
833 | - public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
834 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
835 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
836 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
833 | + public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
834 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
835 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
836 | + if (empty($field) || empty($current_value)) { |
|
837 | 837 | return array(); |
838 | 838 | } |
839 | - return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select ); |
|
839 | + return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | |
@@ -855,13 +855,13 @@ discard block |
||
855 | 855 | * |
856 | 856 | * @return array|EE_Base_Class |
857 | 857 | */ |
858 | - public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) { |
|
859 | - $field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
860 | - $current_value = ! empty( $field ) ? $this->get( $field ) : null; |
|
861 | - if ( empty( $field ) || empty( $current_value ) ) { |
|
858 | + public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) { |
|
859 | + $field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by; |
|
860 | + $current_value = ! empty($field) ? $this->get($field) : null; |
|
861 | + if (empty($field) || empty($current_value)) { |
|
862 | 862 | return array(); |
863 | 863 | } |
864 | - return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select ); |
|
864 | + return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select); |
|
865 | 865 | } |
866 | 866 | |
867 | 867 | |
@@ -875,25 +875,25 @@ discard block |
||
875 | 875 | * @param string $field_name |
876 | 876 | * @param mixed $field_value_from_db |
877 | 877 | */ |
878 | - public function set_from_db($field_name,$field_value_from_db){ |
|
878 | + public function set_from_db($field_name, $field_value_from_db) { |
|
879 | 879 | $field_obj = $this->get_model()->field_settings_for($field_name); |
880 | - if ( $field_obj instanceof EE_Model_Field_Base ) { |
|
880 | + if ($field_obj instanceof EE_Model_Field_Base) { |
|
881 | 881 | //you would think the DB has no NULLs for non-null label fields right? wrong! |
882 | 882 | //eg, a CPT model object could have an entry in the posts table, but no |
883 | 883 | //entry in the meta table. Meaning that all its columns in the meta table |
884 | 884 | //are null! yikes! so when we find one like that, use defaults for its meta columns |
885 | - if($field_value_from_db === NULL ){ |
|
886 | - if( $field_obj->is_nullable()){ |
|
885 | + if ($field_value_from_db === NULL) { |
|
886 | + if ($field_obj->is_nullable()) { |
|
887 | 887 | //if the field allows nulls, then let it be null |
888 | 888 | $field_value = NULL; |
889 | - }else{ |
|
889 | + } else { |
|
890 | 890 | $field_value = $field_obj->get_default_value(); |
891 | 891 | } |
892 | - }else{ |
|
893 | - $field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db ); |
|
892 | + } else { |
|
893 | + $field_value = $field_obj->prepare_for_set_from_db($field_value_from_db); |
|
894 | 894 | } |
895 | 895 | $this->_fields[$field_name] = $field_value; |
896 | - $this->_clear_cached_property( $field_name ); |
|
896 | + $this->_clear_cached_property($field_name); |
|
897 | 897 | } |
898 | 898 | } |
899 | 899 | |
@@ -905,8 +905,8 @@ discard block |
||
905 | 905 | * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.) |
906 | 906 | * @return boolean |
907 | 907 | */ |
908 | - public function get($field_name, $extra_cache_ref = NULL ){ |
|
909 | - return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref ); |
|
908 | + public function get($field_name, $extra_cache_ref = NULL) { |
|
909 | + return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref); |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | |
@@ -936,11 +936,11 @@ discard block |
||
936 | 936 | * just null is returned (because that indicates that likely |
937 | 937 | * this field is nullable). |
938 | 938 | */ |
939 | - public function get_DateTime_object( $field_name ) { |
|
940 | - $field_settings = $this->get_model()->field_settings_for( $field_name ); |
|
939 | + public function get_DateTime_object($field_name) { |
|
940 | + $field_settings = $this->get_model()->field_settings_for($field_name); |
|
941 | 941 | |
942 | - if ( ! $field_settings instanceof EE_Datetime_Field ) { |
|
943 | - EE_Error::add_error( sprintf( __('The field %s is not an EE_Datetime_Field field. There is no DateTime object stored on this field type.', 'event_espresso' ), $field_name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
942 | + if ( ! $field_settings instanceof EE_Datetime_Field) { |
|
943 | + EE_Error::add_error(sprintf(__('The field %s is not an EE_Datetime_Field field. There is no DateTime object stored on this field type.', 'event_espresso'), $field_name), __FILE__, __FUNCTION__, __LINE__); |
|
944 | 944 | return false; |
945 | 945 | } |
946 | 946 | |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.) |
957 | 957 | * @return void |
958 | 958 | */ |
959 | - public function e($field_name, $extra_cache_ref = NULL){ |
|
959 | + public function e($field_name, $extra_cache_ref = NULL) { |
|
960 | 960 | echo $this->get_pretty($field_name, $extra_cache_ref); |
961 | 961 | } |
962 | 962 | /** |
@@ -965,8 +965,8 @@ discard block |
||
965 | 965 | * @param string $field_name |
966 | 966 | * @return void |
967 | 967 | */ |
968 | - public function f($field_name){ |
|
969 | - $this->e($field_name,'form_input'); |
|
968 | + public function f($field_name) { |
|
969 | + $this->e($field_name, 'form_input'); |
|
970 | 970 | } |
971 | 971 | |
972 | 972 | /** |
@@ -975,8 +975,8 @@ discard block |
||
975 | 975 | * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.) |
976 | 976 | * @return mixed |
977 | 977 | */ |
978 | - public function get_pretty($field_name, $extra_cache_ref = NULL){ |
|
979 | - return $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref ); |
|
978 | + public function get_pretty($field_name, $extra_cache_ref = NULL) { |
|
979 | + return $this->_get_cached_property($field_name, TRUE, $extra_cache_ref); |
|
980 | 980 | } |
981 | 981 | |
982 | 982 | |
@@ -993,37 +993,37 @@ discard block |
||
993 | 993 | * @param boolean $echo Whether the dtt is echoing using pretty echoing or just returned using vanilla get |
994 | 994 | * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing |
995 | 995 | */ |
996 | - protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) { |
|
996 | + protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) { |
|
997 | 997 | |
998 | - $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
998 | + $in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt; |
|
999 | 999 | $in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt; |
1000 | 1000 | |
1001 | 1001 | //validate field for datetime and returns field settings if valid. |
1002 | - $field = $this->_get_dtt_field_settings( $field_name ); |
|
1002 | + $field = $this->_get_dtt_field_settings($field_name); |
|
1003 | 1003 | |
1004 | 1004 | //clear cached property if either formats are not null. |
1005 | - if( $dt_frmt !== null || $tm_frmt !== null ) { |
|
1006 | - $this->_clear_cached_property( $field_name ); |
|
1005 | + if ($dt_frmt !== null || $tm_frmt !== null) { |
|
1006 | + $this->_clear_cached_property($field_name); |
|
1007 | 1007 | //reset format properties because they are used in get() |
1008 | 1008 | $this->_dt_frmt = $in_dt_frmt; |
1009 | 1009 | $this->_tm_frmt = $in_tm_frmt; |
1010 | 1010 | } |
1011 | 1011 | |
1012 | - if ( $echo ) |
|
1013 | - $field->set_pretty_date_format( $in_dt_frmt ); |
|
1012 | + if ($echo) |
|
1013 | + $field->set_pretty_date_format($in_dt_frmt); |
|
1014 | 1014 | else |
1015 | - $field->set_date_format( $in_dt_frmt ); |
|
1015 | + $field->set_date_format($in_dt_frmt); |
|
1016 | 1016 | |
1017 | - if ( $echo ) |
|
1018 | - $field->set_pretty_time_format( $in_tm_frmt ); |
|
1017 | + if ($echo) |
|
1018 | + $field->set_pretty_time_format($in_tm_frmt); |
|
1019 | 1019 | else |
1020 | - $field->set_time_format( $in_tm_frmt ); |
|
1020 | + $field->set_time_format($in_tm_frmt); |
|
1021 | 1021 | |
1022 | 1022 | //set timezone in field object |
1023 | - $field->set_timezone( $this->_timezone ); |
|
1023 | + $field->set_timezone($this->_timezone); |
|
1024 | 1024 | |
1025 | 1025 | //set the output returned |
1026 | - switch ( $date_or_time ) { |
|
1026 | + switch ($date_or_time) { |
|
1027 | 1027 | |
1028 | 1028 | case 'D' : |
1029 | 1029 | $field->set_date_time_output('date'); |
@@ -1038,11 +1038,11 @@ discard block |
||
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | |
1041 | - if ( $echo ) { |
|
1042 | - $this->e( $field_name, $date_or_time ); |
|
1041 | + if ($echo) { |
|
1042 | + $this->e($field_name, $date_or_time); |
|
1043 | 1043 | return ''; |
1044 | 1044 | } |
1045 | - return $this->get( $field_name, $date_or_time ); |
|
1045 | + return $this->get($field_name, $date_or_time); |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | |
@@ -1052,8 +1052,8 @@ discard block |
||
1052 | 1052 | * @param string $format format for the date returned (if NULL we use default in dt_frmt property) |
1053 | 1053 | * @return string datetime value formatted |
1054 | 1054 | */ |
1055 | - public function get_date( $field_name, $format = NULL ) { |
|
1056 | - return $this->_get_datetime( $field_name, $format, NULL, 'D' ); |
|
1055 | + public function get_date($field_name, $format = NULL) { |
|
1056 | + return $this->_get_datetime($field_name, $format, NULL, 'D'); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | |
@@ -1062,8 +1062,8 @@ discard block |
||
1062 | 1062 | * @param $field_name |
1063 | 1063 | * @param null $format |
1064 | 1064 | */ |
1065 | - public function e_date( $field_name, $format = NULL ) { |
|
1066 | - $this->_get_datetime( $field_name, $format, NULL, 'D', TRUE ); |
|
1065 | + public function e_date($field_name, $format = NULL) { |
|
1066 | + $this->_get_datetime($field_name, $format, NULL, 'D', TRUE); |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | |
@@ -1073,8 +1073,8 @@ discard block |
||
1073 | 1073 | * @param string $format format for the time returned ( if NULL we use default in tm_frmt property) |
1074 | 1074 | * @return string datetime value formatted |
1075 | 1075 | */ |
1076 | - public function get_time( $field_name, $format = NULL ) { |
|
1077 | - return $this->_get_datetime( $field_name, NULL, $format, 'T' ); |
|
1076 | + public function get_time($field_name, $format = NULL) { |
|
1077 | + return $this->_get_datetime($field_name, NULL, $format, 'T'); |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | |
@@ -1083,8 +1083,8 @@ discard block |
||
1083 | 1083 | * @param $field_name |
1084 | 1084 | * @param null $format |
1085 | 1085 | */ |
1086 | - public function e_time( $field_name, $format = NULL ) { |
|
1087 | - $this->_get_datetime( $field_name, NULL, $format, 'T', TRUE ); |
|
1086 | + public function e_time($field_name, $format = NULL) { |
|
1087 | + $this->_get_datetime($field_name, NULL, $format, 'T', TRUE); |
|
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | |
@@ -1097,8 +1097,8 @@ discard block |
||
1097 | 1097 | * @param string $tm_frmt format for the time returned (if NULL we use default in tm_frmt property) |
1098 | 1098 | * @return string datetime value formatted |
1099 | 1099 | */ |
1100 | - public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1101 | - return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt ); |
|
1100 | + public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1101 | + return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | 1104 | |
@@ -1108,8 +1108,8 @@ discard block |
||
1108 | 1108 | * @param null $dt_frmt |
1109 | 1109 | * @param null $tm_frmt |
1110 | 1110 | */ |
1111 | - public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) { |
|
1112 | - $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1111 | + public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) { |
|
1112 | + $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE); |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | |
@@ -1124,10 +1124,10 @@ discard block |
||
1124 | 1124 | * @return string Date and time string in set locale or false if no field exists for the given |
1125 | 1125 | * field name. |
1126 | 1126 | */ |
1127 | - public function get_i18n_datetime( $field_name, $format = NULL ) { |
|
1128 | - EE_Registry::instance()->load_helper( 'DTT_Helper' ); |
|
1129 | - $format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format; |
|
1130 | - return date_i18n( $format, EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone ) ); |
|
1127 | + public function get_i18n_datetime($field_name, $format = NULL) { |
|
1128 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
1129 | + $format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format; |
|
1130 | + return date_i18n($format, EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone)); |
|
1131 | 1131 | } |
1132 | 1132 | |
1133 | 1133 | |
@@ -1139,14 +1139,14 @@ discard block |
||
1139 | 1139 | * @throws EE_Error |
1140 | 1140 | * @return EE_Datetime_Field |
1141 | 1141 | */ |
1142 | - protected function _get_dtt_field_settings( $field_name ) { |
|
1142 | + protected function _get_dtt_field_settings($field_name) { |
|
1143 | 1143 | $field = $this->get_model()->field_settings_for($field_name); |
1144 | 1144 | |
1145 | 1145 | //check if field is dtt |
1146 | - if ( $field instanceof EE_Datetime_Field ) { |
|
1146 | + if ($field instanceof EE_Datetime_Field) { |
|
1147 | 1147 | return $field; |
1148 | 1148 | } else { |
1149 | - throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) ); |
|
1149 | + throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field. Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this)))); |
|
1150 | 1150 | } |
1151 | 1151 | } |
1152 | 1152 | |
@@ -1167,8 +1167,8 @@ discard block |
||
1167 | 1167 | * @param string|Datetime $time a valid time string for php datetime functions (or DateTime object) |
1168 | 1168 | * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field) |
1169 | 1169 | */ |
1170 | - protected function _set_time_for( $time, $fieldname ) { |
|
1171 | - $this->_set_date_time( 'T', $time, $fieldname ); |
|
1170 | + protected function _set_time_for($time, $fieldname) { |
|
1171 | + $this->_set_date_time('T', $time, $fieldname); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | |
@@ -1182,8 +1182,8 @@ discard block |
||
1182 | 1182 | * @param string|DateTime $date a valid date string for php datetime functions ( or DateTime object) |
1183 | 1183 | * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field) |
1184 | 1184 | */ |
1185 | - protected function _set_date_for( $date, $fieldname ) { |
|
1186 | - $this->_set_date_time( 'D', $date, $fieldname ); |
|
1185 | + protected function _set_date_for($date, $fieldname) { |
|
1186 | + $this->_set_date_time('D', $date, $fieldname); |
|
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | |
@@ -1199,21 +1199,21 @@ discard block |
||
1199 | 1199 | * @param string|DateTime $datetime_value A valid Date or Time string (or DateTime object) |
1200 | 1200 | * @param string $fieldname the name of the field the date OR time is being set on (must match a EE_Datetime_Field property) |
1201 | 1201 | */ |
1202 | - protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) { |
|
1203 | - $field = $this->_get_dtt_field_settings( $fieldname ); |
|
1204 | - $field->set_timezone( $this->_timezone ); |
|
1205 | - $field->set_date_format( $this->_dt_frmt ); |
|
1206 | - $field->set_time_format( $this->_tm_frmt ); |
|
1202 | + protected function _set_date_time($what = 'T', $datetime_value, $fieldname) { |
|
1203 | + $field = $this->_get_dtt_field_settings($fieldname); |
|
1204 | + $field->set_timezone($this->_timezone); |
|
1205 | + $field->set_date_format($this->_dt_frmt); |
|
1206 | + $field->set_time_format($this->_tm_frmt); |
|
1207 | 1207 | |
1208 | - switch ( $what ) { |
|
1208 | + switch ($what) { |
|
1209 | 1209 | case 'T' : |
1210 | - $this->_fields[$fieldname] = $field->prepare_for_set_with_new_time( $datetime_value, $this->_fields[$fieldname] ); |
|
1210 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_time($datetime_value, $this->_fields[$fieldname]); |
|
1211 | 1211 | break; |
1212 | 1212 | case 'D' : |
1213 | - $this->_fields[$fieldname] = $field->prepare_for_set_with_new_date( $datetime_value, $this->_fields[$fieldname] ); |
|
1213 | + $this->_fields[$fieldname] = $field->prepare_for_set_with_new_date($datetime_value, $this->_fields[$fieldname]); |
|
1214 | 1214 | break; |
1215 | 1215 | case 'B' : |
1216 | - $this->_fields[$fieldname] = $field->prepare_for_set( $datetime_value ); |
|
1216 | + $this->_fields[$fieldname] = $field->prepare_for_set($datetime_value); |
|
1217 | 1217 | break; |
1218 | 1218 | } |
1219 | 1219 | |
@@ -1236,25 +1236,25 @@ discard block |
||
1236 | 1236 | * @throws EE_Error |
1237 | 1237 | * @return string timestamp |
1238 | 1238 | */ |
1239 | - public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) { |
|
1239 | + public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') { |
|
1240 | 1240 | EE_Registry::instance()->load_helper('DTT_Helper'); |
1241 | 1241 | $timezone = EEH_DTT_Helper::get_timezone(); |
1242 | 1242 | |
1243 | - if ( $timezone == $this->_timezone ) |
|
1243 | + if ($timezone == $this->_timezone) |
|
1244 | 1244 | return ''; |
1245 | 1245 | |
1246 | 1246 | $original_timezone = $this->_timezone; |
1247 | - $this->set_timezone( $timezone ); |
|
1247 | + $this->set_timezone($timezone); |
|
1248 | 1248 | |
1249 | 1249 | $fn = (array) $field_name; |
1250 | - $args = array_merge( $fn, (array) $args ); |
|
1250 | + $args = array_merge($fn, (array) $args); |
|
1251 | 1251 | |
1252 | - if ( !method_exists( $this, $callback ) ) |
|
1253 | - throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist. Please check your spelling', 'event_espresso'), $callback ) ); |
|
1252 | + if ( ! method_exists($this, $callback)) |
|
1253 | + throw new EE_Error(sprintf(__('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist. Please check your spelling', 'event_espresso'), $callback)); |
|
1254 | 1254 | $args = (array) $args; |
1255 | - $return = $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append; |
|
1255 | + $return = $prepend.call_user_func_array(array($this, $callback), $args).$append; |
|
1256 | 1256 | |
1257 | - $this->set_timezone( $original_timezone ); |
|
1257 | + $this->set_timezone($original_timezone); |
|
1258 | 1258 | return $return; |
1259 | 1259 | } |
1260 | 1260 | |
@@ -1268,7 +1268,7 @@ discard block |
||
1268 | 1268 | * |
1269 | 1269 | * @return boolean | int |
1270 | 1270 | */ |
1271 | - public function delete(){ |
|
1271 | + public function delete() { |
|
1272 | 1272 | /** |
1273 | 1273 | * Called just before the `EE_Base_Class::_delete` method call. |
1274 | 1274 | * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions |
@@ -1277,7 +1277,7 @@ discard block |
||
1277 | 1277 | * |
1278 | 1278 | * @param EE_Base_Class $model_object about to be 'deleted' |
1279 | 1279 | */ |
1280 | - do_action( 'AHEE__EE_Base_Class__delete__before', $this ); |
|
1280 | + do_action('AHEE__EE_Base_Class__delete__before', $this); |
|
1281 | 1281 | $result = $this->_delete(); |
1282 | 1282 | /** |
1283 | 1283 | * Called just after the `EE_Base_Class::_delete` method call. |
@@ -1287,7 +1287,7 @@ discard block |
||
1287 | 1287 | * @param EE_Base_Class $model_object that was just 'deleted' |
1288 | 1288 | * @param boolean $result |
1289 | 1289 | */ |
1290 | - do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result ); |
|
1290 | + do_action('AHEE__EE_Base_Class__delete__end', $this, $result); |
|
1291 | 1291 | return $result; |
1292 | 1292 | } |
1293 | 1293 | |
@@ -1310,22 +1310,22 @@ discard block |
||
1310 | 1310 | * Deletes this model object permanently from db (but keep in mind related models my block the delete and return an error) |
1311 | 1311 | * @return bool | int |
1312 | 1312 | */ |
1313 | - public function delete_permanently(){ |
|
1313 | + public function delete_permanently() { |
|
1314 | 1314 | /** |
1315 | 1315 | * Called just before HARD deleting a model object |
1316 | 1316 | * |
1317 | 1317 | * @param EE_Base_Class $model_object about to be 'deleted' |
1318 | 1318 | */ |
1319 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this ); |
|
1320 | - $model=$this->get_model(); |
|
1321 | - $result=$model->delete_permanently_by_ID($this->ID()); |
|
1319 | + do_action('AHEE__EE_Base_Class__delete_permanently__before', $this); |
|
1320 | + $model = $this->get_model(); |
|
1321 | + $result = $model->delete_permanently_by_ID($this->ID()); |
|
1322 | 1322 | $this->refresh_cache_of_related_objects(); |
1323 | 1323 | /** |
1324 | 1324 | * Called just after HARD deleting a model object |
1325 | 1325 | * @param EE_Base_Class $model_object that was just 'deleted' |
1326 | 1326 | * @param boolean $result |
1327 | 1327 | */ |
1328 | - do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result ); |
|
1328 | + do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result); |
|
1329 | 1329 | return $result; |
1330 | 1330 | } |
1331 | 1331 | |
@@ -1334,18 +1334,18 @@ discard block |
||
1334 | 1334 | * related model objects |
1335 | 1335 | */ |
1336 | 1336 | public function refresh_cache_of_related_objects() { |
1337 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
1338 | - if( ! empty( $this->_model_relations[ $relation_name ] ) ) { |
|
1339 | - $related_objects = $this->_model_relations[ $relation_name ]; |
|
1340 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
1337 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1338 | + if ( ! empty($this->_model_relations[$relation_name])) { |
|
1339 | + $related_objects = $this->_model_relations[$relation_name]; |
|
1340 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
1341 | 1341 | //this relation only stores a single model object, not an array |
1342 | 1342 | //but let's make it consistent |
1343 | - $related_objects = array( $related_objects ); |
|
1343 | + $related_objects = array($related_objects); |
|
1344 | 1344 | } |
1345 | - foreach( $related_objects as $related_object ) { |
|
1345 | + foreach ($related_objects as $related_object) { |
|
1346 | 1346 | //only refresh their cache if they're in memory |
1347 | - if( $related_object instanceof EE_Base_Class ) { |
|
1348 | - $related_object->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1347 | + if ($related_object instanceof EE_Base_Class) { |
|
1348 | + $related_object->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1349 | 1349 | } |
1350 | 1350 | } |
1351 | 1351 | } |
@@ -1365,17 +1365,17 @@ discard block |
||
1365 | 1365 | * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object |
1366 | 1366 | * isn't allowed to persist (as determined by EE_Base_Class::allow_persist()) |
1367 | 1367 | */ |
1368 | - public function save($set_cols_n_values=array()) { |
|
1368 | + public function save($set_cols_n_values = array()) { |
|
1369 | 1369 | /** |
1370 | 1370 | * Filters the fields we're about to save on the model object |
1371 | 1371 | * |
1372 | 1372 | * @param array $set_cols_n_values |
1373 | 1373 | * @param EE_Base_Class $model_object |
1374 | 1374 | */ |
1375 | - $set_cols_n_values = apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this ); |
|
1375 | + $set_cols_n_values = apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this); |
|
1376 | 1376 | //set attributes as provided in $set_cols_n_values |
1377 | - foreach($set_cols_n_values as $column=>$value){ |
|
1378 | - $this->set($column,$value); |
|
1377 | + foreach ($set_cols_n_values as $column=>$value) { |
|
1378 | + $this->set($column, $value); |
|
1379 | 1379 | } |
1380 | 1380 | /** |
1381 | 1381 | * Saving a model object. |
@@ -1383,8 +1383,8 @@ discard block |
||
1383 | 1383 | * Before we perform a save, this action is fired. |
1384 | 1384 | * @param EE_Base_Class $model_object the model object about to be saved. |
1385 | 1385 | */ |
1386 | - do_action( 'AHEE__EE_Base_Class__save__begin', $this ); |
|
1387 | - if( ! $this->allow_persist() ) { |
|
1386 | + do_action('AHEE__EE_Base_Class__save__begin', $this); |
|
1387 | + if ( ! $this->allow_persist()) { |
|
1388 | 1388 | return 0; |
1389 | 1389 | } |
1390 | 1390 | //now get current attribute values |
@@ -1394,61 +1394,61 @@ discard block |
||
1394 | 1394 | $old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object(); |
1395 | 1395 | $this->get_model()->assume_values_already_prepared_by_model_object(true); |
1396 | 1396 | //does this model have an autoincrement PK? |
1397 | - if($this->get_model()->has_primary_key_field()){ |
|
1398 | - if($this->get_model()->get_primary_key_field()->is_auto_increment()){ |
|
1397 | + if ($this->get_model()->has_primary_key_field()) { |
|
1398 | + if ($this->get_model()->get_primary_key_field()->is_auto_increment()) { |
|
1399 | 1399 | //ok check if it's set, if so: update; if not, insert |
1400 | - if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){ |
|
1401 | - $results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() ); |
|
1400 | + if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) { |
|
1401 | + $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
|
1402 | 1402 | } else { |
1403 | - unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]); |
|
1404 | - $results = $this->get_model()->insert( $save_cols_n_values, true); |
|
1405 | - if($results){ |
|
1403 | + unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]); |
|
1404 | + $results = $this->get_model()->insert($save_cols_n_values, true); |
|
1405 | + if ($results) { |
|
1406 | 1406 | //if successful, set the primary key |
1407 | 1407 | //but don't use the normal SET method, because it will check if |
1408 | 1408 | //an item with the same ID exists in the mapper & db, then |
1409 | 1409 | //will find it in the db (because we just added it) and THAT object |
1410 | 1410 | //will get added to the mapper before we can add this one! |
1411 | 1411 | //but if we just avoid using the SET method, all that headache can be avoided |
1412 | - $pk_field_name =self::_get_primary_key_name( get_class($this)); |
|
1412 | + $pk_field_name = self::_get_primary_key_name(get_class($this)); |
|
1413 | 1413 | $this->_fields[$pk_field_name] = $results; |
1414 | 1414 | $this->_clear_cached_property($pk_field_name); |
1415 | - $this->get_model()->add_to_entity_map( $this ); |
|
1415 | + $this->get_model()->add_to_entity_map($this); |
|
1416 | 1416 | $this->_update_cached_related_model_objs_fks(); |
1417 | 1417 | } |
1418 | 1418 | } |
1419 | - }else{//PK is NOT auto-increment |
|
1419 | + } else {//PK is NOT auto-increment |
|
1420 | 1420 | //so check if one like it already exists in the db |
1421 | - if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
|
1422 | - if( ! $this->in_entity_map() && WP_DEBUG ){ |
|
1421 | + if ($this->get_model()->exists_by_ID($this->ID())) { |
|
1422 | + if ( ! $this->in_entity_map() && WP_DEBUG) { |
|
1423 | 1423 | throw new EE_Error( |
1424 | 1424 | sprintf( |
1425 | - __( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ), |
|
1425 | + __('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'), |
|
1426 | 1426 | get_class($this), |
1427 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
1428 | - get_class( $this->get_model() ) . '::instance()->get_one_by_ID()', |
|
1427 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
1428 | + get_class($this->get_model()).'::instance()->get_one_by_ID()', |
|
1429 | 1429 | '<br />' |
1430 | 1430 | ) |
1431 | 1431 | ); |
1432 | 1432 | } |
1433 | 1433 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
1434 | - }else{ |
|
1434 | + } else { |
|
1435 | 1435 | $results = $this->get_model()->insert($save_cols_n_values); |
1436 | 1436 | $this->_update_cached_related_model_objs_fks(); |
1437 | 1437 | } |
1438 | 1438 | } |
1439 | - }else{//there is NO primary key |
|
1439 | + } else {//there is NO primary key |
|
1440 | 1440 | $already_in_db = false; |
1441 | - foreach($this->get_model()->unique_indexes() as $index){ |
|
1441 | + foreach ($this->get_model()->unique_indexes() as $index) { |
|
1442 | 1442 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
1443 | - if($this->get_model()->exists(array($uniqueness_where_params))){ |
|
1443 | + if ($this->get_model()->exists(array($uniqueness_where_params))) { |
|
1444 | 1444 | $already_in_db = true; |
1445 | 1445 | } |
1446 | 1446 | } |
1447 | - if( $already_in_db ){ |
|
1448 | - $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
|
1449 | - $results = $this->get_model()->update( $save_cols_n_values,array( $combined_pk_fields_n_values ) ); |
|
1450 | - }else{ |
|
1451 | - $results = $this->get_model()->insert( $save_cols_n_values ); |
|
1447 | + if ($already_in_db) { |
|
1448 | + $combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields()); |
|
1449 | + $results = $this->get_model()->update($save_cols_n_values, array($combined_pk_fields_n_values)); |
|
1450 | + } else { |
|
1451 | + $results = $this->get_model()->insert($save_cols_n_values); |
|
1452 | 1452 | } |
1453 | 1453 | } |
1454 | 1454 | //restore the old assumption about values being prepared by the model object |
@@ -1461,7 +1461,7 @@ discard block |
||
1461 | 1461 | * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted |
1462 | 1462 | * the new ID (or 0 if an error occurred and it wasn't updated) |
1463 | 1463 | */ |
1464 | - do_action( 'AHEE__EE_Base_Class__save__end', $this, $results ); |
|
1464 | + do_action('AHEE__EE_Base_Class__save__end', $this, $results); |
|
1465 | 1465 | return $results; |
1466 | 1466 | } |
1467 | 1467 | |
@@ -1473,13 +1473,13 @@ discard block |
||
1473 | 1473 | * and we want to let its cached relations with foreign keys to it know about that change. Eg: we've created a transaction but haven't saved it to the db. We also create a registration and don't save it to the DB, but we DO cache it on the transaction. Now, when we save the transaction, the registration's TXN_ID will be automatically updated, whether or not they exist in the DB (if they do, their DB records will be automatically updated) |
1474 | 1474 | * @return void |
1475 | 1475 | */ |
1476 | - protected function _update_cached_related_model_objs_fks(){ |
|
1477 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){ |
|
1478 | - if( $relation_obj instanceof EE_Has_Many_Relation ){ |
|
1479 | - foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) { |
|
1480 | - $fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to( $this->get_model()->get_this_model_name() ); |
|
1481 | - $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() ); |
|
1482 | - if( $related_model_obj_in_cache->ID() ){ |
|
1476 | + protected function _update_cached_related_model_objs_fks() { |
|
1477 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
1478 | + if ($relation_obj instanceof EE_Has_Many_Relation) { |
|
1479 | + foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) { |
|
1480 | + $fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to($this->get_model()->get_this_model_name()); |
|
1481 | + $related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID()); |
|
1482 | + if ($related_model_obj_in_cache->ID()) { |
|
1483 | 1483 | $related_model_obj_in_cache->save(); |
1484 | 1484 | } |
1485 | 1485 | } |
@@ -1495,21 +1495,21 @@ discard block |
||
1495 | 1495 | * and this object and properly setup |
1496 | 1496 | * @return int ID of new model object on save; 0 on failure+ |
1497 | 1497 | */ |
1498 | - public function save_new_cached_related_model_objs(){ |
|
1498 | + public function save_new_cached_related_model_objs() { |
|
1499 | 1499 | //make sure this has been saved |
1500 | - if( ! $this->ID()){ |
|
1500 | + if ( ! $this->ID()) { |
|
1501 | 1501 | $id = $this->save(); |
1502 | - }else{ |
|
1502 | + } else { |
|
1503 | 1503 | $id = $this->ID(); |
1504 | 1504 | } |
1505 | 1505 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
1506 | - foreach($this->get_model()->relation_settings() as $relationName => $relationObj){ |
|
1506 | + foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) { |
|
1507 | 1507 | |
1508 | 1508 | |
1509 | - if($this->_model_relations[$relationName]){ |
|
1509 | + if ($this->_model_relations[$relationName]) { |
|
1510 | 1510 | //is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation) |
1511 | 1511 | //or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)? |
1512 | - if($relationObj instanceof EE_Belongs_To_Relation){ |
|
1512 | + if ($relationObj instanceof EE_Belongs_To_Relation) { |
|
1513 | 1513 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1514 | 1514 | //but ONLY if it DOES NOT exist in the DB |
1515 | 1515 | /* @var $related_model_obj EE_Base_Class */ |
@@ -1518,8 +1518,8 @@ discard block |
||
1518 | 1518 | $this->_add_relation_to($related_model_obj, $relationName); |
1519 | 1519 | $related_model_obj->save_new_cached_related_model_objs(); |
1520 | 1520 | // } |
1521 | - }else{ |
|
1522 | - foreach($this->_model_relations[$relationName] as $related_model_obj){ |
|
1521 | + } else { |
|
1522 | + foreach ($this->_model_relations[$relationName] as $related_model_obj) { |
|
1523 | 1523 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1524 | 1524 | //but ONLY if it DOES NOT exist in the DB |
1525 | 1525 | // if( ! $related_model_obj->ID()){ |
@@ -1540,8 +1540,8 @@ discard block |
||
1540 | 1540 | * @return \EEM_Base | \EEM_CPT_Base |
1541 | 1541 | */ |
1542 | 1542 | public function get_model() { |
1543 | - $modelName = self::_get_model_classname( get_class($this) ); |
|
1544 | - return self::_get_model_instance_with_name($modelName, $this->_timezone ); |
|
1543 | + $modelName = self::_get_model_classname(get_class($this)); |
|
1544 | + return self::_get_model_instance_with_name($modelName, $this->_timezone); |
|
1545 | 1545 | } |
1546 | 1546 | |
1547 | 1547 | |
@@ -1551,10 +1551,10 @@ discard block |
||
1551 | 1551 | * @param $classname |
1552 | 1552 | * @return mixed bool|EE_Base_Class|EEM_CPT_Base |
1553 | 1553 | */ |
1554 | - protected static function _get_object_from_entity_mapper($props_n_values, $classname){ |
|
1554 | + protected static function _get_object_from_entity_mapper($props_n_values, $classname) { |
|
1555 | 1555 | //TODO: will not work for Term_Relationships because they have no PK! |
1556 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1557 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
|
1556 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1557 | + if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) { |
|
1558 | 1558 | $id = $props_n_values[$primary_id_ref]; |
1559 | 1559 | return self::_get_model($classname)->get_from_entity_map($id); |
1560 | 1560 | } |
@@ -1573,35 +1573,35 @@ discard block |
||
1573 | 1573 | * date_format and the second value is the time format |
1574 | 1574 | * @return mixed (EE_Base_Class|bool) |
1575 | 1575 | */ |
1576 | - protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL, $date_formats = array() ) { |
|
1577 | - if( self::_get_model( $classname )->has_primary_key_field()){ |
|
1578 | - $primary_id_ref = self::_get_primary_key_name( $classname ); |
|
1576 | + protected static function _check_for_object($props_n_values, $classname, $timezone = NULL, $date_formats = array()) { |
|
1577 | + if (self::_get_model($classname)->has_primary_key_field()) { |
|
1578 | + $primary_id_ref = self::_get_primary_key_name($classname); |
|
1579 | 1579 | |
1580 | - if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
|
1581 | - $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( $props_n_values[$primary_id_ref] ); |
|
1582 | - }else{ |
|
1580 | + if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) { |
|
1581 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID($props_n_values[$primary_id_ref]); |
|
1582 | + } else { |
|
1583 | 1583 | $existing = null; |
1584 | 1584 | } |
1585 | - }elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ){ |
|
1585 | + }elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) { |
|
1586 | 1586 | //no primary key on this model, but there's still a matching item in the DB |
1587 | - $existing = self::_get_model($classname, $timezone)->get_one_by_ID( self::_get_model($classname, $timezone)->get_index_primary_key_string( $props_n_values ) ); |
|
1588 | - }else{ |
|
1587 | + $existing = self::_get_model($classname, $timezone)->get_one_by_ID(self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values)); |
|
1588 | + } else { |
|
1589 | 1589 | $existing = null; |
1590 | 1590 | } |
1591 | - if ( $existing ) { |
|
1591 | + if ($existing) { |
|
1592 | 1592 | |
1593 | 1593 | //set date formats if present before setting values |
1594 | - if ( ! empty( $date_formats ) && is_array( $date_formats ) ) { |
|
1595 | - $existing->set_date_format( $date_formats[0] ); |
|
1596 | - $existing->set_time_format( $date_formats[1] ); |
|
1594 | + if ( ! empty($date_formats) && is_array($date_formats)) { |
|
1595 | + $existing->set_date_format($date_formats[0]); |
|
1596 | + $existing->set_time_format($date_formats[1]); |
|
1597 | 1597 | } else { |
1598 | 1598 | //set default formats for date and time |
1599 | - $existing->set_date_format( get_option( 'date_format' ) ); |
|
1600 | - $existing->set_time_format( get_option( 'time_format' ) ); |
|
1599 | + $existing->set_date_format(get_option('date_format')); |
|
1600 | + $existing->set_time_format(get_option('time_format')); |
|
1601 | 1601 | } |
1602 | 1602 | |
1603 | - foreach ( $props_n_values as $property => $field_value ) { |
|
1604 | - $existing->set( $property, $field_value ); |
|
1603 | + foreach ($props_n_values as $property => $field_value) { |
|
1604 | + $existing->set($property, $field_value); |
|
1605 | 1605 | } |
1606 | 1606 | return $existing; |
1607 | 1607 | } else { |
@@ -1619,13 +1619,13 @@ discard block |
||
1619 | 1619 | * @throws EE_Error |
1620 | 1620 | * @return EEM_Base |
1621 | 1621 | */ |
1622 | - protected static function _get_model( $classname, $timezone = NULL ){ |
|
1622 | + protected static function _get_model($classname, $timezone = NULL) { |
|
1623 | 1623 | //find model for this class |
1624 | - if( ! $classname ){ |
|
1625 | - throw new EE_Error(sprintf(__("What were you thinking calling _get_model(%s)?? You need to specify the class name", "event_espresso"),$classname)); |
|
1624 | + if ( ! $classname) { |
|
1625 | + throw new EE_Error(sprintf(__("What were you thinking calling _get_model(%s)?? You need to specify the class name", "event_espresso"), $classname)); |
|
1626 | 1626 | } |
1627 | - $modelName=self::_get_model_classname($classname); |
|
1628 | - return self::_get_model_instance_with_name($modelName, $timezone ); |
|
1627 | + $modelName = self::_get_model_classname($classname); |
|
1628 | + return self::_get_model_instance_with_name($modelName, $timezone); |
|
1629 | 1629 | } |
1630 | 1630 | |
1631 | 1631 | |
@@ -1636,10 +1636,10 @@ discard block |
||
1636 | 1636 | * @param null $timezone |
1637 | 1637 | * @return EEM_Base |
1638 | 1638 | */ |
1639 | - protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){ |
|
1640 | - $model_classname = str_replace( 'EEM_', '', $model_classname ); |
|
1641 | - $model = EE_Registry::instance()->load_model( $model_classname ); |
|
1642 | - $model->set_timezone( $timezone ); |
|
1639 | + protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) { |
|
1640 | + $model_classname = str_replace('EEM_', '', $model_classname); |
|
1641 | + $model = EE_Registry::instance()->load_model($model_classname); |
|
1642 | + $model->set_timezone($timezone); |
|
1643 | 1643 | return $model; |
1644 | 1644 | } |
1645 | 1645 | |
@@ -1651,10 +1651,10 @@ discard block |
||
1651 | 1651 | * @param null $model_name |
1652 | 1652 | * @return string like EEM_Attendee |
1653 | 1653 | */ |
1654 | - private static function _get_model_classname( $model_name = null){ |
|
1655 | - if(strpos($model_name,"EE_")===0){ |
|
1656 | - $model_classname=str_replace("EE_","EEM_",$model_name); |
|
1657 | - }else{ |
|
1654 | + private static function _get_model_classname($model_name = null) { |
|
1655 | + if (strpos($model_name, "EE_") === 0) { |
|
1656 | + $model_classname = str_replace("EE_", "EEM_", $model_name); |
|
1657 | + } else { |
|
1658 | 1658 | $model_classname = "EEM_".$model_name; |
1659 | 1659 | } |
1660 | 1660 | return $model_classname; |
@@ -1668,11 +1668,11 @@ discard block |
||
1668 | 1668 | * @throws EE_Error |
1669 | 1669 | * @return string |
1670 | 1670 | */ |
1671 | - protected static function _get_primary_key_name( $classname = NULL ){ |
|
1672 | - if( ! $classname){ |
|
1673 | - throw new EE_Error(sprintf(__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"),$classname)); |
|
1671 | + protected static function _get_primary_key_name($classname = NULL) { |
|
1672 | + if ( ! $classname) { |
|
1673 | + throw new EE_Error(sprintf(__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"), $classname)); |
|
1674 | 1674 | } |
1675 | - return self::_get_model( $classname )->get_primary_key_field()->get_name(); |
|
1675 | + return self::_get_model($classname)->get_primary_key_field()->get_name(); |
|
1676 | 1676 | } |
1677 | 1677 | |
1678 | 1678 | |
@@ -1684,12 +1684,12 @@ discard block |
||
1684 | 1684 | * Usually defaults for integer primary keys are 0; string primary keys are usually NULL). |
1685 | 1685 | * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string |
1686 | 1686 | */ |
1687 | - public function ID(){ |
|
1687 | + public function ID() { |
|
1688 | 1688 | //now that we know the name of the variable, use a variable variable to get its value and return its |
1689 | - if( $this->get_model()->has_primary_key_field() ) { |
|
1690 | - return $this->_fields[self::_get_primary_key_name( get_class($this) )]; |
|
1691 | - }else{ |
|
1692 | - return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
|
1689 | + if ($this->get_model()->has_primary_key_field()) { |
|
1690 | + return $this->_fields[self::_get_primary_key_name(get_class($this))]; |
|
1691 | + } else { |
|
1692 | + return $this->get_model()->get_index_primary_key_string($this->_fields); |
|
1693 | 1693 | } |
1694 | 1694 | } |
1695 | 1695 | |
@@ -1707,38 +1707,38 @@ discard block |
||
1707 | 1707 | * @throws EE_Error |
1708 | 1708 | * @return EE_Base_Class the object the relation was added to |
1709 | 1709 | */ |
1710 | - public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){ |
|
1710 | + public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) { |
|
1711 | 1711 | //if this thing exists in the DB, save the relation to the DB |
1712 | - if( $this->ID() ){ |
|
1713 | - $otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values ); |
|
1712 | + if ($this->ID()) { |
|
1713 | + $otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values); |
|
1714 | 1714 | //clear cache so future get_many_related and get_first_related() return new results. |
1715 | - $this->clear_cache( $relationName, $otherObject, TRUE ); |
|
1716 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1717 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1715 | + $this->clear_cache($relationName, $otherObject, TRUE); |
|
1716 | + if ($otherObject instanceof EE_Base_Class) { |
|
1717 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1718 | 1718 | } |
1719 | 1719 | } else { |
1720 | 1720 | //this thing doesn't exist in the DB, so just cache it |
1721 | - if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){ |
|
1722 | - throw new EE_Error( sprintf( |
|
1723 | - __( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ), |
|
1721 | + if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) { |
|
1722 | + throw new EE_Error(sprintf( |
|
1723 | + __('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'), |
|
1724 | 1724 | $otherObjectModelObjectOrID, |
1725 | - get_class( $this ) |
|
1725 | + get_class($this) |
|
1726 | 1726 | )); |
1727 | 1727 | } else { |
1728 | 1728 | $otherObject = $otherObjectModelObjectOrID; |
1729 | 1729 | } |
1730 | - $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
|
1730 | + $this->cache($relationName, $otherObjectModelObjectOrID, $cache_id); |
|
1731 | 1731 | } |
1732 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1732 | + if ($otherObject instanceof EE_Base_Class) { |
|
1733 | 1733 | //fix the reciprocal relation too |
1734 | - if( $otherObject->ID() ) { |
|
1734 | + if ($otherObject->ID()) { |
|
1735 | 1735 | //its saved so assumed relations exist in the DB, so we can just |
1736 | 1736 | //clear the cache so future queries use the updated info in the DB |
1737 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
1737 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true); |
|
1738 | 1738 | } else { |
1739 | 1739 | |
1740 | 1740 | //it's not saved, so it caches relations like this |
1741 | - $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
1741 | + $otherObject->cache($this->get_model()->get_this_model_name(), $this); |
|
1742 | 1742 | } |
1743 | 1743 | } |
1744 | 1744 | return $otherObject; |
@@ -1761,17 +1761,17 @@ discard block |
||
1761 | 1761 | * Also remember that if an exact match isn't found for these extra cols/val pairs, then a NEW row is created in the join table. |
1762 | 1762 | * @return EE_Base_Class the relation was removed from |
1763 | 1763 | */ |
1764 | - public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){ |
|
1765 | - if ( $this->ID() ) { |
|
1764 | + public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) { |
|
1765 | + if ($this->ID()) { |
|
1766 | 1766 | //if this exists in the DB, save the relation change to the DB too |
1767 | - $otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query ); |
|
1768 | - $this->clear_cache( $relationName, $otherObject ); |
|
1767 | + $otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query); |
|
1768 | + $this->clear_cache($relationName, $otherObject); |
|
1769 | 1769 | } else { |
1770 | 1770 | //this doesn't exist in the DB, just remove it from the cache |
1771 | - $otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID ); |
|
1771 | + $otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID); |
|
1772 | 1772 | } |
1773 | - if( $otherObject instanceof EE_Base_Class ) { |
|
1774 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1773 | + if ($otherObject instanceof EE_Base_Class) { |
|
1774 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1775 | 1775 | } |
1776 | 1776 | return $otherObject; |
1777 | 1777 | } |
@@ -1782,18 +1782,18 @@ discard block |
||
1782 | 1782 | * @param array $where_query_params like EEM_Base::get_all's $query_params[0] (where conditions) |
1783 | 1783 | * @return EE_Base_Class |
1784 | 1784 | */ |
1785 | - public function _remove_relations($relationName,$where_query_params = array()){ |
|
1786 | - if ( $this->ID() ) { |
|
1785 | + public function _remove_relations($relationName, $where_query_params = array()) { |
|
1786 | + if ($this->ID()) { |
|
1787 | 1787 | //if this exists in the DB, save the relation change to the DB too |
1788 | - $otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params ); |
|
1789 | - $this->clear_cache( $relationName, null, true ); |
|
1788 | + $otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params); |
|
1789 | + $this->clear_cache($relationName, null, true); |
|
1790 | 1790 | } else { |
1791 | 1791 | //this doesn't exist in the DB, just remove it from the cache |
1792 | - $otherObjects = $this->clear_cache( $relationName, null, true ); |
|
1792 | + $otherObjects = $this->clear_cache($relationName, null, true); |
|
1793 | 1793 | } |
1794 | - if( is_array( $otherObjects ) ) { |
|
1795 | - foreach ( $otherObjects as $otherObject ) { |
|
1796 | - $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this ); |
|
1794 | + if (is_array($otherObjects)) { |
|
1795 | + foreach ($otherObjects as $otherObject) { |
|
1796 | + $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this); |
|
1797 | 1797 | } |
1798 | 1798 | } |
1799 | 1799 | return $otherObjects; |
@@ -1811,26 +1811,26 @@ discard block |
||
1811 | 1811 | * @return EE_Base_Class[] Results not necessarily indexed by IDs, because some results might not have primary keys |
1812 | 1812 | * or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs |
1813 | 1813 | */ |
1814 | - public function get_many_related($relationName,$query_params = array()){ |
|
1815 | - if($this->ID()){//this exists in the DB, so get the related things from either the cache or the DB |
|
1814 | + public function get_many_related($relationName, $query_params = array()) { |
|
1815 | + if ($this->ID()) {//this exists in the DB, so get the related things from either the cache or the DB |
|
1816 | 1816 | //if there are query parameters, forget about caching the related model objects. |
1817 | - if( $query_params ){ |
|
1817 | + if ($query_params) { |
|
1818 | 1818 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1819 | - }else{ |
|
1819 | + } else { |
|
1820 | 1820 | //did we already cache the result of this query? |
1821 | 1821 | $cached_results = $this->get_all_from_cache($relationName); |
1822 | - if ( ! $cached_results ){ |
|
1822 | + if ( ! $cached_results) { |
|
1823 | 1823 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1824 | 1824 | //if no query parameters were passed, then we got all the related model objects |
1825 | 1825 | //for that relation. We can cache them then. |
1826 | - foreach($related_model_objects as $related_model_object){ |
|
1826 | + foreach ($related_model_objects as $related_model_object) { |
|
1827 | 1827 | $this->cache($relationName, $related_model_object); |
1828 | 1828 | } |
1829 | - }else{ |
|
1829 | + } else { |
|
1830 | 1830 | $related_model_objects = $cached_results; |
1831 | 1831 | } |
1832 | 1832 | } |
1833 | - }else{//this doesn't exist itn eh DB, so just get the related things from the cache |
|
1833 | + } else {//this doesn't exist itn eh DB, so just get the related things from the cache |
|
1834 | 1834 | $related_model_objects = $this->get_all_from_cache($relationName); |
1835 | 1835 | } |
1836 | 1836 | return $related_model_objects; |
@@ -1847,8 +1847,8 @@ discard block |
||
1847 | 1847 | * @param bool $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE; |
1848 | 1848 | * @return int |
1849 | 1849 | */ |
1850 | - public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){ |
|
1851 | - return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct); |
|
1850 | + public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) { |
|
1851 | + return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct); |
|
1852 | 1852 | } |
1853 | 1853 | |
1854 | 1854 | |
@@ -1862,7 +1862,7 @@ discard block |
||
1862 | 1862 | * By default, uses primary key (which doesn't make much sense, so you should probably change it) |
1863 | 1863 | * @return int |
1864 | 1864 | */ |
1865 | - public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){ |
|
1865 | + public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) { |
|
1866 | 1866 | return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum); |
1867 | 1867 | } |
1868 | 1868 | |
@@ -1874,34 +1874,34 @@ discard block |
||
1874 | 1874 | * @param array $query_params like EEM_Base::get_all |
1875 | 1875 | * @return EE_Base_Class (not an array, a single object) |
1876 | 1876 | */ |
1877 | - public function get_first_related($relationName,$query_params = array()){ |
|
1878 | - if($this->ID()){//this exists in the DB, get from the cache OR the DB |
|
1877 | + public function get_first_related($relationName, $query_params = array()) { |
|
1878 | + if ($this->ID()) {//this exists in the DB, get from the cache OR the DB |
|
1879 | 1879 | |
1880 | 1880 | //if they've provided some query parameters, don't bother trying to cache the result |
1881 | 1881 | //also make sure we're not caching the result of get_first_related |
1882 | 1882 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
1883 | - if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
1884 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
1885 | - }else{ |
|
1883 | + if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
1884 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
1885 | + } else { |
|
1886 | 1886 | //first, check if we've already cached the result of this query |
1887 | 1887 | $cached_result = $this->get_one_from_cache($relationName); |
1888 | - if ( ! $cached_result ){ |
|
1888 | + if ( ! $cached_result) { |
|
1889 | 1889 | |
1890 | 1890 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
1891 | - $this->cache($relationName,$related_model_object); |
|
1892 | - }else{ |
|
1891 | + $this->cache($relationName, $related_model_object); |
|
1892 | + } else { |
|
1893 | 1893 | $related_model_object = $cached_result; |
1894 | 1894 | } |
1895 | 1895 | } |
1896 | - }else{ |
|
1896 | + } else { |
|
1897 | 1897 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
1898 | - if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
1899 | - $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
1900 | - }else{ |
|
1898 | + if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) { |
|
1899 | + $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
1900 | + } else { |
|
1901 | 1901 | $related_model_object = null; |
1902 | 1902 | } |
1903 | 1903 | //this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object |
1904 | - if( ! $related_model_object){ |
|
1904 | + if ( ! $related_model_object) { |
|
1905 | 1905 | $related_model_object = $this->get_one_from_cache($relationName); |
1906 | 1906 | } |
1907 | 1907 | |
@@ -1920,12 +1920,12 @@ discard block |
||
1920 | 1920 | * @param array $query_params like EEM_Base::get_all's |
1921 | 1921 | * @return int how many deleted |
1922 | 1922 | */ |
1923 | - public function delete_related($relationName,$query_params = array()){ |
|
1924 | - if($this->ID()){ |
|
1925 | - $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
1926 | - }else{ |
|
1923 | + public function delete_related($relationName, $query_params = array()) { |
|
1924 | + if ($this->ID()) { |
|
1925 | + $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
|
1926 | + } else { |
|
1927 | 1927 | $count = count($this->get_all_from_cache($relationName)); |
1928 | - $this->clear_cache($relationName,NULL,TRUE); |
|
1928 | + $this->clear_cache($relationName, NULL, TRUE); |
|
1929 | 1929 | } |
1930 | 1930 | return $count; |
1931 | 1931 | } |
@@ -1940,13 +1940,13 @@ discard block |
||
1940 | 1940 | * @param array $query_params like EEM_Base::get_all's |
1941 | 1941 | * @return int how many deleted (including those soft deleted) |
1942 | 1942 | */ |
1943 | - public function delete_related_permanently($relationName,$query_params = array()){ |
|
1944 | - if($this->ID()){ |
|
1945 | - $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
1946 | - }else{ |
|
1943 | + public function delete_related_permanently($relationName, $query_params = array()) { |
|
1944 | + if ($this->ID()) { |
|
1945 | + $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
|
1946 | + } else { |
|
1947 | 1947 | $count = count($this->get_all_from_cache($relationName)); |
1948 | 1948 | } |
1949 | - $this->clear_cache($relationName,NULL,TRUE); |
|
1949 | + $this->clear_cache($relationName, NULL, TRUE); |
|
1950 | 1950 | return $count; |
1951 | 1951 | } |
1952 | 1952 | |
@@ -1962,7 +1962,7 @@ discard block |
||
1962 | 1962 | * @param string $field_name property to check |
1963 | 1963 | * @return bool TRUE if existing,FALSE if not. |
1964 | 1964 | */ |
1965 | - public function is_set( $field_name ) { |
|
1965 | + public function is_set($field_name) { |
|
1966 | 1966 | return isset($this->_fields[$field_name]); |
1967 | 1967 | } |
1968 | 1968 | |
@@ -1974,12 +1974,12 @@ discard block |
||
1974 | 1974 | * @throws EE_Error |
1975 | 1975 | * @return bool TRUE if existing, throw EE_Error if not. |
1976 | 1976 | */ |
1977 | - protected function _property_exists( $properties ) { |
|
1977 | + protected function _property_exists($properties) { |
|
1978 | 1978 | |
1979 | - foreach ( (array) $properties as $property_name ) { |
|
1979 | + foreach ((array) $properties as $property_name) { |
|
1980 | 1980 | //first make sure this property exists |
1981 | - if ( ! $this->_fields[ $property_name ] ) |
|
1982 | - throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s). Double check the spelling please', 'event_espresso'), $property_name ) ); |
|
1981 | + if ( ! $this->_fields[$property_name]) |
|
1982 | + throw new EE_Error(sprintf(__('Trying to retrieve a non-existent property (%s). Double check the spelling please', 'event_espresso'), $property_name)); |
|
1983 | 1983 | } |
1984 | 1984 | |
1985 | 1985 | return TRUE; |
@@ -1996,7 +1996,7 @@ discard block |
||
1996 | 1996 | $fields = $this->get_model()->field_settings(FALSE); |
1997 | 1997 | $properties = array(); |
1998 | 1998 | //remove prepended underscore |
1999 | - foreach ( $fields as $field_name => $settings ) { |
|
1999 | + foreach ($fields as $field_name => $settings) { |
|
2000 | 2000 | $properties[$field_name] = $this->get($field_name); |
2001 | 2001 | } |
2002 | 2002 | return $properties; |
@@ -2026,14 +2026,14 @@ discard block |
||
2026 | 2026 | * @throws EE_Error |
2027 | 2027 | * @return mixed whatever the plugin which calls add_filter decides |
2028 | 2028 | */ |
2029 | - public function __call($methodName,$args){ |
|
2030 | - $className=get_class($this); |
|
2031 | - $tagName="FHEE__{$className}__{$methodName}"; |
|
2032 | - if(!has_filter($tagName)){ |
|
2033 | - throw new EE_Error(sprintf(__("Method %s on class %s does not exist! You can create one with the following code in functions.php or in a plugin: add_filter('%s','my_callback',10,3);function my_callback(\$previousReturnValue,EE_Base_Class \$object, \$argsArray){/*function body*/return \$whatever;}","event_espresso"), |
|
2034 | - $methodName,$className,$tagName)); |
|
2029 | + public function __call($methodName, $args) { |
|
2030 | + $className = get_class($this); |
|
2031 | + $tagName = "FHEE__{$className}__{$methodName}"; |
|
2032 | + if ( ! has_filter($tagName)) { |
|
2033 | + throw new EE_Error(sprintf(__("Method %s on class %s does not exist! You can create one with the following code in functions.php or in a plugin: add_filter('%s','my_callback',10,3);function my_callback(\$previousReturnValue,EE_Base_Class \$object, \$argsArray){/*function body*/return \$whatever;}", "event_espresso"), |
|
2034 | + $methodName, $className, $tagName)); |
|
2035 | 2035 | } |
2036 | - return apply_filters($tagName,null,$this,$args); |
|
2036 | + return apply_filters($tagName, null, $this, $args); |
|
2037 | 2037 | } |
2038 | 2038 | |
2039 | 2039 | |
@@ -2048,22 +2048,22 @@ discard block |
||
2048 | 2048 | * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row) |
2049 | 2049 | * NOTE: if the values haven't changed, returns 0 |
2050 | 2050 | */ |
2051 | - public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){ |
|
2052 | - $query_params = array(array( |
|
2051 | + public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) { |
|
2052 | + $query_params = array(array( |
|
2053 | 2053 | 'EXM_key'=>$meta_key, |
2054 | 2054 | 'OBJ_ID'=>$this->ID(), |
2055 | 2055 | 'EXM_type'=>$this->get_model()->get_this_model_name())); |
2056 | - if($previous_value !== NULL){ |
|
2056 | + if ($previous_value !== NULL) { |
|
2057 | 2057 | $query_params[0]['EXM_value'] = $meta_value; |
2058 | 2058 | } |
2059 | 2059 | $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params); |
2060 | - if( ! $existing_rows_like_that){ |
|
2060 | + if ( ! $existing_rows_like_that) { |
|
2061 | 2061 | return $this->add_extra_meta($meta_key, $meta_value); |
2062 | - }else{ |
|
2063 | - foreach( $existing_rows_like_that as $existing_row){ |
|
2064 | - $existing_row->save( array( 'EXM_value' => $meta_value ) ); |
|
2062 | + } else { |
|
2063 | + foreach ($existing_rows_like_that as $existing_row) { |
|
2064 | + $existing_row->save(array('EXM_value' => $meta_value)); |
|
2065 | 2065 | } |
2066 | - return count( $existing_rows_like_that ); |
|
2066 | + return count($existing_rows_like_that); |
|
2067 | 2067 | } |
2068 | 2068 | } |
2069 | 2069 | |
@@ -2076,10 +2076,10 @@ discard block |
||
2076 | 2076 | * @param boolean $unique |
2077 | 2077 | * @return boolean |
2078 | 2078 | */ |
2079 | - public function add_extra_meta($meta_key,$meta_value,$unique = false){ |
|
2080 | - if($unique){ |
|
2081 | - $existing_extra_meta = EEM_Extra_Meta::instance()->get_one(array(array('EXM_key'=>$meta_key,'OBJ_ID'=>$this->ID(),'EXM_type'=>$this->_get_model_classname(get_class($this))))); |
|
2082 | - if($existing_extra_meta){ |
|
2079 | + public function add_extra_meta($meta_key, $meta_value, $unique = false) { |
|
2080 | + if ($unique) { |
|
2081 | + $existing_extra_meta = EEM_Extra_Meta::instance()->get_one(array(array('EXM_key'=>$meta_key, 'OBJ_ID'=>$this->ID(), 'EXM_type'=>$this->_get_model_classname(get_class($this))))); |
|
2082 | + if ($existing_extra_meta) { |
|
2083 | 2083 | return false; |
2084 | 2084 | } |
2085 | 2085 | } |
@@ -2099,12 +2099,12 @@ discard block |
||
2099 | 2099 | * @param string $meta_value |
2100 | 2100 | * @return int number of extra meta rows deleted |
2101 | 2101 | */ |
2102 | - public function delete_extra_meta($meta_key,$meta_value = NULL){ |
|
2103 | - $query_params = array(array( |
|
2102 | + public function delete_extra_meta($meta_key, $meta_value = NULL) { |
|
2103 | + $query_params = array(array( |
|
2104 | 2104 | 'EXM_key'=>$meta_key, |
2105 | 2105 | 'OBJ_ID'=>$this->ID(), |
2106 | 2106 | 'EXM_type'=>$this->get_model()->get_this_model_name())); |
2107 | - if($meta_value !== NULL){ |
|
2107 | + if ($meta_value !== NULL) { |
|
2108 | 2108 | $query_params[0]['EXM_value'] = $meta_value; |
2109 | 2109 | } |
2110 | 2110 | $count_deleted = EEM_Extra_Meta::instance()->delete($query_params); |
@@ -2120,25 +2120,25 @@ discard block |
||
2120 | 2120 | * @param mixed $default if we don't find anything, what should we return? |
2121 | 2121 | * @return mixed single value if $single; array if ! $single |
2122 | 2122 | */ |
2123 | - public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){ |
|
2124 | - if($single){ |
|
2125 | - $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2126 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2123 | + public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) { |
|
2124 | + if ($single) { |
|
2125 | + $result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2126 | + if ($result instanceof EE_Extra_Meta) { |
|
2127 | 2127 | return $result->value(); |
2128 | - }else{ |
|
2128 | + } else { |
|
2129 | 2129 | return $default; |
2130 | 2130 | } |
2131 | - }else{ |
|
2132 | - $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
|
2133 | - if($results){ |
|
2131 | + } else { |
|
2132 | + $results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key))); |
|
2133 | + if ($results) { |
|
2134 | 2134 | $values = array(); |
2135 | - foreach($results as $result){ |
|
2136 | - if ( $result instanceof EE_Extra_Meta ){ |
|
2135 | + foreach ($results as $result) { |
|
2136 | + if ($result instanceof EE_Extra_Meta) { |
|
2137 | 2137 | $values[$result->ID()] = $result->value(); |
2138 | 2138 | } |
2139 | 2139 | } |
2140 | 2140 | return $values; |
2141 | - }else{ |
|
2141 | + } else { |
|
2142 | 2142 | return $default; |
2143 | 2143 | } |
2144 | 2144 | } |
@@ -2155,20 +2155,20 @@ discard block |
||
2155 | 2155 | * @param boolean $one_of_each_key |
2156 | 2156 | * @return array |
2157 | 2157 | */ |
2158 | - public function all_extra_meta_array($one_of_each_key = true){ |
|
2158 | + public function all_extra_meta_array($one_of_each_key = true) { |
|
2159 | 2159 | $return_array = array(); |
2160 | - if($one_of_each_key){ |
|
2160 | + if ($one_of_each_key) { |
|
2161 | 2161 | $extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key')); |
2162 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2163 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2162 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2163 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2164 | 2164 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
2165 | 2165 | } |
2166 | 2166 | } |
2167 | - }else{ |
|
2167 | + } else { |
|
2168 | 2168 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
2169 | - foreach($extra_meta_objs as $extra_meta_obj){ |
|
2170 | - if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
|
2171 | - if( ! isset($return_array[$extra_meta_obj->key()])){ |
|
2169 | + foreach ($extra_meta_objs as $extra_meta_obj) { |
|
2170 | + if ($extra_meta_obj instanceof EE_Extra_Meta) { |
|
2171 | + if ( ! isset($return_array[$extra_meta_obj->key()])) { |
|
2172 | 2172 | $return_array[$extra_meta_obj->key()] = array(); |
2173 | 2173 | } |
2174 | 2174 | $return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value(); |
@@ -2181,19 +2181,19 @@ discard block |
||
2181 | 2181 | * Gets a pretty nice displayable nice for this model object. Often overridden |
2182 | 2182 | * @return string |
2183 | 2183 | */ |
2184 | - public function name(){ |
|
2184 | + public function name() { |
|
2185 | 2185 | //find a field that's not a text field |
2186 | 2186 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
2187 | - if($field_we_can_use){ |
|
2187 | + if ($field_we_can_use) { |
|
2188 | 2188 | return $this->get($field_we_can_use->get_name()); |
2189 | - }else{ |
|
2189 | + } else { |
|
2190 | 2190 | $first_few_properties = $this->model_field_array(); |
2191 | - $first_few_properties = array_slice($first_few_properties,0,3); |
|
2191 | + $first_few_properties = array_slice($first_few_properties, 0, 3); |
|
2192 | 2192 | $name_parts = array(); |
2193 | - foreach( $first_few_properties as $name=> $value ){ |
|
2193 | + foreach ($first_few_properties as $name=> $value) { |
|
2194 | 2194 | $name_parts[] = "$name:$value"; |
2195 | 2195 | } |
2196 | - return implode(",",$name_parts); |
|
2196 | + return implode(",", $name_parts); |
|
2197 | 2197 | } |
2198 | 2198 | } |
2199 | 2199 | |
@@ -2202,11 +2202,11 @@ discard block |
||
2202 | 2202 | * Checks if this model object has been proven to already be in the entity map |
2203 | 2203 | * @return boolean |
2204 | 2204 | */ |
2205 | - public function in_entity_map(){ |
|
2206 | - if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
|
2205 | + public function in_entity_map() { |
|
2206 | + if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) { |
|
2207 | 2207 | //well, if we looked, did we find it in the entity map? |
2208 | 2208 | return TRUE; |
2209 | - }else{ |
|
2209 | + } else { |
|
2210 | 2210 | return FALSE; |
2211 | 2211 | } |
2212 | 2212 | } |
@@ -2217,21 +2217,21 @@ discard block |
||
2217 | 2217 | * @throws EE_Error if this model object isn't in the entity mapper (because then you should |
2218 | 2218 | * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE |
2219 | 2219 | */ |
2220 | - public function refresh_from_db(){ |
|
2221 | - if( $this->ID() && $this->in_entity_map() ){ |
|
2222 | - $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
|
2223 | - }else{ |
|
2220 | + public function refresh_from_db() { |
|
2221 | + if ($this->ID() && $this->in_entity_map()) { |
|
2222 | + $this->get_model()->refresh_entity_map_from_db($this->ID()); |
|
2223 | + } else { |
|
2224 | 2224 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
2225 | 2225 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
2226 | 2226 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
2227 | 2227 | //absolutely nothing in it for this ID |
2228 | - if( WP_DEBUG ) { |
|
2228 | + if (WP_DEBUG) { |
|
2229 | 2229 | throw new EE_Error( |
2230 | 2230 | sprintf( |
2231 | - __( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ), |
|
2231 | + __('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'), |
|
2232 | 2232 | $this->ID(), |
2233 | - get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
|
2234 | - get_class( $this->get_model() ) . '::instance()->refresh_entity_map()' |
|
2233 | + get_class($this->get_model()).'::instance()->add_to_entity_map()', |
|
2234 | + get_class($this->get_model()).'::instance()->refresh_entity_map()' |
|
2235 | 2235 | ) |
2236 | 2236 | ); |
2237 | 2237 | } |
@@ -2243,8 +2243,8 @@ discard block |
||
2243 | 2243 | * (probably a bad assumption they have made, oh well) |
2244 | 2244 | * @return string |
2245 | 2245 | */ |
2246 | - public function __toString(){ |
|
2247 | - return sprintf( '%s (%s)', $this->name(), $this->ID() ); |
|
2246 | + public function __toString() { |
|
2247 | + return sprintf('%s (%s)', $this->name(), $this->ID()); |
|
2248 | 2248 | } |
2249 | 2249 | |
2250 | 2250 | /** |
@@ -2276,16 +2276,16 @@ discard block |
||
2276 | 2276 | * @return array |
2277 | 2277 | */ |
2278 | 2278 | public function __sleep() { |
2279 | - foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) { |
|
2280 | - if( $relation_obj instanceof EE_Belongs_To_Relation ) { |
|
2281 | - $classname = 'EE_' . $this->get_model()->get_this_model_name(); |
|
2282 | - if( $this->get_one_from_cache( $relation_name ) instanceof $classname && |
|
2283 | - $this->get_one_from_cache( $relation_name )->ID() ) { |
|
2284 | - $this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() ); |
|
2279 | + foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) { |
|
2280 | + if ($relation_obj instanceof EE_Belongs_To_Relation) { |
|
2281 | + $classname = 'EE_'.$this->get_model()->get_this_model_name(); |
|
2282 | + if ($this->get_one_from_cache($relation_name) instanceof $classname && |
|
2283 | + $this->get_one_from_cache($relation_name)->ID()) { |
|
2284 | + $this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID()); |
|
2285 | 2285 | } |
2286 | 2286 | } |
2287 | 2287 | } |
2288 | - return array_keys( get_object_vars( $this ) ); |
|
2288 | + return array_keys(get_object_vars($this)); |
|
2289 | 2289 | } |
2290 | 2290 | |
2291 | 2291 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' ); |
3 | 5 | /** |
4 | 6 | * |
@@ -170,7 +172,7 @@ discard block |
||
170 | 172 | foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){ |
171 | 173 | if($relation_obj instanceof EE_Belongs_To_Relation){ |
172 | 174 | $this->_model_relations[$relation_name] = NULL; |
173 | - }else{ |
|
175 | + } else{ |
|
174 | 176 | $this->_model_relations[$relation_name] = array(); |
175 | 177 | } |
176 | 178 | } |
@@ -215,7 +217,7 @@ discard block |
||
215 | 217 | if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) && |
216 | 218 | $field_settings = $this->get_Model()->field_settings_for( $field_name )){ |
217 | 219 | return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] ); |
218 | - }else{ |
|
220 | + } else{ |
|
219 | 221 | return NULL; |
220 | 222 | } |
221 | 223 | } |
@@ -264,7 +266,7 @@ discard block |
||
264 | 266 | empty( $this->_fields[$field_name] ) ? $this->set( $field_name, time() ) : $this->set( $field_name, $this->_fields[$field_name] ); |
265 | 267 | } |
266 | 268 | |
267 | - }else{ |
|
269 | + } else{ |
|
268 | 270 | $this->_fields[$field_name] = $holder_of_value; |
269 | 271 | } |
270 | 272 | |
@@ -292,7 +294,7 @@ discard block |
||
292 | 294 | } |
293 | 295 | //let's unset any cache for this field_name from the $_cached_properties property. |
294 | 296 | $this->_clear_cached_property( $field_name ); |
295 | - }else{ |
|
297 | + } else{ |
|
296 | 298 | throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name ) ); |
297 | 299 | } |
298 | 300 | |
@@ -588,8 +590,9 @@ discard block |
||
588 | 590 | * @return void |
589 | 591 | */ |
590 | 592 | protected function _clear_cached_property( $property_name ) { |
591 | - if ( isset( $this->_cached_properties[ $property_name ] ) ) |
|
592 | - unset( $this->_cached_properties[ $property_name ] ); |
|
593 | + if ( isset( $this->_cached_properties[ $property_name ] ) ) { |
|
594 | + unset( $this->_cached_properties[ $property_name ] ); |
|
595 | + } |
|
593 | 596 | } |
594 | 597 | |
595 | 598 | |
@@ -629,10 +632,10 @@ discard block |
||
629 | 632 | if($clear_all){ |
630 | 633 | $obj_removed = true; |
631 | 634 | $this->_model_relations[$relationName] = null; |
632 | - }elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
635 | + } elseif($relationship_to_model instanceof EE_Belongs_To_Relation){ |
|
633 | 636 | $obj_removed = $this->_model_relations[$relationName]; |
634 | 637 | $this->_model_relations[$relationName] = null; |
635 | - }else{ |
|
638 | + } else{ |
|
636 | 639 | if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){ |
637 | 640 | $index_in_cache = $object_to_remove_or_index_into_array->ID(); |
638 | 641 | if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){ |
@@ -646,20 +649,20 @@ discard block |
||
646 | 649 | } |
647 | 650 | if($index_found_at){ |
648 | 651 | $index_in_cache = $index_found_at; |
649 | - }else{ |
|
652 | + } else{ |
|
650 | 653 | //it wasn't found. huh. well obviously it doesn't need to be removed from teh cache |
651 | 654 | //if it wasn't in it to begin with. So we're done |
652 | 655 | return $object_to_remove_or_index_into_array; |
653 | 656 | } |
654 | 657 | } |
655 | - }elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
658 | + } elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){ |
|
656 | 659 | //so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it! |
657 | 660 | foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){ |
658 | 661 | if($potentially_obj_we_want == $object_to_remove_or_index_into_array){ |
659 | 662 | $index_in_cache = $index; |
660 | 663 | } |
661 | 664 | } |
662 | - }else{ |
|
665 | + } else{ |
|
663 | 666 | $index_in_cache = $object_to_remove_or_index_into_array; |
664 | 667 | } |
665 | 668 | //supposedly we've found it. But it could just be that the client code |
@@ -668,7 +671,7 @@ discard block |
||
668 | 671 | isset( $this->_model_relations[$relationName][$index_in_cache])){ |
669 | 672 | $obj_removed = $this->_model_relations[$relationName][$index_in_cache]; |
670 | 673 | unset($this->_model_relations[$relationName][$index_in_cache]); |
671 | - }else{ |
|
674 | + } else{ |
|
672 | 675 | //that thing was never cached anyways. |
673 | 676 | $obj_removed = NULL; |
674 | 677 | } |
@@ -724,7 +727,7 @@ discard block |
||
724 | 727 | $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null; |
725 | 728 | if(is_array($cached_array_or_object)){ |
726 | 729 | return array_shift($cached_array_or_object); |
727 | - }else{ |
|
730 | + } else{ |
|
728 | 731 | return $cached_array_or_object; |
729 | 732 | } |
730 | 733 | } |
@@ -743,10 +746,10 @@ discard block |
||
743 | 746 | $cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array(); |
744 | 747 | if(is_array($cached_array_or_object)){ |
745 | 748 | $objects = $cached_array_or_object; |
746 | - }elseif($cached_array_or_object){ |
|
749 | + } elseif($cached_array_or_object){ |
|
747 | 750 | //if the result is not an array, but exists, make it an array |
748 | 751 | $objects = array($cached_array_or_object); |
749 | - }else{ |
|
752 | + } else{ |
|
750 | 753 | //if nothing was found, return an empty array |
751 | 754 | $objects = array(); |
752 | 755 | } |
@@ -761,7 +764,7 @@ discard block |
||
761 | 764 | if( $model_object->ID() ){ |
762 | 765 | $model->add_to_entity_map( $model_object ); |
763 | 766 | } |
764 | - }else{ |
|
767 | + } else{ |
|
765 | 768 | throw new EE_Error( sprintf( __( 'Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso' ), $relationName, gettype( $model_object ))); |
766 | 769 | } |
767 | 770 | } |
@@ -886,10 +889,10 @@ discard block |
||
886 | 889 | if( $field_obj->is_nullable()){ |
887 | 890 | //if the field allows nulls, then let it be null |
888 | 891 | $field_value = NULL; |
889 | - }else{ |
|
892 | + } else{ |
|
890 | 893 | $field_value = $field_obj->get_default_value(); |
891 | 894 | } |
892 | - }else{ |
|
895 | + } else{ |
|
893 | 896 | $field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db ); |
894 | 897 | } |
895 | 898 | $this->_fields[$field_name] = $field_value; |
@@ -1009,15 +1012,17 @@ discard block |
||
1009 | 1012 | $this->_tm_frmt = $in_tm_frmt; |
1010 | 1013 | } |
1011 | 1014 | |
1012 | - if ( $echo ) |
|
1013 | - $field->set_pretty_date_format( $in_dt_frmt ); |
|
1014 | - else |
|
1015 | - $field->set_date_format( $in_dt_frmt ); |
|
1015 | + if ( $echo ) { |
|
1016 | + $field->set_pretty_date_format( $in_dt_frmt ); |
|
1017 | + } else { |
|
1018 | + $field->set_date_format( $in_dt_frmt ); |
|
1019 | + } |
|
1016 | 1020 | |
1017 | - if ( $echo ) |
|
1018 | - $field->set_pretty_time_format( $in_tm_frmt ); |
|
1019 | - else |
|
1020 | - $field->set_time_format( $in_tm_frmt ); |
|
1021 | + if ( $echo ) { |
|
1022 | + $field->set_pretty_time_format( $in_tm_frmt ); |
|
1023 | + } else { |
|
1024 | + $field->set_time_format( $in_tm_frmt ); |
|
1025 | + } |
|
1021 | 1026 | |
1022 | 1027 | //set timezone in field object |
1023 | 1028 | $field->set_timezone( $this->_timezone ); |
@@ -1240,8 +1245,9 @@ discard block |
||
1240 | 1245 | EE_Registry::instance()->load_helper('DTT_Helper'); |
1241 | 1246 | $timezone = EEH_DTT_Helper::get_timezone(); |
1242 | 1247 | |
1243 | - if ( $timezone == $this->_timezone ) |
|
1244 | - return ''; |
|
1248 | + if ( $timezone == $this->_timezone ) { |
|
1249 | + return ''; |
|
1250 | + } |
|
1245 | 1251 | |
1246 | 1252 | $original_timezone = $this->_timezone; |
1247 | 1253 | $this->set_timezone( $timezone ); |
@@ -1249,8 +1255,9 @@ discard block |
||
1249 | 1255 | $fn = (array) $field_name; |
1250 | 1256 | $args = array_merge( $fn, (array) $args ); |
1251 | 1257 | |
1252 | - if ( !method_exists( $this, $callback ) ) |
|
1253 | - throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist. Please check your spelling', 'event_espresso'), $callback ) ); |
|
1258 | + if ( !method_exists( $this, $callback ) ) { |
|
1259 | + throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist. Please check your spelling', 'event_espresso'), $callback ) ); |
|
1260 | + } |
|
1254 | 1261 | $args = (array) $args; |
1255 | 1262 | $return = $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append; |
1256 | 1263 | |
@@ -1416,7 +1423,7 @@ discard block |
||
1416 | 1423 | $this->_update_cached_related_model_objs_fks(); |
1417 | 1424 | } |
1418 | 1425 | } |
1419 | - }else{//PK is NOT auto-increment |
|
1426 | + } else{//PK is NOT auto-increment |
|
1420 | 1427 | //so check if one like it already exists in the db |
1421 | 1428 | if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
1422 | 1429 | if( ! $this->in_entity_map() && WP_DEBUG ){ |
@@ -1431,12 +1438,12 @@ discard block |
||
1431 | 1438 | ); |
1432 | 1439 | } |
1433 | 1440 | $results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
1434 | - }else{ |
|
1441 | + } else{ |
|
1435 | 1442 | $results = $this->get_model()->insert($save_cols_n_values); |
1436 | 1443 | $this->_update_cached_related_model_objs_fks(); |
1437 | 1444 | } |
1438 | 1445 | } |
1439 | - }else{//there is NO primary key |
|
1446 | + } else{//there is NO primary key |
|
1440 | 1447 | $already_in_db = false; |
1441 | 1448 | foreach($this->get_model()->unique_indexes() as $index){ |
1442 | 1449 | $uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields()); |
@@ -1447,7 +1454,7 @@ discard block |
||
1447 | 1454 | if( $already_in_db ){ |
1448 | 1455 | $combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() ); |
1449 | 1456 | $results = $this->get_model()->update( $save_cols_n_values,array( $combined_pk_fields_n_values ) ); |
1450 | - }else{ |
|
1457 | + } else{ |
|
1451 | 1458 | $results = $this->get_model()->insert( $save_cols_n_values ); |
1452 | 1459 | } |
1453 | 1460 | } |
@@ -1499,7 +1506,7 @@ discard block |
||
1499 | 1506 | //make sure this has been saved |
1500 | 1507 | if( ! $this->ID()){ |
1501 | 1508 | $id = $this->save(); |
1502 | - }else{ |
|
1509 | + } else{ |
|
1503 | 1510 | $id = $this->ID(); |
1504 | 1511 | } |
1505 | 1512 | //now save all the NEW cached model objects (ie they don't exist in the DB) |
@@ -1518,7 +1525,7 @@ discard block |
||
1518 | 1525 | $this->_add_relation_to($related_model_obj, $relationName); |
1519 | 1526 | $related_model_obj->save_new_cached_related_model_objs(); |
1520 | 1527 | // } |
1521 | - }else{ |
|
1528 | + } else{ |
|
1522 | 1529 | foreach($this->_model_relations[$relationName] as $related_model_obj){ |
1523 | 1530 | //add a relation to that relation type (which saves the appropriate thing in the process) |
1524 | 1531 | //but ONLY if it DOES NOT exist in the DB |
@@ -1579,13 +1586,13 @@ discard block |
||
1579 | 1586 | |
1580 | 1587 | if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) { |
1581 | 1588 | $existing = self::_get_model( $classname, $timezone )->get_one_by_ID( $props_n_values[$primary_id_ref] ); |
1582 | - }else{ |
|
1589 | + } else{ |
|
1583 | 1590 | $existing = null; |
1584 | 1591 | } |
1585 | - }elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ){ |
|
1592 | + } elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ){ |
|
1586 | 1593 | //no primary key on this model, but there's still a matching item in the DB |
1587 | 1594 | $existing = self::_get_model($classname, $timezone)->get_one_by_ID( self::_get_model($classname, $timezone)->get_index_primary_key_string( $props_n_values ) ); |
1588 | - }else{ |
|
1595 | + } else{ |
|
1589 | 1596 | $existing = null; |
1590 | 1597 | } |
1591 | 1598 | if ( $existing ) { |
@@ -1654,7 +1661,7 @@ discard block |
||
1654 | 1661 | private static function _get_model_classname( $model_name = null){ |
1655 | 1662 | if(strpos($model_name,"EE_")===0){ |
1656 | 1663 | $model_classname=str_replace("EE_","EEM_",$model_name); |
1657 | - }else{ |
|
1664 | + } else{ |
|
1658 | 1665 | $model_classname = "EEM_".$model_name; |
1659 | 1666 | } |
1660 | 1667 | return $model_classname; |
@@ -1688,7 +1695,7 @@ discard block |
||
1688 | 1695 | //now that we know the name of the variable, use a variable variable to get its value and return its |
1689 | 1696 | if( $this->get_model()->has_primary_key_field() ) { |
1690 | 1697 | return $this->_fields[self::_get_primary_key_name( get_class($this) )]; |
1691 | - }else{ |
|
1698 | + } else{ |
|
1692 | 1699 | return $this->get_model()->get_index_primary_key_string( $this->_fields ); |
1693 | 1700 | } |
1694 | 1701 | } |
@@ -1816,7 +1823,7 @@ discard block |
||
1816 | 1823 | //if there are query parameters, forget about caching the related model objects. |
1817 | 1824 | if( $query_params ){ |
1818 | 1825 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
1819 | - }else{ |
|
1826 | + } else{ |
|
1820 | 1827 | //did we already cache the result of this query? |
1821 | 1828 | $cached_results = $this->get_all_from_cache($relationName); |
1822 | 1829 | if ( ! $cached_results ){ |
@@ -1826,11 +1833,11 @@ discard block |
||
1826 | 1833 | foreach($related_model_objects as $related_model_object){ |
1827 | 1834 | $this->cache($relationName, $related_model_object); |
1828 | 1835 | } |
1829 | - }else{ |
|
1836 | + } else{ |
|
1830 | 1837 | $related_model_objects = $cached_results; |
1831 | 1838 | } |
1832 | 1839 | } |
1833 | - }else{//this doesn't exist itn eh DB, so just get the related things from the cache |
|
1840 | + } else{//this doesn't exist itn eh DB, so just get the related things from the cache |
|
1834 | 1841 | $related_model_objects = $this->get_all_from_cache($relationName); |
1835 | 1842 | } |
1836 | 1843 | return $related_model_objects; |
@@ -1882,22 +1889,22 @@ discard block |
||
1882 | 1889 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
1883 | 1890 | if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
1884 | 1891 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
1885 | - }else{ |
|
1892 | + } else{ |
|
1886 | 1893 | //first, check if we've already cached the result of this query |
1887 | 1894 | $cached_result = $this->get_one_from_cache($relationName); |
1888 | 1895 | if ( ! $cached_result ){ |
1889 | 1896 | |
1890 | 1897 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
1891 | 1898 | $this->cache($relationName,$related_model_object); |
1892 | - }else{ |
|
1899 | + } else{ |
|
1893 | 1900 | $related_model_object = $cached_result; |
1894 | 1901 | } |
1895 | 1902 | } |
1896 | - }else{ |
|
1903 | + } else{ |
|
1897 | 1904 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |
1898 | 1905 | if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
1899 | 1906 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
1900 | - }else{ |
|
1907 | + } else{ |
|
1901 | 1908 | $related_model_object = null; |
1902 | 1909 | } |
1903 | 1910 | //this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object |
@@ -1923,7 +1930,7 @@ discard block |
||
1923 | 1930 | public function delete_related($relationName,$query_params = array()){ |
1924 | 1931 | if($this->ID()){ |
1925 | 1932 | $count = $this->get_model()->delete_related($this, $relationName, $query_params); |
1926 | - }else{ |
|
1933 | + } else{ |
|
1927 | 1934 | $count = count($this->get_all_from_cache($relationName)); |
1928 | 1935 | $this->clear_cache($relationName,NULL,TRUE); |
1929 | 1936 | } |
@@ -1943,7 +1950,7 @@ discard block |
||
1943 | 1950 | public function delete_related_permanently($relationName,$query_params = array()){ |
1944 | 1951 | if($this->ID()){ |
1945 | 1952 | $count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params); |
1946 | - }else{ |
|
1953 | + } else{ |
|
1947 | 1954 | $count = count($this->get_all_from_cache($relationName)); |
1948 | 1955 | } |
1949 | 1956 | $this->clear_cache($relationName,NULL,TRUE); |
@@ -1978,8 +1985,9 @@ discard block |
||
1978 | 1985 | |
1979 | 1986 | foreach ( (array) $properties as $property_name ) { |
1980 | 1987 | //first make sure this property exists |
1981 | - if ( ! $this->_fields[ $property_name ] ) |
|
1982 | - throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s). Double check the spelling please', 'event_espresso'), $property_name ) ); |
|
1988 | + if ( ! $this->_fields[ $property_name ] ) { |
|
1989 | + throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s). Double check the spelling please', 'event_espresso'), $property_name ) ); |
|
1990 | + } |
|
1983 | 1991 | } |
1984 | 1992 | |
1985 | 1993 | return TRUE; |
@@ -2059,7 +2067,7 @@ discard block |
||
2059 | 2067 | $existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params); |
2060 | 2068 | if( ! $existing_rows_like_that){ |
2061 | 2069 | return $this->add_extra_meta($meta_key, $meta_value); |
2062 | - }else{ |
|
2070 | + } else{ |
|
2063 | 2071 | foreach( $existing_rows_like_that as $existing_row){ |
2064 | 2072 | $existing_row->save( array( 'EXM_value' => $meta_value ) ); |
2065 | 2073 | } |
@@ -2125,10 +2133,10 @@ discard block |
||
2125 | 2133 | $result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
2126 | 2134 | if ( $result instanceof EE_Extra_Meta ){ |
2127 | 2135 | return $result->value(); |
2128 | - }else{ |
|
2136 | + } else{ |
|
2129 | 2137 | return $default; |
2130 | 2138 | } |
2131 | - }else{ |
|
2139 | + } else{ |
|
2132 | 2140 | $results = $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key))); |
2133 | 2141 | if($results){ |
2134 | 2142 | $values = array(); |
@@ -2138,7 +2146,7 @@ discard block |
||
2138 | 2146 | } |
2139 | 2147 | } |
2140 | 2148 | return $values; |
2141 | - }else{ |
|
2149 | + } else{ |
|
2142 | 2150 | return $default; |
2143 | 2151 | } |
2144 | 2152 | } |
@@ -2164,7 +2172,7 @@ discard block |
||
2164 | 2172 | $return_array[$extra_meta_obj->key()] = $extra_meta_obj->value(); |
2165 | 2173 | } |
2166 | 2174 | } |
2167 | - }else{ |
|
2175 | + } else{ |
|
2168 | 2176 | $extra_meta_objs = $this->get_many_related('Extra_Meta'); |
2169 | 2177 | foreach($extra_meta_objs as $extra_meta_obj){ |
2170 | 2178 | if ( $extra_meta_obj instanceof EE_Extra_Meta ) { |
@@ -2186,7 +2194,7 @@ discard block |
||
2186 | 2194 | $field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base'); |
2187 | 2195 | if($field_we_can_use){ |
2188 | 2196 | return $this->get($field_we_can_use->get_name()); |
2189 | - }else{ |
|
2197 | + } else{ |
|
2190 | 2198 | $first_few_properties = $this->model_field_array(); |
2191 | 2199 | $first_few_properties = array_slice($first_few_properties,0,3); |
2192 | 2200 | $name_parts = array(); |
@@ -2206,7 +2214,7 @@ discard block |
||
2206 | 2214 | if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) { |
2207 | 2215 | //well, if we looked, did we find it in the entity map? |
2208 | 2216 | return TRUE; |
2209 | - }else{ |
|
2217 | + } else{ |
|
2210 | 2218 | return FALSE; |
2211 | 2219 | } |
2212 | 2220 | } |
@@ -2220,7 +2228,7 @@ discard block |
||
2220 | 2228 | public function refresh_from_db(){ |
2221 | 2229 | if( $this->ID() && $this->in_entity_map() ){ |
2222 | 2230 | $this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
2223 | - }else{ |
|
2231 | + } else{ |
|
2224 | 2232 | //if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
2225 | 2233 | //if it has an ID but it's not in the map, and you're asking me to refresh it |
2226 | 2234 | //that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | * the registration's share of the transaction total, so that the |
665 | 665 | * sum of all the transaction's REG_final_prices equal the transaction's total |
666 | 666 | * @access public |
667 | - * @return float |
|
667 | + * @return boolean |
|
668 | 668 | */ |
669 | 669 | public function final_price() { |
670 | 670 | return $this->get( 'REG_final_price' ); |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | /** |
687 | 687 | * get paid (yeah) |
688 | 688 | * @access public |
689 | - * @return float |
|
689 | + * @return boolean |
|
690 | 690 | */ |
691 | 691 | public function paid() { |
692 | 692 | return $this->get( 'REG_paid' ); |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | /** |
899 | 899 | * Sets deleted |
900 | 900 | * @param boolean $deleted |
901 | - * @return boolean |
|
901 | + * @return boolean|null |
|
902 | 902 | */ |
903 | 903 | public function set_deleted($deleted) { |
904 | 904 | $this->set( 'REG_deleted', $deleted ); |
@@ -942,6 +942,7 @@ discard block |
||
942 | 942 | * |
943 | 943 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
944 | 944 | * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also consider registration status as well as datetime access. |
945 | + * @param integer $DTT_OR_ID |
|
945 | 946 | * |
946 | 947 | * @return bool |
947 | 948 | */ |
@@ -1179,7 +1180,7 @@ discard block |
||
1179 | 1180 | |
1180 | 1181 | |
1181 | 1182 | /** |
1182 | - * @return int |
|
1183 | + * @return boolean |
|
1183 | 1184 | */ |
1184 | 1185 | public function ticket_ID() { |
1185 | 1186 | return $this->get( 'TKT_ID' ); |
@@ -1302,7 +1303,7 @@ discard block |
||
1302 | 1303 | * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
1303 | 1304 | * Note: if there are no payments on the registration there will be no payment method returned. |
1304 | 1305 | * |
1305 | - * @return EE_Payment_Method|null |
|
1306 | + * @return EE_Base_Class|null |
|
1306 | 1307 | */ |
1307 | 1308 | public function payment_method() { |
1308 | 1309 | return EEM_Payment_Method::instance()->get_last_used_for_registration( $this ); |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * EE_Registration class |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * date_format and the second value is the time format |
42 | 42 | * @return EE_Registration |
43 | 43 | */ |
44 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
45 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
46 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
44 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
45 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
46 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * the website will be used. |
55 | 55 | * @return EE_Registration |
56 | 56 | */ |
57 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
58 | - return new self( $props_n_values, TRUE, $timezone ); |
|
57 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
58 | + return new self($props_n_values, TRUE, $timezone); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * @access public |
67 | 67 | * @param int $EVT_ID Event ID |
68 | 68 | */ |
69 | - public function set_event( $EVT_ID = 0 ) { |
|
70 | - $this->set( 'EVT_ID', $EVT_ID ); |
|
69 | + public function set_event($EVT_ID = 0) { |
|
70 | + $this->set('EVT_ID', $EVT_ID); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
@@ -78,18 +78,18 @@ discard block |
||
78 | 78 | * @param mixed $field_value |
79 | 79 | * @param bool $use_default |
80 | 80 | */ |
81 | - public function set( $field_name, $field_value, $use_default = FALSE ) { |
|
82 | - switch( $field_name ) { |
|
81 | + public function set($field_name, $field_value, $use_default = FALSE) { |
|
82 | + switch ($field_name) { |
|
83 | 83 | case 'REG_code' : |
84 | - if ( ! empty( $field_value ) && $this->reg_code() == '' ) { |
|
85 | - $this->set_reg_code( $field_value, $use_default ); |
|
84 | + if ( ! empty($field_value) && $this->reg_code() == '') { |
|
85 | + $this->set_reg_code($field_value, $use_default); |
|
86 | 86 | } |
87 | 87 | break; |
88 | 88 | case 'STS_ID' : |
89 | - $this->set_status( $field_value, $use_default ); |
|
89 | + $this->set_status($field_value, $use_default); |
|
90 | 90 | break; |
91 | 91 | default : |
92 | - parent::set( $field_name, $field_value, $use_default ); |
|
92 | + parent::set($field_name, $field_value, $use_default); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -106,30 +106,30 @@ discard block |
||
106 | 106 | * @param boolean $use_default |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function set_status( $new_STS_ID = NULL, $use_default = FALSE ) { |
|
109 | + public function set_status($new_STS_ID = NULL, $use_default = FALSE) { |
|
110 | 110 | // get current REG_Status |
111 | 111 | $old_STS_ID = $this->status_ID(); |
112 | 112 | // if status has changed |
113 | - if ( $old_STS_ID != $new_STS_ID && $this->ID() ) { |
|
113 | + if ($old_STS_ID != $new_STS_ID && $this->ID()) { |
|
114 | 114 | // TO approved |
115 | - if ( $new_STS_ID == EEM_Registration::status_id_approved ) { |
|
115 | + if ($new_STS_ID == EEM_Registration::status_id_approved) { |
|
116 | 116 | // reserve a space by incrementing ticket and datetime sold values |
117 | 117 | $this->_reserve_registration_space(); |
118 | - do_action( 'AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
118 | + do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
119 | 119 | // OR FROM approved |
120 | - } else if ( $old_STS_ID == EEM_Registration::status_id_approved ) { |
|
120 | + } else if ($old_STS_ID == EEM_Registration::status_id_approved) { |
|
121 | 121 | // release a space by decrementing ticket and datetime sold values |
122 | 122 | $this->_release_registration_space(); |
123 | - do_action( 'AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID ); |
|
123 | + do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
124 | 124 | } |
125 | 125 | // update status |
126 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
127 | - do_action( 'AHEE__EE_Registration__set_status__after_update', $this ); |
|
126 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
127 | + do_action('AHEE__EE_Registration__set_status__after_update', $this); |
|
128 | 128 | return TRUE; |
129 | - }else{ |
|
129 | + } else { |
|
130 | 130 | //even though the old value matches the new value, it's still good to |
131 | 131 | //allow the parent set method to have a say |
132 | - parent::set( 'STS_ID', $new_STS_ID, $use_default ); |
|
132 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
133 | 133 | return TRUE; |
134 | 134 | } |
135 | 135 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @access public |
142 | 142 | */ |
143 | 143 | public function status_ID() { |
144 | - return $this->get( 'STS_ID' ); |
|
144 | + return $this->get('STS_ID'); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | * @param boolean $include_archived whether to include archived tickets or not. |
167 | 167 | * @return EE_Ticket |
168 | 168 | */ |
169 | - public function ticket( $include_archived = TRUE ) { |
|
169 | + public function ticket($include_archived = TRUE) { |
|
170 | 170 | $query_params = array(); |
171 | - if ( $include_archived ) { |
|
172 | - $query_params[ 'default_where_conditions' ] = 'none'; |
|
171 | + if ($include_archived) { |
|
172 | + $query_params['default_where_conditions'] = 'none'; |
|
173 | 173 | } |
174 | - return $this->get_first_related( 'Ticket', $query_params ); |
|
174 | + return $this->get_first_related('Ticket', $query_params); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @return EE_Event |
182 | 182 | */ |
183 | 183 | public function event() { |
184 | - return $this->get_first_related( 'Event' ); |
|
184 | + return $this->get_first_related('Event'); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function wp_user() { |
197 | 197 | $event = $this->event(); |
198 | - if ( $event instanceof EE_Event ) { |
|
198 | + if ($event instanceof EE_Event) { |
|
199 | 199 | return $event->wp_user(); |
200 | 200 | } |
201 | 201 | return 0; |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @access public |
222 | 222 | * @param int $ATT_ID Attendee ID |
223 | 223 | */ |
224 | - public function set_attendee_id( $ATT_ID = 0 ) { |
|
225 | - $this->set( 'ATT_ID', $ATT_ID ); |
|
224 | + public function set_attendee_id($ATT_ID = 0) { |
|
225 | + $this->set('ATT_ID', $ATT_ID); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @access public |
234 | 234 | * @param int $TXN_ID Transaction ID |
235 | 235 | */ |
236 | - public function set_transaction_id( $TXN_ID = 0 ) { |
|
237 | - $this->set( 'TXN_ID', $TXN_ID ); |
|
236 | + public function set_transaction_id($TXN_ID = 0) { |
|
237 | + $this->set('TXN_ID', $TXN_ID); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | * @access public |
246 | 246 | * @param string $REG_session PHP Session ID |
247 | 247 | */ |
248 | - public function set_session( $REG_session = '' ) { |
|
249 | - $this->set( 'REG_session', $REG_session ); |
|
248 | + public function set_session($REG_session = '') { |
|
249 | + $this->set('REG_session', $REG_session); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | * @access public |
258 | 258 | * @param string $REG_url_link Registration URL Link |
259 | 259 | */ |
260 | - public function set_reg_url_link( $REG_url_link = '' ) { |
|
261 | - $this->set( 'REG_url_link', $REG_url_link ); |
|
260 | + public function set_reg_url_link($REG_url_link = '') { |
|
261 | + $this->set('REG_url_link', $REG_url_link); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @access public |
270 | 270 | * @param int $REG_count Primary Attendee |
271 | 271 | */ |
272 | - public function set_count( $REG_count = 1 ) { |
|
273 | - $this->set( 'REG_count', $REG_count ); |
|
272 | + public function set_count($REG_count = 1) { |
|
273 | + $this->set('REG_count', $REG_count); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * @access public |
282 | 282 | * @param boolean $REG_group_size Group Registration |
283 | 283 | */ |
284 | - public function set_group_size( $REG_group_size = FALSE ) { |
|
285 | - $this->set( 'REG_group_size', $REG_group_size ); |
|
284 | + public function set_group_size($REG_group_size = FALSE) { |
|
285 | + $this->set('REG_group_size', $REG_group_size); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @access public |
366 | 366 | * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of Date |
367 | 367 | */ |
368 | - public function set_reg_date( $REG_date = FALSE ) { |
|
369 | - $this->set( 'REG_date', $REG_date ); |
|
368 | + public function set_reg_date($REG_date = FALSE) { |
|
369 | + $this->set('REG_date', $REG_date); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | * @access public |
378 | 378 | * @param float $REG_final_price |
379 | 379 | */ |
380 | - public function set_final_price( $REG_final_price = 0.00 ) { |
|
381 | - $this->set( 'REG_final_price', $REG_final_price ); |
|
380 | + public function set_final_price($REG_final_price = 0.00) { |
|
381 | + $this->set('REG_final_price', $REG_final_price); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | |
@@ -389,8 +389,8 @@ discard block |
||
389 | 389 | * @access public |
390 | 390 | * @param float $REG_paid |
391 | 391 | */ |
392 | - public function set_paid( $REG_paid = 0.00 ) { |
|
393 | - $this->set( 'REG_paid', $REG_paid ); |
|
392 | + public function set_paid($REG_paid = 0.00) { |
|
393 | + $this->set('REG_paid', $REG_paid); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | |
@@ -401,8 +401,8 @@ discard block |
||
401 | 401 | * @access public |
402 | 402 | * @param boolean $REG_att_is_going Attendee Is Going |
403 | 403 | */ |
404 | - public function set_att_is_going( $REG_att_is_going = FALSE ) { |
|
405 | - $this->set( 'REG_att_is_going', $REG_att_is_going ); |
|
404 | + public function set_att_is_going($REG_att_is_going = FALSE) { |
|
405 | + $this->set('REG_att_is_going', $REG_att_is_going); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @return EE_Attendee |
413 | 413 | */ |
414 | 414 | public function attendee() { |
415 | - return $this->get_first_related( 'Attendee' ); |
|
415 | + return $this->get_first_related('Attendee'); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @access public |
423 | 423 | */ |
424 | 424 | public function event_ID() { |
425 | - return $this->get( 'EVT_ID' ); |
|
425 | + return $this->get('EVT_ID'); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | */ |
434 | 434 | public function event_name() { |
435 | 435 | $event = $this->event_obj(); |
436 | - if ( $event ) { |
|
436 | + if ($event) { |
|
437 | 437 | return $event->name(); |
438 | 438 | } else { |
439 | 439 | return NULL; |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | * @return EE_Event |
448 | 448 | */ |
449 | 449 | public function event_obj() { |
450 | - return $this->get_first_related( 'Event' ); |
|
450 | + return $this->get_first_related('Event'); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * @access public |
458 | 458 | */ |
459 | 459 | public function attendee_ID() { |
460 | - return $this->get( 'ATT_ID' ); |
|
460 | + return $this->get('ATT_ID'); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | * @access public |
468 | 468 | */ |
469 | 469 | public function session_ID() { |
470 | - return $this->get( 'REG_session' ); |
|
470 | + return $this->get('REG_session'); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
478 | 478 | * @return string |
479 | 479 | */ |
480 | - public function receipt_url( $messenger = 'html' ) { |
|
480 | + public function receipt_url($messenger = 'html') { |
|
481 | 481 | |
482 | 482 | /** |
483 | 483 | * The below will be deprecated one version after this. We check first if there is a custom receipt template already in use on old system. If there is then we just return the standard url for it. |
@@ -486,12 +486,12 @@ discard block |
||
486 | 486 | */ |
487 | 487 | EE_Registry::instance()->load_helper('Template'); |
488 | 488 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
489 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
489 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
490 | 490 | |
491 | - if ( $has_custom ) { |
|
492 | - return add_query_arg( array( 'receipt' => 'true' ), $this->invoice_url( 'launch' ) ); |
|
491 | + if ($has_custom) { |
|
492 | + return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
493 | 493 | } |
494 | - return apply_filters( 'FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt' ); |
|
494 | + return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | * @param string $messenger 'pdf' or 'html'. Default 'html'. |
503 | 503 | * @return string |
504 | 504 | */ |
505 | - public function invoice_url( $messenger = 'html' ) { |
|
505 | + public function invoice_url($messenger = 'html') { |
|
506 | 506 | /** |
507 | 507 | * The below will be deprecated one version after this. We check first if there is a custom invoice template already in use on old system. If there is then we just return the standard url for it. |
508 | 508 | * |
@@ -510,21 +510,21 @@ discard block |
||
510 | 510 | */ |
511 | 511 | EE_Registry::instance()->load_helper('Template'); |
512 | 512 | $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
513 | - $has_custom = EEH_Template::locate_template( $template_relative_path , array(), TRUE, TRUE, TRUE ); |
|
513 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), TRUE, TRUE, TRUE); |
|
514 | 514 | |
515 | - if ( $has_custom ) { |
|
516 | - if ( $messenger == 'html' ) { |
|
517 | - return $this->invoice_url( 'launch' ); |
|
515 | + if ($has_custom) { |
|
516 | + if ($messenger == 'html') { |
|
517 | + return $this->invoice_url('launch'); |
|
518 | 518 | } |
519 | 519 | $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
520 | 520 | |
521 | - $query_args = array( 'ee' => $route, 'id' => $this->reg_url_link() ); |
|
522 | - if ( $messenger == 'html' ) { |
|
521 | + $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
522 | + if ($messenger == 'html') { |
|
523 | 523 | $query_args['html'] = TRUE; |
524 | 524 | } |
525 | - return add_query_arg( $query_args, get_permalink( EE_Registry::instance()->CFG->core->thank_you_page_id ) ); |
|
525 | + return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
526 | 526 | } |
527 | - return apply_filters( 'FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice' ); |
|
527 | + return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | * @access public |
535 | 535 | */ |
536 | 536 | public function reg_url_link() { |
537 | - return $this->get( 'REG_url_link' ); |
|
537 | + return $this->get('REG_url_link'); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | * @param string $type 'download','launch', or 'html' (default is 'launch') |
545 | 545 | * @return void |
546 | 546 | */ |
547 | - public function e_invoice_url( $type = 'launch' ) { |
|
548 | - echo $this->invoice_url( $type ); |
|
547 | + public function e_invoice_url($type = 'launch') { |
|
548 | + echo $this->invoice_url($type); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * @return string |
566 | 566 | */ |
567 | 567 | public function payment_overview_url() { |
568 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
568 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'payment_options', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | * @return string |
577 | 577 | */ |
578 | 578 | public function edit_attendee_information_url() { |
579 | - return add_query_arg( array( 'e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE ), EE_Registry::instance()->CFG->core->reg_page_url() ); |
|
579 | + return add_query_arg(array('e_reg_url_link' => $this->reg_url_link(), 'step' => 'attendee_information', 'revisit' => TRUE), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | |
@@ -586,8 +586,8 @@ discard block |
||
586 | 586 | * @return string |
587 | 587 | */ |
588 | 588 | public function get_admin_edit_url() { |
589 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
590 | - return EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID() ), admin_url( 'admin.php' ) ); |
|
589 | + EE_Registry::instance()->load_helper('URL'); |
|
590 | + return EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_registrations', 'action' => 'view_registration', '_REG_ID' => $this->ID()), admin_url('admin.php')); |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | * @access public |
598 | 598 | */ |
599 | 599 | public function is_primary_registrant() { |
600 | - return $this->get( 'REG_count' ) == 1 ? TRUE : FALSE; |
|
600 | + return $this->get('REG_count') == 1 ? TRUE : FALSE; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | |
@@ -606,12 +606,12 @@ discard block |
||
606 | 606 | * This returns the primary registration object for this registration group (which may be this object). |
607 | 607 | * @return EE_Registration |
608 | 608 | */ |
609 | - public function get_primary_registration() { |
|
610 | - if ( $this->is_primary_registrant() ) |
|
609 | + public function get_primary_registration() { |
|
610 | + if ($this->is_primary_registrant()) |
|
611 | 611 | return $this; |
612 | 612 | |
613 | 613 | //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
614 | - $primary_registrant = EEM_Registration::instance()->get_one( array( array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1 ) ) ); |
|
614 | + $primary_registrant = EEM_Registration::instance()->get_one(array(array('TXN_ID' => $this->transaction_ID(), 'REG_count' => 1))); |
|
615 | 615 | return $primary_registrant; |
616 | 616 | } |
617 | 617 | |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * @access public |
623 | 623 | */ |
624 | 624 | public function count() { |
625 | - return $this->get( 'REG_count' ); |
|
625 | + return $this->get('REG_count'); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | * @access public |
633 | 633 | */ |
634 | 634 | public function group_size() { |
635 | - return $this->get( 'REG_group_size' ); |
|
635 | + return $this->get('REG_group_size'); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * @access public |
643 | 643 | */ |
644 | 644 | public function date() { |
645 | - return $this->get( 'REG_date' ); |
|
645 | + return $this->get('REG_date'); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | |
@@ -653,8 +653,8 @@ discard block |
||
653 | 653 | * @param string $time_format |
654 | 654 | * @return string |
655 | 655 | */ |
656 | - public function pretty_date( $date_format = NULL, $time_format = NULL ) { |
|
657 | - return $this->get_datetime( 'REG_date', $date_format, $time_format ); |
|
656 | + public function pretty_date($date_format = NULL, $time_format = NULL) { |
|
657 | + return $this->get_datetime('REG_date', $date_format, $time_format); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | * @return float |
668 | 668 | */ |
669 | 669 | public function final_price() { |
670 | - return $this->get( 'REG_final_price' ); |
|
670 | + return $this->get('REG_final_price'); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | * @return string |
679 | 679 | */ |
680 | 680 | public function pretty_final_price() { |
681 | - return $this->get_pretty( 'REG_final_price' ); |
|
681 | + return $this->get_pretty('REG_final_price'); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | |
@@ -689,7 +689,7 @@ discard block |
||
689 | 689 | * @return float |
690 | 690 | */ |
691 | 691 | public function paid() { |
692 | - return $this->get( 'REG_paid' ); |
|
692 | + return $this->get('REG_paid'); |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | * @return float |
701 | 701 | */ |
702 | 702 | public function pretty_paid() { |
703 | - return $this->get_pretty( 'REG_paid' ); |
|
703 | + return $this->get_pretty('REG_paid'); |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | |
@@ -712,11 +712,11 @@ discard block |
||
712 | 712 | * @param array $requires_payment |
713 | 713 | * @return bool |
714 | 714 | */ |
715 | - public function owes_monies_and_can_pay( $requires_payment = array()) { |
|
715 | + public function owes_monies_and_can_pay($requires_payment = array()) { |
|
716 | 716 | // these reg statuses require payment (if event is not free) |
717 | - $requires_payment = ! empty( $requires_payment ) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
717 | + $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
718 | 718 | if ( |
719 | - in_array( $this->status_ID(), $requires_payment ) && |
|
719 | + in_array($this->status_ID(), $requires_payment) && |
|
720 | 720 | $this->final_price() != 0 && |
721 | 721 | $this->final_price() != $this->paid() |
722 | 722 | ) { |
@@ -733,8 +733,8 @@ discard block |
||
733 | 733 | * @param bool $show_icons |
734 | 734 | * @return void |
735 | 735 | */ |
736 | - public function e_pretty_status( $show_icons = FALSE ) { |
|
737 | - echo $this->pretty_status( $show_icons ); |
|
736 | + public function e_pretty_status($show_icons = FALSE) { |
|
737 | + echo $this->pretty_status($show_icons); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | |
@@ -745,10 +745,10 @@ discard block |
||
745 | 745 | * @param bool $show_icons |
746 | 746 | * @return string |
747 | 747 | */ |
748 | - public function pretty_status( $show_icons = FALSE ) { |
|
749 | - $status = EEM_Status::instance()->localized_status( array( $this->status_ID() => __( 'unknown', 'event_espresso' ) ), FALSE, 'sentence' ); |
|
748 | + public function pretty_status($show_icons = FALSE) { |
|
749 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), FALSE, 'sentence'); |
|
750 | 750 | $icon = ''; |
751 | - switch ( $this->status_ID() ) { |
|
751 | + switch ($this->status_ID()) { |
|
752 | 752 | case EEM_Registration::status_id_approved: |
753 | 753 | $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
754 | 754 | break; |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
769 | 769 | break; |
770 | 770 | } |
771 | - return $icon . $status[ $this->status_ID() ]; |
|
771 | + return $icon.$status[$this->status_ID()]; |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | * @access public |
779 | 779 | */ |
780 | 780 | public function att_is_going() { |
781 | - return $this->get( 'REG_att_is_going' ); |
|
781 | + return $this->get('REG_att_is_going'); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | |
@@ -788,8 +788,8 @@ discard block |
||
788 | 788 | * @param array $query_params like EEM_Base::get_all |
789 | 789 | * @return EE_Answer[] |
790 | 790 | */ |
791 | - public function answers( $query_params = NULL ) { |
|
792 | - return $this->get_many_related( 'Answer', $query_params ); |
|
791 | + public function answers($query_params = NULL) { |
|
792 | + return $this->get_many_related('Answer', $query_params); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | |
@@ -803,9 +803,9 @@ discard block |
||
803 | 803 | * (because the answer might be an array of answer values, so passing pretty_value=true |
804 | 804 | * will convert it into some kind of string) |
805 | 805 | */ |
806 | - public function answer_value_to_question( $question, $pretty_value=true ) { |
|
806 | + public function answer_value_to_question($question, $pretty_value = true) { |
|
807 | 807 | $question_id = EEM_Question::instance()->ensure_is_ID($question); |
808 | - return EEM_Answer::instance()->get_answer_value_to_question($this,$question_id,$pretty_value); |
|
808 | + return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | |
@@ -818,13 +818,13 @@ discard block |
||
818 | 818 | */ |
819 | 819 | public function question_groups() { |
820 | 820 | $question_groups = array(); |
821 | - if ( $this->event() instanceof EE_Event ) { |
|
821 | + if ($this->event() instanceof EE_Event) { |
|
822 | 822 | $question_groups = $this->event()->question_groups( |
823 | 823 | array( |
824 | 824 | array( |
825 | 825 | 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false |
826 | 826 | ), |
827 | - 'order_by' => array( 'QSG_order' => 'ASC' ) |
|
827 | + 'order_by' => array('QSG_order' => 'ASC') |
|
828 | 828 | ) |
829 | 829 | ); |
830 | 830 | } |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | */ |
842 | 842 | public function count_question_groups() { |
843 | 843 | $qg_count = 0; |
844 | - if ( $this->event() instanceof EE_Event ) { |
|
844 | + if ($this->event() instanceof EE_Event) { |
|
845 | 845 | $qg_count = $this->event()->count_related( |
846 | 846 | 'Question_Group', |
847 | 847 | array( |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | * @return string |
863 | 863 | */ |
864 | 864 | public function reg_date() { |
865 | - return $this->get_datetime( 'REG_date' ); |
|
865 | + return $this->get_datetime('REG_date'); |
|
866 | 866 | } |
867 | 867 | |
868 | 868 | |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | * @return EE_Datetime_Ticket |
875 | 875 | */ |
876 | 876 | public function datetime_ticket() { |
877 | - return $this->get_first_related( 'Datetime_Ticket' ); |
|
877 | + return $this->get_first_related('Datetime_Ticket'); |
|
878 | 878 | } |
879 | 879 | |
880 | 880 | |
@@ -884,15 +884,15 @@ discard block |
||
884 | 884 | * @param EE_Datetime_Ticket $datetime_ticket |
885 | 885 | * @return EE_Datetime_Ticket |
886 | 886 | */ |
887 | - public function set_datetime_ticket( $datetime_ticket ) { |
|
888 | - return $this->_add_relation_to( $datetime_ticket, 'Datetime_Ticket' ); |
|
887 | + public function set_datetime_ticket($datetime_ticket) { |
|
888 | + return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
889 | 889 | } |
890 | 890 | /** |
891 | 891 | * Gets deleted |
892 | 892 | * @return boolean |
893 | 893 | */ |
894 | 894 | public function deleted() { |
895 | - return $this->get( 'REG_deleted' ); |
|
895 | + return $this->get('REG_deleted'); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | * @return boolean |
902 | 902 | */ |
903 | 903 | public function set_deleted($deleted) { |
904 | - $this->set( 'REG_deleted', $deleted ); |
|
904 | + $this->set('REG_deleted', $deleted); |
|
905 | 905 | } |
906 | 906 | |
907 | 907 | |
@@ -911,7 +911,7 @@ discard block |
||
911 | 911 | * @return EE_Status |
912 | 912 | */ |
913 | 913 | public function status_obj() { |
914 | - return $this->get_first_related( 'Status' ); |
|
914 | + return $this->get_first_related('Status'); |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | * @return int |
923 | 923 | */ |
924 | 924 | public function count_checkins() { |
925 | - return $this->get_model()->count_related( $this, 'Checkin' ); |
|
925 | + return $this->get_model()->count_related($this, 'Checkin'); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | * @return int |
933 | 933 | */ |
934 | 934 | public function count_checkins_not_checkedout() { |
935 | - return $this->get_model()->count_related( $this, 'Checkin', array( array( 'CHK_in' => 1 ) ) ); |
|
935 | + return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | |
@@ -945,20 +945,20 @@ discard block |
||
945 | 945 | * |
946 | 946 | * @return bool |
947 | 947 | */ |
948 | - public function can_checkin( $DTT_OR_ID, $check_approved = TRUE ) { |
|
949 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
948 | + public function can_checkin($DTT_OR_ID, $check_approved = TRUE) { |
|
949 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
950 | 950 | |
951 | 951 | //first check registration status |
952 | - if ( ( $check_approved && ! $this->is_approved() ) || ! $DTT_ID ) { |
|
952 | + if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
953 | 953 | return false; |
954 | 954 | } |
955 | 955 | //is there a datetime ticket that matches this dtt_ID? |
956 | - if ( ! ( EEM_Datetime_Ticket::instance()->exists( array( array( 'TKT_ID' => $this->get('TKT_ID' ), 'DTT_ID' => $DTT_ID ) ) ) ) ) { |
|
956 | + if ( ! (EEM_Datetime_Ticket::instance()->exists(array(array('TKT_ID' => $this->get('TKT_ID'), 'DTT_ID' => $DTT_ID))))) { |
|
957 | 957 | return false; |
958 | 958 | } |
959 | 959 | |
960 | 960 | //final check is against TKT_uses |
961 | - return $this->verify_can_checkin_against_TKT_uses( $DTT_ID ); |
|
961 | + return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | |
@@ -971,10 +971,10 @@ discard block |
||
971 | 971 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
972 | 972 | * @return bool true means can checkin. false means cannot checkin. |
973 | 973 | */ |
974 | - public function verify_can_checkin_against_TKT_uses( $DTT_OR_ID ) { |
|
975 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID( $DTT_OR_ID ); |
|
974 | + public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) { |
|
975 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
976 | 976 | |
977 | - if ( ! $DTT_ID ) { |
|
977 | + if ( ! $DTT_ID) { |
|
978 | 978 | return false; |
979 | 979 | } |
980 | 980 | |
@@ -982,23 +982,23 @@ discard block |
||
982 | 982 | |
983 | 983 | // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
984 | 984 | // or not. |
985 | - if ( ! $max_uses || $max_uses === EE_INF ) { |
|
985 | + if ( ! $max_uses || $max_uses === EE_INF) { |
|
986 | 986 | return true; |
987 | 987 | } |
988 | 988 | |
989 | 989 | //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
990 | 990 | //go ahead and toggle. |
991 | - if ( EEM_Checkin::instance()->exists( array( array( 'REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID ) ) ) ) { |
|
991 | + if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
992 | 992 | return true; |
993 | 993 | } |
994 | 994 | |
995 | 995 | //made it here so the last check is whether the number of checkins per unique datetime on this registration |
996 | 996 | //disallows further check-ins. |
997 | - $count_unique_dtt_checkins = EEM_Checkin::instance()->count( array( array( 'REG_ID' => $this->ID(), 'CHK_in' => true ) ), 'DTT_ID', true ); |
|
997 | + $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array(array('REG_ID' => $this->ID(), 'CHK_in' => true)), 'DTT_ID', true); |
|
998 | 998 | // checkins have already reached their max number of uses |
999 | 999 | // so registrant can NOT checkin |
1000 | - if ( $count_unique_dtt_checkins >= $max_uses ) { |
|
1001 | - EE_Error::add_error( __( 'Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
1000 | + if ($count_unique_dtt_checkins >= $max_uses) { |
|
1001 | + EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1002 | 1002 | return false; |
1003 | 1003 | } |
1004 | 1004 | return true; |
@@ -1019,15 +1019,15 @@ discard block |
||
1019 | 1019 | * @param bool $verify If true then can_checkin() is used to verify whether the person can be checked in or not. Otherwise this forces change in checkin status. |
1020 | 1020 | * @return int|BOOL the chk_in status toggled to OR false if nothing got changed. |
1021 | 1021 | */ |
1022 | - public function toggle_checkin_status( $DTT_ID = null, $verify = false ) { |
|
1023 | - if ( empty( $DTT_ID ) ) { |
|
1022 | + public function toggle_checkin_status($DTT_ID = null, $verify = false) { |
|
1023 | + if (empty($DTT_ID)) { |
|
1024 | 1024 | $datetime = $this->get_related_primary_datetime(); |
1025 | 1025 | $DTT_ID = $datetime->ID(); |
1026 | 1026 | // verify the registration can checkin for the given DTT_ID |
1027 | - } elseif ( ! $this->can_checkin( $DTT_ID, $verify ) ) { |
|
1027 | + } elseif ( ! $this->can_checkin($DTT_ID, $verify)) { |
|
1028 | 1028 | EE_Error::add_error( |
1029 | 1029 | sprintf( |
1030 | - __( 'The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'), |
|
1030 | + __('The given registration (ID:%1$d) can not be checked in to the given DTT_ID (%2$d), because the registration does not have access', 'event_espresso'), |
|
1031 | 1031 | $this->ID(), |
1032 | 1032 | $DTT_ID |
1033 | 1033 | ), |
@@ -1041,8 +1041,8 @@ discard block |
||
1041 | 1041 | EE_Registration::checkin_status_out => EE_Registration::checkin_status_in |
1042 | 1042 | ); |
1043 | 1043 | //start by getting the current status so we know what status we'll be changing to. |
1044 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID, NULL ); |
|
1045 | - $status_to = $status_paths[ $cur_status ]; |
|
1044 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID, NULL); |
|
1045 | + $status_to = $status_paths[$cur_status]; |
|
1046 | 1046 | // database only records true for checked IN or false for checked OUT |
1047 | 1047 | // no record ( null ) means checked in NEVER, but we obviously don't save that |
1048 | 1048 | $new_status = $status_to == EE_Registration::checkin_status_in ? true : false; |
@@ -1050,24 +1050,24 @@ discard block |
||
1050 | 1050 | // because we are keeping track of Check-ins over time. |
1051 | 1051 | // Eventually we'll probably want to show a list table |
1052 | 1052 | // for the individual Check-ins so that they can be managed. |
1053 | - $checkin = EE_Checkin::new_instance( array( |
|
1053 | + $checkin = EE_Checkin::new_instance(array( |
|
1054 | 1054 | 'REG_ID' => $this->ID(), |
1055 | 1055 | 'DTT_ID' => $DTT_ID, |
1056 | 1056 | 'CHK_in' => $new_status |
1057 | - ) ); |
|
1057 | + )); |
|
1058 | 1058 | // if the record could not be saved then return false |
1059 | - if ( $checkin->save() === 0 ) { |
|
1060 | - if ( WP_DEBUG ) { |
|
1059 | + if ($checkin->save() === 0) { |
|
1060 | + if (WP_DEBUG) { |
|
1061 | 1061 | global $wpdb; |
1062 | 1062 | $error = sprintf( |
1063 | - __( 'Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso' ), |
|
1063 | + __('Registration check in update failed because of the following database error: %1$s%2$s', 'event_espresso'), |
|
1064 | 1064 | '<br />', |
1065 | 1065 | $wpdb->last_error |
1066 | 1066 | ); |
1067 | 1067 | } else { |
1068 | - $error = __( 'Registration check in update failed because of an unknown database error', 'event_espresso' ); |
|
1068 | + $error = __('Registration check in update failed because of an unknown database error', 'event_espresso'); |
|
1069 | 1069 | } |
1070 | - EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ ); |
|
1070 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
1071 | 1071 | return false; |
1072 | 1072 | } |
1073 | 1073 | return $status_to; |
@@ -1091,19 +1091,19 @@ discard block |
||
1091 | 1091 | * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
1092 | 1092 | * @return int Integer representing Check-in status. |
1093 | 1093 | */ |
1094 | - public function check_in_status_for_datetime( $DTT_ID = 0, $checkin = NULL ) { |
|
1095 | - if ( empty( $DTT_ID ) && ! $checkin instanceof EE_Checkin ) { |
|
1094 | + public function check_in_status_for_datetime($DTT_ID = 0, $checkin = NULL) { |
|
1095 | + if (empty($DTT_ID) && ! $checkin instanceof EE_Checkin) { |
|
1096 | 1096 | $datetime = $this->get_related_primary_datetime(); |
1097 | - if ( ! $datetime instanceof EE_Datetime ) { |
|
1097 | + if ( ! $datetime instanceof EE_Datetime) { |
|
1098 | 1098 | return 0; |
1099 | 1099 | } |
1100 | 1100 | $DTT_ID = $datetime->ID(); |
1101 | 1101 | //verify the registration can checkin for the given DTT_ID |
1102 | 1102 | } |
1103 | 1103 | //get checkin object (if exists) |
1104 | - $checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related( 'Checkin', array( array( 'DTT_ID' => $DTT_ID ), 'order_by' => array( 'CHK_timestamp' => 'DESC' ) ) ); |
|
1105 | - if ( $checkin instanceof EE_Checkin ) { |
|
1106 | - if ( $checkin->get( 'CHK_in' ) ) { |
|
1104 | + $checkin = $checkin instanceof EE_Checkin ? $checkin : $this->get_first_related('Checkin', array(array('DTT_ID' => $DTT_ID), 'order_by' => array('CHK_timestamp' => 'DESC'))); |
|
1105 | + if ($checkin instanceof EE_Checkin) { |
|
1106 | + if ($checkin->get('CHK_in')) { |
|
1107 | 1107 | return EE_Registration::checkin_status_in; //checked in |
1108 | 1108 | } else { |
1109 | 1109 | return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
@@ -1121,28 +1121,28 @@ discard block |
||
1121 | 1121 | * @param bool $error This just flags that you want an error message returned. This is put in so that the error message can be customized with the attendee name. |
1122 | 1122 | * @return string internationalized message |
1123 | 1123 | */ |
1124 | - public function get_checkin_msg( $DTT_ID, $error = FALSE ) { |
|
1124 | + public function get_checkin_msg($DTT_ID, $error = FALSE) { |
|
1125 | 1125 | //let's get the attendee first so we can include the name of the attendee |
1126 | - $attendee = $this->get_first_related( 'Attendee' ); |
|
1127 | - if ( $attendee instanceof EE_Attendee ) { |
|
1128 | - if ( $error ) { |
|
1129 | - return sprintf( __( "%s's check-in status was not changed.", "event_espresso" ), $attendee->full_name() ); |
|
1126 | + $attendee = $this->get_first_related('Attendee'); |
|
1127 | + if ($attendee instanceof EE_Attendee) { |
|
1128 | + if ($error) { |
|
1129 | + return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
1130 | 1130 | } |
1131 | - $cur_status = $this->check_in_status_for_datetime( $DTT_ID ); |
|
1131 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
1132 | 1132 | //what is the status message going to be? |
1133 | - switch ( $cur_status ) { |
|
1133 | + switch ($cur_status) { |
|
1134 | 1134 | case EE_Registration::checkin_status_never : |
1135 | - return sprintf( __( "%s has been removed from Check-in records", "event_espresso" ), $attendee->full_name() ); |
|
1135 | + return sprintf(__("%s has been removed from Check-in records", "event_espresso"), $attendee->full_name()); |
|
1136 | 1136 | break; |
1137 | 1137 | case EE_Registration::checkin_status_in : |
1138 | - return sprintf( __( '%s has been checked in', 'event_espresso' ), $attendee->full_name() ); |
|
1138 | + return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
1139 | 1139 | break; |
1140 | 1140 | case EE_Registration::checkin_status_out : |
1141 | - return sprintf( __( '%s has been checked out', 'event_espresso' ), $attendee->full_name() ); |
|
1141 | + return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
1142 | 1142 | break; |
1143 | 1143 | } |
1144 | 1144 | } |
1145 | - return __( "The check-in status could not be determined.", "event_espresso" ); |
|
1145 | + return __("The check-in status could not be determined.", "event_espresso"); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | * @return EE_Transaction |
1153 | 1153 | */ |
1154 | 1154 | public function transaction() { |
1155 | - return $this->get_first_related( 'Transaction' ); |
|
1155 | + return $this->get_first_related('Transaction'); |
|
1156 | 1156 | } |
1157 | 1157 | |
1158 | 1158 | |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | * @access public |
1164 | 1164 | */ |
1165 | 1165 | public function reg_code() { |
1166 | - return $this->get( 'REG_code' ); |
|
1166 | + return $this->get('REG_code'); |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | * @access public |
1174 | 1174 | */ |
1175 | 1175 | public function transaction_ID() { |
1176 | - return $this->get( 'TXN_ID' ); |
|
1176 | + return $this->get('TXN_ID'); |
|
1177 | 1177 | } |
1178 | 1178 | |
1179 | 1179 | |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | * @return int |
1183 | 1183 | */ |
1184 | 1184 | public function ticket_ID() { |
1185 | - return $this->get( 'TKT_ID' ); |
|
1185 | + return $this->get('TKT_ID'); |
|
1186 | 1186 | } |
1187 | 1187 | |
1188 | 1188 | |
@@ -1194,17 +1194,17 @@ discard block |
||
1194 | 1194 | * @param string $REG_code Registration Code |
1195 | 1195 | * @param boolean $use_default |
1196 | 1196 | */ |
1197 | - public function set_reg_code( $REG_code, $use_default = FALSE ) { |
|
1198 | - if ( empty( $REG_code )) { |
|
1199 | - EE_Error::add_error( __( 'REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
1197 | + public function set_reg_code($REG_code, $use_default = FALSE) { |
|
1198 | + if (empty($REG_code)) { |
|
1199 | + EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
1200 | 1200 | return; |
1201 | 1201 | } |
1202 | - if ( ! $this->reg_code() ) { |
|
1203 | - parent::set( 'REG_code', $REG_code, $use_default ); |
|
1202 | + if ( ! $this->reg_code()) { |
|
1203 | + parent::set('REG_code', $REG_code, $use_default); |
|
1204 | 1204 | } else { |
1205 | 1205 | EE_Error::doing_it_wrong( |
1206 | - __CLASS__ . '::' . __FUNCTION__, |
|
1207 | - __( 'Can not change a registration REG_code once it has been set.', 'event_espresso' ), |
|
1206 | + __CLASS__.'::'.__FUNCTION__, |
|
1207 | + __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
1208 | 1208 | '4.6.0' |
1209 | 1209 | ); |
1210 | 1210 | } |
@@ -1224,17 +1224,17 @@ discard block |
||
1224 | 1224 | * @return EE_Registration[] or empty array if this isn't a group registration. |
1225 | 1225 | */ |
1226 | 1226 | public function get_all_other_registrations_in_group() { |
1227 | - if ( $this->group_size() < 2 ) { |
|
1227 | + if ($this->group_size() < 2) { |
|
1228 | 1228 | return array(); |
1229 | 1229 | } |
1230 | 1230 | |
1231 | 1231 | $query[0] = array( |
1232 | 1232 | 'TXN_ID' => $this->transaction_ID(), |
1233 | - 'REG_ID' => array( '!=', $this->ID() ), |
|
1233 | + 'REG_ID' => array('!=', $this->ID()), |
|
1234 | 1234 | 'TKT_ID' => $this->ticket_ID() |
1235 | 1235 | ); |
1236 | 1236 | |
1237 | - $registrations = $this->get_model()->get_all( $query ); |
|
1237 | + $registrations = $this->get_model()->get_all($query); |
|
1238 | 1238 | return $registrations; |
1239 | 1239 | } |
1240 | 1240 | |
@@ -1244,8 +1244,8 @@ discard block |
||
1244 | 1244 | * @param array $query_params |
1245 | 1245 | * @return \EE_Registration[] |
1246 | 1246 | */ |
1247 | - public function payments( $query_params = array() ) { |
|
1248 | - return $this->get_many_related( 'Payment', $query_params ); |
|
1247 | + public function payments($query_params = array()) { |
|
1248 | + return $this->get_many_related('Payment', $query_params); |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | |
@@ -1254,8 +1254,8 @@ discard block |
||
1254 | 1254 | * @param array $query_params |
1255 | 1255 | * @return \EE_Registration[] |
1256 | 1256 | */ |
1257 | - public function registration_payments( $query_params = array() ) { |
|
1258 | - return $this->get_many_related( 'Registration_Payment', $query_params ); |
|
1257 | + public function registration_payments($query_params = array()) { |
|
1258 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | * @access public |
1267 | 1267 | */ |
1268 | 1268 | public function price_paid() { |
1269 | - EE_Error::doing_it_wrong( 'EE_Registration::price_paid()', __( 'This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso' ), '4.7.0' ); |
|
1269 | + EE_Error::doing_it_wrong('EE_Registration::price_paid()', __('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'), '4.7.0'); |
|
1270 | 1270 | return $this->final_price(); |
1271 | 1271 | } |
1272 | 1272 | |
@@ -1278,9 +1278,9 @@ discard block |
||
1278 | 1278 | * @access public |
1279 | 1279 | * @param float $REG_final_price |
1280 | 1280 | */ |
1281 | - public function set_price_paid( $REG_final_price = 0.00 ) { |
|
1282 | - EE_Error::doing_it_wrong( 'EE_Registration::set_price_paid()', __( 'This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso' ), '4.7.0' ); |
|
1283 | - $this->set_final_price( $REG_final_price ); |
|
1281 | + public function set_price_paid($REG_final_price = 0.00) { |
|
1282 | + EE_Error::doing_it_wrong('EE_Registration::set_price_paid()', __('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'), '4.7.0'); |
|
1283 | + $this->set_final_price($REG_final_price); |
|
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | |
@@ -1291,7 +1291,7 @@ discard block |
||
1291 | 1291 | * @return string |
1292 | 1292 | */ |
1293 | 1293 | public function pretty_price_paid() { |
1294 | - EE_Error::doing_it_wrong( 'EE_Registration::pretty_price_paid()', __( 'This method is deprecated, please use EE_Registration::pretty_final_price() instead.', 'event_espresso' ), '4.7.0' ); |
|
1294 | + EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', 'event_espresso'), '4.7.0'); |
|
1295 | 1295 | return $this->pretty_final_price(); |
1296 | 1296 | } |
1297 | 1297 | |
@@ -1305,7 +1305,7 @@ discard block |
||
1305 | 1305 | * @return EE_Payment_Method|null |
1306 | 1306 | */ |
1307 | 1307 | public function payment_method() { |
1308 | - return EEM_Payment_Method::instance()->get_last_used_for_registration( $this ); |
|
1308 | + return EEM_Payment_Method::instance()->get_last_used_for_registration($this); |
|
1309 | 1309 | } |
1310 | 1310 | |
1311 | 1311 |
@@ -167,7 +167,7 @@ |
||
167 | 167 | /** |
168 | 168 | * @param EE_Event $item |
169 | 169 | * |
170 | - * @return mixed|string |
|
170 | + * @return string |
|
171 | 171 | */ |
172 | 172 | public function column_id( EE_Event $item ) { |
173 | 173 | $content = $item->ID(); |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -209,8 +210,9 @@ discard block |
||
209 | 210 | */ |
210 | 211 | protected function _column_name_action_setup( EE_Event $item ) { |
211 | 212 | //todo: remove when attendees is active |
212 | - if ( !defined('REG_ADMIN_URL') ) |
|
213 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
213 | + if ( !defined('REG_ADMIN_URL') ) { |
|
214 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
215 | + } |
|
214 | 216 | |
215 | 217 | $actions = array(); |
216 | 218 | |
@@ -368,8 +370,9 @@ discard block |
||
368 | 370 | */ |
369 | 371 | public function column_actions( EE_Event $item ) { |
370 | 372 | //todo: remove when attendees is active |
371 | - if ( !defined('REG_ADMIN_URL') ) |
|
372 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
373 | + if ( !defined('REG_ADMIN_URL') ) { |
|
374 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
375 | + } |
|
373 | 376 | $actionlinks = array(); |
374 | 377 | |
375 | 378 | $view_link = get_permalink($item->ID()); |
@@ -157,8 +157,8 @@ |
||
157 | 157 | $regs = $item->count_related('Registration'); |
158 | 158 | return $regs > 0 && $this->_view == 'trash' ? '<span class="ee-lock-icon"></span>' : sprintf( |
159 | 159 | '<input type="checkbox" name="EVT_IDs[]" value="%s" />', $item->ID() |
160 | - ); |
|
161 | - } |
|
160 | + ); |
|
161 | + } |
|
162 | 162 | |
163 | 163 | |
164 | 164 | /** |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @param EE_Admin_Page $admin_page |
45 | 45 | */ |
46 | - public function __construct( $admin_page ) { |
|
46 | + public function __construct($admin_page) { |
|
47 | 47 | parent::__construct($admin_page); |
48 | - require_once( EE_HELPERS . 'EEH_DTT_Helper.helper.php' ); |
|
48 | + require_once(EE_HELPERS.'EEH_DTT_Helper.helper.php'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | protected function _setup_data() { |
56 | 56 | $this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page); |
57 | - $this->_all_data_count = $this->_admin_page->get_events(0,0, TRUE); |
|
57 | + $this->_all_data_count = $this->_admin_page->get_events(0, 0, TRUE); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | |
@@ -85,17 +85,17 @@ discard block |
||
85 | 85 | |
86 | 86 | |
87 | 87 | $this->_sortable_columns = array( |
88 | - 'id' => array( 'EVT_ID' => true ), |
|
89 | - 'name' => array( 'EVT_name' => false ), |
|
90 | - 'author' => array( 'EVT_wp_user' => false ), |
|
91 | - 'venue' => array( 'Venue.VNU_name' => false ), |
|
88 | + 'id' => array('EVT_ID' => true), |
|
89 | + 'name' => array('EVT_name' => false), |
|
90 | + 'author' => array('EVT_wp_user' => false), |
|
91 | + 'venue' => array('Venue.VNU_name' => false), |
|
92 | 92 | 'start_date_time' => array('Datetime.DTT_EVT_start' => false), |
93 | 93 | 'reg_begins' => array('Datetime.Ticket.TKT_start_date' => false), |
94 | 94 | ); |
95 | 95 | |
96 | 96 | $this->_primary_column = 'id'; |
97 | 97 | |
98 | - $this->_hidden_columns = array( 'author' ); |
|
98 | + $this->_hidden_columns = array('author'); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | protected function _add_view_counts() { |
114 | 114 | $this->_views['all']['count'] = $this->_admin_page->total_events(); |
115 | 115 | $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
116 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
116 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
117 | 117 | $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
118 | 118 | } |
119 | 119 | } |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return string |
126 | 126 | */ |
127 | - protected function _get_row_class( EE_Event $item ) { |
|
128 | - $class = parent::_get_row_class( $item ); |
|
127 | + protected function _get_row_class(EE_Event $item) { |
|
128 | + $class = parent::_get_row_class($item); |
|
129 | 129 | //add status class |
130 | - $class .= ' ee-status-strip event-status-' . $item->get_active_status(); |
|
131 | - if ( $this->_has_checkbox_column ) { |
|
130 | + $class .= ' ee-status-strip event-status-'.$item->get_active_status(); |
|
131 | + if ($this->_has_checkbox_column) { |
|
132 | 132 | $class .= ' has-checkbox-column'; |
133 | 133 | } |
134 | 134 | return $class; |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return string |
142 | 142 | */ |
143 | - public function column_status( EE_Event $item ) { |
|
144 | - return '<span class="ee-status-strip ee-status-strip-td event-status-' . $item->get_active_status() . '"></span>'; |
|
143 | + public function column_status(EE_Event $item) { |
|
144 | + return '<span class="ee-status-strip ee-status-strip-td event-status-'.$item->get_active_status().'"></span>'; |
|
145 | 145 | }/**/ |
146 | 146 | |
147 | 147 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function column_cb( $item ) { |
|
153 | + public function column_cb($item) { |
|
154 | 154 | $this->_dtt = $item->primary_datetime(); //set this for use in other columns |
155 | 155 | |
156 | 156 | //does event have any attached registrations? |
@@ -166,9 +166,9 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return mixed|string |
168 | 168 | */ |
169 | - public function column_id( EE_Event $item ) { |
|
169 | + public function column_id(EE_Event $item) { |
|
170 | 170 | $content = $item->ID(); |
171 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
171 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->name().'</span>'; |
|
172 | 172 | return $content; |
173 | 173 | } |
174 | 174 | |
@@ -178,16 +178,16 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return string |
180 | 180 | */ |
181 | - public function column_name( EE_Event $item ) { |
|
181 | + public function column_name(EE_Event $item) { |
|
182 | 182 | $edit_query_args = array( |
183 | 183 | 'action' => 'edit', |
184 | 184 | 'post' => $item->ID() |
185 | 185 | ); |
186 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EVENTS_ADMIN_URL ); |
|
187 | - $actions = $this->_column_name_action_setup( $item ); |
|
186 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
187 | + $actions = $this->_column_name_action_setup($item); |
|
188 | 188 | $status = ''; //$item->status() !== 'publish' ? ' (' . $item->status() . ')' : ''; |
189 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $item->name() . '</a></strong>' . $status; |
|
190 | - $content .= '<br><span class="ee-status-text-small">' . EEH_Template::pretty_status( $item->get_active_status(), false, 'sentence' ) . '</span>'; |
|
189 | + $content = '<strong><a class="row-title" href="'.$edit_link.'">'.$item->name().'</a></strong>'.$status; |
|
190 | + $content .= '<br><span class="ee-status-text-small">'.EEH_Template::pretty_status($item->get_active_status(), false, 'sentence').'</span>'; |
|
191 | 191 | $content .= $this->row_actions($actions); |
192 | 192 | return $content; |
193 | 193 | |
@@ -204,72 +204,72 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return array array of actions |
206 | 206 | */ |
207 | - protected function _column_name_action_setup( EE_Event $item ) { |
|
207 | + protected function _column_name_action_setup(EE_Event $item) { |
|
208 | 208 | //todo: remove when attendees is active |
209 | - if ( !defined('REG_ADMIN_URL') ) |
|
209 | + if ( ! defined('REG_ADMIN_URL')) |
|
210 | 210 | define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
211 | 211 | |
212 | 212 | $actions = array(); |
213 | 213 | |
214 | - if ( EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID() ) ) { |
|
214 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) { |
|
215 | 215 | $edit_query_args = array( |
216 | 216 | 'action' => 'edit', |
217 | 217 | 'post' => $item->ID() |
218 | 218 | ); |
219 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EVENTS_ADMIN_URL ); |
|
220 | - $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event', 'event_espresso') . '">' . __('Edit', 'event_espresso') . '</a>'; |
|
219 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
220 | + $actions['edit'] = '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Event', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>'; |
|
221 | 221 | |
222 | 222 | } |
223 | 223 | |
224 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ) { |
|
224 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID())) { |
|
225 | 225 | $attendees_query_args = array( |
226 | 226 | 'action' => 'default', |
227 | 227 | 'event_id' => $item->ID() |
228 | 228 | ); |
229 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce( $attendees_query_args, REG_ADMIN_URL ); |
|
230 | - $actions['attendees'] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrations', 'event_espresso') . '">' . __('Registrations', 'event_espresso') . '</a>'; |
|
229 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
230 | + $actions['attendees'] = '<a href="'.$attendees_link.'" title="'.esc_attr__('View Registrations', 'event_espresso').'">'.__('Registrations', 'event_espresso').'</a>'; |
|
231 | 231 | } |
232 | 232 | |
233 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_trash_event', $item->ID() ) ) { |
|
233 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event', $item->ID())) { |
|
234 | 234 | $trash_event_query_args = array( |
235 | 235 | 'action' => 'trash_event', |
236 | 236 | 'EVT_ID' => $item->ID() |
237 | 237 | ); |
238 | - $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( $trash_event_query_args, EVENTS_ADMIN_URL ); |
|
238 | + $trash_event_link = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_args, EVENTS_ADMIN_URL); |
|
239 | 239 | } |
240 | 240 | |
241 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_restore_event', $item->ID() ) ) { |
|
241 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event', $item->ID())) { |
|
242 | 242 | $restore_event_query_args = array( |
243 | 243 | 'action' => 'restore_event', |
244 | 244 | 'EVT_ID' => $item->ID() |
245 | 245 | ); |
246 | - $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( $restore_event_query_args, EVENTS_ADMIN_URL ); |
|
246 | + $restore_event_link = EE_Admin_Page::add_query_args_and_nonce($restore_event_query_args, EVENTS_ADMIN_URL); |
|
247 | 247 | } |
248 | 248 | |
249 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_delete_event', $item->ID() ) ) { |
|
249 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_delete_event', $item->ID())) { |
|
250 | 250 | $delete_event_query_args = array( |
251 | 251 | 'action' => 'delete_event', |
252 | 252 | 'EVT_ID' => $item->ID() |
253 | 253 | ); |
254 | - $delete_event_link = EE_Admin_Page::add_query_args_and_nonce( $delete_event_query_args, EVENTS_ADMIN_URL ); |
|
254 | + $delete_event_link = EE_Admin_Page::add_query_args_and_nonce($delete_event_query_args, EVENTS_ADMIN_URL); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | $view_link = get_permalink($item->ID()); |
258 | 258 | |
259 | - $actions['view'] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event', 'event_espresso') . '">' . __('View', 'event_espresso') . '</a>'; |
|
259 | + $actions['view'] = '<a href="'.$view_link.'" title="'.esc_attr__('View Event', 'event_espresso').'">'.__('View', 'event_espresso').'</a>'; |
|
260 | 260 | |
261 | - switch ( $item->get( 'status' ) ) { |
|
261 | + switch ($item->get('status')) { |
|
262 | 262 | case 'trash' : |
263 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_restore_event', $item->ID() ) ) { |
|
264 | - $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '" title="' . esc_attr__('Restore from Trash', 'event_espresso') . '">' . __('Restore from Trash', 'event_espresso') . '</a>'; |
|
263 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_restore_event', $item->ID())) { |
|
264 | + $actions['restore_from_trash'] = '<a href="'.$restore_event_link.'" title="'.esc_attr__('Restore from Trash', 'event_espresso').'">'.__('Restore from Trash', 'event_espresso').'</a>'; |
|
265 | 265 | } |
266 | - if ( $item->count_related('Registration') === 0 && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_delete_event', $item->ID() ) ) { |
|
267 | - $actions['delete'] = '<a href="' . $delete_event_link . '" title="' . esc_attr__('Delete Permanently', 'event_espresso') . '">' . __('Delete Permanently', 'event_espresso') . '</a>'; |
|
266 | + if ($item->count_related('Registration') === 0 && EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_delete_event', $item->ID())) { |
|
267 | + $actions['delete'] = '<a href="'.$delete_event_link.'" title="'.esc_attr__('Delete Permanently', 'event_espresso').'">'.__('Delete Permanently', 'event_espresso').'</a>'; |
|
268 | 268 | } |
269 | 269 | break; |
270 | 270 | default : |
271 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_event', 'espresso_events_trash_event', $item->ID() ) ) { |
|
272 | - $actions['move to trash'] = '<a href="' . $trash_event_link . '" title="' . esc_attr__('Trash Event', 'event_espresso') . '">' . __('Trash', 'event_espresso') . '</a>'; |
|
271 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_event', 'espresso_events_trash_event', $item->ID())) { |
|
272 | + $actions['move to trash'] = '<a href="'.$trash_event_link.'" title="'.esc_attr__('Trash Event', 'event_espresso').'">'.__('Trash', 'event_espresso').'</a>'; |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | return $actions; |
@@ -281,17 +281,17 @@ discard block |
||
281 | 281 | * |
282 | 282 | * @return string |
283 | 283 | */ |
284 | - public function column_author( EE_Event $item ) { |
|
284 | + public function column_author(EE_Event $item) { |
|
285 | 285 | //user author info |
286 | - $event_author = get_userdata( $item->wp_user() ); |
|
287 | - $gravatar = get_avatar( $item->wp_user(), '15' ); |
|
286 | + $event_author = get_userdata($item->wp_user()); |
|
287 | + $gravatar = get_avatar($item->wp_user(), '15'); |
|
288 | 288 | //filter link |
289 | 289 | $query_args = array( |
290 | 290 | 'action' => 'default', |
291 | 291 | 'EVT_wp_user' => $item->wp_user() |
292 | 292 | ); |
293 | - $filter_url = EE_Admin_Page::add_query_args_and_nonce( $query_args, EVENTS_ADMIN_URL ); |
|
294 | - return $gravatar . ' <a href="' . $filter_url . '" title="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' . $event_author->display_name . '</a>'; |
|
293 | + $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
294 | + return $gravatar.' <a href="'.$filter_url.'" title="'.esc_attr__('Click to filter events by this author.', 'event_espresso').'">'.$event_author->display_name.'</a>'; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | * |
301 | 301 | * @return string |
302 | 302 | */ |
303 | - public function column_venue( EE_Event $item ) { |
|
304 | - $venue = $item->get_first_related( 'Venue' ); |
|
305 | - return !empty( $venue ) ? $venue->name() : ''; |
|
303 | + public function column_venue(EE_Event $item) { |
|
304 | + $venue = $item->get_first_related('Venue'); |
|
305 | + return ! empty($venue) ? $venue->name() : ''; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | |
@@ -311,10 +311,10 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @throws EE_Error |
313 | 313 | */ |
314 | - public function column_start_date_time( EE_Event $item ) { |
|
315 | - echo !empty( $this->_dtt ) ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') : __('No Date was saved for this Event', 'event_espresso'); |
|
314 | + public function column_start_date_time(EE_Event $item) { |
|
315 | + echo ! empty($this->_dtt) ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') : __('No Date was saved for this Event', 'event_espresso'); |
|
316 | 316 | //display in user's timezone? |
317 | - echo !empty( $this->_dtt ) ? $this->_dtt->display_in_my_timezone('DTT_EVT_start', 'get_i18n_datetime', '', 'My Timezone: ' ) : ''; |
|
317 | + echo ! empty($this->_dtt) ? $this->_dtt->display_in_my_timezone('DTT_EVT_start', 'get_i18n_datetime', '', 'My Timezone: ') : ''; |
|
318 | 318 | |
319 | 319 | } |
320 | 320 | |
@@ -324,11 +324,11 @@ discard block |
||
324 | 324 | * |
325 | 325 | * @throws EE_Error |
326 | 326 | */ |
327 | - public function column_reg_begins( EE_Event $item ) { |
|
327 | + public function column_reg_begins(EE_Event $item) { |
|
328 | 328 | $reg_start = $item->get_ticket_with_earliest_start_time(); |
329 | - echo !empty( $reg_start ) ? $reg_start->get_i18n_datetime('TKT_start_date') : __('No Tickets have been setup for this Event', 'event_espresso'); |
|
329 | + echo ! empty($reg_start) ? $reg_start->get_i18n_datetime('TKT_start_date') : __('No Tickets have been setup for this Event', 'event_espresso'); |
|
330 | 330 | //display in user's timezone? |
331 | - echo !empty( $reg_start ) ? $reg_start->display_in_my_timezone('TKT_start_date', 'get_i18n_datetime', '', 'My Timezone: ' ) : '';/**/ |
|
331 | + echo ! empty($reg_start) ? $reg_start->display_in_my_timezone('TKT_start_date', 'get_i18n_datetime', '', 'My Timezone: ') : ''; /**/ |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | |
@@ -337,14 +337,14 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @return int|string |
339 | 339 | */ |
340 | - public function column_attendees( EE_Event $item ) { |
|
340 | + public function column_attendees(EE_Event $item) { |
|
341 | 341 | $attendees_query_args = array( |
342 | 342 | 'action' => 'default', |
343 | 343 | 'event_id' => $item->ID() |
344 | 344 | ); |
345 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce( $attendees_query_args, REG_ADMIN_URL ); |
|
346 | - $registered_attendees = EEM_Registration::instance()->get_event_registration_count( $item->ID() ); |
|
347 | - return EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' : $registered_attendees; |
|
345 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
346 | + $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID()); |
|
347 | + return EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID()) ? '<a href="'.$attendees_link.'">'.$registered_attendees.'</a>' : $registered_attendees; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | |
@@ -353,8 +353,8 @@ discard block |
||
353 | 353 | * |
354 | 354 | * @return float |
355 | 355 | */ |
356 | - public function column_tkts_sold( EE_Event $item ) { |
|
357 | - return EEM_Ticket::instance()->sum(array( array('Datetime.EVT_ID' => $item->ID() )), 'TKT_sold' ); |
|
356 | + public function column_tkts_sold(EE_Event $item) { |
|
357 | + return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold'); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -363,38 +363,38 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @return string |
365 | 365 | */ |
366 | - public function column_actions( EE_Event $item ) { |
|
366 | + public function column_actions(EE_Event $item) { |
|
367 | 367 | //todo: remove when attendees is active |
368 | - if ( !defined('REG_ADMIN_URL') ) |
|
368 | + if ( ! defined('REG_ADMIN_URL')) |
|
369 | 369 | define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
370 | 370 | $actionlinks = array(); |
371 | 371 | |
372 | 372 | $view_link = get_permalink($item->ID()); |
373 | 373 | |
374 | - $actionlinks[] = '<a href="' . $view_link . '" title="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">'; |
|
374 | + $actionlinks[] = '<a href="'.$view_link.'" title="'.esc_attr__('View Event', 'event_espresso').'" target="_blank">'; |
|
375 | 375 | $actionlinks[] = '<div class="dashicons dashicons-search"></div></a>'; |
376 | 376 | |
377 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'espresso_events_edit', $item->ID() ) ) { |
|
377 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_event', 'espresso_events_edit', $item->ID())) { |
|
378 | 378 | $edit_query_args = array( |
379 | 379 | 'action' => 'edit', |
380 | 380 | 'post' => $item->ID() |
381 | 381 | ); |
382 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( $edit_query_args, EVENTS_ADMIN_URL ); |
|
383 | - $actionlinks[] = '<a href="' . $edit_link . '" title="' . esc_attr__('Edit Event', 'event_espresso') . '"><div class="ee-icon ee-icon-calendar-edit"></div></a>'; |
|
382 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
383 | + $actionlinks[] = '<a href="'.$edit_link.'" title="'.esc_attr__('Edit Event', 'event_espresso').'"><div class="ee-icon ee-icon-calendar-edit"></div></a>'; |
|
384 | 384 | } |
385 | 385 | |
386 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registration', 'espresso_registrations_view_registration', $item->ID() ) ) { |
|
386 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_registration', 'espresso_registrations_view_registration', $item->ID())) { |
|
387 | 387 | $attendees_query_args = array( |
388 | 388 | 'action' => 'default', |
389 | 389 | 'event_id' => $item->ID() |
390 | 390 | ); |
391 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce( $attendees_query_args, REG_ADMIN_URL ); |
|
392 | - $actionlinks[] = '<a href="' . $attendees_link . '" title="' . esc_attr__('View Registrants', 'event_espresso') . '"><div class="dashicons dashicons-groups"></div></a>'; |
|
391 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
392 | + $actionlinks[] = '<a href="'.$attendees_link.'" title="'.esc_attr__('View Registrants', 'event_espresso').'"><div class="dashicons dashicons-groups"></div></a>'; |
|
393 | 393 | } |
394 | 394 | |
395 | - $actionlinks = apply_filters( 'FHEE__Events_Admin_List_Table__column_actions__action_links', $actionlinks, $item ); |
|
395 | + $actionlinks = apply_filters('FHEE__Events_Admin_List_Table__column_actions__action_links', $actionlinks, $item); |
|
396 | 396 | |
397 | - return $this->_action_string( implode( "\n\t", $actionlinks ), $item, 'div' ); |
|
397 | + return $this->_action_string(implode("\n\t", $actionlinks), $item, 'div'); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @return EED_Event_Single_Caff |
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 | |
@@ -50,34 +50,34 @@ discard block |
||
50 | 50 | * @return void |
51 | 51 | */ |
52 | 52 | public static function set_hooks_admin() { |
53 | - define( 'EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path( __FILE__ ) . 'templates' . DS ); |
|
54 | - define( 'EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
53 | + define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS); |
|
54 | + define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
55 | 55 | add_action( |
56 | 56 | 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings', |
57 | - array( 'EED_Event_Single_Caff', 'load_scripts_styles' ), |
|
57 | + array('EED_Event_Single_Caff', 'load_scripts_styles'), |
|
58 | 58 | 10 |
59 | 59 | ); |
60 | - add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Event_Single_Caff', 'template_settings_form' ), 10 ); |
|
61 | - add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Event_Single_Caff', 'update_template_settings' ), 10, 2 ); |
|
60 | + add_action('AHEE__template_settings__template__before_settings_form', array('EED_Event_Single_Caff', 'template_settings_form'), 10); |
|
61 | + add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Event_Single_Caff', 'update_template_settings'), 10, 2); |
|
62 | 62 | // AJAX |
63 | - add_action( 'wp_ajax_espresso_update_event_single_order', array( 'EED_Event_Single_Caff', 'update_event_single_order' ) ); |
|
64 | - add_action( 'wp_ajax_nopriv_espresso_update_event_single_order', array( 'EED_Event_Single_Caff', 'update_event_single_order' ) ); |
|
63 | + add_action('wp_ajax_espresso_update_event_single_order', array('EED_Event_Single_Caff', 'update_event_single_order')); |
|
64 | + add_action('wp_ajax_nopriv_espresso_update_event_single_order', array('EED_Event_Single_Caff', 'update_event_single_order')); |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
68 | 68 | |
69 | 69 | |
70 | 70 | public static function load_scripts_styles() { |
71 | - add_action( 'admin_enqueue_scripts', array( 'EED_Event_Single_Caff', 'enqueue_scripts_styles' ), 10 ); |
|
71 | + add_action('admin_enqueue_scripts', array('EED_Event_Single_Caff', 'enqueue_scripts_styles'), 10); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
75 | 75 | |
76 | 76 | public static function enqueue_scripts_styles() { |
77 | - wp_register_style( 'eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css', array(), EVENT_ESPRESSO_VERSION ); |
|
78 | - wp_enqueue_style( 'eed-event-single-sortable' ); |
|
79 | - wp_register_script( 'eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js', array( 'jquery-ui-sortable' ), EVENT_ESPRESSO_VERSION, true ); |
|
80 | - wp_enqueue_script( 'eed-event-single-sortable' ); |
|
77 | + wp_register_style('eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.css', array(), EVENT_ESPRESSO_VERSION); |
|
78 | + wp_enqueue_style('eed-event-single-sortable'); |
|
79 | + wp_register_script('eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
80 | + wp_enqueue_script('eed-event-single-sortable'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
@@ -91,21 +91,21 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function template_settings_form() { |
93 | 93 | $config = EE_Registry::instance()->CFG->template_settings; |
94 | - $config = isset( $config->EED_Event_Single ) && $config->EED_Event_Single instanceof EE_Event_Single_Config ? $config->EED_Event_Single : new EE_Event_Single_Config(); |
|
95 | - $config->use_sortable_display_order = isset( $config->use_sortable_display_order ) ? $config->use_sortable_display_order : false; |
|
96 | - $config = apply_filters( 'FHEE__EED_Event_Single__template_settings_form__event_list_config', $config ); |
|
94 | + $config = isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config ? $config->EED_Event_Single : new EE_Event_Single_Config(); |
|
95 | + $config->use_sortable_display_order = isset($config->use_sortable_display_order) ? $config->use_sortable_display_order : false; |
|
96 | + $config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config); |
|
97 | 97 | |
98 | 98 | $event_single_order_array = array(); |
99 | - $event_single_order_array[ $config->display_order_tickets ] = 'tickets'; |
|
100 | - $event_single_order_array[ $config->display_order_datetimes ] = 'datetimes'; |
|
101 | - $event_single_order_array[ $config->display_order_event ] = 'event'; |
|
102 | - $event_single_order_array[ $config->display_order_venue ] = 'venue'; |
|
99 | + $event_single_order_array[$config->display_order_tickets] = 'tickets'; |
|
100 | + $event_single_order_array[$config->display_order_datetimes] = 'datetimes'; |
|
101 | + $event_single_order_array[$config->display_order_event] = 'event'; |
|
102 | + $event_single_order_array[$config->display_order_venue] = 'venue'; |
|
103 | 103 | // get template parts |
104 | - $template_parts = EED_Event_Single::instance()->initialize_template_parts( $config ); |
|
104 | + $template_parts = EED_Event_Single::instance()->initialize_template_parts($config); |
|
105 | 105 | // convert to array so that we can add more properties |
106 | - $config = get_object_vars( $config ); |
|
107 | - $config[ 'event_single_display_order' ] = $template_parts->generate_sortable_list_of_template_parts( 'event-single-sortable-js', '', 'single-sortable-li single-sortable-js' ); |
|
108 | - EEH_Template::display_template( EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php', $config ); |
|
106 | + $config = get_object_vars($config); |
|
107 | + $config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts('event-single-sortable-js', '', 'single-sortable-li single-sortable-js'); |
|
108 | + EEH_Template::display_template(EVENT_SINGLE_CAFF_TEMPLATES_PATH.'admin-event-single-settings.template.php', $config); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | |
@@ -118,20 +118,20 @@ discard block |
||
118 | 118 | * @param array $REQ |
119 | 119 | * @return EE_Event_Single_Config |
120 | 120 | */ |
121 | - public static function update_template_settings( $CFG, $REQ ) { |
|
122 | - $display_order_tickets = isset( $CFG->EED_Event_Single->display_order_tickets ) ? $CFG->EED_Event_Single->display_order_tickets : 100; |
|
123 | - $display_order_datetimes = isset( $CFG->EED_Event_Single->display_order_datetimes ) ? $CFG->EED_Event_Single->display_order_datetimes : 110; |
|
124 | - $display_order_event = isset( $CFG->EED_Event_Single->display_order_event ) ? $CFG->EED_Event_Single->display_order_event : 120; |
|
125 | - $display_order_venue = isset( $CFG->EED_Event_Single->display_order_venue ) ? $CFG->EED_Event_Single->display_order_venue : 130; |
|
121 | + public static function update_template_settings($CFG, $REQ) { |
|
122 | + $display_order_tickets = isset($CFG->EED_Event_Single->display_order_tickets) ? $CFG->EED_Event_Single->display_order_tickets : 100; |
|
123 | + $display_order_datetimes = isset($CFG->EED_Event_Single->display_order_datetimes) ? $CFG->EED_Event_Single->display_order_datetimes : 110; |
|
124 | + $display_order_event = isset($CFG->EED_Event_Single->display_order_event) ? $CFG->EED_Event_Single->display_order_event : 120; |
|
125 | + $display_order_venue = isset($CFG->EED_Event_Single->display_order_venue) ? $CFG->EED_Event_Single->display_order_venue : 130; |
|
126 | 126 | $CFG->EED_Event_Single = new EE_Event_Single_Config(); |
127 | - $CFG->EED_Event_Single->display_status_banner_single = !empty( $REQ['display_status_banner_single'] ) && $REQ['display_status_banner_single'] ? TRUE : FALSE; |
|
128 | - $CFG->EED_Event_Single->display_venue = ! empty( $REQ['display_venue'] ) && $REQ['display_venue'] ? TRUE : FALSE; |
|
129 | - $CFG->EED_Event_Single->use_sortable_display_order = ! empty( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] ) ? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] ) : 0; |
|
127 | + $CFG->EED_Event_Single->display_status_banner_single = ! empty($REQ['display_status_banner_single']) && $REQ['display_status_banner_single'] ? TRUE : FALSE; |
|
128 | + $CFG->EED_Event_Single->display_venue = ! empty($REQ['display_venue']) && $REQ['display_venue'] ? TRUE : FALSE; |
|
129 | + $CFG->EED_Event_Single->use_sortable_display_order = ! empty($REQ['EED_Events_Single_use_sortable_display_order']) ? absint($REQ['EED_Events_Single_use_sortable_display_order']) : 0; |
|
130 | 130 | $CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order ? $display_order_tickets : 100; |
131 | 131 | $CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order ? $display_order_datetimes : 110; |
132 | 132 | $CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order ? $display_order_event : 120; |
133 | 133 | $CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order ? $display_order_venue : 130; |
134 | - do_action( 'AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ ); |
|
134 | + do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ); |
|
135 | 135 | return $CFG; |
136 | 136 | } |
137 | 137 | |
@@ -145,23 +145,23 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public static function update_event_single_order() { |
147 | 147 | $config_saved = false; |
148 | - $template_parts = sanitize_text_field( $_POST[ 'elements' ] ); |
|
149 | - if ( ! empty( $template_parts ) ) { |
|
150 | - $template_parts = explode( ',', trim( $template_parts, ',' ) ); |
|
151 | - foreach ( $template_parts as $key => $template_part ) { |
|
148 | + $template_parts = sanitize_text_field($_POST['elements']); |
|
149 | + if ( ! empty($template_parts)) { |
|
150 | + $template_parts = explode(',', trim($template_parts, ',')); |
|
151 | + foreach ($template_parts as $key => $template_part) { |
|
152 | 152 | $template_part = "display_order_$template_part"; |
153 | - $priority = ( $key * 10 ) + 100; |
|
153 | + $priority = ($key * 10) + 100; |
|
154 | 154 | EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority; |
155 | - do_action( "AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority ); |
|
155 | + do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority); |
|
156 | 156 | } |
157 | - $config_saved = EE_Registry::instance()->CFG->update_espresso_config( false, false ); |
|
157 | + $config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false); |
|
158 | 158 | } |
159 | - if ( $config_saved ) { |
|
160 | - EE_Error::add_success( __( 'Display Order has been successfully updated.', 'event_espresso' ) ); |
|
159 | + if ($config_saved) { |
|
160 | + EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso')); |
|
161 | 161 | } else { |
162 | - EE_Error::add_error( __( 'Display Order was not updated.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
162 | + EE_Error::add_error(__('Display Order was not updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
163 | 163 | } |
164 | - echo wp_json_encode( EE_Error::get_notices( false )); |
|
164 | + echo wp_json_encode(EE_Error::get_notices(false)); |
|
165 | 165 | exit(); |
166 | 166 | } |
167 | 167 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param WP $WP |
175 | 175 | * @return void |
176 | 176 | */ |
177 | - public function run( $WP ) { |
|
177 | + public function run($WP) { |
|
178 | 178 | } |
179 | 179 | |
180 | 180 |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @return EED_Events_Archive_Caff |
29 | 29 | */ |
30 | 30 | public static function instance() { |
31 | - return parent::get_instance( __CLASS__ ); |
|
31 | + return parent::get_instance(__CLASS__); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @return void |
50 | 50 | */ |
51 | 51 | public static function set_hooks_admin() { |
52 | - define( 'EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
53 | - define( 'EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
54 | - add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Events_Archive_Caff', 'template_settings_form' ), 10 ); |
|
55 | - add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Events_Archive_Caff', 'update_template_settings' ), 10, 2 ); |
|
52 | + define('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
53 | + define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
54 | + add_action('AHEE__template_settings__template__before_settings_form', array('EED_Events_Archive_Caff', 'template_settings_form'), 10); |
|
55 | + add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Events_Archive_Caff', 'update_template_settings'), 10, 2); |
|
56 | 56 | // AJAX |
57 | - add_action( 'wp_ajax_espresso_update_event_archive_order', array( 'EED_Events_Archive_Caff', 'update_event_archive_order' ) ); |
|
58 | - add_action( 'wp_ajax_nopriv_espresso_update_event_archive_order', array( 'EED_Events_Archive_Caff', 'update_event_archive_order' ) ); |
|
57 | + add_action('wp_ajax_espresso_update_event_archive_order', array('EED_Events_Archive_Caff', 'update_event_archive_order')); |
|
58 | + add_action('wp_ajax_nopriv_espresso_update_event_archive_order', array('EED_Events_Archive_Caff', 'update_event_archive_order')); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param WP $WP |
69 | 69 | * @return void |
70 | 70 | */ |
71 | - public function run( $WP ) { |
|
71 | + public function run($WP) { |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -83,33 +83,33 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public static function template_settings_form() { |
85 | 85 | // grab general settings admin page and remove the existing hook callback |
86 | - $gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object( 'general_settings' ); |
|
87 | - if ( $gen_set_admin instanceof General_Settings_Admin_Page ) { |
|
88 | - remove_action( 'AHEE__template_settings__template__before_settings_form', array( $gen_set_admin, 'template_settings_caff_features' ), 100 ); |
|
86 | + $gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object('general_settings'); |
|
87 | + if ($gen_set_admin instanceof General_Settings_Admin_Page) { |
|
88 | + remove_action('AHEE__template_settings__template__before_settings_form', array($gen_set_admin, 'template_settings_caff_features'), 100); |
|
89 | 89 | } |
90 | 90 | // first just grab the template settings |
91 | 91 | $config = EE_Registry::instance()->CFG->template_settings; |
92 | 92 | // then if the Event Archive config is valid, use that, else create a new one |
93 | - $config = isset( $config->EED_Events_Archive ) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config ? $config->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
94 | - $config = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config ); |
|
95 | - $config->display_status_banner = isset( $config->display_status_banner ) ? $config->display_status_banner : 0; |
|
96 | - $config->display_description = isset( $config->display_description ) ? $config->display_description : 1; |
|
97 | - $config->display_ticket_selector = isset( $config->display_ticket_selector ) ? $config->display_ticket_selector : 0; |
|
98 | - $config->display_datetimes = isset( $config->display_datetimes ) ? $config->display_datetimes : 1; |
|
99 | - $config->display_venue = isset( $config->display_venue ) ? $config->display_venue : 0; |
|
100 | - $config->display_expired_events = isset( $config->display_expired_events ) ? $config->display_expired_events : 0; |
|
93 | + $config = isset($config->EED_Events_Archive) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config ? $config->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
94 | + $config = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config); |
|
95 | + $config->display_status_banner = isset($config->display_status_banner) ? $config->display_status_banner : 0; |
|
96 | + $config->display_description = isset($config->display_description) ? $config->display_description : 1; |
|
97 | + $config->display_ticket_selector = isset($config->display_ticket_selector) ? $config->display_ticket_selector : 0; |
|
98 | + $config->display_datetimes = isset($config->display_datetimes) ? $config->display_datetimes : 1; |
|
99 | + $config->display_venue = isset($config->display_venue) ? $config->display_venue : 0; |
|
100 | + $config->display_expired_events = isset($config->display_expired_events) ? $config->display_expired_events : 0; |
|
101 | 101 | // display order options |
102 | - $config->use_sortable_display_order = isset( $config->use_sortable_display_order )? $config->use_sortable_display_order : false; |
|
103 | - $config->display_order_tickets = isset( $config->display_order_tickets )? $config->display_order_tickets : 100; |
|
104 | - $config->display_order_datetimes = isset( $config->display_order_datetimes )? $config->display_order_datetimes : 110; |
|
105 | - $config->display_order_event = isset( $config->display_order_event )? $config->display_order_event : 120; |
|
106 | - $config->display_order_venue = isset( $config->display_order_venue )? $config->display_order_venue : 130; |
|
102 | + $config->use_sortable_display_order = isset($config->use_sortable_display_order) ? $config->use_sortable_display_order : false; |
|
103 | + $config->display_order_tickets = isset($config->display_order_tickets) ? $config->display_order_tickets : 100; |
|
104 | + $config->display_order_datetimes = isset($config->display_order_datetimes) ? $config->display_order_datetimes : 110; |
|
105 | + $config->display_order_event = isset($config->display_order_event) ? $config->display_order_event : 120; |
|
106 | + $config->display_order_venue = isset($config->display_order_venue) ? $config->display_order_venue : 130; |
|
107 | 107 | // get template parts |
108 | - $template_parts = EED_Events_Archive::instance()->initialize_template_parts( $config ); |
|
108 | + $template_parts = EED_Events_Archive::instance()->initialize_template_parts($config); |
|
109 | 109 | // convert to array so that we can add more properties |
110 | - $config = get_object_vars( $config ); |
|
111 | - $config[ 'event_archive_display_order' ] = $template_parts->generate_sortable_list_of_template_parts( 'event-archive-sortable-js', '', 'archive-sortable-li archive-sortable-js' ); |
|
112 | - EEH_Template::display_template( EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $config ); |
|
110 | + $config = get_object_vars($config); |
|
111 | + $config['event_archive_display_order'] = $template_parts->generate_sortable_list_of_template_parts('event-archive-sortable-js', '', 'archive-sortable-li archive-sortable-js'); |
|
112 | + EEH_Template::display_template(EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH.'admin-event-list-settings.template.php', $config); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
@@ -125,24 +125,24 @@ discard block |
||
125 | 125 | * @param array $REQ |
126 | 126 | * @return EE_Events_Archive_Config |
127 | 127 | */ |
128 | - public static function update_template_settings( $CFG, $REQ ) { |
|
128 | + public static function update_template_settings($CFG, $REQ) { |
|
129 | 129 | $config = new EE_Events_Archive_Config(); |
130 | 130 | // unless we are resetting the config... |
131 | - if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) { |
|
132 | - $config->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0; |
|
133 | - $config->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1; |
|
134 | - $config->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0; |
|
135 | - $config->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1; |
|
136 | - $config->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0; |
|
137 | - $config->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0; |
|
138 | - $config->use_sortable_display_order = isset( $REQ['EED_Events_Archive_use_sortable_display_order'] ) ? absint( $REQ['EED_Events_Archive_use_sortable_display_order'] ) : 0; |
|
139 | - $config->display_order_tickets = isset( $CFG->EED_Events_Archive->display_order_tickets ) && $config->use_sortable_display_order ? $CFG->EED_Events_Archive->display_order_tickets : 100; |
|
140 | - $config->display_order_datetimes = isset( $CFG->EED_Events_Archive->display_order_datetimes ) && $config->use_sortable_display_order ? $CFG->EED_Events_Archive->display_order_datetimes : 110; |
|
141 | - $config->display_order_event = isset( $CFG->EED_Events_Archive->display_order_event ) && $config->use_sortable_display_order ? $CFG->EED_Events_Archive->display_order_event : 120; |
|
142 | - $config->display_order_venue = isset( $CFG->EED_Events_Archive->display_order_venue ) && $config->use_sortable_display_order ? $CFG->EED_Events_Archive->display_order_venue : 130; |
|
131 | + if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) { |
|
132 | + $config->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
133 | + $config->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
134 | + $config->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
135 | + $config->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1; |
|
136 | + $config->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0; |
|
137 | + $config->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; |
|
138 | + $config->use_sortable_display_order = isset($REQ['EED_Events_Archive_use_sortable_display_order']) ? absint($REQ['EED_Events_Archive_use_sortable_display_order']) : 0; |
|
139 | + $config->display_order_tickets = isset($CFG->EED_Events_Archive->display_order_tickets) && $config->use_sortable_display_order ? $CFG->EED_Events_Archive->display_order_tickets : 100; |
|
140 | + $config->display_order_datetimes = isset($CFG->EED_Events_Archive->display_order_datetimes) && $config->use_sortable_display_order ? $CFG->EED_Events_Archive->display_order_datetimes : 110; |
|
141 | + $config->display_order_event = isset($CFG->EED_Events_Archive->display_order_event) && $config->use_sortable_display_order ? $CFG->EED_Events_Archive->display_order_event : 120; |
|
142 | + $config->display_order_venue = isset($CFG->EED_Events_Archive->display_order_venue) && $config->use_sortable_display_order ? $CFG->EED_Events_Archive->display_order_venue : 130; |
|
143 | 143 | } |
144 | 144 | $CFG->EED_Events_Archive = $config; |
145 | - do_action( 'AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ ); |
|
145 | + do_action('AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ); |
|
146 | 146 | return $CFG; |
147 | 147 | } |
148 | 148 | |
@@ -156,12 +156,12 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public static function update_event_archive_order() { |
158 | 158 | $config_saved = false; |
159 | - $template_parts = sanitize_text_field( $_POST[ 'elements' ] ); |
|
160 | - if ( ! empty( $template_parts ) ) { |
|
161 | - $template_parts = explode( ',', trim( $template_parts, ',' ) ); |
|
162 | - foreach ( $template_parts as $key => $template_part ) { |
|
159 | + $template_parts = sanitize_text_field($_POST['elements']); |
|
160 | + if ( ! empty($template_parts)) { |
|
161 | + $template_parts = explode(',', trim($template_parts, ',')); |
|
162 | + foreach ($template_parts as $key => $template_part) { |
|
163 | 163 | $template_part = "display_order_$template_part"; |
164 | - $priority = ( $key * 10 ) + 100; |
|
164 | + $priority = ($key * 10) + 100; |
|
165 | 165 | if ( |
166 | 166 | property_exists( |
167 | 167 | EE_Registry::instance()->CFG->template_settings->EED_Events_Archive, |
@@ -170,16 +170,16 @@ discard block |
||
170 | 170 | ) { |
171 | 171 | EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->{$template_part} = $priority; |
172 | 172 | } |
173 | - do_action( "AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority ); |
|
173 | + do_action("AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority); |
|
174 | 174 | } |
175 | - $config_saved = EE_Registry::instance()->CFG->update_espresso_config( false, false ); |
|
175 | + $config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false); |
|
176 | 176 | } |
177 | - if ( $config_saved ) { |
|
178 | - EE_Error::add_success( __( 'Display Order has been successfully updated.', 'event_espresso' ) ); |
|
177 | + if ($config_saved) { |
|
178 | + EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso')); |
|
179 | 179 | } else { |
180 | - EE_Error::add_error( __( 'Display Order was not updated.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
180 | + EE_Error::add_error(__('Display Order was not updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
181 | 181 | } |
182 | - echo wp_json_encode( EE_Error::get_notices( false ) ); |
|
182 | + echo wp_json_encode(EE_Error::get_notices(false)); |
|
183 | 183 | exit(); |
184 | 184 | } |
185 | 185 |