@@ -1042,88 +1042,88 @@ |
||
| 1042 | 1042 | class EE_Event_List_Query extends WP_Query |
| 1043 | 1043 | { |
| 1044 | 1044 | |
| 1045 | - private $title; |
|
| 1046 | - |
|
| 1047 | - private $css_class; |
|
| 1048 | - |
|
| 1049 | - private $category_slug; |
|
| 1050 | - |
|
| 1051 | - /** |
|
| 1052 | - * EE_Event_List_Query constructor. |
|
| 1053 | - * |
|
| 1054 | - * @param array $args |
|
| 1055 | - */ |
|
| 1056 | - public function __construct($args = array()) |
|
| 1057 | - { |
|
| 1058 | - \EE_Error::doing_it_wrong( |
|
| 1059 | - __METHOD__, |
|
| 1060 | - __( |
|
| 1061 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
| 1062 | - 'event_espresso' |
|
| 1063 | - ), |
|
| 1064 | - '4.9.27', |
|
| 1065 | - '5.0.0' |
|
| 1066 | - ); |
|
| 1067 | - $this->title = isset($args['title']) ? $args['title'] : ''; |
|
| 1068 | - $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
| 1069 | - $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
| 1070 | - $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
| 1071 | - // the current "page" we are viewing |
|
| 1072 | - $paged = max(1, get_query_var('paged')); |
|
| 1073 | - // Force these args |
|
| 1074 | - $args = array_merge( |
|
| 1075 | - $args, array( |
|
| 1076 | - 'post_type' => 'espresso_events', |
|
| 1077 | - 'posts_per_page' => $limit, |
|
| 1078 | - 'update_post_term_cache' => false, |
|
| 1079 | - 'update_post_meta_cache' => false, |
|
| 1080 | - 'paged' => $paged, |
|
| 1081 | - 'offset' => ($paged - 1) * $limit |
|
| 1082 | - ) |
|
| 1083 | - ); |
|
| 1084 | - // run the query |
|
| 1085 | - parent::__construct($args); |
|
| 1086 | - } |
|
| 1087 | - |
|
| 1088 | - |
|
| 1089 | - |
|
| 1090 | - /** |
|
| 1091 | - * event_list_title |
|
| 1092 | - * |
|
| 1093 | - * @param string $event_list_title |
|
| 1094 | - * @return string |
|
| 1095 | - */ |
|
| 1096 | - public function event_list_title($event_list_title = '') |
|
| 1097 | - { |
|
| 1098 | - if (! empty($this->title)) { |
|
| 1099 | - return $this->title; |
|
| 1100 | - } |
|
| 1101 | - return $event_list_title; |
|
| 1102 | - } |
|
| 1103 | - |
|
| 1104 | - |
|
| 1105 | - |
|
| 1106 | - /** |
|
| 1107 | - * event_list_css |
|
| 1108 | - * |
|
| 1109 | - * @param string $event_list_css |
|
| 1110 | - * @return string |
|
| 1111 | - */ |
|
| 1112 | - public function event_list_css($event_list_css = '') |
|
| 1113 | - { |
|
| 1114 | - $event_list_css .= ! empty($event_list_css) |
|
| 1115 | - ? ' ' |
|
| 1116 | - : ''; |
|
| 1117 | - $event_list_css .= ! empty($this->css_class) |
|
| 1118 | - ? $this->css_class |
|
| 1119 | - : ''; |
|
| 1120 | - $event_list_css .= ! empty($event_list_css) |
|
| 1121 | - ? ' ' |
|
| 1122 | - : ''; |
|
| 1123 | - $event_list_css .= ! empty($this->category_slug) |
|
| 1124 | - ? $this->category_slug |
|
| 1125 | - : ''; |
|
| 1126 | - return $event_list_css; |
|
| 1127 | - } |
|
| 1045 | + private $title; |
|
| 1046 | + |
|
| 1047 | + private $css_class; |
|
| 1048 | + |
|
| 1049 | + private $category_slug; |
|
| 1050 | + |
|
| 1051 | + /** |
|
| 1052 | + * EE_Event_List_Query constructor. |
|
| 1053 | + * |
|
| 1054 | + * @param array $args |
|
| 1055 | + */ |
|
| 1056 | + public function __construct($args = array()) |
|
| 1057 | + { |
|
| 1058 | + \EE_Error::doing_it_wrong( |
|
| 1059 | + __METHOD__, |
|
| 1060 | + __( |
|
| 1061 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.', |
|
| 1062 | + 'event_espresso' |
|
| 1063 | + ), |
|
| 1064 | + '4.9.27', |
|
| 1065 | + '5.0.0' |
|
| 1066 | + ); |
|
| 1067 | + $this->title = isset($args['title']) ? $args['title'] : ''; |
|
| 1068 | + $this->css_class = isset($args['css_class']) ? $args['css_class'] : ''; |
|
| 1069 | + $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : ''; |
|
| 1070 | + $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10; |
|
| 1071 | + // the current "page" we are viewing |
|
| 1072 | + $paged = max(1, get_query_var('paged')); |
|
| 1073 | + // Force these args |
|
| 1074 | + $args = array_merge( |
|
| 1075 | + $args, array( |
|
| 1076 | + 'post_type' => 'espresso_events', |
|
| 1077 | + 'posts_per_page' => $limit, |
|
| 1078 | + 'update_post_term_cache' => false, |
|
| 1079 | + 'update_post_meta_cache' => false, |
|
| 1080 | + 'paged' => $paged, |
|
| 1081 | + 'offset' => ($paged - 1) * $limit |
|
| 1082 | + ) |
|
| 1083 | + ); |
|
| 1084 | + // run the query |
|
| 1085 | + parent::__construct($args); |
|
| 1086 | + } |
|
| 1087 | + |
|
| 1088 | + |
|
| 1089 | + |
|
| 1090 | + /** |
|
| 1091 | + * event_list_title |
|
| 1092 | + * |
|
| 1093 | + * @param string $event_list_title |
|
| 1094 | + * @return string |
|
| 1095 | + */ |
|
| 1096 | + public function event_list_title($event_list_title = '') |
|
| 1097 | + { |
|
| 1098 | + if (! empty($this->title)) { |
|
| 1099 | + return $this->title; |
|
| 1100 | + } |
|
| 1101 | + return $event_list_title; |
|
| 1102 | + } |
|
| 1103 | + |
|
| 1104 | + |
|
| 1105 | + |
|
| 1106 | + /** |
|
| 1107 | + * event_list_css |
|
| 1108 | + * |
|
| 1109 | + * @param string $event_list_css |
|
| 1110 | + * @return string |
|
| 1111 | + */ |
|
| 1112 | + public function event_list_css($event_list_css = '') |
|
| 1113 | + { |
|
| 1114 | + $event_list_css .= ! empty($event_list_css) |
|
| 1115 | + ? ' ' |
|
| 1116 | + : ''; |
|
| 1117 | + $event_list_css .= ! empty($this->css_class) |
|
| 1118 | + ? $this->css_class |
|
| 1119 | + : ''; |
|
| 1120 | + $event_list_css .= ! empty($event_list_css) |
|
| 1121 | + ? ' ' |
|
| 1122 | + : ''; |
|
| 1123 | + $event_list_css .= ! empty($this->category_slug) |
|
| 1124 | + ? $this->category_slug |
|
| 1125 | + : ''; |
|
| 1126 | + return $event_list_css; |
|
| 1127 | + } |
|
| 1128 | 1128 | |
| 1129 | 1129 | } |
@@ -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 | * ************************************************************************ |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | $action_or_filter = 'action' |
| 44 | 44 | ) { |
| 45 | 45 | $action_or_filter = $action_or_filter === 'action' |
| 46 | - ? esc_html__( 'action', 'event_espresso' ) |
|
| 47 | - : esc_html__( 'filter', 'event_espresso' ); |
|
| 46 | + ? esc_html__('action', 'event_espresso') |
|
| 47 | + : esc_html__('filter', 'event_espresso'); |
|
| 48 | 48 | EE_Error::doing_it_wrong( |
| 49 | 49 | $deprecated_filter, |
| 50 | 50 | sprintf( |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param \EE_Checkout $checkout |
| 69 | 69 | * @return string |
| 70 | 70 | */ |
| 71 | -function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) { |
|
| 71 | +function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) { |
|
| 72 | 72 | // list of old filters |
| 73 | 73 | $deprecated_filters = array( |
| 74 | 74 | 'update_registration_details' => true, |
@@ -78,16 +78,16 @@ discard block |
||
| 78 | 78 | 'proceed_to' => true, |
| 79 | 79 | ); |
| 80 | 80 | // loop thru and call doing_it_wrong() or remove any that aren't being used |
| 81 | - foreach ( $deprecated_filters as $deprecated_filter => $on ) { |
|
| 81 | + foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
| 82 | 82 | // was this filter called ? |
| 83 | - if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) { |
|
| 83 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) { |
|
| 84 | 84 | // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
| 85 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) { |
|
| 85 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) { |
|
| 86 | 86 | EE_Error::doing_it_wrong( |
| 87 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
| 87 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
| 88 | 88 | sprintf( |
| 89 | - __( 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ), |
|
| 90 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
| 89 | + __('The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'), |
|
| 90 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
| 91 | 91 | '<br />', |
| 92 | 92 | 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
| 93 | 93 | '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
@@ -96,24 +96,24 @@ discard block |
||
| 96 | 96 | ); |
| 97 | 97 | } |
| 98 | 98 | } else { |
| 99 | - unset( $deprecated_filters[ $deprecated_filter ] ); |
|
| 99 | + unset($deprecated_filters[$deprecated_filter]); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | - if ( ! empty( $deprecated_filters )) { |
|
| 103 | - |
|
| 104 | - if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) { |
|
| 105 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text ); |
|
| 106 | - } else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) { |
|
| 107 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text ); |
|
| 108 | - } else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) { |
|
| 109 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text ); |
|
| 102 | + if ( ! empty($deprecated_filters)) { |
|
| 103 | + |
|
| 104 | + if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
| 105 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text); |
|
| 106 | + } else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
| 107 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text); |
|
| 108 | + } else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
| 109 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text); |
|
| 110 | 110 | } |
| 111 | - if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
| 112 | - if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) { |
|
| 113 | - $submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text ); |
|
| 111 | + if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 112 | + if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
| 113 | + $submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text); |
|
| 114 | 114 | } |
| 115 | - if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) { |
|
| 116 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name(); |
|
| 115 | + if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
| 116 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name(); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | return $submit_button_text; |
| 122 | 122 | |
| 123 | 123 | } |
| 124 | -add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 ); |
|
| 124 | +add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2); |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | |
@@ -132,16 +132,16 @@ discard block |
||
| 132 | 132 | * @param \EE_Checkout $checkout |
| 133 | 133 | * @param boolean $status_updates |
| 134 | 134 | */ |
| 135 | -function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) { |
|
| 135 | +function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) { |
|
| 136 | 136 | $action_ref = NULL; |
| 137 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
| 138 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
| 139 | - if ( $action_ref ) { |
|
| 137 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
| 138 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
| 139 | + if ($action_ref) { |
|
| 140 | 140 | |
| 141 | 141 | EE_Error::doing_it_wrong( |
| 142 | 142 | $action_ref, |
| 143 | 143 | sprintf( |
| 144 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ), |
|
| 144 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'), |
|
| 145 | 145 | '<br />', |
| 146 | 146 | '/core/business/EE_Transaction_Processor.class.php', |
| 147 | 147 | 'AHEE__EE_Transaction_Processor__finalize', |
@@ -151,39 +151,39 @@ discard block |
||
| 151 | 151 | ), |
| 152 | 152 | '4.6.0' |
| 153 | 153 | ); |
| 154 | - switch ( $action_ref ) { |
|
| 154 | + switch ($action_ref) { |
|
| 155 | 155 | case 'AHEE__EE_Transaction__finalize__new_transaction' : |
| 156 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request ); |
|
| 156 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request); |
|
| 157 | 157 | break; |
| 158 | 158 | case 'AHEE__EE_Transaction__finalize__all_transaction' : |
| 159 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request ); |
|
| 159 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request); |
|
| 160 | 160 | break; |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | -add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 ); |
|
| 164 | +add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2); |
|
| 165 | 165 | /** |
| 166 | 166 | * ee_deprecated_finalize_registration |
| 167 | 167 | * |
| 168 | 168 | * @param EE_Registration $registration |
| 169 | 169 | */ |
| 170 | -function ee_deprecated_finalize_registration( EE_Registration $registration ) { |
|
| 171 | - $action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
| 172 | - if ( $action_ref ) { |
|
| 170 | +function ee_deprecated_finalize_registration(EE_Registration $registration) { |
|
| 171 | + $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
| 172 | + if ($action_ref) { |
|
| 173 | 173 | EE_Error::doing_it_wrong( |
| 174 | 174 | $action_ref, |
| 175 | 175 | sprintf( |
| 176 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ), |
|
| 176 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'), |
|
| 177 | 177 | '<br />', |
| 178 | 178 | '/core/business/EE_Registration_Processor.class.php', |
| 179 | 179 | 'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook' |
| 180 | 180 | ), |
| 181 | 181 | '4.6.0' |
| 182 | 182 | ); |
| 183 | - do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ))); |
|
| 183 | + do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | -add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 ); |
|
| 186 | +add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1); |
|
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called. |
| 192 | 192 | * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately. |
| 193 | 193 | */ |
| 194 | -function ee_deprecated_hooks(){ |
|
| 194 | +function ee_deprecated_hooks() { |
|
| 195 | 195 | /** |
| 196 | 196 | * @var $hooks array where keys are hook names, and their values are array{ |
| 197 | 197 | * @type string $version when deprecated |
@@ -202,25 +202,25 @@ discard block |
||
| 202 | 202 | $hooks = array( |
| 203 | 203 | 'AHEE__EE_System___do_setup_validations' => array( |
| 204 | 204 | 'version' => '4.6.0', |
| 205 | - 'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ), |
|
| 205 | + 'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'), |
|
| 206 | 206 | 'still_works' => FALSE |
| 207 | 207 | ) |
| 208 | 208 | ); |
| 209 | - foreach( $hooks as $name => $deprecation_info ){ |
|
| 210 | - if( has_action( $name ) ){ |
|
| 209 | + foreach ($hooks as $name => $deprecation_info) { |
|
| 210 | + if (has_action($name)) { |
|
| 211 | 211 | EE_Error::doing_it_wrong( |
| 212 | 212 | $name, |
| 213 | 213 | sprintf( |
| 214 | - __('This filter is deprecated. %1$s%2$s','event_espresso'), |
|
| 215 | - $deprecation_info[ 'still_works' ] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ), |
|
| 216 | - isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' ) |
|
| 214 | + __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
| 215 | + $deprecation_info['still_works'] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'), |
|
| 216 | + isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso') |
|
| 217 | 217 | ), |
| 218 | - isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' ) |
|
| 218 | + isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso') |
|
| 219 | 219 | ); |
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | -add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' ); |
|
| 223 | +add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks'); |
|
| 224 | 224 | |
| 225 | 225 | |
| 226 | 226 | |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | * @return boolean |
| 232 | 232 | */ |
| 233 | 233 | function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() { |
| 234 | - $in_use = has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' ) |
|
| 235 | - || has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' ); |
|
| 236 | - if( $in_use ) { |
|
| 234 | + $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
| 235 | + || has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'); |
|
| 236 | + if ($in_use) { |
|
| 237 | 237 | $msg = __( |
| 238 | 238 | 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
| 239 | 239 | . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
@@ -242,18 +242,18 @@ discard block |
||
| 242 | 242 | 'event_espresso' ) |
| 243 | 243 | ; |
| 244 | 244 | EE_Error::doing_it_wrong( |
| 245 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 245 | + __CLASS__.'::'.__FUNCTION__, |
|
| 246 | 246 | $msg, |
| 247 | 247 | '4.8.32.rc.000' |
| 248 | 248 | ); |
| 249 | 249 | //it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
| 250 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 251 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 250 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
| 251 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | return $in_use; |
| 255 | 255 | } |
| 256 | -add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' ); |
|
| 256 | +add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'); |
|
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | 259 | * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165 |
@@ -262,34 +262,34 @@ discard block |
||
| 262 | 262 | * @param EE_Admin_Page $admin_page |
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | -function ee_deprecated_update_attendee_registration_form_old( $admin_page ) { |
|
| 265 | +function ee_deprecated_update_attendee_registration_form_old($admin_page) { |
|
| 266 | 266 | //check if the old hooks are in use. If not, do the default |
| 267 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 268 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
| 267 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 268 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
| 269 | 269 | return; |
| 270 | 270 | } |
| 271 | 271 | $req_data = $admin_page->get_request_data(); |
| 272 | - $qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE; |
|
| 273 | - $REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE; |
|
| 274 | - $qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns ); |
|
| 275 | - if ( ! $REG_ID || ! $qstns ) { |
|
| 276 | - EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 272 | + $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE; |
|
| 273 | + $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE; |
|
| 274 | + $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
| 275 | + if ( ! $REG_ID || ! $qstns) { |
|
| 276 | + EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 277 | 277 | } |
| 278 | 278 | $success = TRUE; |
| 279 | 279 | |
| 280 | 280 | // allow others to get in on this awesome fun :D |
| 281 | - do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns ); |
|
| 281 | + do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns); |
|
| 282 | 282 | // loop thru questions... FINALLY!!! |
| 283 | 283 | |
| 284 | - foreach ( $qstns as $QST_ID => $qstn ) { |
|
| 284 | + foreach ($qstns as $QST_ID => $qstn) { |
|
| 285 | 285 | //if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
| 286 | - if ( !is_array($qstn) ) { |
|
| 287 | - $success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn); |
|
| 286 | + if ( ! is_array($qstn)) { |
|
| 287 | + $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
| 288 | 288 | continue; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
| 292 | - foreach ( $qstn as $ANS_ID => $ANS_value ) { |
|
| 292 | + foreach ($qstn as $ANS_ID => $ANS_value) { |
|
| 293 | 293 | //get answer |
| 294 | 294 | $query_params = array( |
| 295 | 295 | 0 => array( |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | ); |
| 301 | 301 | $answer = EEM_Answer::instance()->get_one($query_params); |
| 302 | 302 | //this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
| 303 | - if ( ! $answer instanceof EE_Answer ) { |
|
| 303 | + if ( ! $answer instanceof EE_Answer) { |
|
| 304 | 304 | $set_values = array( |
| 305 | 305 | 'QST_ID' => $QST_ID, |
| 306 | 306 | 'REG_ID' => $REG_ID, |
@@ -315,11 +315,11 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | $what = __('Registration Form', 'event_espresso'); |
| 318 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
| 319 | - $admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
| 318 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
| 319 | + $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
| 320 | 320 | exit; |
| 321 | 321 | } |
| 322 | -add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 ); |
|
| 322 | +add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1); |
|
| 323 | 323 | /** |
| 324 | 324 | * Render the registration admin page's custom questions area in the old fashion |
| 325 | 325 | * and firing the old hooks. When this method is removed, we can probably also |
@@ -332,31 +332,31 @@ discard block |
||
| 332 | 332 | * @return bool |
| 333 | 333 | * @throws \EE_Error |
| 334 | 334 | */ |
| 335 | -function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) { |
|
| 335 | +function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) { |
|
| 336 | 336 | //check if the old hooks are in use. If not, do the default |
| 337 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 338 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
| 337 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 338 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
| 339 | 339 | return $do_default_action; |
| 340 | 340 | } |
| 341 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 ); |
|
| 342 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 ); |
|
| 343 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 ); |
|
| 344 | - add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 ); |
|
| 341 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1); |
|
| 342 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1); |
|
| 343 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
| 344 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
| 345 | 345 | |
| 346 | - $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') ); |
|
| 346 | + $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID')); |
|
| 347 | 347 | |
| 348 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
| 348 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
| 349 | 349 | $template_args = array( |
| 350 | - 'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ), |
|
| 350 | + 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
| 351 | 351 | 'reg_questions_form_action' => 'edit_registration', |
| 352 | 352 | 'REG_ID' => $registration->ID() |
| 353 | 353 | ); |
| 354 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 355 | - echo EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
| 354 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 355 | + echo EEH_Template::display_template($template_path, $template_args, TRUE); |
|
| 356 | 356 | //indicate that we should not do the default admin page code |
| 357 | 357 | return false; |
| 358 | 358 | } |
| 359 | -add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 ); |
|
| 359 | +add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3); |
|
| 360 | 360 | |
| 361 | 361 | |
| 362 | 362 | |
@@ -397,9 +397,9 @@ discard block |
||
| 397 | 397 | '4.9.0' |
| 398 | 398 | ); |
| 399 | 399 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
| 400 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 401 | - $messenger = $message_resource_manager->get_messenger( $messenger_name ); |
|
| 402 | - $message_type = $message_resource_manager->get_message_type( $message_type_name ); |
|
| 400 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 401 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
| 402 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
| 403 | 403 | return EE_Registry::instance()->load_lib( |
| 404 | 404 | 'Messages_Template_Defaults', |
| 405 | 405 | array( |
@@ -464,15 +464,15 @@ discard block |
||
| 464 | 464 | /** |
| 465 | 465 | * @param string $method |
| 466 | 466 | */ |
| 467 | - public function _class_is_deprecated( $method ) { |
|
| 467 | + public function _class_is_deprecated($method) { |
|
| 468 | 468 | EE_Error::doing_it_wrong( |
| 469 | - 'EE_messages::' . $method, |
|
| 470 | - __( 'EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.' ), |
|
| 469 | + 'EE_messages::'.$method, |
|
| 470 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
| 471 | 471 | '4.9.0', |
| 472 | 472 | '4.10.0.p' |
| 473 | 473 | ); |
| 474 | 474 | // Please use EE_Message_Resource_Manager instead |
| 475 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 475 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | |
@@ -482,10 +482,10 @@ discard block |
||
| 482 | 482 | * @param string $messenger_name |
| 483 | 483 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
| 484 | 484 | */ |
| 485 | - public function ensure_messenger_is_active( $messenger_name ) { |
|
| 485 | + public function ensure_messenger_is_active($messenger_name) { |
|
| 486 | 486 | // EE_messages has been deprecated |
| 487 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 488 | - return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name ); |
|
| 487 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 488 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | |
@@ -497,10 +497,10 @@ discard block |
||
| 497 | 497 | * @return bool true if it got activated (or was active) and false if not. |
| 498 | 498 | * @throws \EE_Error |
| 499 | 499 | */ |
| 500 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
| 500 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
| 501 | 501 | // EE_messages has been deprecated |
| 502 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 503 | - return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger ); |
|
| 502 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 503 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | |
@@ -513,10 +513,10 @@ discard block |
||
| 513 | 513 | * they are already setup.) |
| 514 | 514 | * @return boolean an array of generated templates or false if nothing generated/activated. |
| 515 | 515 | */ |
| 516 | - public function activate_messenger( $messenger_name, $mts_to_activate = array() ) { |
|
| 516 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) { |
|
| 517 | 517 | // EE_messages has been deprecated |
| 518 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 519 | - return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate ); |
|
| 518 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 519 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | |
@@ -528,10 +528,10 @@ discard block |
||
| 528 | 528 | * |
| 529 | 529 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
| 530 | 530 | */ |
| 531 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
| 531 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
| 532 | 532 | // EE_messages has been deprecated |
| 533 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 534 | - return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type ); |
|
| 533 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 534 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | |
@@ -541,10 +541,10 @@ discard block |
||
| 541 | 541 | * @param string $messenger |
| 542 | 542 | * @return EE_messenger | null |
| 543 | 543 | */ |
| 544 | - public function get_messenger_if_active( $messenger ) { |
|
| 544 | + public function get_messenger_if_active($messenger) { |
|
| 545 | 545 | // EE_messages has been deprecated |
| 546 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 547 | - return $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
| 546 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 547 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | |
@@ -565,9 +565,9 @@ discard block |
||
| 565 | 565 | * 'message_type' => null |
| 566 | 566 | * ) |
| 567 | 567 | */ |
| 568 | - public function validate_for_use( EE_Message $message ) { |
|
| 568 | + public function validate_for_use(EE_Message $message) { |
|
| 569 | 569 | // EE_messages has been deprecated |
| 570 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 570 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 571 | 571 | return array( |
| 572 | 572 | 'messenger' => $message->messenger_object(), |
| 573 | 573 | 'message_type' => $message->message_type_object(), |
@@ -595,41 +595,41 @@ discard block |
||
| 595 | 595 | $send = true |
| 596 | 596 | ) { |
| 597 | 597 | // EE_messages has been deprecated |
| 598 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 598 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 599 | 599 | /** @type EE_Messages_Processor $processor */ |
| 600 | - $processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
| 600 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
| 601 | 601 | $error = false; |
| 602 | 602 | //try to intelligently determine what method we'll call based on the incoming data. |
| 603 | 603 | //if generating and sending are different then generate and send immediately. |
| 604 | - if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) { |
|
| 604 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
| 605 | 605 | //in the legacy system, when generating and sending were different, that means all the |
| 606 | 606 | //vars are already in the request object. So let's just use that. |
| 607 | 607 | try { |
| 608 | 608 | /** @type EE_Message_To_Generate_From_Request $mtg */ |
| 609 | - $mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
| 610 | - $processor->generate_and_send_now( $mtg ); |
|
| 611 | - } catch ( EE_Error $e ) { |
|
| 609 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
| 610 | + $processor->generate_and_send_now($mtg); |
|
| 611 | + } catch (EE_Error $e) { |
|
| 612 | 612 | $error_msg = __( |
| 613 | 613 | 'Please note that a system message failed to send due to a technical issue.', |
| 614 | 614 | 'event_espresso' |
| 615 | 615 | ); |
| 616 | 616 | // add specific message for developers if WP_DEBUG in on |
| 617 | - $error_msg .= '||' . $e->getMessage(); |
|
| 618 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 617 | + $error_msg .= '||'.$e->getMessage(); |
|
| 618 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 619 | 619 | $error = true; |
| 620 | 620 | } |
| 621 | 621 | } else { |
| 622 | - $processor->generate_for_all_active_messengers( $type, $vars, $send ); |
|
| 622 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
| 623 | 623 | //let's find out if there were any errors and how many successfully were queued. |
| 624 | 624 | $count_errors = $processor->get_queue()->count_STS_in_queue( |
| 625 | - array( EEM_Message::status_failed, EEM_Message::status_debug_only ) |
|
| 625 | + array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
| 626 | 626 | ); |
| 627 | - $count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
| 628 | - $count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry ); |
|
| 627 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
| 628 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
| 629 | 629 | $count_errors = $count_errors + $count_retry; |
| 630 | - if ( $count_errors > 0 ) { |
|
| 630 | + if ($count_errors > 0) { |
|
| 631 | 631 | $error = true; |
| 632 | - if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) { |
|
| 632 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
| 633 | 633 | $message = sprintf( |
| 634 | 634 | __( |
| 635 | 635 | 'There were %d errors and %d messages successfully queued for generation and sending', |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | $count_errors, |
| 639 | 639 | $count_queued |
| 640 | 640 | ); |
| 641 | - } elseif ( $count_errors > 1 && $count_queued === 1 ) { |
|
| 641 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
| 642 | 642 | $message = sprintf( |
| 643 | 643 | __( |
| 644 | 644 | 'There were %d errors and %d message successfully queued for generation.', |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | $count_errors, |
| 648 | 648 | $count_queued |
| 649 | 649 | ); |
| 650 | - } elseif ( $count_errors === 1 && $count_queued > 1 ) { |
|
| 650 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
| 651 | 651 | $message = sprintf( |
| 652 | 652 | __( |
| 653 | 653 | 'There was %d error and %d messages successfully queued for generation.', |
@@ -665,9 +665,9 @@ discard block |
||
| 665 | 665 | $count_errors |
| 666 | 666 | ); |
| 667 | 667 | } |
| 668 | - EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 668 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
| 669 | 669 | } else { |
| 670 | - if ( $count_queued === 1 ) { |
|
| 670 | + if ($count_queued === 1) { |
|
| 671 | 671 | $message = sprintf( |
| 672 | 672 | __( |
| 673 | 673 | '%d message successfully queued for generation.', |
@@ -684,18 +684,18 @@ discard block |
||
| 684 | 684 | $count_queued |
| 685 | 685 | ); |
| 686 | 686 | } |
| 687 | - EE_Error::add_success( $message ); |
|
| 687 | + EE_Error::add_success($message); |
|
| 688 | 688 | } |
| 689 | 689 | } |
| 690 | 690 | //if no error then return the generated message(s). |
| 691 | - if ( ! $error && ! $send ) { |
|
| 692 | - $generated_queue = $processor->generate_queue( false ); |
|
| 691 | + if ( ! $error && ! $send) { |
|
| 692 | + $generated_queue = $processor->generate_queue(false); |
|
| 693 | 693 | //get message and return. |
| 694 | 694 | $generated_queue->get_message_repository()->rewind(); |
| 695 | 695 | $messages = array(); |
| 696 | - while ( $generated_queue->get_message_repository()->valid() ) { |
|
| 696 | + while ($generated_queue->get_message_repository()->valid()) { |
|
| 697 | 697 | $message = $generated_queue->get_message_repository()->current(); |
| 698 | - if ( $message instanceof EE_Message ) { |
|
| 698 | + if ($message instanceof EE_Message) { |
|
| 699 | 699 | //set properties that might be expected by add-ons (backward compat) |
| 700 | 700 | $message->content = $message->content(); |
| 701 | 701 | $message->template_pack = $message->get_template_pack(); |
@@ -720,10 +720,10 @@ discard block |
||
| 720 | 720 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
| 721 | 721 | * @return string The body of the message. |
| 722 | 722 | */ |
| 723 | - public function preview_message( $type, $context, $messenger, $send = false ) { |
|
| 723 | + public function preview_message($type, $context, $messenger, $send = false) { |
|
| 724 | 724 | // EE_messages has been deprecated |
| 725 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 726 | - return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
|
| 725 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 726 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | |
@@ -737,14 +737,14 @@ discard block |
||
| 737 | 737 | * |
| 738 | 738 | * @return bool success or fail. |
| 739 | 739 | */ |
| 740 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
| 740 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
| 741 | 741 | // EE_messages has been deprecated |
| 742 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 742 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 743 | 743 | //setup for sending to new method. |
| 744 | 744 | /** @type EE_Messages_Queue $queue */ |
| 745 | - $queue = EE_Registry::instance()->load_lib( 'Messages_Queue' ); |
|
| 745 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
| 746 | 746 | //make sure we have a proper message object |
| 747 | - if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) { |
|
| 747 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
| 748 | 748 | $msg = EE_Message_Factory::create( |
| 749 | 749 | array( |
| 750 | 750 | 'MSG_messenger' => $messenger, |
@@ -756,15 +756,15 @@ discard block |
||
| 756 | 756 | } else { |
| 757 | 757 | $msg = $message; |
| 758 | 758 | } |
| 759 | - if ( ! $msg instanceof EE_Message ) { |
|
| 759 | + if ( ! $msg instanceof EE_Message) { |
|
| 760 | 760 | return false; |
| 761 | 761 | } |
| 762 | 762 | //make sure any content in a content property (if not empty) is set on the MSG_content. |
| 763 | - if ( ! empty( $msg->content ) ) { |
|
| 764 | - $msg->set( 'MSG_content', $msg->content ); |
|
| 763 | + if ( ! empty($msg->content)) { |
|
| 764 | + $msg->set('MSG_content', $msg->content); |
|
| 765 | 765 | } |
| 766 | - $queue->add( $msg ); |
|
| 767 | - return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue ); |
|
| 766 | + $queue->add($msg); |
|
| 767 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | |
@@ -778,11 +778,11 @@ discard block |
||
| 778 | 778 | * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned. |
| 779 | 779 | * @throws \EE_Error |
| 780 | 780 | */ |
| 781 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
| 781 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
| 782 | 782 | // EE_messages has been deprecated |
| 783 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 784 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 785 | - return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global ); |
|
| 783 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 784 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 785 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | |
@@ -793,11 +793,11 @@ discard block |
||
| 793 | 793 | * @param string $message_type_name name of EE_message_type |
| 794 | 794 | * @return array |
| 795 | 795 | */ |
| 796 | - public function get_fields( $messenger_name, $message_type_name ) { |
|
| 796 | + public function get_fields($messenger_name, $message_type_name) { |
|
| 797 | 797 | // EE_messages has been deprecated |
| 798 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 799 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 800 | - return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name ); |
|
| 798 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 799 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 800 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | |
@@ -811,13 +811,13 @@ discard block |
||
| 811 | 811 | * @return array multidimensional array of messenger and message_type objects |
| 812 | 812 | * (messengers index, and message_type index); |
| 813 | 813 | */ |
| 814 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
| 814 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
| 815 | 815 | // EE_messages has been deprecated |
| 816 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 817 | - if ( $skip_cache ) { |
|
| 816 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 817 | + if ($skip_cache) { |
|
| 818 | 818 | $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
| 819 | 819 | } |
| 820 | - switch ( $type ) { |
|
| 820 | + switch ($type) { |
|
| 821 | 821 | case 'messengers' : |
| 822 | 822 | return array( |
| 823 | 823 | 'messenger' => $this->_message_resource_manager->installed_messengers(), |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | */ |
| 847 | 847 | public function get_active_messengers() { |
| 848 | 848 | // EE_messages has been deprecated |
| 849 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 849 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 850 | 850 | return $this->_message_resource_manager->active_messengers(); |
| 851 | 851 | } |
| 852 | 852 | |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | */ |
| 859 | 859 | public function get_active_message_types() { |
| 860 | 860 | // EE_messages has been deprecated |
| 861 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 861 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 862 | 862 | return $this->_message_resource_manager->list_of_active_message_types(); |
| 863 | 863 | } |
| 864 | 864 | |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | */ |
| 871 | 871 | public function get_active_message_type_objects() { |
| 872 | 872 | // EE_messages has been deprecated |
| 873 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 873 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 874 | 874 | return $this->_message_resource_manager->get_active_message_type_objects(); |
| 875 | 875 | } |
| 876 | 876 | |
@@ -882,10 +882,10 @@ discard block |
||
| 882 | 882 | * @param string $messenger The messenger being checked |
| 883 | 883 | * @return EE_message_type[] (or empty array if none present) |
| 884 | 884 | */ |
| 885 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
| 885 | + public function get_active_message_types_per_messenger($messenger) { |
|
| 886 | 886 | // EE_messages has been deprecated |
| 887 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 888 | - return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger ); |
|
| 887 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 888 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | |
@@ -896,10 +896,10 @@ discard block |
||
| 896 | 896 | * @param string $message_type The string should correspond to a message type. |
| 897 | 897 | * @return EE_message_type|null |
| 898 | 898 | */ |
| 899 | - public function get_active_message_type( $messenger, $message_type ) { |
|
| 899 | + public function get_active_message_type($messenger, $message_type) { |
|
| 900 | 900 | // EE_messages has been deprecated |
| 901 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 902 | - return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type ); |
|
| 901 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 902 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | |
@@ -910,7 +910,7 @@ discard block |
||
| 910 | 910 | */ |
| 911 | 911 | public function get_installed_message_types() { |
| 912 | 912 | // EE_messages has been deprecated |
| 913 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 913 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 914 | 914 | return $this->_message_resource_manager->installed_message_types(); |
| 915 | 915 | } |
| 916 | 916 | |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | */ |
| 923 | 923 | public function get_installed_messengers() { |
| 924 | 924 | // EE_messages has been deprecated |
| 925 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 925 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 926 | 926 | return $this->_message_resource_manager->installed_messengers(); |
| 927 | 927 | } |
| 928 | 928 | |
@@ -933,10 +933,10 @@ discard block |
||
| 933 | 933 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
| 934 | 934 | * @return array |
| 935 | 935 | */ |
| 936 | - public function get_all_contexts( $slugs_only = true ) { |
|
| 936 | + public function get_all_contexts($slugs_only = true) { |
|
| 937 | 937 | // EE_messages has been deprecated |
| 938 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 939 | - return $this->_message_resource_manager->get_all_contexts( $slugs_only ); |
|
| 938 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 939 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | add_filter( |
| 996 | 996 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
| 997 | 997 | function($event_list_iframe_css) { |
| 998 | - if ( ! has_filter( 'FHEE__EventsArchiveIframe__event_list_iframe__css' )) { |
|
| 998 | + if ( ! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
| 999 | 999 | return $event_list_iframe_css; |
| 1000 | 1000 | } |
| 1001 | 1001 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | add_filter( |
| 1016 | 1016 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
| 1017 | 1017 | function($event_list_iframe_js) { |
| 1018 | - if ( ! has_filter( 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js' )) { |
|
| 1018 | + if ( ! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
| 1019 | 1019 | return $event_list_iframe_js; |
| 1020 | 1020 | } |
| 1021 | 1021 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | */ |
| 1096 | 1096 | public function event_list_title($event_list_title = '') |
| 1097 | 1097 | { |
| 1098 | - if (! empty($this->title)) { |
|
| 1098 | + if ( ! empty($this->title)) { |
|
| 1099 | 1099 | return $this->title; |
| 1100 | 1100 | } |
| 1101 | 1101 | return $event_list_title; |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * @since 4.3.2 |
| 8 | 8 | */ |
| 9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 10 | - exit('No direct script access allowed'); |
|
| 10 | + exit('No direct script access allowed'); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -22,735 +22,735 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * constructor. |
|
| 27 | - */ |
|
| 28 | - public function __construct() |
|
| 29 | - { |
|
| 30 | - $this->_caf_hooks(); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Contains all the hooks filters for setting up caffeinated messages functionality. |
|
| 36 | - * |
|
| 37 | - * @since 4.3.2 |
|
| 38 | - * |
|
| 39 | - * @return void |
|
| 40 | - */ |
|
| 41 | - private function _caf_hooks() |
|
| 42 | - { |
|
| 43 | - add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5); |
|
| 44 | - add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'), |
|
| 45 | - 5, 2); |
|
| 46 | - add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5, |
|
| 47 | - 2); |
|
| 48 | - add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5, |
|
| 49 | - 2); |
|
| 50 | - add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5, |
|
| 51 | - 2); |
|
| 52 | - add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2); |
|
| 53 | - add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5, |
|
| 54 | - 2); |
|
| 55 | - add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', |
|
| 56 | - array($this, 'new_default_templates'), 5, 7); |
|
| 57 | - add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5, |
|
| 58 | - 2); |
|
| 59 | - |
|
| 60 | - //shortcode parsers |
|
| 61 | - add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2); |
|
| 62 | - add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5); |
|
| 63 | - add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes', |
|
| 64 | - array($this, 'additional_recipient_details_shortcodes'), 5, 2); |
|
| 65 | - add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after', |
|
| 66 | - array($this, 'additional_recipient_details_parser'), 5, 5); |
|
| 67 | - add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes', |
|
| 68 | - array($this, 'additional_primary_registration_details_shortcodes'), 5, 2); |
|
| 69 | - add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after', |
|
| 70 | - array($this, 'additional_primary_registration_details_parser'), 5, 5); |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @since 4.2.0 |
|
| 74 | - */ |
|
| 75 | - add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2); |
|
| 76 | - add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5); |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @since 4.3.0 |
|
| 80 | - */ |
|
| 81 | - //eat our own dog food! |
|
| 82 | - add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types')); |
|
| 83 | - add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes')); |
|
| 84 | - do_action('EE_Brewing_Regular___messages_caf'); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the |
|
| 90 | - * messages system. |
|
| 91 | - * |
|
| 92 | - * @param array $dir_ref original array of paths |
|
| 93 | - * |
|
| 94 | - * @return array appended paths |
|
| 95 | - */ |
|
| 96 | - public function messages_autoload_paths($dir_ref) |
|
| 97 | - { |
|
| 98 | - $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
| 99 | - |
|
| 100 | - return $dir_ref; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger) |
|
| 105 | - { |
|
| 106 | - $validator_config['attendee_list'] = array( |
|
| 107 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
| 108 | - 'required' => array('[ATTENDEE_LIST]') |
|
| 109 | - ); |
|
| 110 | - $validator_config['question_list'] = array( |
|
| 111 | - 'shortcodes' => array('question'), |
|
| 112 | - 'required' => array('[QUESTION_LIST]') |
|
| 113 | - ); |
|
| 114 | - |
|
| 115 | - return $validator_config; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger) |
|
| 120 | - { |
|
| 121 | - $validator_config['attendee_list'] = array( |
|
| 122 | - 'shortcodes' => array('attendee', 'question_list'), |
|
| 123 | - 'required' => array('[ATTENDEE_LIST]') |
|
| 124 | - ); |
|
| 125 | - $validator_config['question_list'] = array( |
|
| 126 | - 'shortcodes' => array('question'), |
|
| 127 | - 'required' => array('[QUESTION_LIST]') |
|
| 128 | - ); |
|
| 129 | - |
|
| 130 | - return $validator_config; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger) |
|
| 135 | - { |
|
| 136 | - $validator_config['attendee_list'] = array( |
|
| 137 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
| 138 | - 'required' => array('[ATTENDEE_LIST]') |
|
| 139 | - ); |
|
| 140 | - $validator_config['question_list'] = array( |
|
| 141 | - 'shortcodes' => array('question'), |
|
| 142 | - 'required' => array('[QUESTION_LIST]') |
|
| 143 | - ); |
|
| 144 | - |
|
| 145 | - return $validator_config; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger) |
|
| 150 | - { |
|
| 151 | - $template_fields['extra']['content']['question_list'] = array( |
|
| 152 | - 'input' => 'textarea', |
|
| 153 | - 'label' => '[QUESTION_LIST]', |
|
| 154 | - 'type' => 'string', |
|
| 155 | - 'required' => true, |
|
| 156 | - 'validation' => true, |
|
| 157 | - 'format' => '%s', |
|
| 158 | - 'css_class' => 'large-text', |
|
| 159 | - 'rows' => '5', |
|
| 160 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
| 161 | - ); |
|
| 162 | - |
|
| 163 | - return $template_fields; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger) |
|
| 168 | - { |
|
| 169 | - $template_fields['extra']['content']['question_list'] = array( |
|
| 170 | - 'input' => 'textarea', |
|
| 171 | - 'label' => '[QUESTION_LIST]', |
|
| 172 | - 'type' => 'string', |
|
| 173 | - 'required' => true, |
|
| 174 | - 'validation' => true, |
|
| 175 | - 'format' => '%s', |
|
| 176 | - 'css_class' => 'large-text', |
|
| 177 | - 'rows' => '5', |
|
| 178 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
| 179 | - ); |
|
| 180 | - |
|
| 181 | - return $template_fields; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - |
|
| 185 | - public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger) |
|
| 186 | - { |
|
| 187 | - $template_fields['extra']['content']['question_list'] = array( |
|
| 188 | - 'input' => 'textarea', |
|
| 189 | - 'label' => '[QUESTION_LIST]', |
|
| 190 | - 'type' => 'string', |
|
| 191 | - 'required' => true, |
|
| 192 | - 'validation' => true, |
|
| 193 | - 'format' => '%s', |
|
| 194 | - 'css_class' => 'large-text', |
|
| 195 | - 'rows' => '5', |
|
| 196 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
| 197 | - ); |
|
| 198 | - |
|
| 199 | - return $template_fields; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - |
|
| 203 | - public function new_default_templates( |
|
| 204 | - $contents, |
|
| 205 | - $actual_path, |
|
| 206 | - EE_messenger $messenger, |
|
| 207 | - EE_message_type $message_type, |
|
| 208 | - $field, |
|
| 209 | - $context, |
|
| 210 | - EE_Messages_Template_Pack $template_pack |
|
| 211 | - ) { |
|
| 212 | - |
|
| 213 | - //we're only modifying templates for the default template pack |
|
| 214 | - if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
| 215 | - return $contents; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - //the template file name we're replacing contents for. |
|
| 219 | - $template_file_prefix = $field . '_' . $context; |
|
| 220 | - $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
| 221 | - |
|
| 222 | - $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
| 223 | - |
|
| 224 | - if ($messenger->name == 'email' && $message_type->name == 'registration') { |
|
| 25 | + /** |
|
| 26 | + * constructor. |
|
| 27 | + */ |
|
| 28 | + public function __construct() |
|
| 29 | + { |
|
| 30 | + $this->_caf_hooks(); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Contains all the hooks filters for setting up caffeinated messages functionality. |
|
| 36 | + * |
|
| 37 | + * @since 4.3.2 |
|
| 38 | + * |
|
| 39 | + * @return void |
|
| 40 | + */ |
|
| 41 | + private function _caf_hooks() |
|
| 42 | + { |
|
| 43 | + add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5); |
|
| 44 | + add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'), |
|
| 45 | + 5, 2); |
|
| 46 | + add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5, |
|
| 47 | + 2); |
|
| 48 | + add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5, |
|
| 49 | + 2); |
|
| 50 | + add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5, |
|
| 51 | + 2); |
|
| 52 | + add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2); |
|
| 53 | + add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5, |
|
| 54 | + 2); |
|
| 55 | + add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', |
|
| 56 | + array($this, 'new_default_templates'), 5, 7); |
|
| 57 | + add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5, |
|
| 58 | + 2); |
|
| 59 | + |
|
| 60 | + //shortcode parsers |
|
| 61 | + add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2); |
|
| 62 | + add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5); |
|
| 63 | + add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes', |
|
| 64 | + array($this, 'additional_recipient_details_shortcodes'), 5, 2); |
|
| 65 | + add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after', |
|
| 66 | + array($this, 'additional_recipient_details_parser'), 5, 5); |
|
| 67 | + add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes', |
|
| 68 | + array($this, 'additional_primary_registration_details_shortcodes'), 5, 2); |
|
| 69 | + add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after', |
|
| 70 | + array($this, 'additional_primary_registration_details_parser'), 5, 5); |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @since 4.2.0 |
|
| 74 | + */ |
|
| 75 | + add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2); |
|
| 76 | + add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5); |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @since 4.3.0 |
|
| 80 | + */ |
|
| 81 | + //eat our own dog food! |
|
| 82 | + add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types')); |
|
| 83 | + add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes')); |
|
| 84 | + do_action('EE_Brewing_Regular___messages_caf'); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the |
|
| 90 | + * messages system. |
|
| 91 | + * |
|
| 92 | + * @param array $dir_ref original array of paths |
|
| 93 | + * |
|
| 94 | + * @return array appended paths |
|
| 95 | + */ |
|
| 96 | + public function messages_autoload_paths($dir_ref) |
|
| 97 | + { |
|
| 98 | + $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
| 99 | + |
|
| 100 | + return $dir_ref; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger) |
|
| 105 | + { |
|
| 106 | + $validator_config['attendee_list'] = array( |
|
| 107 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
| 108 | + 'required' => array('[ATTENDEE_LIST]') |
|
| 109 | + ); |
|
| 110 | + $validator_config['question_list'] = array( |
|
| 111 | + 'shortcodes' => array('question'), |
|
| 112 | + 'required' => array('[QUESTION_LIST]') |
|
| 113 | + ); |
|
| 114 | + |
|
| 115 | + return $validator_config; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger) |
|
| 120 | + { |
|
| 121 | + $validator_config['attendee_list'] = array( |
|
| 122 | + 'shortcodes' => array('attendee', 'question_list'), |
|
| 123 | + 'required' => array('[ATTENDEE_LIST]') |
|
| 124 | + ); |
|
| 125 | + $validator_config['question_list'] = array( |
|
| 126 | + 'shortcodes' => array('question'), |
|
| 127 | + 'required' => array('[QUESTION_LIST]') |
|
| 128 | + ); |
|
| 129 | + |
|
| 130 | + return $validator_config; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger) |
|
| 135 | + { |
|
| 136 | + $validator_config['attendee_list'] = array( |
|
| 137 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
| 138 | + 'required' => array('[ATTENDEE_LIST]') |
|
| 139 | + ); |
|
| 140 | + $validator_config['question_list'] = array( |
|
| 141 | + 'shortcodes' => array('question'), |
|
| 142 | + 'required' => array('[QUESTION_LIST]') |
|
| 143 | + ); |
|
| 144 | + |
|
| 145 | + return $validator_config; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger) |
|
| 150 | + { |
|
| 151 | + $template_fields['extra']['content']['question_list'] = array( |
|
| 152 | + 'input' => 'textarea', |
|
| 153 | + 'label' => '[QUESTION_LIST]', |
|
| 154 | + 'type' => 'string', |
|
| 155 | + 'required' => true, |
|
| 156 | + 'validation' => true, |
|
| 157 | + 'format' => '%s', |
|
| 158 | + 'css_class' => 'large-text', |
|
| 159 | + 'rows' => '5', |
|
| 160 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
| 161 | + ); |
|
| 162 | + |
|
| 163 | + return $template_fields; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger) |
|
| 168 | + { |
|
| 169 | + $template_fields['extra']['content']['question_list'] = array( |
|
| 170 | + 'input' => 'textarea', |
|
| 171 | + 'label' => '[QUESTION_LIST]', |
|
| 172 | + 'type' => 'string', |
|
| 173 | + 'required' => true, |
|
| 174 | + 'validation' => true, |
|
| 175 | + 'format' => '%s', |
|
| 176 | + 'css_class' => 'large-text', |
|
| 177 | + 'rows' => '5', |
|
| 178 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
| 179 | + ); |
|
| 180 | + |
|
| 181 | + return $template_fields; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + |
|
| 185 | + public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger) |
|
| 186 | + { |
|
| 187 | + $template_fields['extra']['content']['question_list'] = array( |
|
| 188 | + 'input' => 'textarea', |
|
| 189 | + 'label' => '[QUESTION_LIST]', |
|
| 190 | + 'type' => 'string', |
|
| 191 | + 'required' => true, |
|
| 192 | + 'validation' => true, |
|
| 193 | + 'format' => '%s', |
|
| 194 | + 'css_class' => 'large-text', |
|
| 195 | + 'rows' => '5', |
|
| 196 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
| 197 | + ); |
|
| 198 | + |
|
| 199 | + return $template_fields; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + |
|
| 203 | + public function new_default_templates( |
|
| 204 | + $contents, |
|
| 205 | + $actual_path, |
|
| 206 | + EE_messenger $messenger, |
|
| 207 | + EE_message_type $message_type, |
|
| 208 | + $field, |
|
| 209 | + $context, |
|
| 210 | + EE_Messages_Template_Pack $template_pack |
|
| 211 | + ) { |
|
| 212 | + |
|
| 213 | + //we're only modifying templates for the default template pack |
|
| 214 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
| 215 | + return $contents; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + //the template file name we're replacing contents for. |
|
| 219 | + $template_file_prefix = $field . '_' . $context; |
|
| 220 | + $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
| 221 | + |
|
| 222 | + $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
| 223 | + |
|
| 224 | + if ($messenger->name == 'email' && $message_type->name == 'registration') { |
|
| 225 | 225 | |
| 226 | - switch ($template_file_prefix) { |
|
| 226 | + switch ($template_file_prefix) { |
|
| 227 | 227 | |
| 228 | - case 'question_list_admin' : |
|
| 229 | - case 'question_list_attendee' : |
|
| 230 | - case 'question_list_primary_attendee' : |
|
| 231 | - $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
| 232 | - $contents = EEH_Template::display_template($path, array(), true); |
|
| 233 | - break; |
|
| 228 | + case 'question_list_admin' : |
|
| 229 | + case 'question_list_attendee' : |
|
| 230 | + case 'question_list_primary_attendee' : |
|
| 231 | + $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
| 232 | + $contents = EEH_Template::display_template($path, array(), true); |
|
| 233 | + break; |
|
| 234 | 234 | |
| 235 | - case 'attendee_list_primary_attendee' : |
|
| 236 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
| 237 | - $contents = EEH_Template::display_template($path, array(), true); |
|
| 238 | - break; |
|
| 235 | + case 'attendee_list_primary_attendee' : |
|
| 236 | + $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
| 237 | + $contents = EEH_Template::display_template($path, array(), true); |
|
| 238 | + break; |
|
| 239 | 239 | |
| 240 | - case 'attendee_list_admin' : |
|
| 241 | - $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
| 242 | - $contents = EEH_Template::display_template($path, |
|
| 243 | - array(), true); |
|
| 244 | - break; |
|
| 240 | + case 'attendee_list_admin' : |
|
| 241 | + $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
| 242 | + $contents = EEH_Template::display_template($path, |
|
| 243 | + array(), true); |
|
| 244 | + break; |
|
| 245 | 245 | |
| 246 | - case 'attendee_list_attendee' : |
|
| 247 | - $contents = ''; |
|
| 248 | - break; |
|
| 246 | + case 'attendee_list_attendee' : |
|
| 247 | + $contents = ''; |
|
| 248 | + break; |
|
| 249 | 249 | |
| 250 | - case 'event_list_attendee' : |
|
| 251 | - $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
| 252 | - $contents = EEH_Template::display_template($path, array(), true); |
|
| 253 | - break; |
|
| 254 | - } |
|
| 255 | - } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') { |
|
| 256 | - switch ($template_file_prefix) { |
|
| 250 | + case 'event_list_attendee' : |
|
| 251 | + $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
| 252 | + $contents = EEH_Template::display_template($path, array(), true); |
|
| 253 | + break; |
|
| 254 | + } |
|
| 255 | + } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') { |
|
| 256 | + switch ($template_file_prefix) { |
|
| 257 | 257 | |
| 258 | - case 'content_attendee' : |
|
| 259 | - $path = $base_path . $msg_prefix . 'content.template.php'; |
|
| 260 | - $contents = EEH_Template::display_template($path, array(), true); |
|
| 261 | - break; |
|
| 258 | + case 'content_attendee' : |
|
| 259 | + $path = $base_path . $msg_prefix . 'content.template.php'; |
|
| 260 | + $contents = EEH_Template::display_template($path, array(), true); |
|
| 261 | + break; |
|
| 262 | 262 | |
| 263 | - case 'newsletter_content_attendee' : |
|
| 264 | - $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
| 265 | - $contents = EEH_Template::display_template($path, array(), true); |
|
| 266 | - break; |
|
| 263 | + case 'newsletter_content_attendee' : |
|
| 264 | + $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
| 265 | + $contents = EEH_Template::display_template($path, array(), true); |
|
| 266 | + break; |
|
| 267 | 267 | |
| 268 | - case 'newsletter_subject_attendee' : |
|
| 269 | - $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
| 270 | - $contents = EEH_Template::display_template($path, array(), true); |
|
| 271 | - break; |
|
| 272 | - } |
|
| 273 | - } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
|
| 274 | - switch ($template_file_prefix) { |
|
| 275 | - case 'attendee_list_purchaser' : |
|
| 276 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
| 277 | - $contents = EEH_Template::display_template($path, array(), true); |
|
| 278 | - break; |
|
| 279 | - } |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - return $contents; |
|
| 283 | - |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - |
|
| 287 | - public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg) |
|
| 288 | - { |
|
| 289 | - //make sure question_list and question are ONLY added for the core message types. Any other message types will have to explicitly set question_list as a valid shortcode. |
|
| 290 | - $include_with = array( |
|
| 291 | - 'registration', |
|
| 292 | - 'cancelled_registration', |
|
| 293 | - 'declined_registration', |
|
| 294 | - 'not_approved_registration', |
|
| 295 | - 'payment_declined', |
|
| 296 | - 'payment_failed', |
|
| 297 | - 'payment_cancelled', |
|
| 298 | - 'payment', |
|
| 299 | - 'payment_reminder', |
|
| 300 | - 'pending_approval', |
|
| 301 | - 'registration_summary', |
|
| 302 | - 'invoice', |
|
| 303 | - 'receipt' |
|
| 304 | - ); |
|
| 305 | - if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) { |
|
| 306 | - $contexts = array_keys($msg->get_contexts()); |
|
| 307 | - foreach ($contexts as $context) { |
|
| 308 | - $valid_shortcodes[$context][] = 'question_list'; |
|
| 309 | - $valid_shortcodes[$context][] = 'question'; |
|
| 310 | - } |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - return $valid_shortcodes; |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - |
|
| 317 | - public function additional_attendee_shortcodes($shortcodes, $shortcode_parser) |
|
| 318 | - { |
|
| 319 | - $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.', |
|
| 320 | - 'event_espresso'); |
|
| 321 | - |
|
| 322 | - return $shortcodes; |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - |
|
| 326 | - public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
| 327 | - { |
|
| 328 | - |
|
| 329 | - if (strpos($shortcode, |
|
| 330 | - '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations) |
|
| 331 | - ) { |
|
| 332 | - return $parsed; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - //let's get the question from the code. |
|
| 336 | - $shortcode = str_replace('[ANSWER_*', '', $shortcode); |
|
| 337 | - $shortcode = trim(str_replace(']', '', $shortcode)); |
|
| 338 | - |
|
| 339 | - $registration = $data instanceof EE_Registration ? $data : null; |
|
| 340 | - $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration; |
|
| 341 | - |
|
| 342 | - $aee = $data instanceof EE_Messages_Addressee ? $data : null; |
|
| 343 | - $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee; |
|
| 344 | - |
|
| 345 | - if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) { |
|
| 346 | - return $parsed; |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - //now let's figure out which question has this text. |
|
| 350 | - foreach ($aee->questions as $ansid => $question) { |
|
| 351 | - if ( |
|
| 352 | - $question instanceof EE_Question |
|
| 353 | - && trim($question->display_text()) == trim($shortcode) |
|
| 354 | - && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid]) |
|
| 355 | - ) { |
|
| 356 | - return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', |
|
| 357 | - 'no_wpautop'); |
|
| 358 | - } |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - //nothing! |
|
| 362 | - return $parsed; |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * Callback for additional shortcodes filter for adding additional datetime shortcodes. |
|
| 368 | - * |
|
| 369 | - * @since 4.2 |
|
| 370 | - * |
|
| 371 | - * @param array $shortcodes array of shortcodes and |
|
| 372 | - * descriptions |
|
| 373 | - * @param EE_Datetime_Shortcodes $shortcode_parser EE_Shortcodes object |
|
| 374 | - * |
|
| 375 | - * @return array array of shortcodes and |
|
| 376 | - * descriptions |
|
| 377 | - */ |
|
| 378 | - public function additional_datetime_shortcodes($shortcodes, $shortcode_parser) |
|
| 379 | - { |
|
| 380 | - $shortcodes['[DTT_NAME]'] = __('This will be parsed to the Title given for a Datetime', |
|
| 381 | - 'event_espresso'); |
|
| 382 | - $shortcodes['[DTT_DESCRIPTION]'] = __('This will be parsed to the description for a Datetime', |
|
| 383 | - 'event_espresso'); |
|
| 384 | - $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.', |
|
| 385 | - 'event_espresso'); |
|
| 386 | - |
|
| 387 | - return $shortcodes; |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - |
|
| 391 | - /** |
|
| 392 | - * Callback for additional shortcodes parser filter used for adding parser for new |
|
| 393 | - * Datetime shortcodes |
|
| 394 | - * |
|
| 395 | - * @since 4.2 |
|
| 396 | - * |
|
| 397 | - * @param string $parsed The finished parsed string for the given shortcode. |
|
| 398 | - * @param string $shortcode The shortcode being parsed. |
|
| 399 | - * @param object $data The incoming data object for the Shortcode Parser. |
|
| 400 | - * @param object $extra_data The incoming extra date object for the Shortcode |
|
| 401 | - * Parser. |
|
| 402 | - * @param EE_Datetime_Shortcodes $shortcode_parser |
|
| 403 | - * |
|
| 404 | - * @return string The new parsed string. |
|
| 405 | - */ |
|
| 406 | - public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
| 407 | - { |
|
| 408 | - |
|
| 409 | - if ( ! $data instanceof EE_Datetime) { |
|
| 410 | - return ''; //get out because we can only parse with the datetime object. |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - switch ($shortcode) { |
|
| 414 | - case '[DTT_NAME]' : |
|
| 415 | - return $data->name(); |
|
| 416 | - break; |
|
| 417 | - case '[DTT_DESCRIPTION]' : |
|
| 418 | - return $data->description(); |
|
| 419 | - break; |
|
| 420 | - case '[DTT_NAME_OR_DATES]' : |
|
| 421 | - return $data->get_dtt_display_name(true); |
|
| 422 | - break; |
|
| 423 | - default : |
|
| 424 | - return $parsed; |
|
| 425 | - break; |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - |
|
| 430 | - public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser) |
|
| 431 | - { |
|
| 432 | - $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.', |
|
| 433 | - 'event_espresso'); |
|
| 434 | - |
|
| 435 | - return $shortcodes; |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - |
|
| 439 | - /** |
|
| 440 | - * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter). |
|
| 441 | - * |
|
| 442 | - * @param string $parsed The original parsed content for the shortcode |
|
| 443 | - * @param string $shortcode The shortcode being parsed |
|
| 444 | - * @param array $data The shortcode parser data array |
|
| 445 | - * @param array $extra_data The shortcode parser extra data array |
|
| 446 | - * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
| 447 | - * |
|
| 448 | - * @return string |
|
| 449 | - */ |
|
| 450 | - public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
| 451 | - { |
|
| 452 | - |
|
| 453 | - if (array($data) && ! isset($data['data'])) { |
|
| 454 | - return $parsed; |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
| 458 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
| 459 | - |
|
| 460 | - if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
| 461 | - return $parsed; |
|
| 462 | - } |
|
| 463 | - |
|
| 464 | - switch ($shortcode) { |
|
| 465 | - case '[RECIPIENT_QUESTION_LIST]' : |
|
| 466 | - $att = $recipient->att_obj; |
|
| 467 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array(); |
|
| 468 | - $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee; |
|
| 469 | - $answers = array(); |
|
| 268 | + case 'newsletter_subject_attendee' : |
|
| 269 | + $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
| 270 | + $contents = EEH_Template::display_template($path, array(), true); |
|
| 271 | + break; |
|
| 272 | + } |
|
| 273 | + } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
|
| 274 | + switch ($template_file_prefix) { |
|
| 275 | + case 'attendee_list_purchaser' : |
|
| 276 | + $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
| 277 | + $contents = EEH_Template::display_template($path, array(), true); |
|
| 278 | + break; |
|
| 279 | + } |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + return $contents; |
|
| 283 | + |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + |
|
| 287 | + public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg) |
|
| 288 | + { |
|
| 289 | + //make sure question_list and question are ONLY added for the core message types. Any other message types will have to explicitly set question_list as a valid shortcode. |
|
| 290 | + $include_with = array( |
|
| 291 | + 'registration', |
|
| 292 | + 'cancelled_registration', |
|
| 293 | + 'declined_registration', |
|
| 294 | + 'not_approved_registration', |
|
| 295 | + 'payment_declined', |
|
| 296 | + 'payment_failed', |
|
| 297 | + 'payment_cancelled', |
|
| 298 | + 'payment', |
|
| 299 | + 'payment_reminder', |
|
| 300 | + 'pending_approval', |
|
| 301 | + 'registration_summary', |
|
| 302 | + 'invoice', |
|
| 303 | + 'receipt' |
|
| 304 | + ); |
|
| 305 | + if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) { |
|
| 306 | + $contexts = array_keys($msg->get_contexts()); |
|
| 307 | + foreach ($contexts as $context) { |
|
| 308 | + $valid_shortcodes[$context][] = 'question_list'; |
|
| 309 | + $valid_shortcodes[$context][] = 'question'; |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + return $valid_shortcodes; |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + |
|
| 317 | + public function additional_attendee_shortcodes($shortcodes, $shortcode_parser) |
|
| 318 | + { |
|
| 319 | + $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.', |
|
| 320 | + 'event_espresso'); |
|
| 321 | + |
|
| 322 | + return $shortcodes; |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + |
|
| 326 | + public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
| 327 | + { |
|
| 328 | + |
|
| 329 | + if (strpos($shortcode, |
|
| 330 | + '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations) |
|
| 331 | + ) { |
|
| 332 | + return $parsed; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + //let's get the question from the code. |
|
| 336 | + $shortcode = str_replace('[ANSWER_*', '', $shortcode); |
|
| 337 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
| 338 | + |
|
| 339 | + $registration = $data instanceof EE_Registration ? $data : null; |
|
| 340 | + $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration; |
|
| 341 | + |
|
| 342 | + $aee = $data instanceof EE_Messages_Addressee ? $data : null; |
|
| 343 | + $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee; |
|
| 344 | + |
|
| 345 | + if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) { |
|
| 346 | + return $parsed; |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + //now let's figure out which question has this text. |
|
| 350 | + foreach ($aee->questions as $ansid => $question) { |
|
| 351 | + if ( |
|
| 352 | + $question instanceof EE_Question |
|
| 353 | + && trim($question->display_text()) == trim($shortcode) |
|
| 354 | + && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid]) |
|
| 355 | + ) { |
|
| 356 | + return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', |
|
| 357 | + 'no_wpautop'); |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + //nothing! |
|
| 362 | + return $parsed; |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * Callback for additional shortcodes filter for adding additional datetime shortcodes. |
|
| 368 | + * |
|
| 369 | + * @since 4.2 |
|
| 370 | + * |
|
| 371 | + * @param array $shortcodes array of shortcodes and |
|
| 372 | + * descriptions |
|
| 373 | + * @param EE_Datetime_Shortcodes $shortcode_parser EE_Shortcodes object |
|
| 374 | + * |
|
| 375 | + * @return array array of shortcodes and |
|
| 376 | + * descriptions |
|
| 377 | + */ |
|
| 378 | + public function additional_datetime_shortcodes($shortcodes, $shortcode_parser) |
|
| 379 | + { |
|
| 380 | + $shortcodes['[DTT_NAME]'] = __('This will be parsed to the Title given for a Datetime', |
|
| 381 | + 'event_espresso'); |
|
| 382 | + $shortcodes['[DTT_DESCRIPTION]'] = __('This will be parsed to the description for a Datetime', |
|
| 383 | + 'event_espresso'); |
|
| 384 | + $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.', |
|
| 385 | + 'event_espresso'); |
|
| 386 | + |
|
| 387 | + return $shortcodes; |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + |
|
| 391 | + /** |
|
| 392 | + * Callback for additional shortcodes parser filter used for adding parser for new |
|
| 393 | + * Datetime shortcodes |
|
| 394 | + * |
|
| 395 | + * @since 4.2 |
|
| 396 | + * |
|
| 397 | + * @param string $parsed The finished parsed string for the given shortcode. |
|
| 398 | + * @param string $shortcode The shortcode being parsed. |
|
| 399 | + * @param object $data The incoming data object for the Shortcode Parser. |
|
| 400 | + * @param object $extra_data The incoming extra date object for the Shortcode |
|
| 401 | + * Parser. |
|
| 402 | + * @param EE_Datetime_Shortcodes $shortcode_parser |
|
| 403 | + * |
|
| 404 | + * @return string The new parsed string. |
|
| 405 | + */ |
|
| 406 | + public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
| 407 | + { |
|
| 408 | + |
|
| 409 | + if ( ! $data instanceof EE_Datetime) { |
|
| 410 | + return ''; //get out because we can only parse with the datetime object. |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + switch ($shortcode) { |
|
| 414 | + case '[DTT_NAME]' : |
|
| 415 | + return $data->name(); |
|
| 416 | + break; |
|
| 417 | + case '[DTT_DESCRIPTION]' : |
|
| 418 | + return $data->description(); |
|
| 419 | + break; |
|
| 420 | + case '[DTT_NAME_OR_DATES]' : |
|
| 421 | + return $data->get_dtt_display_name(true); |
|
| 422 | + break; |
|
| 423 | + default : |
|
| 424 | + return $parsed; |
|
| 425 | + break; |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + |
|
| 430 | + public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser) |
|
| 431 | + { |
|
| 432 | + $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.', |
|
| 433 | + 'event_espresso'); |
|
| 434 | + |
|
| 435 | + return $shortcodes; |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + |
|
| 439 | + /** |
|
| 440 | + * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter). |
|
| 441 | + * |
|
| 442 | + * @param string $parsed The original parsed content for the shortcode |
|
| 443 | + * @param string $shortcode The shortcode being parsed |
|
| 444 | + * @param array $data The shortcode parser data array |
|
| 445 | + * @param array $extra_data The shortcode parser extra data array |
|
| 446 | + * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
| 447 | + * |
|
| 448 | + * @return string |
|
| 449 | + */ |
|
| 450 | + public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
| 451 | + { |
|
| 452 | + |
|
| 453 | + if (array($data) && ! isset($data['data'])) { |
|
| 454 | + return $parsed; |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
| 458 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
| 459 | + |
|
| 460 | + if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
| 461 | + return $parsed; |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + switch ($shortcode) { |
|
| 465 | + case '[RECIPIENT_QUESTION_LIST]' : |
|
| 466 | + $att = $recipient->att_obj; |
|
| 467 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array(); |
|
| 468 | + $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee; |
|
| 469 | + $answers = array(); |
|
| 470 | 470 | |
| 471 | - $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
| 472 | - $valid_shortcodes = array('question'); |
|
| 471 | + $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
| 472 | + $valid_shortcodes = array('question'); |
|
| 473 | 473 | |
| 474 | - //if the context is main_content then get all answers for all registrations on this attendee |
|
| 475 | - if ($data['data'] instanceof EE_Messages_Addressee) { |
|
| 474 | + //if the context is main_content then get all answers for all registrations on this attendee |
|
| 475 | + if ($data['data'] instanceof EE_Messages_Addressee) { |
|
| 476 | 476 | |
| 477 | - foreach ($registrations_on_attendee as $reg) { |
|
| 478 | - if ($reg instanceof EE_Registration) { |
|
| 479 | - $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
| 480 | - foreach ($anss as $ans) { |
|
| 481 | - if ($ans instanceof EE_Answer) { |
|
| 482 | - $answers[$ans->ID()] = $ans; |
|
| 483 | - } |
|
| 484 | - } |
|
| 485 | - } |
|
| 486 | - } |
|
| 487 | - } |
|
| 477 | + foreach ($registrations_on_attendee as $reg) { |
|
| 478 | + if ($reg instanceof EE_Registration) { |
|
| 479 | + $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
| 480 | + foreach ($anss as $ans) { |
|
| 481 | + if ($ans instanceof EE_Answer) { |
|
| 482 | + $answers[$ans->ID()] = $ans; |
|
| 483 | + } |
|
| 484 | + } |
|
| 485 | + } |
|
| 486 | + } |
|
| 487 | + } |
|
| 488 | 488 | |
| 489 | - //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event. |
|
| 490 | - if ($data['data'] instanceof EE_Event) { |
|
| 491 | - $event = $data['data']; |
|
| 492 | - foreach ($registrations_on_attendee as $reg) { |
|
| 493 | - if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
| 494 | - $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
| 495 | - foreach ($anss as $ans) { |
|
| 496 | - if ($ans instanceof EE_Answer) { |
|
| 497 | - $answers[$ans->ID()] = $ans; |
|
| 498 | - } |
|
| 499 | - } |
|
| 500 | - } |
|
| 501 | - } |
|
| 502 | - } |
|
| 489 | + //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event. |
|
| 490 | + if ($data['data'] instanceof EE_Event) { |
|
| 491 | + $event = $data['data']; |
|
| 492 | + foreach ($registrations_on_attendee as $reg) { |
|
| 493 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
| 494 | + $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
| 495 | + foreach ($anss as $ans) { |
|
| 496 | + if ($ans instanceof EE_Answer) { |
|
| 497 | + $answers[$ans->ID()] = $ans; |
|
| 498 | + } |
|
| 499 | + } |
|
| 500 | + } |
|
| 501 | + } |
|
| 502 | + } |
|
| 503 | 503 | |
| 504 | - $questions = $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
| 504 | + $questions = $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
| 505 | 505 | |
| 506 | - //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
| 507 | - //object on it. |
|
| 508 | - if ( ! isset( $extra_data['data'] ) ) { |
|
| 509 | - $extra_data['data'] = $recipient; |
|
| 510 | - } |
|
| 506 | + //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
| 507 | + //object on it. |
|
| 508 | + if ( ! isset( $extra_data['data'] ) ) { |
|
| 509 | + $extra_data['data'] = $recipient; |
|
| 510 | + } |
|
| 511 | 511 | |
| 512 | - return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
| 513 | - $shortcode_parser, |
|
| 514 | - $questions, |
|
| 515 | - $answers, |
|
| 516 | - $template, |
|
| 517 | - $valid_shortcodes, |
|
| 518 | - $extra_data |
|
| 519 | - ); |
|
| 520 | - break; |
|
| 512 | + return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
| 513 | + $shortcode_parser, |
|
| 514 | + $questions, |
|
| 515 | + $answers, |
|
| 516 | + $template, |
|
| 517 | + $valid_shortcodes, |
|
| 518 | + $extra_data |
|
| 519 | + ); |
|
| 520 | + break; |
|
| 521 | 521 | |
| 522 | - default : |
|
| 523 | - return $parsed; |
|
| 524 | - break; |
|
| 525 | - } |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - |
|
| 529 | - public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser) |
|
| 530 | - { |
|
| 531 | - $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field', |
|
| 532 | - 'event_espresso'); |
|
| 533 | - |
|
| 534 | - return $shortcodes; |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - |
|
| 538 | - /** |
|
| 539 | - * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter). |
|
| 540 | - * |
|
| 541 | - * @param string $parsed The original parsed content for the shortcode |
|
| 542 | - * @param string $shortcode The shortcode being parsed |
|
| 543 | - * @param array $data The shortcode parser data array |
|
| 544 | - * @param array $extra_data The shortcode parser extra data array |
|
| 545 | - * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
| 546 | - * |
|
| 547 | - * @return string |
|
| 548 | - */ |
|
| 549 | - public function additional_primary_registration_details_parser( |
|
| 550 | - $parsed, |
|
| 551 | - $shortcode, |
|
| 552 | - $data, |
|
| 553 | - $extra_data, |
|
| 554 | - $shortcode_parser |
|
| 555 | - ) { |
|
| 556 | - if (array($data) && ! isset($data['data'])) { |
|
| 557 | - return $parsed; |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
| 561 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
| 562 | - |
|
| 563 | - if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
| 564 | - return $parsed; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - switch ($shortcode) { |
|
| 568 | - case '[PRIMARY_REGISTRANT_QUESTION_LIST]' : |
|
| 569 | - if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) { |
|
| 570 | - return ''; |
|
| 571 | - } |
|
| 572 | - $registration = $recipient->primary_reg_obj; |
|
| 573 | - $answers = isset($recipient->registrations[$registration->ID()]['ans_objs']) |
|
| 574 | - ? $recipient->registrations[$registration->ID()]['ans_objs'] |
|
| 575 | - : array(); |
|
| 576 | - if (empty($answers)) { |
|
| 577 | - return ''; |
|
| 578 | - } |
|
| 579 | - $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
| 580 | - $valid_shortcodes = array('question'); |
|
| 581 | - $answers = $recipient->registrations[$registration->ID()]['ans_objs']; |
|
| 582 | - $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
| 583 | - //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
| 584 | - //object on it. |
|
| 585 | - if ( ! isset( $extra_data['data'] ) ){ |
|
| 586 | - $extra_data['data'] = $recipient; |
|
| 587 | - } |
|
| 588 | - return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
| 589 | - $shortcode_parser, |
|
| 590 | - $questions, |
|
| 591 | - $answers, |
|
| 592 | - $template, |
|
| 593 | - $valid_shortcodes, |
|
| 594 | - $extra_data |
|
| 595 | - ); |
|
| 596 | - break; |
|
| 522 | + default : |
|
| 523 | + return $parsed; |
|
| 524 | + break; |
|
| 525 | + } |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + |
|
| 529 | + public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser) |
|
| 530 | + { |
|
| 531 | + $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field', |
|
| 532 | + 'event_espresso'); |
|
| 533 | + |
|
| 534 | + return $shortcodes; |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + |
|
| 538 | + /** |
|
| 539 | + * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter). |
|
| 540 | + * |
|
| 541 | + * @param string $parsed The original parsed content for the shortcode |
|
| 542 | + * @param string $shortcode The shortcode being parsed |
|
| 543 | + * @param array $data The shortcode parser data array |
|
| 544 | + * @param array $extra_data The shortcode parser extra data array |
|
| 545 | + * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
| 546 | + * |
|
| 547 | + * @return string |
|
| 548 | + */ |
|
| 549 | + public function additional_primary_registration_details_parser( |
|
| 550 | + $parsed, |
|
| 551 | + $shortcode, |
|
| 552 | + $data, |
|
| 553 | + $extra_data, |
|
| 554 | + $shortcode_parser |
|
| 555 | + ) { |
|
| 556 | + if (array($data) && ! isset($data['data'])) { |
|
| 557 | + return $parsed; |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
| 561 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
| 562 | + |
|
| 563 | + if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
| 564 | + return $parsed; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + switch ($shortcode) { |
|
| 568 | + case '[PRIMARY_REGISTRANT_QUESTION_LIST]' : |
|
| 569 | + if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) { |
|
| 570 | + return ''; |
|
| 571 | + } |
|
| 572 | + $registration = $recipient->primary_reg_obj; |
|
| 573 | + $answers = isset($recipient->registrations[$registration->ID()]['ans_objs']) |
|
| 574 | + ? $recipient->registrations[$registration->ID()]['ans_objs'] |
|
| 575 | + : array(); |
|
| 576 | + if (empty($answers)) { |
|
| 577 | + return ''; |
|
| 578 | + } |
|
| 579 | + $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
| 580 | + $valid_shortcodes = array('question'); |
|
| 581 | + $answers = $recipient->registrations[$registration->ID()]['ans_objs']; |
|
| 582 | + $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
| 583 | + //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
| 584 | + //object on it. |
|
| 585 | + if ( ! isset( $extra_data['data'] ) ){ |
|
| 586 | + $extra_data['data'] = $recipient; |
|
| 587 | + } |
|
| 588 | + return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
| 589 | + $shortcode_parser, |
|
| 590 | + $questions, |
|
| 591 | + $answers, |
|
| 592 | + $template, |
|
| 593 | + $valid_shortcodes, |
|
| 594 | + $extra_data |
|
| 595 | + ); |
|
| 596 | + break; |
|
| 597 | 597 | |
| 598 | - default : |
|
| 599 | - return $parsed; |
|
| 600 | - break; |
|
| 601 | - } |
|
| 602 | - } |
|
| 603 | - |
|
| 604 | - |
|
| 605 | - /** |
|
| 606 | - * Takes care of registering the message types that are only available in caffeinated EE. |
|
| 607 | - * |
|
| 608 | - * @since 4.3.2 |
|
| 609 | - * |
|
| 610 | - * @return void |
|
| 611 | - */ |
|
| 612 | - public function register_caf_message_types() |
|
| 613 | - { |
|
| 614 | - //register newsletter message type |
|
| 615 | - $setup_args = array( |
|
| 616 | - 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
|
| 617 | - 'autoloadpaths' => array( |
|
| 618 | - EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
| 619 | - ), |
|
| 620 | - 'messengers_to_activate_with' => array('email'), |
|
| 621 | - 'messengers_to_validate_with' => array('email'), |
|
| 622 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 623 | - ); |
|
| 624 | - EE_Register_Message_Type::register('newsletter', $setup_args); |
|
| 625 | - |
|
| 626 | - //register payment reminder message type |
|
| 627 | - $setup_args = array( |
|
| 628 | - 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
|
| 629 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
| 630 | - 'messengers_to_activate_with' => array('email'), |
|
| 631 | - 'messengers_to_validate_with' => array('email'), |
|
| 632 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 633 | - ); |
|
| 634 | - EE_Register_Message_Type::register('payment_reminder', $setup_args); |
|
| 635 | - |
|
| 636 | - //register payment declined message type |
|
| 637 | - $setup_args = array( |
|
| 638 | - 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
|
| 639 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
| 640 | - 'messengers_to_activate_with' => array('email'), |
|
| 641 | - 'messengers_to_validate_with' => array('email'), |
|
| 642 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 643 | - ); |
|
| 644 | - EE_Register_Message_Type::register('payment_declined', $setup_args); |
|
| 645 | - |
|
| 646 | - //register registration declined message type |
|
| 647 | - $setup_args = array( |
|
| 648 | - 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
|
| 649 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
| 650 | - 'messengers_to_activate_with' => array('email'), |
|
| 651 | - 'messengers_to_validate_with' => array('email'), |
|
| 652 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 653 | - ); |
|
| 654 | - EE_Register_Message_Type::register('declined_registration', $setup_args); |
|
| 655 | - |
|
| 656 | - //register registration cancelled message type |
|
| 657 | - $setup_args = array( |
|
| 658 | - 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
|
| 659 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
| 660 | - 'messengers_to_activate_with' => array('email'), |
|
| 661 | - 'messengers_to_validate_with' => array('email'), |
|
| 662 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 663 | - ); |
|
| 664 | - EE_Register_Message_Type::register('cancelled_registration', $setup_args); |
|
| 665 | - |
|
| 666 | - |
|
| 667 | - //register payment failed message type |
|
| 668 | - $setup_args = array( |
|
| 669 | - 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
|
| 670 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
| 671 | - 'messengers_to_activate_with' => array('email'), |
|
| 672 | - 'messengers_to_validate_with' => array('email'), |
|
| 673 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 674 | - ); |
|
| 675 | - EE_Register_Message_Type::register('payment_failed', $setup_args); |
|
| 676 | - |
|
| 677 | - //register payment declined message type |
|
| 678 | - $setup_args = array( |
|
| 679 | - 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
|
| 680 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
| 681 | - 'messengers_to_activate_with' => array('email'), |
|
| 682 | - 'messengers_to_validate_with' => array('email'), |
|
| 683 | - 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 684 | - ); |
|
| 685 | - EE_Register_Message_Type::register('payment_cancelled', $setup_args); |
|
| 686 | - } |
|
| 687 | - |
|
| 688 | - |
|
| 689 | - /** |
|
| 690 | - * Takes care of registering the shortcode libraries implemented with caffeinated EE and set up related items. |
|
| 691 | - * |
|
| 692 | - * @since 4.3.2 |
|
| 693 | - * |
|
| 694 | - * @return void |
|
| 695 | - */ |
|
| 696 | - public function register_caf_shortcodes() |
|
| 697 | - { |
|
| 698 | - $setup_args = array( |
|
| 699 | - 'autoloadpaths' => array( |
|
| 700 | - EE_CAF_LIBRARIES . 'shortcodes/' |
|
| 701 | - ), |
|
| 702 | - 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
|
| 703 | - 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
|
| 704 | - 'list_type_shortcodes' => array('[NEWSLETTER_CONTENT]') |
|
| 705 | - ); |
|
| 706 | - EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args); |
|
| 707 | - } |
|
| 708 | - |
|
| 709 | - |
|
| 710 | - /** |
|
| 711 | - * Parses a question list shortcode using given data and template |
|
| 712 | - * |
|
| 713 | - * @param \EE_Shortcodes $shortcode_parser |
|
| 714 | - * @param EE_Question[] $questions An array of questions indexed by answer id. |
|
| 715 | - * @param EE_Answer[] $answers An array of answer objects |
|
| 716 | - * @param string $template Template content to be parsed. |
|
| 717 | - * @param array $valid_shortcodes Valid shortcodes for the template being parsed. |
|
| 718 | - * @param array $extra_data Extra data that might be used when parsing the template. |
|
| 719 | - */ |
|
| 720 | - protected function _parse_question_list_for_primary_or_recipient_registration( |
|
| 721 | - $shortcode_parser, |
|
| 722 | - $questions, |
|
| 723 | - $answers, |
|
| 724 | - $template, |
|
| 725 | - $valid_shortcodes, |
|
| 726 | - $extra_data |
|
| 727 | - ) { |
|
| 728 | - $question_list = ''; |
|
| 729 | - /** @var EEH_Parse_Shortcodes $shortcode_helper */ |
|
| 730 | - $shortcode_helper = $shortcode_parser->get_shortcode_helper(); |
|
| 731 | - foreach ($answers as $answer) { |
|
| 732 | - if ($answer instanceof EE_Answer) { |
|
| 733 | - //first see if the question is in our $questions array. If not then try to get from answer object. |
|
| 734 | - $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null; |
|
| 735 | - $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
| 736 | - if ( |
|
| 737 | - ! $question instanceof EE_Question |
|
| 738 | - || ( |
|
| 739 | - $question instanceof EE_Question |
|
| 740 | - && $question->admin_only() |
|
| 741 | - ) |
|
| 742 | - ) { |
|
| 743 | - continue; |
|
| 744 | - } |
|
| 745 | - $question_list .= $shortcode_helper->parse_question_list_template( |
|
| 746 | - $template, |
|
| 747 | - $answer, |
|
| 748 | - $valid_shortcodes, |
|
| 749 | - $extra_data |
|
| 750 | - ); |
|
| 751 | - } |
|
| 752 | - } |
|
| 753 | - |
|
| 754 | - return $question_list; |
|
| 755 | - } |
|
| 598 | + default : |
|
| 599 | + return $parsed; |
|
| 600 | + break; |
|
| 601 | + } |
|
| 602 | + } |
|
| 603 | + |
|
| 604 | + |
|
| 605 | + /** |
|
| 606 | + * Takes care of registering the message types that are only available in caffeinated EE. |
|
| 607 | + * |
|
| 608 | + * @since 4.3.2 |
|
| 609 | + * |
|
| 610 | + * @return void |
|
| 611 | + */ |
|
| 612 | + public function register_caf_message_types() |
|
| 613 | + { |
|
| 614 | + //register newsletter message type |
|
| 615 | + $setup_args = array( |
|
| 616 | + 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
|
| 617 | + 'autoloadpaths' => array( |
|
| 618 | + EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
| 619 | + ), |
|
| 620 | + 'messengers_to_activate_with' => array('email'), |
|
| 621 | + 'messengers_to_validate_with' => array('email'), |
|
| 622 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 623 | + ); |
|
| 624 | + EE_Register_Message_Type::register('newsletter', $setup_args); |
|
| 625 | + |
|
| 626 | + //register payment reminder message type |
|
| 627 | + $setup_args = array( |
|
| 628 | + 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
|
| 629 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
| 630 | + 'messengers_to_activate_with' => array('email'), |
|
| 631 | + 'messengers_to_validate_with' => array('email'), |
|
| 632 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 633 | + ); |
|
| 634 | + EE_Register_Message_Type::register('payment_reminder', $setup_args); |
|
| 635 | + |
|
| 636 | + //register payment declined message type |
|
| 637 | + $setup_args = array( |
|
| 638 | + 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
|
| 639 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
| 640 | + 'messengers_to_activate_with' => array('email'), |
|
| 641 | + 'messengers_to_validate_with' => array('email'), |
|
| 642 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 643 | + ); |
|
| 644 | + EE_Register_Message_Type::register('payment_declined', $setup_args); |
|
| 645 | + |
|
| 646 | + //register registration declined message type |
|
| 647 | + $setup_args = array( |
|
| 648 | + 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
|
| 649 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
| 650 | + 'messengers_to_activate_with' => array('email'), |
|
| 651 | + 'messengers_to_validate_with' => array('email'), |
|
| 652 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 653 | + ); |
|
| 654 | + EE_Register_Message_Type::register('declined_registration', $setup_args); |
|
| 655 | + |
|
| 656 | + //register registration cancelled message type |
|
| 657 | + $setup_args = array( |
|
| 658 | + 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
|
| 659 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
| 660 | + 'messengers_to_activate_with' => array('email'), |
|
| 661 | + 'messengers_to_validate_with' => array('email'), |
|
| 662 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 663 | + ); |
|
| 664 | + EE_Register_Message_Type::register('cancelled_registration', $setup_args); |
|
| 665 | + |
|
| 666 | + |
|
| 667 | + //register payment failed message type |
|
| 668 | + $setup_args = array( |
|
| 669 | + 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
|
| 670 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
| 671 | + 'messengers_to_activate_with' => array('email'), |
|
| 672 | + 'messengers_to_validate_with' => array('email'), |
|
| 673 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 674 | + ); |
|
| 675 | + EE_Register_Message_Type::register('payment_failed', $setup_args); |
|
| 676 | + |
|
| 677 | + //register payment declined message type |
|
| 678 | + $setup_args = array( |
|
| 679 | + 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
|
| 680 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
| 681 | + 'messengers_to_activate_with' => array('email'), |
|
| 682 | + 'messengers_to_validate_with' => array('email'), |
|
| 683 | + 'messengers_supporting_default_template_pack_with' => array('email') |
|
| 684 | + ); |
|
| 685 | + EE_Register_Message_Type::register('payment_cancelled', $setup_args); |
|
| 686 | + } |
|
| 687 | + |
|
| 688 | + |
|
| 689 | + /** |
|
| 690 | + * Takes care of registering the shortcode libraries implemented with caffeinated EE and set up related items. |
|
| 691 | + * |
|
| 692 | + * @since 4.3.2 |
|
| 693 | + * |
|
| 694 | + * @return void |
|
| 695 | + */ |
|
| 696 | + public function register_caf_shortcodes() |
|
| 697 | + { |
|
| 698 | + $setup_args = array( |
|
| 699 | + 'autoloadpaths' => array( |
|
| 700 | + EE_CAF_LIBRARIES . 'shortcodes/' |
|
| 701 | + ), |
|
| 702 | + 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
|
| 703 | + 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
|
| 704 | + 'list_type_shortcodes' => array('[NEWSLETTER_CONTENT]') |
|
| 705 | + ); |
|
| 706 | + EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args); |
|
| 707 | + } |
|
| 708 | + |
|
| 709 | + |
|
| 710 | + /** |
|
| 711 | + * Parses a question list shortcode using given data and template |
|
| 712 | + * |
|
| 713 | + * @param \EE_Shortcodes $shortcode_parser |
|
| 714 | + * @param EE_Question[] $questions An array of questions indexed by answer id. |
|
| 715 | + * @param EE_Answer[] $answers An array of answer objects |
|
| 716 | + * @param string $template Template content to be parsed. |
|
| 717 | + * @param array $valid_shortcodes Valid shortcodes for the template being parsed. |
|
| 718 | + * @param array $extra_data Extra data that might be used when parsing the template. |
|
| 719 | + */ |
|
| 720 | + protected function _parse_question_list_for_primary_or_recipient_registration( |
|
| 721 | + $shortcode_parser, |
|
| 722 | + $questions, |
|
| 723 | + $answers, |
|
| 724 | + $template, |
|
| 725 | + $valid_shortcodes, |
|
| 726 | + $extra_data |
|
| 727 | + ) { |
|
| 728 | + $question_list = ''; |
|
| 729 | + /** @var EEH_Parse_Shortcodes $shortcode_helper */ |
|
| 730 | + $shortcode_helper = $shortcode_parser->get_shortcode_helper(); |
|
| 731 | + foreach ($answers as $answer) { |
|
| 732 | + if ($answer instanceof EE_Answer) { |
|
| 733 | + //first see if the question is in our $questions array. If not then try to get from answer object. |
|
| 734 | + $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null; |
|
| 735 | + $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
| 736 | + if ( |
|
| 737 | + ! $question instanceof EE_Question |
|
| 738 | + || ( |
|
| 739 | + $question instanceof EE_Question |
|
| 740 | + && $question->admin_only() |
|
| 741 | + ) |
|
| 742 | + ) { |
|
| 743 | + continue; |
|
| 744 | + } |
|
| 745 | + $question_list .= $shortcode_helper->parse_question_list_template( |
|
| 746 | + $template, |
|
| 747 | + $answer, |
|
| 748 | + $valid_shortcodes, |
|
| 749 | + $extra_data |
|
| 750 | + ); |
|
| 751 | + } |
|
| 752 | + } |
|
| 753 | + |
|
| 754 | + return $question_list; |
|
| 755 | + } |
|
| 756 | 756 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public function messages_autoload_paths($dir_ref) |
| 97 | 97 | { |
| 98 | - $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
| 98 | + $dir_ref[] = EE_CAF_LIBRARIES.'shortcodes/'; |
|
| 99 | 99 | |
| 100 | 100 | return $dir_ref; |
| 101 | 101 | } |
@@ -216,10 +216,10 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | //the template file name we're replacing contents for. |
| 219 | - $template_file_prefix = $field . '_' . $context; |
|
| 220 | - $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
| 219 | + $template_file_prefix = $field.'_'.$context; |
|
| 220 | + $msg_prefix = $messenger->name.'_'.$message_type->name.'_'; |
|
| 221 | 221 | |
| 222 | - $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
| 222 | + $base_path = EE_CAF_LIBRARIES.'messages/defaults/default/'; |
|
| 223 | 223 | |
| 224 | 224 | if ($messenger->name == 'email' && $message_type->name == 'registration') { |
| 225 | 225 | |
@@ -228,17 +228,17 @@ discard block |
||
| 228 | 228 | case 'question_list_admin' : |
| 229 | 229 | case 'question_list_attendee' : |
| 230 | 230 | case 'question_list_primary_attendee' : |
| 231 | - $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
| 231 | + $path = $base_path.$msg_prefix.'question_list.template.php'; |
|
| 232 | 232 | $contents = EEH_Template::display_template($path, array(), true); |
| 233 | 233 | break; |
| 234 | 234 | |
| 235 | 235 | case 'attendee_list_primary_attendee' : |
| 236 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
| 236 | + $path = $base_path.$msg_prefix.'attendee_list.template.php'; |
|
| 237 | 237 | $contents = EEH_Template::display_template($path, array(), true); |
| 238 | 238 | break; |
| 239 | 239 | |
| 240 | 240 | case 'attendee_list_admin' : |
| 241 | - $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
| 241 | + $path = $base_path.$msg_prefix.'attendee_list_admin.template.php'; |
|
| 242 | 242 | $contents = EEH_Template::display_template($path, |
| 243 | 243 | array(), true); |
| 244 | 244 | break; |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | break; |
| 249 | 249 | |
| 250 | 250 | case 'event_list_attendee' : |
| 251 | - $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
| 251 | + $path = $base_path.$msg_prefix.'event_list_attendee.template.php'; |
|
| 252 | 252 | $contents = EEH_Template::display_template($path, array(), true); |
| 253 | 253 | break; |
| 254 | 254 | } |
@@ -256,24 +256,24 @@ discard block |
||
| 256 | 256 | switch ($template_file_prefix) { |
| 257 | 257 | |
| 258 | 258 | case 'content_attendee' : |
| 259 | - $path = $base_path . $msg_prefix . 'content.template.php'; |
|
| 259 | + $path = $base_path.$msg_prefix.'content.template.php'; |
|
| 260 | 260 | $contents = EEH_Template::display_template($path, array(), true); |
| 261 | 261 | break; |
| 262 | 262 | |
| 263 | 263 | case 'newsletter_content_attendee' : |
| 264 | - $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
| 264 | + $path = $base_path.$msg_prefix.'newsletter_content.template.php'; |
|
| 265 | 265 | $contents = EEH_Template::display_template($path, array(), true); |
| 266 | 266 | break; |
| 267 | 267 | |
| 268 | 268 | case 'newsletter_subject_attendee' : |
| 269 | - $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
| 269 | + $path = $base_path.$msg_prefix.'subject.template.php'; |
|
| 270 | 270 | $contents = EEH_Template::display_template($path, array(), true); |
| 271 | 271 | break; |
| 272 | 272 | } |
| 273 | 273 | } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
| 274 | 274 | switch ($template_file_prefix) { |
| 275 | 275 | case 'attendee_list_purchaser' : |
| 276 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
| 276 | + $path = $base_path.$msg_prefix.'attendee_list.template.php'; |
|
| 277 | 277 | $contents = EEH_Template::display_template($path, array(), true); |
| 278 | 278 | break; |
| 279 | 279 | } |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | |
| 506 | 506 | //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
| 507 | 507 | //object on it. |
| 508 | - if ( ! isset( $extra_data['data'] ) ) { |
|
| 508 | + if ( ! isset($extra_data['data'])) { |
|
| 509 | 509 | $extra_data['data'] = $recipient; |
| 510 | 510 | } |
| 511 | 511 | |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) { |
| 570 | 570 | return ''; |
| 571 | 571 | } |
| 572 | - $registration = $recipient->primary_reg_obj; |
|
| 572 | + $registration = $recipient->primary_reg_obj; |
|
| 573 | 573 | $answers = isset($recipient->registrations[$registration->ID()]['ans_objs']) |
| 574 | 574 | ? $recipient->registrations[$registration->ID()]['ans_objs'] |
| 575 | 575 | : array(); |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | $questions = isset($recipient->questions) ? $recipient->questions : array(); |
| 583 | 583 | //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
| 584 | 584 | //object on it. |
| 585 | - if ( ! isset( $extra_data['data'] ) ){ |
|
| 585 | + if ( ! isset($extra_data['data'])) { |
|
| 586 | 586 | $extra_data['data'] = $recipient; |
| 587 | 587 | } |
| 588 | 588 | return $this->_parse_question_list_for_primary_or_recipient_registration( |
@@ -615,7 +615,7 @@ discard block |
||
| 615 | 615 | $setup_args = array( |
| 616 | 616 | 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
| 617 | 617 | 'autoloadpaths' => array( |
| 618 | - EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
| 618 | + EE_CAF_LIBRARIES.'messages/message_type/newsletter/' |
|
| 619 | 619 | ), |
| 620 | 620 | 'messengers_to_activate_with' => array('email'), |
| 621 | 621 | 'messengers_to_validate_with' => array('email'), |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | //register payment reminder message type |
| 627 | 627 | $setup_args = array( |
| 628 | 628 | 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
| 629 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
| 629 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'), |
|
| 630 | 630 | 'messengers_to_activate_with' => array('email'), |
| 631 | 631 | 'messengers_to_validate_with' => array('email'), |
| 632 | 632 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | //register payment declined message type |
| 637 | 637 | $setup_args = array( |
| 638 | 638 | 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
| 639 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
| 639 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'), |
|
| 640 | 640 | 'messengers_to_activate_with' => array('email'), |
| 641 | 641 | 'messengers_to_validate_with' => array('email'), |
| 642 | 642 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | //register registration declined message type |
| 647 | 647 | $setup_args = array( |
| 648 | 648 | 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
| 649 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
| 649 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'), |
|
| 650 | 650 | 'messengers_to_activate_with' => array('email'), |
| 651 | 651 | 'messengers_to_validate_with' => array('email'), |
| 652 | 652 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | //register registration cancelled message type |
| 657 | 657 | $setup_args = array( |
| 658 | 658 | 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
| 659 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
| 659 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'), |
|
| 660 | 660 | 'messengers_to_activate_with' => array('email'), |
| 661 | 661 | 'messengers_to_validate_with' => array('email'), |
| 662 | 662 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | //register payment failed message type |
| 668 | 668 | $setup_args = array( |
| 669 | 669 | 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
| 670 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
| 670 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'), |
|
| 671 | 671 | 'messengers_to_activate_with' => array('email'), |
| 672 | 672 | 'messengers_to_validate_with' => array('email'), |
| 673 | 673 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | //register payment declined message type |
| 678 | 678 | $setup_args = array( |
| 679 | 679 | 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
| 680 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
| 680 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'), |
|
| 681 | 681 | 'messengers_to_activate_with' => array('email'), |
| 682 | 682 | 'messengers_to_validate_with' => array('email'), |
| 683 | 683 | 'messengers_supporting_default_template_pack_with' => array('email') |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | { |
| 698 | 698 | $setup_args = array( |
| 699 | 699 | 'autoloadpaths' => array( |
| 700 | - EE_CAF_LIBRARIES . 'shortcodes/' |
|
| 700 | + EE_CAF_LIBRARIES.'shortcodes/' |
|
| 701 | 701 | ), |
| 702 | 702 | 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
| 703 | 703 | 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
@@ -32,211 +32,211 @@ |
||
| 32 | 32 | class ShortcodesManager |
| 33 | 33 | { |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 37 | - */ |
|
| 38 | - private $legacy_shortcodes_manager; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var ShortcodeInterface[] $shortcodes |
|
| 42 | - */ |
|
| 43 | - private $shortcodes; |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * ShortcodesManager constructor |
|
| 49 | - * |
|
| 50 | - * @param LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 51 | - */ |
|
| 52 | - public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager) { |
|
| 53 | - $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
| 54 | - // assemble a list of installed and active shortcodes |
|
| 55 | - add_action( |
|
| 56 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 57 | - array($this, 'registerShortcodes'), |
|
| 58 | - 999 |
|
| 59 | - ); |
|
| 60 | - // call add_shortcode() for all installed shortcodes |
|
| 61 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes')); |
|
| 62 | - // check content for shortcodes the old way |
|
| 63 | - add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5); |
|
| 64 | - // check content for shortcodes the NEW more efficient way |
|
| 65 | - add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @return CollectionInterface|ShortcodeInterface[] |
|
| 72 | - * @throws InvalidIdentifierException |
|
| 73 | - * @throws InvalidInterfaceException |
|
| 74 | - * @throws InvalidFilePathException |
|
| 75 | - * @throws InvalidEntityException |
|
| 76 | - * @throws InvalidDataTypeException |
|
| 77 | - * @throws InvalidClassException |
|
| 78 | - */ |
|
| 79 | - public function getShortcodes() |
|
| 80 | - { |
|
| 81 | - if ( ! $this->shortcodes instanceof CollectionInterface) { |
|
| 82 | - $this->shortcodes = $this->loadShortcodesCollection(); |
|
| 83 | - } |
|
| 84 | - return $this->shortcodes; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @return CollectionInterface|ShortcodeInterface[] |
|
| 91 | - * @throws InvalidIdentifierException |
|
| 92 | - * @throws InvalidInterfaceException |
|
| 93 | - * @throws InvalidFilePathException |
|
| 94 | - * @throws InvalidEntityException |
|
| 95 | - * @throws InvalidDataTypeException |
|
| 96 | - * @throws InvalidClassException |
|
| 97 | - */ |
|
| 98 | - protected function loadShortcodesCollection() |
|
| 99 | - { |
|
| 100 | - $loader = new CollectionLoader( |
|
| 101 | - new CollectionDetails( |
|
| 102 | - // collection name |
|
| 103 | - 'shortcodes', |
|
| 104 | - // collection interface |
|
| 105 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 106 | - // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
| 107 | - array('EventEspresso\core\domain\entities\shortcodes'), |
|
| 108 | - // filepaths to classes to add |
|
| 109 | - array(), |
|
| 110 | - // file mask to use if parsing folder for files to add |
|
| 111 | - '', |
|
| 112 | - // what to use as identifier for collection entities |
|
| 113 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
| 114 | - CollectionDetails::ID_CLASS_NAME |
|
| 115 | - ) |
|
| 116 | - ); |
|
| 117 | - return $loader->getCollection(); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @return void |
|
| 124 | - * @throws DomainException |
|
| 125 | - * @throws InvalidInterfaceException |
|
| 126 | - * @throws InvalidIdentifierException |
|
| 127 | - * @throws InvalidFilePathException |
|
| 128 | - * @throws InvalidEntityException |
|
| 129 | - * @throws InvalidDataTypeException |
|
| 130 | - * @throws InvalidClassException |
|
| 131 | - */ |
|
| 132 | - public function registerShortcodes() |
|
| 133 | - { |
|
| 134 | - try { |
|
| 135 | - $this->shortcodes = apply_filters( |
|
| 136 | - 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
| 137 | - $this->getShortcodes() |
|
| 138 | - ); |
|
| 139 | - if (! $this->shortcodes instanceof CollectionInterface) { |
|
| 140 | - throw new InvalidEntityException( |
|
| 141 | - $this->shortcodes, |
|
| 142 | - 'CollectionInterface', |
|
| 143 | - sprintf( |
|
| 144 | - esc_html__( |
|
| 145 | - 'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.', |
|
| 146 | - 'event_espresso' |
|
| 147 | - ), |
|
| 148 | - is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes) |
|
| 149 | - ) |
|
| 150 | - ); |
|
| 151 | - } |
|
| 152 | - $this->legacy_shortcodes_manager->registerShortcodes(); |
|
| 153 | - } catch (Exception $exception) { |
|
| 154 | - new ExceptionStackTraceDisplay($exception); |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * @return void |
|
| 162 | - */ |
|
| 163 | - public function addShortcodes() |
|
| 164 | - { |
|
| 165 | - try { |
|
| 166 | - // cycle thru shortcode folders |
|
| 167 | - foreach ($this->shortcodes as $shortcode) { |
|
| 168 | - /** @var ShortcodeInterface $shortcode */ |
|
| 169 | - if ( $shortcode instanceof EnqueueAssetsInterface) { |
|
| 170 | - add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10); |
|
| 171 | - add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11); |
|
| 172 | - } |
|
| 173 | - // add_shortcode() if it has not already been added |
|
| 174 | - if ( ! shortcode_exists($shortcode->getTag())) { |
|
| 175 | - add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback')); |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - $this->legacy_shortcodes_manager->addShortcodes(); |
|
| 179 | - } catch (Exception $exception) { |
|
| 180 | - new ExceptionStackTraceDisplay($exception); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * callback for the "template_redirect" hook point |
|
| 188 | - * checks posts for EE shortcodes, and initializes them, |
|
| 189 | - * then toggles filter switch that loads core default assets |
|
| 190 | - * |
|
| 191 | - * @return void |
|
| 192 | - */ |
|
| 193 | - public function templateRedirect() |
|
| 194 | - { |
|
| 195 | - global $wp_query; |
|
| 196 | - if (empty($wp_query->posts)) { |
|
| 197 | - return; |
|
| 198 | - } |
|
| 199 | - $load_assets = false; |
|
| 200 | - // array of posts displayed in current request |
|
| 201 | - $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts); |
|
| 202 | - foreach ($posts as $post) { |
|
| 203 | - // now check post content and excerpt for EE shortcodes |
|
| 204 | - $load_assets = $this->parseContentForShortcodes($post->post_content) |
|
| 205 | - ? true |
|
| 206 | - : $load_assets; |
|
| 207 | - } |
|
| 208 | - if ($load_assets) { |
|
| 209 | - $this->legacy_shortcodes_manager->registry()->REQ->set_espresso_page(true); |
|
| 210 | - add_filter('FHEE_load_css', '__return_true'); |
|
| 211 | - add_filter('FHEE_load_js', '__return_true'); |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - |
|
| 217 | - /** |
|
| 218 | - * checks supplied content against list of shortcodes, |
|
| 219 | - * then initializes any found shortcodes, and returns true. |
|
| 220 | - * returns false if no shortcodes found. |
|
| 221 | - * |
|
| 222 | - * @param string $content |
|
| 223 | - * @return bool |
|
| 224 | - */ |
|
| 225 | - public function parseContentForShortcodes($content) |
|
| 226 | - { |
|
| 227 | - $has_shortcode = false; |
|
| 228 | - if(empty($this->shortcodes)){ |
|
| 229 | - return $has_shortcode; |
|
| 230 | - } |
|
| 231 | - foreach ($this->shortcodes as $shortcode) { |
|
| 232 | - /** @var ShortcodeInterface $shortcode */ |
|
| 233 | - if (has_shortcode($content, $shortcode->getTag())) { |
|
| 234 | - $shortcode->initializeShortcode(); |
|
| 235 | - $has_shortcode = true; |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - return $has_shortcode; |
|
| 239 | - } |
|
| 35 | + /** |
|
| 36 | + * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 37 | + */ |
|
| 38 | + private $legacy_shortcodes_manager; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var ShortcodeInterface[] $shortcodes |
|
| 42 | + */ |
|
| 43 | + private $shortcodes; |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * ShortcodesManager constructor |
|
| 49 | + * |
|
| 50 | + * @param LegacyShortcodesManager $legacy_shortcodes_manager |
|
| 51 | + */ |
|
| 52 | + public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager) { |
|
| 53 | + $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
| 54 | + // assemble a list of installed and active shortcodes |
|
| 55 | + add_action( |
|
| 56 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
| 57 | + array($this, 'registerShortcodes'), |
|
| 58 | + 999 |
|
| 59 | + ); |
|
| 60 | + // call add_shortcode() for all installed shortcodes |
|
| 61 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes')); |
|
| 62 | + // check content for shortcodes the old way |
|
| 63 | + add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5); |
|
| 64 | + // check content for shortcodes the NEW more efficient way |
|
| 65 | + add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @return CollectionInterface|ShortcodeInterface[] |
|
| 72 | + * @throws InvalidIdentifierException |
|
| 73 | + * @throws InvalidInterfaceException |
|
| 74 | + * @throws InvalidFilePathException |
|
| 75 | + * @throws InvalidEntityException |
|
| 76 | + * @throws InvalidDataTypeException |
|
| 77 | + * @throws InvalidClassException |
|
| 78 | + */ |
|
| 79 | + public function getShortcodes() |
|
| 80 | + { |
|
| 81 | + if ( ! $this->shortcodes instanceof CollectionInterface) { |
|
| 82 | + $this->shortcodes = $this->loadShortcodesCollection(); |
|
| 83 | + } |
|
| 84 | + return $this->shortcodes; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @return CollectionInterface|ShortcodeInterface[] |
|
| 91 | + * @throws InvalidIdentifierException |
|
| 92 | + * @throws InvalidInterfaceException |
|
| 93 | + * @throws InvalidFilePathException |
|
| 94 | + * @throws InvalidEntityException |
|
| 95 | + * @throws InvalidDataTypeException |
|
| 96 | + * @throws InvalidClassException |
|
| 97 | + */ |
|
| 98 | + protected function loadShortcodesCollection() |
|
| 99 | + { |
|
| 100 | + $loader = new CollectionLoader( |
|
| 101 | + new CollectionDetails( |
|
| 102 | + // collection name |
|
| 103 | + 'shortcodes', |
|
| 104 | + // collection interface |
|
| 105 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 106 | + // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
| 107 | + array('EventEspresso\core\domain\entities\shortcodes'), |
|
| 108 | + // filepaths to classes to add |
|
| 109 | + array(), |
|
| 110 | + // file mask to use if parsing folder for files to add |
|
| 111 | + '', |
|
| 112 | + // what to use as identifier for collection entities |
|
| 113 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
| 114 | + CollectionDetails::ID_CLASS_NAME |
|
| 115 | + ) |
|
| 116 | + ); |
|
| 117 | + return $loader->getCollection(); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @return void |
|
| 124 | + * @throws DomainException |
|
| 125 | + * @throws InvalidInterfaceException |
|
| 126 | + * @throws InvalidIdentifierException |
|
| 127 | + * @throws InvalidFilePathException |
|
| 128 | + * @throws InvalidEntityException |
|
| 129 | + * @throws InvalidDataTypeException |
|
| 130 | + * @throws InvalidClassException |
|
| 131 | + */ |
|
| 132 | + public function registerShortcodes() |
|
| 133 | + { |
|
| 134 | + try { |
|
| 135 | + $this->shortcodes = apply_filters( |
|
| 136 | + 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
| 137 | + $this->getShortcodes() |
|
| 138 | + ); |
|
| 139 | + if (! $this->shortcodes instanceof CollectionInterface) { |
|
| 140 | + throw new InvalidEntityException( |
|
| 141 | + $this->shortcodes, |
|
| 142 | + 'CollectionInterface', |
|
| 143 | + sprintf( |
|
| 144 | + esc_html__( |
|
| 145 | + 'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.', |
|
| 146 | + 'event_espresso' |
|
| 147 | + ), |
|
| 148 | + is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes) |
|
| 149 | + ) |
|
| 150 | + ); |
|
| 151 | + } |
|
| 152 | + $this->legacy_shortcodes_manager->registerShortcodes(); |
|
| 153 | + } catch (Exception $exception) { |
|
| 154 | + new ExceptionStackTraceDisplay($exception); |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * @return void |
|
| 162 | + */ |
|
| 163 | + public function addShortcodes() |
|
| 164 | + { |
|
| 165 | + try { |
|
| 166 | + // cycle thru shortcode folders |
|
| 167 | + foreach ($this->shortcodes as $shortcode) { |
|
| 168 | + /** @var ShortcodeInterface $shortcode */ |
|
| 169 | + if ( $shortcode instanceof EnqueueAssetsInterface) { |
|
| 170 | + add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10); |
|
| 171 | + add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11); |
|
| 172 | + } |
|
| 173 | + // add_shortcode() if it has not already been added |
|
| 174 | + if ( ! shortcode_exists($shortcode->getTag())) { |
|
| 175 | + add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback')); |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + $this->legacy_shortcodes_manager->addShortcodes(); |
|
| 179 | + } catch (Exception $exception) { |
|
| 180 | + new ExceptionStackTraceDisplay($exception); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * callback for the "template_redirect" hook point |
|
| 188 | + * checks posts for EE shortcodes, and initializes them, |
|
| 189 | + * then toggles filter switch that loads core default assets |
|
| 190 | + * |
|
| 191 | + * @return void |
|
| 192 | + */ |
|
| 193 | + public function templateRedirect() |
|
| 194 | + { |
|
| 195 | + global $wp_query; |
|
| 196 | + if (empty($wp_query->posts)) { |
|
| 197 | + return; |
|
| 198 | + } |
|
| 199 | + $load_assets = false; |
|
| 200 | + // array of posts displayed in current request |
|
| 201 | + $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts); |
|
| 202 | + foreach ($posts as $post) { |
|
| 203 | + // now check post content and excerpt for EE shortcodes |
|
| 204 | + $load_assets = $this->parseContentForShortcodes($post->post_content) |
|
| 205 | + ? true |
|
| 206 | + : $load_assets; |
|
| 207 | + } |
|
| 208 | + if ($load_assets) { |
|
| 209 | + $this->legacy_shortcodes_manager->registry()->REQ->set_espresso_page(true); |
|
| 210 | + add_filter('FHEE_load_css', '__return_true'); |
|
| 211 | + add_filter('FHEE_load_js', '__return_true'); |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + |
|
| 217 | + /** |
|
| 218 | + * checks supplied content against list of shortcodes, |
|
| 219 | + * then initializes any found shortcodes, and returns true. |
|
| 220 | + * returns false if no shortcodes found. |
|
| 221 | + * |
|
| 222 | + * @param string $content |
|
| 223 | + * @return bool |
|
| 224 | + */ |
|
| 225 | + public function parseContentForShortcodes($content) |
|
| 226 | + { |
|
| 227 | + $has_shortcode = false; |
|
| 228 | + if(empty($this->shortcodes)){ |
|
| 229 | + return $has_shortcode; |
|
| 230 | + } |
|
| 231 | + foreach ($this->shortcodes as $shortcode) { |
|
| 232 | + /** @var ShortcodeInterface $shortcode */ |
|
| 233 | + if (has_shortcode($content, $shortcode->getTag())) { |
|
| 234 | + $shortcode->initializeShortcode(); |
|
| 235 | + $has_shortcode = true; |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + return $has_shortcode; |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | 241 | } |
| 242 | 242 | // End of file ShortcodesManager.php |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | use EventEspresso\widgets\EspressoWidget; |
| 4 | 4 | |
| 5 | 5 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 6 | - exit('No direct script access allowed'); |
|
| 6 | + exit('No direct script access allowed'); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | /** |
@@ -26,378 +26,378 @@ discard block |
||
| 26 | 26 | final class EE_Front_Controller |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var string $_template_path |
|
| 31 | - */ |
|
| 32 | - private $_template_path; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var string $_template |
|
| 36 | - */ |
|
| 37 | - private $_template; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @type EE_Registry $Registry |
|
| 41 | - */ |
|
| 42 | - protected $Registry; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @type EE_Request_Handler $Request_Handler |
|
| 46 | - */ |
|
| 47 | - protected $Request_Handler; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @type EE_Module_Request_Router $Module_Request_Router |
|
| 51 | - */ |
|
| 52 | - protected $Module_Request_Router; |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * class constructor |
|
| 57 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
| 58 | - * |
|
| 59 | - * @access public |
|
| 60 | - * @param \EE_Registry $Registry |
|
| 61 | - * @param \EE_Request_Handler $Request_Handler |
|
| 62 | - * @param \EE_Module_Request_Router $Module_Request_Router |
|
| 63 | - */ |
|
| 64 | - public function __construct( |
|
| 65 | - EE_Registry $Registry, |
|
| 66 | - EE_Request_Handler $Request_Handler, |
|
| 67 | - EE_Module_Request_Router $Module_Request_Router |
|
| 68 | - ) { |
|
| 69 | - $this->Registry = $Registry; |
|
| 70 | - $this->Request_Handler = $Request_Handler; |
|
| 71 | - $this->Module_Request_Router = $Module_Request_Router; |
|
| 72 | - // determine how to integrate WP_Query with the EE models |
|
| 73 | - add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
| 74 | - // load other resources and begin to actually run shortcodes and modules |
|
| 75 | - add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
| 76 | - // analyse the incoming WP request |
|
| 77 | - add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
| 78 | - // process request with module factory |
|
| 79 | - add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
| 80 | - // before headers sent |
|
| 81 | - add_action('wp', array($this, 'wp'), 5); |
|
| 82 | - // primarily used to process any content shortcodes |
|
| 83 | - add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
| 84 | - // header |
|
| 85 | - add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
| 86 | - add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
| 87 | - add_filter('template_include', array($this, 'template_include'), 1); |
|
| 88 | - // display errors |
|
| 89 | - add_action('loop_start', array($this, 'display_errors'), 2); |
|
| 90 | - // the content |
|
| 91 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
| 92 | - //exclude our private cpt comments |
|
| 93 | - add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
| 94 | - //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
| 95 | - add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
| 96 | - // action hook EE |
|
| 97 | - do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
| 98 | - // for checking that browser cookies are enabled |
|
| 99 | - if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
| 100 | - setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @return EE_Request_Handler |
|
| 107 | - */ |
|
| 108 | - public function Request_Handler() |
|
| 109 | - { |
|
| 110 | - return $this->Request_Handler; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @return EE_Module_Request_Router |
|
| 116 | - */ |
|
| 117 | - public function Module_Request_Router() |
|
| 118 | - { |
|
| 119 | - return $this->Module_Request_Router; |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * @return LegacyShortcodesManager |
|
| 126 | - */ |
|
| 127 | - public function getLegacyShortcodesManager() |
|
| 128 | - { |
|
| 129 | - return EE_Config::getLegacyShortcodesManager(); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * filter_wp_comments |
|
| 142 | - * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
| 143 | - * widgets/queries done on frontend |
|
| 144 | - * |
|
| 145 | - * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
| 146 | - * @return array array of comment clauses with modifications. |
|
| 147 | - */ |
|
| 148 | - public function filter_wp_comments($clauses) |
|
| 149 | - { |
|
| 150 | - global $wpdb; |
|
| 151 | - if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
| 152 | - $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
| 153 | - foreach ($cpts as $cpt => $details) { |
|
| 154 | - $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - return $clauses; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * employ_CPT_Strategy |
|
| 163 | - * |
|
| 164 | - * @access public |
|
| 165 | - * @return void |
|
| 166 | - */ |
|
| 167 | - public function employ_CPT_Strategy() |
|
| 168 | - { |
|
| 169 | - if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
| 170 | - $this->Registry->load_core('CPT_Strategy'); |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
| 177 | - * |
|
| 178 | - * @param string $url incoming url |
|
| 179 | - * @return string final assembled url |
|
| 180 | - */ |
|
| 181 | - public function maybe_force_admin_ajax_ssl($url) |
|
| 182 | - { |
|
| 183 | - if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
| 184 | - $url = str_replace('http://', 'https://', $url); |
|
| 185 | - } |
|
| 186 | - return $url; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - |
|
| 190 | - |
|
| 191 | - |
|
| 192 | - |
|
| 193 | - |
|
| 194 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
| 199 | - * default priority init phases have run |
|
| 200 | - * |
|
| 201 | - * @access public |
|
| 202 | - * @return void |
|
| 203 | - */ |
|
| 204 | - public function wp_loaded() |
|
| 205 | - { |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - |
|
| 209 | - |
|
| 210 | - |
|
| 211 | - |
|
| 212 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
| 213 | - /** |
|
| 214 | - * _get_request |
|
| 215 | - * |
|
| 216 | - * @access public |
|
| 217 | - * @param WP $WP |
|
| 218 | - * @return void |
|
| 219 | - */ |
|
| 220 | - public function get_request(WP $WP) |
|
| 221 | - { |
|
| 222 | - do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
| 223 | - $this->Request_Handler->parse_request($WP); |
|
| 224 | - do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
| 231 | - * |
|
| 232 | - * @access public |
|
| 233 | - * @param WP_Query $WP_Query |
|
| 234 | - * @return void |
|
| 235 | - */ |
|
| 236 | - public function pre_get_posts($WP_Query) |
|
| 237 | - { |
|
| 238 | - // only load Module_Request_Router if this is the main query |
|
| 239 | - if ( |
|
| 240 | - $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
| 241 | - && $WP_Query->is_main_query() |
|
| 242 | - ) { |
|
| 243 | - // cycle thru module routes |
|
| 244 | - while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
| 245 | - // determine module and method for route |
|
| 246 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
| 247 | - if ($module instanceof EED_Module) { |
|
| 248 | - // get registered view for route |
|
| 249 | - $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
| 250 | - // grab module name |
|
| 251 | - $module_name = $module->module_name(); |
|
| 252 | - // map the module to the module objects |
|
| 253 | - $this->Registry->modules->{$module_name} = $module; |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - |
|
| 260 | - |
|
| 261 | - |
|
| 262 | - |
|
| 263 | - /*********************************************** WP HOOK ***********************************************/ |
|
| 264 | - |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * wp - basically last chance to do stuff before headers sent |
|
| 268 | - * |
|
| 269 | - * @access public |
|
| 270 | - * @return void |
|
| 271 | - */ |
|
| 272 | - public function wp() |
|
| 273 | - { |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - |
|
| 277 | - |
|
| 278 | - /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
| 279 | - |
|
| 280 | - |
|
| 281 | - |
|
| 282 | - /** |
|
| 283 | - * callback for the "template_redirect" hook point |
|
| 284 | - * checks sidebars for EE widgets |
|
| 285 | - * loads resources and assets accordingly |
|
| 286 | - * |
|
| 287 | - * @return void |
|
| 288 | - */ |
|
| 289 | - public function templateRedirect() |
|
| 290 | - { |
|
| 291 | - global $wp_query; |
|
| 292 | - if (empty($wp_query->posts)){ |
|
| 293 | - return; |
|
| 294 | - } |
|
| 295 | - // if we already know this is an espresso page, then load assets |
|
| 296 | - $load_assets = $this->Request_Handler->is_espresso_page(); |
|
| 297 | - // if we are already loading assets then just move along, otherwise check for widgets |
|
| 298 | - $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
| 299 | - if ( $load_assets){ |
|
| 300 | - wp_enqueue_style('espresso_default'); |
|
| 301 | - wp_enqueue_style('espresso_custom_css'); |
|
| 302 | - wp_enqueue_script('espresso_core'); |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * builds list of active widgets then scans active sidebars looking for them |
|
| 310 | - * returns true is an EE widget is found in an active sidebar |
|
| 311 | - * Please Note: this does NOT mean that the sidebar or widget |
|
| 312 | - * is actually in use in a given template, as that is unfortunately not known |
|
| 313 | - * until a sidebar and it's widgets are actually loaded |
|
| 314 | - * |
|
| 315 | - * @return boolean |
|
| 316 | - */ |
|
| 317 | - private function espresso_widgets_in_active_sidebars() |
|
| 318 | - { |
|
| 319 | - $espresso_widgets = array(); |
|
| 320 | - foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
| 321 | - $id_base = EspressoWidget::getIdBase($widget_class); |
|
| 322 | - if (is_active_widget(false, false, $id_base)) { |
|
| 323 | - $espresso_widgets[] = $id_base; |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
| 327 | - foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
| 328 | - if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
| 329 | - foreach ($sidebar_widgets as $sidebar_widget) { |
|
| 330 | - foreach ($espresso_widgets as $espresso_widget) { |
|
| 331 | - if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
| 332 | - return true; |
|
| 333 | - } |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - } |
|
| 337 | - } |
|
| 338 | - return false; |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - |
|
| 342 | - |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * header_meta_tag |
|
| 346 | - * |
|
| 347 | - * @access public |
|
| 348 | - * @return void |
|
| 349 | - */ |
|
| 350 | - public function header_meta_tag() |
|
| 351 | - { |
|
| 352 | - print( |
|
| 353 | - apply_filters( |
|
| 354 | - 'FHEE__EE_Front_Controller__header_meta_tag', |
|
| 355 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
| 356 | - ); |
|
| 357 | - |
|
| 358 | - //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
| 359 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
| 360 | - //also exclude all critical pages from indexing |
|
| 361 | - if ( |
|
| 362 | - ( |
|
| 363 | - is_tax('espresso_event_type') |
|
| 364 | - && get_option( 'blog_public' ) !== '0' |
|
| 365 | - ) |
|
| 366 | - || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
| 367 | - ) { |
|
| 368 | - print( |
|
| 369 | - apply_filters( |
|
| 370 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
| 371 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
| 372 | - ) |
|
| 373 | - ); |
|
| 374 | - } |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * wp_print_scripts |
|
| 381 | - * |
|
| 382 | - * @return void |
|
| 383 | - */ |
|
| 384 | - public function wp_print_scripts() |
|
| 385 | - { |
|
| 386 | - global $post; |
|
| 387 | - if ( |
|
| 388 | - isset($post->EE_Event) |
|
| 389 | - && $post->EE_Event instanceof EE_Event |
|
| 390 | - && get_post_type() === 'espresso_events' |
|
| 391 | - && is_singular() |
|
| 392 | - ) { |
|
| 393 | - \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
| 394 | - } |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - |
|
| 398 | - |
|
| 399 | - |
|
| 400 | - /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
| 29 | + /** |
|
| 30 | + * @var string $_template_path |
|
| 31 | + */ |
|
| 32 | + private $_template_path; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var string $_template |
|
| 36 | + */ |
|
| 37 | + private $_template; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @type EE_Registry $Registry |
|
| 41 | + */ |
|
| 42 | + protected $Registry; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @type EE_Request_Handler $Request_Handler |
|
| 46 | + */ |
|
| 47 | + protected $Request_Handler; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @type EE_Module_Request_Router $Module_Request_Router |
|
| 51 | + */ |
|
| 52 | + protected $Module_Request_Router; |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * class constructor |
|
| 57 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
| 58 | + * |
|
| 59 | + * @access public |
|
| 60 | + * @param \EE_Registry $Registry |
|
| 61 | + * @param \EE_Request_Handler $Request_Handler |
|
| 62 | + * @param \EE_Module_Request_Router $Module_Request_Router |
|
| 63 | + */ |
|
| 64 | + public function __construct( |
|
| 65 | + EE_Registry $Registry, |
|
| 66 | + EE_Request_Handler $Request_Handler, |
|
| 67 | + EE_Module_Request_Router $Module_Request_Router |
|
| 68 | + ) { |
|
| 69 | + $this->Registry = $Registry; |
|
| 70 | + $this->Request_Handler = $Request_Handler; |
|
| 71 | + $this->Module_Request_Router = $Module_Request_Router; |
|
| 72 | + // determine how to integrate WP_Query with the EE models |
|
| 73 | + add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
| 74 | + // load other resources and begin to actually run shortcodes and modules |
|
| 75 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
| 76 | + // analyse the incoming WP request |
|
| 77 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
| 78 | + // process request with module factory |
|
| 79 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
| 80 | + // before headers sent |
|
| 81 | + add_action('wp', array($this, 'wp'), 5); |
|
| 82 | + // primarily used to process any content shortcodes |
|
| 83 | + add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
| 84 | + // header |
|
| 85 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
| 86 | + add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10); |
|
| 87 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
| 88 | + // display errors |
|
| 89 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
| 90 | + // the content |
|
| 91 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
| 92 | + //exclude our private cpt comments |
|
| 93 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
| 94 | + //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
| 95 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
| 96 | + // action hook EE |
|
| 97 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
| 98 | + // for checking that browser cookies are enabled |
|
| 99 | + if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
| 100 | + setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @return EE_Request_Handler |
|
| 107 | + */ |
|
| 108 | + public function Request_Handler() |
|
| 109 | + { |
|
| 110 | + return $this->Request_Handler; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * @return EE_Module_Request_Router |
|
| 116 | + */ |
|
| 117 | + public function Module_Request_Router() |
|
| 118 | + { |
|
| 119 | + return $this->Module_Request_Router; |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * @return LegacyShortcodesManager |
|
| 126 | + */ |
|
| 127 | + public function getLegacyShortcodesManager() |
|
| 128 | + { |
|
| 129 | + return EE_Config::getLegacyShortcodesManager(); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * filter_wp_comments |
|
| 142 | + * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
| 143 | + * widgets/queries done on frontend |
|
| 144 | + * |
|
| 145 | + * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
| 146 | + * @return array array of comment clauses with modifications. |
|
| 147 | + */ |
|
| 148 | + public function filter_wp_comments($clauses) |
|
| 149 | + { |
|
| 150 | + global $wpdb; |
|
| 151 | + if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
| 152 | + $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
| 153 | + foreach ($cpts as $cpt => $details) { |
|
| 154 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + return $clauses; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * employ_CPT_Strategy |
|
| 163 | + * |
|
| 164 | + * @access public |
|
| 165 | + * @return void |
|
| 166 | + */ |
|
| 167 | + public function employ_CPT_Strategy() |
|
| 168 | + { |
|
| 169 | + if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
| 170 | + $this->Registry->load_core('CPT_Strategy'); |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
| 177 | + * |
|
| 178 | + * @param string $url incoming url |
|
| 179 | + * @return string final assembled url |
|
| 180 | + */ |
|
| 181 | + public function maybe_force_admin_ajax_ssl($url) |
|
| 182 | + { |
|
| 183 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
| 184 | + $url = str_replace('http://', 'https://', $url); |
|
| 185 | + } |
|
| 186 | + return $url; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + |
|
| 190 | + |
|
| 191 | + |
|
| 192 | + |
|
| 193 | + |
|
| 194 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
| 199 | + * default priority init phases have run |
|
| 200 | + * |
|
| 201 | + * @access public |
|
| 202 | + * @return void |
|
| 203 | + */ |
|
| 204 | + public function wp_loaded() |
|
| 205 | + { |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + |
|
| 209 | + |
|
| 210 | + |
|
| 211 | + |
|
| 212 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
| 213 | + /** |
|
| 214 | + * _get_request |
|
| 215 | + * |
|
| 216 | + * @access public |
|
| 217 | + * @param WP $WP |
|
| 218 | + * @return void |
|
| 219 | + */ |
|
| 220 | + public function get_request(WP $WP) |
|
| 221 | + { |
|
| 222 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
| 223 | + $this->Request_Handler->parse_request($WP); |
|
| 224 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
| 231 | + * |
|
| 232 | + * @access public |
|
| 233 | + * @param WP_Query $WP_Query |
|
| 234 | + * @return void |
|
| 235 | + */ |
|
| 236 | + public function pre_get_posts($WP_Query) |
|
| 237 | + { |
|
| 238 | + // only load Module_Request_Router if this is the main query |
|
| 239 | + if ( |
|
| 240 | + $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
| 241 | + && $WP_Query->is_main_query() |
|
| 242 | + ) { |
|
| 243 | + // cycle thru module routes |
|
| 244 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
| 245 | + // determine module and method for route |
|
| 246 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
| 247 | + if ($module instanceof EED_Module) { |
|
| 248 | + // get registered view for route |
|
| 249 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
| 250 | + // grab module name |
|
| 251 | + $module_name = $module->module_name(); |
|
| 252 | + // map the module to the module objects |
|
| 253 | + $this->Registry->modules->{$module_name} = $module; |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + |
|
| 260 | + |
|
| 261 | + |
|
| 262 | + |
|
| 263 | + /*********************************************** WP HOOK ***********************************************/ |
|
| 264 | + |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * wp - basically last chance to do stuff before headers sent |
|
| 268 | + * |
|
| 269 | + * @access public |
|
| 270 | + * @return void |
|
| 271 | + */ |
|
| 272 | + public function wp() |
|
| 273 | + { |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + |
|
| 277 | + |
|
| 278 | + /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
|
| 279 | + |
|
| 280 | + |
|
| 281 | + |
|
| 282 | + /** |
|
| 283 | + * callback for the "template_redirect" hook point |
|
| 284 | + * checks sidebars for EE widgets |
|
| 285 | + * loads resources and assets accordingly |
|
| 286 | + * |
|
| 287 | + * @return void |
|
| 288 | + */ |
|
| 289 | + public function templateRedirect() |
|
| 290 | + { |
|
| 291 | + global $wp_query; |
|
| 292 | + if (empty($wp_query->posts)){ |
|
| 293 | + return; |
|
| 294 | + } |
|
| 295 | + // if we already know this is an espresso page, then load assets |
|
| 296 | + $load_assets = $this->Request_Handler->is_espresso_page(); |
|
| 297 | + // if we are already loading assets then just move along, otherwise check for widgets |
|
| 298 | + $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
|
| 299 | + if ( $load_assets){ |
|
| 300 | + wp_enqueue_style('espresso_default'); |
|
| 301 | + wp_enqueue_style('espresso_custom_css'); |
|
| 302 | + wp_enqueue_script('espresso_core'); |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * builds list of active widgets then scans active sidebars looking for them |
|
| 310 | + * returns true is an EE widget is found in an active sidebar |
|
| 311 | + * Please Note: this does NOT mean that the sidebar or widget |
|
| 312 | + * is actually in use in a given template, as that is unfortunately not known |
|
| 313 | + * until a sidebar and it's widgets are actually loaded |
|
| 314 | + * |
|
| 315 | + * @return boolean |
|
| 316 | + */ |
|
| 317 | + private function espresso_widgets_in_active_sidebars() |
|
| 318 | + { |
|
| 319 | + $espresso_widgets = array(); |
|
| 320 | + foreach ($this->Registry->widgets as $widget_class => $widget) { |
|
| 321 | + $id_base = EspressoWidget::getIdBase($widget_class); |
|
| 322 | + if (is_active_widget(false, false, $id_base)) { |
|
| 323 | + $espresso_widgets[] = $id_base; |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + $all_sidebar_widgets = wp_get_sidebars_widgets(); |
|
| 327 | + foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) { |
|
| 328 | + if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) { |
|
| 329 | + foreach ($sidebar_widgets as $sidebar_widget) { |
|
| 330 | + foreach ($espresso_widgets as $espresso_widget) { |
|
| 331 | + if (strpos($sidebar_widget, $espresso_widget) !== false) { |
|
| 332 | + return true; |
|
| 333 | + } |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | + return false; |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + |
|
| 342 | + |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * header_meta_tag |
|
| 346 | + * |
|
| 347 | + * @access public |
|
| 348 | + * @return void |
|
| 349 | + */ |
|
| 350 | + public function header_meta_tag() |
|
| 351 | + { |
|
| 352 | + print( |
|
| 353 | + apply_filters( |
|
| 354 | + 'FHEE__EE_Front_Controller__header_meta_tag', |
|
| 355 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
| 356 | + ); |
|
| 357 | + |
|
| 358 | + //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
| 359 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
| 360 | + //also exclude all critical pages from indexing |
|
| 361 | + if ( |
|
| 362 | + ( |
|
| 363 | + is_tax('espresso_event_type') |
|
| 364 | + && get_option( 'blog_public' ) !== '0' |
|
| 365 | + ) |
|
| 366 | + || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
|
| 367 | + ) { |
|
| 368 | + print( |
|
| 369 | + apply_filters( |
|
| 370 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
| 371 | + '<meta name="robots" content="noindex,follow" />' . "\n" |
|
| 372 | + ) |
|
| 373 | + ); |
|
| 374 | + } |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + |
|
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * wp_print_scripts |
|
| 381 | + * |
|
| 382 | + * @return void |
|
| 383 | + */ |
|
| 384 | + public function wp_print_scripts() |
|
| 385 | + { |
|
| 386 | + global $post; |
|
| 387 | + if ( |
|
| 388 | + isset($post->EE_Event) |
|
| 389 | + && $post->EE_Event instanceof EE_Event |
|
| 390 | + && get_post_type() === 'espresso_events' |
|
| 391 | + && is_singular() |
|
| 392 | + ) { |
|
| 393 | + \EEH_Schema::add_json_linked_data_for_event($post->EE_Event); |
|
| 394 | + } |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + |
|
| 398 | + |
|
| 399 | + |
|
| 400 | + /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
|
| 401 | 401 | |
| 402 | 402 | |
| 403 | 403 | |
@@ -408,99 +408,99 @@ discard block |
||
| 408 | 408 | // * @param $the_content |
| 409 | 409 | // * @return string |
| 410 | 410 | // */ |
| 411 | - // public function the_content( $the_content ) { |
|
| 412 | - // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
| 413 | - // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
| 414 | - // } |
|
| 415 | - // return $the_content; |
|
| 416 | - // } |
|
| 417 | - |
|
| 418 | - |
|
| 419 | - |
|
| 420 | - /*********************************************** WP_FOOTER ***********************************************/ |
|
| 421 | - |
|
| 422 | - |
|
| 423 | - /** |
|
| 424 | - * display_errors |
|
| 425 | - * |
|
| 426 | - * @access public |
|
| 427 | - * @return void |
|
| 428 | - */ |
|
| 429 | - public function display_errors() |
|
| 430 | - { |
|
| 431 | - static $shown_already = false; |
|
| 432 | - do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
| 433 | - if ( |
|
| 434 | - ! $shown_already |
|
| 435 | - && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
| 436 | - && is_main_query() |
|
| 437 | - && ! is_feed() |
|
| 438 | - && in_the_loop() |
|
| 439 | - && $this->Request_Handler->is_espresso_page() |
|
| 440 | - ) { |
|
| 441 | - echo EE_Error::get_notices(); |
|
| 442 | - $shown_already = true; |
|
| 443 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
| 444 | - } |
|
| 445 | - do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - |
|
| 449 | - |
|
| 450 | - |
|
| 451 | - |
|
| 452 | - /*********************************************** UTILITIES ***********************************************/ |
|
| 453 | - /** |
|
| 454 | - * template_include |
|
| 455 | - * |
|
| 456 | - * @access public |
|
| 457 | - * @param string $template_include_path |
|
| 458 | - * @return string |
|
| 459 | - */ |
|
| 460 | - public function template_include($template_include_path = null) |
|
| 461 | - { |
|
| 462 | - if ($this->Request_Handler->is_espresso_page()) { |
|
| 463 | - $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
| 464 | - $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
| 465 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
| 466 | - $this->_template = basename($this->_template_path); |
|
| 467 | - return $this->_template_path; |
|
| 468 | - } |
|
| 469 | - return $template_include_path; |
|
| 470 | - } |
|
| 471 | - |
|
| 472 | - |
|
| 473 | - /** |
|
| 474 | - * get_selected_template |
|
| 475 | - * |
|
| 476 | - * @access public |
|
| 477 | - * @param bool $with_path |
|
| 478 | - * @return string |
|
| 479 | - */ |
|
| 480 | - public function get_selected_template($with_path = false) |
|
| 481 | - { |
|
| 482 | - return $with_path ? $this->_template_path : $this->_template; |
|
| 483 | - } |
|
| 484 | - |
|
| 485 | - |
|
| 486 | - |
|
| 487 | - /** |
|
| 488 | - * @deprecated 4.9.26 |
|
| 489 | - * @param string $shortcode_class |
|
| 490 | - * @param \WP $wp |
|
| 491 | - */ |
|
| 492 | - public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
| 493 | - { |
|
| 494 | - \EE_Error::doing_it_wrong( |
|
| 495 | - __METHOD__, |
|
| 496 | - __( |
|
| 497 | - 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
| 498 | - 'event_espresso' |
|
| 499 | - ), |
|
| 500 | - '4.9.26' |
|
| 501 | - ); |
|
| 502 | - $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
| 503 | - } |
|
| 411 | + // public function the_content( $the_content ) { |
|
| 412 | + // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
| 413 | + // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
| 414 | + // } |
|
| 415 | + // return $the_content; |
|
| 416 | + // } |
|
| 417 | + |
|
| 418 | + |
|
| 419 | + |
|
| 420 | + /*********************************************** WP_FOOTER ***********************************************/ |
|
| 421 | + |
|
| 422 | + |
|
| 423 | + /** |
|
| 424 | + * display_errors |
|
| 425 | + * |
|
| 426 | + * @access public |
|
| 427 | + * @return void |
|
| 428 | + */ |
|
| 429 | + public function display_errors() |
|
| 430 | + { |
|
| 431 | + static $shown_already = false; |
|
| 432 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
| 433 | + if ( |
|
| 434 | + ! $shown_already |
|
| 435 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
| 436 | + && is_main_query() |
|
| 437 | + && ! is_feed() |
|
| 438 | + && in_the_loop() |
|
| 439 | + && $this->Request_Handler->is_espresso_page() |
|
| 440 | + ) { |
|
| 441 | + echo EE_Error::get_notices(); |
|
| 442 | + $shown_already = true; |
|
| 443 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
| 444 | + } |
|
| 445 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + |
|
| 449 | + |
|
| 450 | + |
|
| 451 | + |
|
| 452 | + /*********************************************** UTILITIES ***********************************************/ |
|
| 453 | + /** |
|
| 454 | + * template_include |
|
| 455 | + * |
|
| 456 | + * @access public |
|
| 457 | + * @param string $template_include_path |
|
| 458 | + * @return string |
|
| 459 | + */ |
|
| 460 | + public function template_include($template_include_path = null) |
|
| 461 | + { |
|
| 462 | + if ($this->Request_Handler->is_espresso_page()) { |
|
| 463 | + $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
| 464 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
| 465 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
| 466 | + $this->_template = basename($this->_template_path); |
|
| 467 | + return $this->_template_path; |
|
| 468 | + } |
|
| 469 | + return $template_include_path; |
|
| 470 | + } |
|
| 471 | + |
|
| 472 | + |
|
| 473 | + /** |
|
| 474 | + * get_selected_template |
|
| 475 | + * |
|
| 476 | + * @access public |
|
| 477 | + * @param bool $with_path |
|
| 478 | + * @return string |
|
| 479 | + */ |
|
| 480 | + public function get_selected_template($with_path = false) |
|
| 481 | + { |
|
| 482 | + return $with_path ? $this->_template_path : $this->_template; |
|
| 483 | + } |
|
| 484 | + |
|
| 485 | + |
|
| 486 | + |
|
| 487 | + /** |
|
| 488 | + * @deprecated 4.9.26 |
|
| 489 | + * @param string $shortcode_class |
|
| 490 | + * @param \WP $wp |
|
| 491 | + */ |
|
| 492 | + public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
|
| 493 | + { |
|
| 494 | + \EE_Error::doing_it_wrong( |
|
| 495 | + __METHOD__, |
|
| 496 | + __( |
|
| 497 | + 'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.', |
|
| 498 | + 'event_espresso' |
|
| 499 | + ), |
|
| 500 | + '4.9.26' |
|
| 501 | + ); |
|
| 502 | + $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp); |
|
| 503 | + } |
|
| 504 | 504 | |
| 505 | 505 | } |
| 506 | 506 | // End of file EE_Front_Controller.core.php |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | do_action('AHEE__EE_Front_Controller__construct__done', $this); |
| 98 | 98 | // for checking that browser cookies are enabled |
| 99 | 99 | if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
| 100 | - setcookie('ee_cookie_test', uniqid('ect',true), time() + DAY_IN_SECONDS, '/'); |
|
| 100 | + setcookie('ee_cookie_test', uniqid('ect', true), time() + DAY_IN_SECONDS, '/'); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
@@ -289,14 +289,14 @@ discard block |
||
| 289 | 289 | public function templateRedirect() |
| 290 | 290 | { |
| 291 | 291 | global $wp_query; |
| 292 | - if (empty($wp_query->posts)){ |
|
| 292 | + if (empty($wp_query->posts)) { |
|
| 293 | 293 | return; |
| 294 | 294 | } |
| 295 | 295 | // if we already know this is an espresso page, then load assets |
| 296 | 296 | $load_assets = $this->Request_Handler->is_espresso_page(); |
| 297 | 297 | // if we are already loading assets then just move along, otherwise check for widgets |
| 298 | 298 | $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars(); |
| 299 | - if ( $load_assets){ |
|
| 299 | + if ($load_assets) { |
|
| 300 | 300 | wp_enqueue_style('espresso_default'); |
| 301 | 301 | wp_enqueue_style('espresso_custom_css'); |
| 302 | 302 | wp_enqueue_script('espresso_core'); |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | print( |
| 353 | 353 | apply_filters( |
| 354 | 354 | 'FHEE__EE_Front_Controller__header_meta_tag', |
| 355 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
| 355 | + '<meta name="generator" content="Event Espresso Version '.EVENT_ESPRESSO_VERSION."\" />\n") |
|
| 356 | 356 | ); |
| 357 | 357 | |
| 358 | 358 | //let's exclude all event type taxonomy term archive pages from search engine indexing |
@@ -361,14 +361,14 @@ discard block |
||
| 361 | 361 | if ( |
| 362 | 362 | ( |
| 363 | 363 | is_tax('espresso_event_type') |
| 364 | - && get_option( 'blog_public' ) !== '0' |
|
| 364 | + && get_option('blog_public') !== '0' |
|
| 365 | 365 | ) |
| 366 | 366 | || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array()) |
| 367 | 367 | ) { |
| 368 | 368 | print( |
| 369 | 369 | apply_filters( |
| 370 | 370 | 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
| 371 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
| 371 | + '<meta name="robots" content="noindex,follow" />'."\n" |
|
| 372 | 372 | ) |
| 373 | 373 | ); |
| 374 | 374 | } |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | ) { |
| 441 | 441 | echo EE_Error::get_notices(); |
| 442 | 442 | $shown_already = true; |
| 443 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
| 443 | + EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php'); |
|
| 444 | 444 | } |
| 445 | 445 | do_action('AHEE__EE_Front_Controller__display_errors__end'); |
| 446 | 446 | } |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | * Sets deleted |
| 1073 | 1073 | * |
| 1074 | 1074 | * @param boolean $deleted |
| 1075 | - * @return boolean |
|
| 1075 | + * @return boolean|null |
|
| 1076 | 1076 | */ |
| 1077 | 1077 | public function set_deleted($deleted) |
| 1078 | 1078 | { |
@@ -1125,6 +1125,7 @@ discard block |
||
| 1125 | 1125 | * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
| 1126 | 1126 | * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also |
| 1127 | 1127 | * consider registration status as well as datetime access. |
| 1128 | + * @param integer $DTT_OR_ID |
|
| 1128 | 1129 | * @return bool |
| 1129 | 1130 | */ |
| 1130 | 1131 | public function can_checkin($DTT_OR_ID, $check_approved = true) |
@@ -1278,7 +1279,7 @@ discard block |
||
| 1278 | 1279 | * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
| 1279 | 1280 | * "Latest" is defined by the `DTT_EVT_start` column. |
| 1280 | 1281 | * |
| 1281 | - * @return EE_Datetime|null |
|
| 1282 | + * @return null|EE_Base_Class |
|
| 1282 | 1283 | * @throws \EE_Error |
| 1283 | 1284 | */ |
| 1284 | 1285 | public function get_latest_related_datetime() |
@@ -1557,7 +1558,7 @@ discard block |
||
| 1557 | 1558 | * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
| 1558 | 1559 | * Note: if there are no payments on the registration there will be no payment method returned. |
| 1559 | 1560 | * |
| 1560 | - * @return EE_Payment_Method|null |
|
| 1561 | + * @return null|EE_Base_Class |
|
| 1561 | 1562 | */ |
| 1562 | 1563 | public function payment_method() |
| 1563 | 1564 | { |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php use EventEspresso\core\exceptions\EntityNotFoundException; |
| 2 | 2 | |
| 3 | 3 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 4 | - exit('No direct script access allowed'); |
|
| 4 | + exit('No direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -15,1691 +15,1691 @@ discard block |
||
| 15 | 15 | { |
| 16 | 16 | |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Used to reference when a registration has never been checked in. |
|
| 20 | - * |
|
| 21 | - * @type int |
|
| 22 | - */ |
|
| 23 | - const checkin_status_never = 2; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Used to reference when a registration has been checked in. |
|
| 27 | - * |
|
| 28 | - * @type int |
|
| 29 | - */ |
|
| 30 | - const checkin_status_in = 1; |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * Used to reference when a registration has been checked out. |
|
| 35 | - * |
|
| 36 | - * @type int |
|
| 37 | - */ |
|
| 38 | - const checkin_status_out = 0; |
|
| 39 | - |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * extra meta key for tracking reg status os trashed registrations |
|
| 43 | - * |
|
| 44 | - * @type string |
|
| 45 | - */ |
|
| 46 | - const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status'; |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * extra meta key for tracking if registration has reserved ticket |
|
| 51 | - * |
|
| 52 | - * @type string |
|
| 53 | - */ |
|
| 54 | - const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket'; |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * @param array $props_n_values incoming values |
|
| 59 | - * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 60 | - * used.) |
|
| 61 | - * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 62 | - * date_format and the second value is the time format |
|
| 63 | - * @return EE_Registration |
|
| 64 | - */ |
|
| 65 | - public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 66 | - { |
|
| 67 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 68 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @param array $props_n_values incoming values from the database |
|
| 74 | - * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 75 | - * the website will be used. |
|
| 76 | - * @return EE_Registration |
|
| 77 | - */ |
|
| 78 | - public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 79 | - { |
|
| 80 | - return new self($props_n_values, true, $timezone); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * Set Event ID |
|
| 86 | - * |
|
| 87 | - * @param int $EVT_ID Event ID |
|
| 88 | - */ |
|
| 89 | - public function set_event($EVT_ID = 0) |
|
| 90 | - { |
|
| 91 | - $this->set('EVT_ID', $EVT_ID); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can |
|
| 97 | - * be routed to internal methods |
|
| 98 | - * |
|
| 99 | - * @param string $field_name |
|
| 100 | - * @param mixed $field_value |
|
| 101 | - * @param bool $use_default |
|
| 102 | - * @throws \EE_Error |
|
| 103 | - * @throws \RuntimeException |
|
| 104 | - */ |
|
| 105 | - public function set($field_name, $field_value, $use_default = false) |
|
| 106 | - { |
|
| 107 | - switch ($field_name) { |
|
| 108 | - case 'REG_code' : |
|
| 109 | - if (! empty($field_value) && $this->reg_code() === null) { |
|
| 110 | - $this->set_reg_code($field_value, $use_default); |
|
| 111 | - } |
|
| 112 | - break; |
|
| 113 | - case 'STS_ID' : |
|
| 114 | - $this->set_status($field_value, $use_default); |
|
| 115 | - break; |
|
| 116 | - default : |
|
| 117 | - parent::set($field_name, $field_value, $use_default); |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Set Status ID |
|
| 124 | - * updates the registration status and ALSO... |
|
| 125 | - * calls reserve_registration_space() if the reg status changes TO approved from any other reg status |
|
| 126 | - * calls release_registration_space() if the reg status changes FROM approved to any other reg status |
|
| 127 | - * |
|
| 128 | - * @param string $new_STS_ID |
|
| 129 | - * @param boolean $use_default |
|
| 130 | - * @return bool |
|
| 131 | - * @throws \RuntimeException |
|
| 132 | - * @throws \EE_Error |
|
| 133 | - */ |
|
| 134 | - public function set_status($new_STS_ID = null, $use_default = false) |
|
| 135 | - { |
|
| 136 | - // get current REG_Status |
|
| 137 | - $old_STS_ID = $this->status_ID(); |
|
| 138 | - // if status has changed |
|
| 139 | - if ( |
|
| 140 | - $old_STS_ID !== $new_STS_ID // and that status has actually changed |
|
| 141 | - && ! empty($old_STS_ID) // and that old status is actually set |
|
| 142 | - && ! empty($new_STS_ID) // as well as the new status |
|
| 143 | - && $this->ID() // ensure registration is in the db |
|
| 144 | - ) { |
|
| 145 | - // TO approved |
|
| 146 | - if ($new_STS_ID === EEM_Registration::status_id_approved) { |
|
| 147 | - // reserve a space by incrementing ticket and datetime sold values |
|
| 148 | - $this->_reserve_registration_space(); |
|
| 149 | - do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
| 150 | - // OR FROM approved |
|
| 151 | - } else if ($old_STS_ID === EEM_Registration::status_id_approved) { |
|
| 152 | - // release a space by decrementing ticket and datetime sold values |
|
| 153 | - $this->_release_registration_space(); |
|
| 154 | - do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
| 155 | - } |
|
| 156 | - // update status |
|
| 157 | - parent::set('STS_ID', $new_STS_ID, $use_default); |
|
| 158 | - $this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID); |
|
| 159 | - /** @type EE_Transaction_Payments $transaction_payments */ |
|
| 160 | - $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
| 161 | - $transaction_payments->recalculate_transaction_total($this->transaction(), false); |
|
| 162 | - $this->transaction()->update_status_based_on_total_paid(true); |
|
| 163 | - do_action('AHEE__EE_Registration__set_status__after_update', $this); |
|
| 164 | - return true; |
|
| 165 | - } else { |
|
| 166 | - //even though the old value matches the new value, it's still good to |
|
| 167 | - //allow the parent set method to have a say |
|
| 168 | - parent::set('STS_ID', $new_STS_ID, $use_default); |
|
| 169 | - return true; |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * update REGs and TXN when cancelled or declined registrations involved |
|
| 176 | - * |
|
| 177 | - * @param string $new_STS_ID |
|
| 178 | - * @param string $old_STS_ID |
|
| 179 | - * @throws \EE_Error |
|
| 180 | - */ |
|
| 181 | - private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID) |
|
| 182 | - { |
|
| 183 | - // these reg statuses should not be considered in any calculations involving monies owing |
|
| 184 | - $closed_reg_statuses = EEM_Registration::closed_reg_statuses(); |
|
| 185 | - // true if registration has been cancelled or declined |
|
| 186 | - if ( |
|
| 187 | - in_array($new_STS_ID, $closed_reg_statuses, true) |
|
| 188 | - && ! in_array($old_STS_ID, $closed_reg_statuses, true) |
|
| 189 | - ) { |
|
| 190 | - /** @type EE_Registration_Processor $registration_processor */ |
|
| 191 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 192 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 193 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 194 | - // cancelled or declined registration |
|
| 195 | - $registration_processor->update_registration_after_being_canceled_or_declined( |
|
| 196 | - $this, |
|
| 197 | - $closed_reg_statuses |
|
| 198 | - ); |
|
| 199 | - $transaction_processor->update_transaction_after_canceled_or_declined_registration( |
|
| 200 | - $this, |
|
| 201 | - $closed_reg_statuses, |
|
| 202 | - false |
|
| 203 | - ); |
|
| 204 | - do_action('AHEE__EE_Registration__set_status__canceled_or_declined', $this, $old_STS_ID, $new_STS_ID); |
|
| 205 | - return; |
|
| 206 | - } |
|
| 207 | - // true if reinstating cancelled or declined registration |
|
| 208 | - if ( |
|
| 209 | - in_array($old_STS_ID, $closed_reg_statuses, true) |
|
| 210 | - && ! in_array($new_STS_ID, $closed_reg_statuses, true) |
|
| 211 | - ) { |
|
| 212 | - /** @type EE_Registration_Processor $registration_processor */ |
|
| 213 | - $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 214 | - /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 215 | - $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 216 | - // reinstating cancelled or declined registration |
|
| 217 | - $registration_processor->update_canceled_or_declined_registration_after_being_reinstated( |
|
| 218 | - $this, |
|
| 219 | - $closed_reg_statuses |
|
| 220 | - ); |
|
| 221 | - $transaction_processor->update_transaction_after_reinstating_canceled_registration( |
|
| 222 | - $this, |
|
| 223 | - $closed_reg_statuses, |
|
| 224 | - false |
|
| 225 | - ); |
|
| 226 | - do_action('AHEE__EE_Registration__set_status__after_reinstated', $this, $old_STS_ID, $new_STS_ID); |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * get Status ID |
|
| 233 | - */ |
|
| 234 | - public function status_ID() |
|
| 235 | - { |
|
| 236 | - return $this->get('STS_ID'); |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * increments this registration's related ticket sold and corresponding datetime sold values |
|
| 242 | - * |
|
| 243 | - * @return void |
|
| 244 | - * @throws \EE_Error |
|
| 245 | - */ |
|
| 246 | - private function _reserve_registration_space() |
|
| 247 | - { |
|
| 248 | - // reserved ticket and datetime counts will be decremented as sold counts are incremented |
|
| 249 | - // so stop tracking that this reg has a ticket reserved |
|
| 250 | - $this->release_reserved_ticket(); |
|
| 251 | - $ticket = $this->ticket(); |
|
| 252 | - $ticket->increase_sold(); |
|
| 253 | - $ticket->save(); |
|
| 254 | - // possibly set event status to sold out |
|
| 255 | - $this->event()->perform_sold_out_status_check(); |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * Gets the ticket this registration is for |
|
| 261 | - * |
|
| 262 | - * @param boolean $include_archived whether to include archived tickets or not. |
|
| 263 | - * @return EE_Ticket|EE_Base_Class |
|
| 264 | - * @throws \EE_Error |
|
| 265 | - */ |
|
| 266 | - public function ticket($include_archived = true) |
|
| 267 | - { |
|
| 268 | - $query_params = array(); |
|
| 269 | - if ($include_archived) { |
|
| 270 | - $query_params['default_where_conditions'] = 'none'; |
|
| 271 | - } |
|
| 272 | - return $this->get_first_related('Ticket', $query_params); |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * Gets the event this registration is for |
|
| 278 | - * |
|
| 279 | - * @return EE_Event |
|
| 280 | - */ |
|
| 281 | - public function event() |
|
| 282 | - { |
|
| 283 | - $event = $this->get_first_related('Event'); |
|
| 284 | - if (! $event instanceof \EE_Event) { |
|
| 285 | - throw new EntityNotFoundException('Event ID', $this->event_ID()); |
|
| 286 | - } |
|
| 287 | - return $event; |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Gets the "author" of the registration. Note that for the purposes of registrations, the author will correspond |
|
| 293 | - * with the author of the event this registration is for. |
|
| 294 | - * |
|
| 295 | - * @since 4.5.0 |
|
| 296 | - * @return int |
|
| 297 | - */ |
|
| 298 | - public function wp_user() |
|
| 299 | - { |
|
| 300 | - $event = $this->event(); |
|
| 301 | - if ($event instanceof EE_Event) { |
|
| 302 | - return $event->wp_user(); |
|
| 303 | - } |
|
| 304 | - return 0; |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values |
|
| 310 | - * |
|
| 311 | - * @return void |
|
| 312 | - * @throws \EE_Error |
|
| 313 | - */ |
|
| 314 | - private function _release_registration_space() |
|
| 315 | - { |
|
| 316 | - $ticket = $this->ticket(); |
|
| 317 | - $ticket->decrease_sold(); |
|
| 318 | - $ticket->save(); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * tracks this registration's ticket reservation in extra meta |
|
| 324 | - * and can increment related ticket reserved and corresponding datetime reserved values |
|
| 325 | - * |
|
| 326 | - * @param bool $update_ticket if true, will increment ticket and datetime reserved count |
|
| 327 | - * @return void |
|
| 328 | - * @throws \EE_Error |
|
| 329 | - */ |
|
| 330 | - public function reserve_ticket($update_ticket = false) |
|
| 331 | - { |
|
| 332 | - if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) === false) { |
|
| 333 | - // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
| 334 | - // we NEED to ALWAYS call update_extra_meta(), which is why that is done first |
|
| 335 | - if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) && $update_ticket) { |
|
| 336 | - $ticket = $this->ticket(); |
|
| 337 | - $ticket->increase_reserved(); |
|
| 338 | - $ticket->save(); |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * stops tracking this registration's ticket reservation in extra meta |
|
| 346 | - * decrements (subtracts) related ticket reserved and corresponding datetime reserved values |
|
| 347 | - * |
|
| 348 | - * @param bool $update_ticket if true, will decrement ticket and datetime reserved count |
|
| 349 | - * @return void |
|
| 350 | - * @throws \EE_Error |
|
| 351 | - */ |
|
| 352 | - public function release_reserved_ticket($update_ticket = false) |
|
| 353 | - { |
|
| 354 | - if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) !== false) { |
|
| 355 | - // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
| 356 | - // we NEED to ALWAYS call delete_extra_meta(), which is why that is done first |
|
| 357 | - if ($this->delete_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY) && $update_ticket) { |
|
| 358 | - $ticket = $this->ticket(); |
|
| 359 | - $ticket->decrease_reserved(); |
|
| 360 | - $ticket->save(); |
|
| 361 | - } |
|
| 362 | - } |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - |
|
| 366 | - /** |
|
| 367 | - * Set Attendee ID |
|
| 368 | - * |
|
| 369 | - * @param int $ATT_ID Attendee ID |
|
| 370 | - */ |
|
| 371 | - public function set_attendee_id($ATT_ID = 0) |
|
| 372 | - { |
|
| 373 | - $this->set('ATT_ID', $ATT_ID); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * Set Transaction ID |
|
| 379 | - * |
|
| 380 | - * @param int $TXN_ID Transaction ID |
|
| 381 | - */ |
|
| 382 | - public function set_transaction_id($TXN_ID = 0) |
|
| 383 | - { |
|
| 384 | - $this->set('TXN_ID', $TXN_ID); |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * Set Session |
|
| 390 | - * |
|
| 391 | - * @param string $REG_session PHP Session ID |
|
| 392 | - */ |
|
| 393 | - public function set_session($REG_session = '') |
|
| 394 | - { |
|
| 395 | - $this->set('REG_session', $REG_session); |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - |
|
| 399 | - /** |
|
| 400 | - * Set Registration URL Link |
|
| 401 | - * |
|
| 402 | - * @param string $REG_url_link Registration URL Link |
|
| 403 | - */ |
|
| 404 | - public function set_reg_url_link($REG_url_link = '') |
|
| 405 | - { |
|
| 406 | - $this->set('REG_url_link', $REG_url_link); |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - |
|
| 410 | - /** |
|
| 411 | - * Set Attendee Counter |
|
| 412 | - * |
|
| 413 | - * @param int $REG_count Primary Attendee |
|
| 414 | - */ |
|
| 415 | - public function set_count($REG_count = 1) |
|
| 416 | - { |
|
| 417 | - $this->set('REG_count', $REG_count); |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - |
|
| 421 | - /** |
|
| 422 | - * Set Group Size |
|
| 423 | - * |
|
| 424 | - * @param boolean $REG_group_size Group Registration |
|
| 425 | - */ |
|
| 426 | - public function set_group_size($REG_group_size = false) |
|
| 427 | - { |
|
| 428 | - $this->set('REG_group_size', $REG_group_size); |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - |
|
| 432 | - /** |
|
| 433 | - * is_not_approved - convenience method that returns TRUE if REG status ID == |
|
| 434 | - * EEM_Registration::status_id_not_approved |
|
| 435 | - * |
|
| 436 | - * @return boolean |
|
| 437 | - */ |
|
| 438 | - public function is_not_approved() |
|
| 439 | - { |
|
| 440 | - return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false; |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - |
|
| 444 | - /** |
|
| 445 | - * is_pending_payment - convenience method that returns TRUE if REG status ID == |
|
| 446 | - * EEM_Registration::status_id_pending_payment |
|
| 447 | - * |
|
| 448 | - * @return boolean |
|
| 449 | - */ |
|
| 450 | - public function is_pending_payment() |
|
| 451 | - { |
|
| 452 | - return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false; |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * is_approved - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved |
|
| 458 | - * |
|
| 459 | - * @return boolean |
|
| 460 | - */ |
|
| 461 | - public function is_approved() |
|
| 462 | - { |
|
| 463 | - return $this->status_ID() == EEM_Registration::status_id_approved ? true : false; |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - |
|
| 467 | - /** |
|
| 468 | - * is_cancelled - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled |
|
| 469 | - * |
|
| 470 | - * @return boolean |
|
| 471 | - */ |
|
| 472 | - public function is_cancelled() |
|
| 473 | - { |
|
| 474 | - return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false; |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - |
|
| 478 | - /** |
|
| 479 | - * is_declined - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined |
|
| 480 | - * |
|
| 481 | - * @return boolean |
|
| 482 | - */ |
|
| 483 | - public function is_declined() |
|
| 484 | - { |
|
| 485 | - return $this->status_ID() == EEM_Registration::status_id_declined ? true : false; |
|
| 486 | - } |
|
| 487 | - |
|
| 488 | - |
|
| 489 | - /** |
|
| 490 | - * is_incomplete - convenience method that returns TRUE if REG status ID == |
|
| 491 | - * EEM_Registration::status_id_incomplete |
|
| 492 | - * |
|
| 493 | - * @return boolean |
|
| 494 | - */ |
|
| 495 | - public function is_incomplete() |
|
| 496 | - { |
|
| 497 | - return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false; |
|
| 498 | - } |
|
| 499 | - |
|
| 500 | - |
|
| 501 | - /** |
|
| 502 | - * Set Registration Date |
|
| 503 | - * |
|
| 504 | - * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of |
|
| 505 | - * Date |
|
| 506 | - */ |
|
| 507 | - public function set_reg_date($REG_date = false) |
|
| 508 | - { |
|
| 509 | - $this->set('REG_date', $REG_date); |
|
| 510 | - } |
|
| 511 | - |
|
| 512 | - |
|
| 513 | - /** |
|
| 514 | - * Set final price owing for this registration after all ticket/price modifications |
|
| 515 | - * |
|
| 516 | - * @access public |
|
| 517 | - * @param float $REG_final_price |
|
| 518 | - */ |
|
| 519 | - public function set_final_price($REG_final_price = 0.00) |
|
| 520 | - { |
|
| 521 | - $this->set('REG_final_price', $REG_final_price); |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - |
|
| 525 | - /** |
|
| 526 | - * Set amount paid towards this registration's final price |
|
| 527 | - * |
|
| 528 | - * @access public |
|
| 529 | - * @param float $REG_paid |
|
| 530 | - */ |
|
| 531 | - public function set_paid($REG_paid = 0.00) |
|
| 532 | - { |
|
| 533 | - $this->set('REG_paid', $REG_paid); |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * Attendee Is Going |
|
| 539 | - * |
|
| 540 | - * @param boolean $REG_att_is_going Attendee Is Going |
|
| 541 | - */ |
|
| 542 | - public function set_att_is_going($REG_att_is_going = false) |
|
| 543 | - { |
|
| 544 | - $this->set('REG_att_is_going', $REG_att_is_going); |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - |
|
| 548 | - /** |
|
| 549 | - * Gets the related attendee |
|
| 550 | - * |
|
| 551 | - * @return EE_Attendee |
|
| 552 | - */ |
|
| 553 | - public function attendee() |
|
| 554 | - { |
|
| 555 | - return $this->get_first_related('Attendee'); |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - |
|
| 559 | - /** |
|
| 560 | - * get Event ID |
|
| 561 | - */ |
|
| 562 | - public function event_ID() |
|
| 563 | - { |
|
| 564 | - return $this->get('EVT_ID'); |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - |
|
| 568 | - /** |
|
| 569 | - * get Event ID |
|
| 570 | - */ |
|
| 571 | - public function event_name() |
|
| 572 | - { |
|
| 573 | - $event = $this->event_obj(); |
|
| 574 | - if ($event) { |
|
| 575 | - return $event->name(); |
|
| 576 | - } else { |
|
| 577 | - return null; |
|
| 578 | - } |
|
| 579 | - } |
|
| 580 | - |
|
| 581 | - |
|
| 582 | - /** |
|
| 583 | - * Fetches the event this registration is for |
|
| 584 | - * |
|
| 585 | - * @return EE_Event |
|
| 586 | - */ |
|
| 587 | - public function event_obj() |
|
| 588 | - { |
|
| 589 | - return $this->get_first_related('Event'); |
|
| 590 | - } |
|
| 591 | - |
|
| 592 | - |
|
| 593 | - /** |
|
| 594 | - * get Attendee ID |
|
| 595 | - */ |
|
| 596 | - public function attendee_ID() |
|
| 597 | - { |
|
| 598 | - return $this->get('ATT_ID'); |
|
| 599 | - } |
|
| 600 | - |
|
| 601 | - |
|
| 602 | - /** |
|
| 603 | - * get PHP Session ID |
|
| 604 | - */ |
|
| 605 | - public function session_ID() |
|
| 606 | - { |
|
| 607 | - return $this->get('REG_session'); |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - |
|
| 611 | - /** |
|
| 612 | - * Gets the string which represents the URL trigger for the receipt template in the message template system. |
|
| 613 | - * |
|
| 614 | - * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
| 615 | - * @return string |
|
| 616 | - */ |
|
| 617 | - public function receipt_url($messenger = 'html') |
|
| 618 | - { |
|
| 619 | - |
|
| 620 | - /** |
|
| 621 | - * 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. |
|
| 622 | - * |
|
| 623 | - * @since 4.5.0 |
|
| 624 | - */ |
|
| 625 | - $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
|
| 626 | - $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
| 627 | - |
|
| 628 | - if ($has_custom) { |
|
| 629 | - return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
| 630 | - } |
|
| 631 | - return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
| 632 | - } |
|
| 633 | - |
|
| 634 | - |
|
| 635 | - /** |
|
| 636 | - * Gets the string which represents the URL trigger for the invoice template in the message template system. |
|
| 637 | - * |
|
| 638 | - * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
| 639 | - * @return string |
|
| 640 | - */ |
|
| 641 | - public function invoice_url($messenger = 'html') |
|
| 642 | - { |
|
| 643 | - /** |
|
| 644 | - * 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. |
|
| 645 | - * |
|
| 646 | - * @since 4.5.0 |
|
| 647 | - */ |
|
| 648 | - $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
|
| 649 | - $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
| 650 | - |
|
| 651 | - if ($has_custom) { |
|
| 652 | - if ($messenger == 'html') { |
|
| 653 | - return $this->invoice_url('launch'); |
|
| 654 | - } |
|
| 655 | - $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
|
| 656 | - |
|
| 657 | - $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
| 658 | - if ($messenger == 'html') { |
|
| 659 | - $query_args['html'] = true; |
|
| 660 | - } |
|
| 661 | - return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
| 662 | - } |
|
| 663 | - return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - |
|
| 667 | - /** |
|
| 668 | - * get Registration URL Link |
|
| 669 | - * |
|
| 670 | - * @access public |
|
| 671 | - * @return string |
|
| 672 | - * @throws \EE_Error |
|
| 673 | - */ |
|
| 674 | - public function reg_url_link() |
|
| 675 | - { |
|
| 676 | - return (string)$this->get('REG_url_link'); |
|
| 677 | - } |
|
| 678 | - |
|
| 679 | - |
|
| 680 | - /** |
|
| 681 | - * Echoes out invoice_url() |
|
| 682 | - * |
|
| 683 | - * @param string $type 'download','launch', or 'html' (default is 'launch') |
|
| 684 | - * @return void |
|
| 685 | - */ |
|
| 686 | - public function e_invoice_url($type = 'launch') |
|
| 687 | - { |
|
| 688 | - echo $this->invoice_url($type); |
|
| 689 | - } |
|
| 690 | - |
|
| 691 | - |
|
| 692 | - /** |
|
| 693 | - * Echoes out payment_overview_url |
|
| 694 | - */ |
|
| 695 | - public function e_payment_overview_url() |
|
| 696 | - { |
|
| 697 | - echo $this->payment_overview_url(); |
|
| 698 | - } |
|
| 699 | - |
|
| 700 | - |
|
| 701 | - /** |
|
| 702 | - * Gets the URL of the thank you page with this registration REG_url_link added as |
|
| 703 | - * a query parameter |
|
| 704 | - * |
|
| 705 | - * @return string |
|
| 706 | - */ |
|
| 707 | - public function payment_overview_url() |
|
| 708 | - { |
|
| 709 | - return add_query_arg(array( |
|
| 710 | - 'e_reg_url_link' => $this->reg_url_link(), |
|
| 711 | - 'step' => 'payment_options', |
|
| 712 | - 'revisit' => true, |
|
| 713 | - ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
| 714 | - } |
|
| 715 | - |
|
| 716 | - |
|
| 717 | - /** |
|
| 718 | - * Gets the URL of the thank you page with this registration REG_url_link added as |
|
| 719 | - * a query parameter |
|
| 720 | - * |
|
| 721 | - * @return string |
|
| 722 | - */ |
|
| 723 | - public function edit_attendee_information_url() |
|
| 724 | - { |
|
| 725 | - return add_query_arg(array( |
|
| 726 | - 'e_reg_url_link' => $this->reg_url_link(), |
|
| 727 | - 'step' => 'attendee_information', |
|
| 728 | - 'revisit' => true, |
|
| 729 | - ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
| 730 | - } |
|
| 731 | - |
|
| 732 | - |
|
| 733 | - /** |
|
| 734 | - * Simply generates and returns the appropriate admin_url link to edit this registration |
|
| 735 | - * |
|
| 736 | - * @return string |
|
| 737 | - */ |
|
| 738 | - public function get_admin_edit_url() |
|
| 739 | - { |
|
| 740 | - return EEH_URL::add_query_args_and_nonce(array( |
|
| 741 | - 'page' => 'espresso_registrations', |
|
| 742 | - 'action' => 'view_registration', |
|
| 743 | - '_REG_ID' => $this->ID(), |
|
| 744 | - ), admin_url('admin.php')); |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - |
|
| 748 | - /** |
|
| 749 | - * is_primary_registrant? |
|
| 750 | - */ |
|
| 751 | - public function is_primary_registrant() |
|
| 752 | - { |
|
| 753 | - return $this->get('REG_count') == 1 ? true : false; |
|
| 754 | - } |
|
| 755 | - |
|
| 756 | - |
|
| 757 | - /** |
|
| 758 | - * This returns the primary registration object for this registration group (which may be this object). |
|
| 759 | - * |
|
| 760 | - * @return EE_Registration |
|
| 761 | - */ |
|
| 762 | - public function get_primary_registration() |
|
| 763 | - { |
|
| 764 | - if ($this->is_primary_registrant()) { |
|
| 765 | - return $this; |
|
| 766 | - } |
|
| 767 | - |
|
| 768 | - //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
|
| 769 | - $primary_registrant = EEM_Registration::instance()->get_one(array( |
|
| 770 | - array( |
|
| 771 | - 'TXN_ID' => $this->transaction_ID(), |
|
| 772 | - 'REG_count' => 1, |
|
| 773 | - ), |
|
| 774 | - )); |
|
| 775 | - return $primary_registrant; |
|
| 776 | - } |
|
| 777 | - |
|
| 778 | - |
|
| 779 | - /** |
|
| 780 | - * get Attendee Number |
|
| 781 | - * |
|
| 782 | - * @access public |
|
| 783 | - */ |
|
| 784 | - public function count() |
|
| 785 | - { |
|
| 786 | - return $this->get('REG_count'); |
|
| 787 | - } |
|
| 788 | - |
|
| 789 | - |
|
| 790 | - /** |
|
| 791 | - * get Group Size |
|
| 792 | - */ |
|
| 793 | - public function group_size() |
|
| 794 | - { |
|
| 795 | - return $this->get('REG_group_size'); |
|
| 796 | - } |
|
| 797 | - |
|
| 798 | - |
|
| 799 | - /** |
|
| 800 | - * get Registration Date |
|
| 801 | - */ |
|
| 802 | - public function date() |
|
| 803 | - { |
|
| 804 | - return $this->get('REG_date'); |
|
| 805 | - } |
|
| 806 | - |
|
| 807 | - |
|
| 808 | - /** |
|
| 809 | - * gets a pretty date |
|
| 810 | - * |
|
| 811 | - * @param string $date_format |
|
| 812 | - * @param string $time_format |
|
| 813 | - * @return string |
|
| 814 | - */ |
|
| 815 | - public function pretty_date($date_format = null, $time_format = null) |
|
| 816 | - { |
|
| 817 | - return $this->get_datetime('REG_date', $date_format, $time_format); |
|
| 818 | - } |
|
| 819 | - |
|
| 820 | - |
|
| 821 | - /** |
|
| 822 | - * final_price |
|
| 823 | - * the registration's share of the transaction total, so that the |
|
| 824 | - * sum of all the transaction's REG_final_prices equal the transaction's total |
|
| 825 | - * |
|
| 826 | - * @return float |
|
| 827 | - */ |
|
| 828 | - public function final_price() |
|
| 829 | - { |
|
| 830 | - return $this->get('REG_final_price'); |
|
| 831 | - } |
|
| 832 | - |
|
| 833 | - |
|
| 834 | - /** |
|
| 835 | - * pretty_final_price |
|
| 836 | - * final price as formatted string, with correct decimal places and currency symbol |
|
| 837 | - * |
|
| 838 | - * @return string |
|
| 839 | - */ |
|
| 840 | - public function pretty_final_price() |
|
| 841 | - { |
|
| 842 | - return $this->get_pretty('REG_final_price'); |
|
| 843 | - } |
|
| 844 | - |
|
| 845 | - |
|
| 846 | - /** |
|
| 847 | - * get paid (yeah) |
|
| 848 | - * |
|
| 849 | - * @return float |
|
| 850 | - */ |
|
| 851 | - public function paid() |
|
| 852 | - { |
|
| 853 | - return $this->get('REG_paid'); |
|
| 854 | - } |
|
| 855 | - |
|
| 856 | - |
|
| 857 | - /** |
|
| 858 | - * pretty_paid |
|
| 859 | - * |
|
| 860 | - * @return float |
|
| 861 | - */ |
|
| 862 | - public function pretty_paid() |
|
| 863 | - { |
|
| 864 | - return $this->get_pretty('REG_paid'); |
|
| 865 | - } |
|
| 866 | - |
|
| 867 | - |
|
| 868 | - /** |
|
| 869 | - * owes_monies_and_can_pay |
|
| 870 | - * whether or not this registration has monies owing and it's' status allows payment |
|
| 871 | - * |
|
| 872 | - * @param array $requires_payment |
|
| 873 | - * @return bool |
|
| 874 | - */ |
|
| 875 | - public function owes_monies_and_can_pay($requires_payment = array()) |
|
| 876 | - { |
|
| 877 | - // these reg statuses require payment (if event is not free) |
|
| 878 | - $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
| 879 | - if ( |
|
| 880 | - in_array($this->status_ID(), $requires_payment) && |
|
| 881 | - $this->final_price() != 0 && |
|
| 882 | - $this->final_price() != $this->paid() |
|
| 883 | - ) { |
|
| 884 | - return true; |
|
| 885 | - } else { |
|
| 886 | - return false; |
|
| 887 | - } |
|
| 888 | - } |
|
| 889 | - |
|
| 890 | - |
|
| 891 | - /** |
|
| 892 | - * Prints out the return value of $this->pretty_status() |
|
| 893 | - * |
|
| 894 | - * @param bool $show_icons |
|
| 895 | - * @return void |
|
| 896 | - */ |
|
| 897 | - public function e_pretty_status($show_icons = false) |
|
| 898 | - { |
|
| 899 | - echo $this->pretty_status($show_icons); |
|
| 900 | - } |
|
| 901 | - |
|
| 902 | - |
|
| 903 | - /** |
|
| 904 | - * Returns a nice version of the status for displaying to customers |
|
| 905 | - * |
|
| 906 | - * @param bool $show_icons |
|
| 907 | - * @return string |
|
| 908 | - */ |
|
| 909 | - public function pretty_status($show_icons = false) |
|
| 910 | - { |
|
| 911 | - $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), |
|
| 912 | - false, 'sentence'); |
|
| 913 | - $icon = ''; |
|
| 914 | - switch ($this->status_ID()) { |
|
| 915 | - case EEM_Registration::status_id_approved: |
|
| 916 | - $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
|
| 917 | - break; |
|
| 918 | - case EEM_Registration::status_id_pending_payment: |
|
| 919 | - $icon = $show_icons ? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>' : ''; |
|
| 920 | - break; |
|
| 921 | - case EEM_Registration::status_id_not_approved: |
|
| 922 | - $icon = $show_icons ? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>' : ''; |
|
| 923 | - break; |
|
| 924 | - case EEM_Registration::status_id_cancelled: |
|
| 925 | - $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>' : ''; |
|
| 926 | - break; |
|
| 927 | - case EEM_Registration::status_id_incomplete: |
|
| 928 | - $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>' : ''; |
|
| 929 | - break; |
|
| 930 | - case EEM_Registration::status_id_declined: |
|
| 931 | - $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
|
| 932 | - break; |
|
| 933 | - case EEM_Registration::status_id_wait_list: |
|
| 934 | - $icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : ''; |
|
| 935 | - break; |
|
| 936 | - } |
|
| 937 | - return $icon . $status[$this->status_ID()]; |
|
| 938 | - } |
|
| 939 | - |
|
| 940 | - |
|
| 941 | - /** |
|
| 942 | - * get Attendee Is Going |
|
| 943 | - */ |
|
| 944 | - public function att_is_going() |
|
| 945 | - { |
|
| 946 | - return $this->get('REG_att_is_going'); |
|
| 947 | - } |
|
| 948 | - |
|
| 949 | - |
|
| 950 | - /** |
|
| 951 | - * Gets related answers |
|
| 952 | - * |
|
| 953 | - * @param array $query_params like EEM_Base::get_all |
|
| 954 | - * @return EE_Answer[] |
|
| 955 | - */ |
|
| 956 | - public function answers($query_params = null) |
|
| 957 | - { |
|
| 958 | - return $this->get_many_related('Answer', $query_params); |
|
| 959 | - } |
|
| 960 | - |
|
| 961 | - |
|
| 962 | - /** |
|
| 963 | - * Gets the registration's answer value to the specified question |
|
| 964 | - * (either the question's ID or a question object) |
|
| 965 | - * |
|
| 966 | - * @param EE_Question|int $question |
|
| 967 | - * @param bool $pretty_value |
|
| 968 | - * @return array|string if pretty_value= true, the result will always be a string |
|
| 969 | - * (because the answer might be an array of answer values, so passing pretty_value=true |
|
| 970 | - * will convert it into some kind of string) |
|
| 971 | - */ |
|
| 972 | - public function answer_value_to_question($question, $pretty_value = true) |
|
| 973 | - { |
|
| 974 | - $question_id = EEM_Question::instance()->ensure_is_ID($question); |
|
| 975 | - return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
| 976 | - } |
|
| 977 | - |
|
| 978 | - |
|
| 979 | - /** |
|
| 980 | - * question_groups |
|
| 981 | - * returns an array of EE_Question_Group objects for this registration |
|
| 982 | - * |
|
| 983 | - * @return EE_Question_Group[] |
|
| 984 | - */ |
|
| 985 | - public function question_groups() |
|
| 986 | - { |
|
| 987 | - $question_groups = array(); |
|
| 988 | - if ($this->event() instanceof EE_Event) { |
|
| 989 | - $question_groups = $this->event()->question_groups( |
|
| 990 | - array( |
|
| 991 | - array( |
|
| 992 | - 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
| 993 | - ), |
|
| 994 | - 'order_by' => array('QSG_order' => 'ASC'), |
|
| 995 | - ) |
|
| 996 | - ); |
|
| 997 | - } |
|
| 998 | - return $question_groups; |
|
| 999 | - } |
|
| 1000 | - |
|
| 1001 | - |
|
| 1002 | - /** |
|
| 1003 | - * count_question_groups |
|
| 1004 | - * returns a count of the number of EE_Question_Group objects for this registration |
|
| 1005 | - * |
|
| 1006 | - * @return int |
|
| 1007 | - */ |
|
| 1008 | - public function count_question_groups() |
|
| 1009 | - { |
|
| 1010 | - $qg_count = 0; |
|
| 1011 | - if ($this->event() instanceof EE_Event) { |
|
| 1012 | - $qg_count = $this->event()->count_related( |
|
| 1013 | - 'Question_Group', |
|
| 1014 | - array( |
|
| 1015 | - array( |
|
| 1016 | - 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
| 1017 | - ), |
|
| 1018 | - ) |
|
| 1019 | - ); |
|
| 1020 | - } |
|
| 1021 | - return $qg_count; |
|
| 1022 | - } |
|
| 1023 | - |
|
| 1024 | - |
|
| 1025 | - /** |
|
| 1026 | - * Returns the registration date in the 'standard' string format |
|
| 1027 | - * (function may be improved in the future to allow for different formats and timezones) |
|
| 1028 | - * |
|
| 1029 | - * @return string |
|
| 1030 | - */ |
|
| 1031 | - public function reg_date() |
|
| 1032 | - { |
|
| 1033 | - return $this->get_datetime('REG_date'); |
|
| 1034 | - } |
|
| 1035 | - |
|
| 1036 | - |
|
| 1037 | - /** |
|
| 1038 | - * Gets the datetime-ticket for this registration (ie, it can be used to isolate |
|
| 1039 | - * the ticket this registration purchased, or the datetime they have registered |
|
| 1040 | - * to attend) |
|
| 1041 | - * |
|
| 1042 | - * @return EE_Datetime_Ticket |
|
| 1043 | - */ |
|
| 1044 | - public function datetime_ticket() |
|
| 1045 | - { |
|
| 1046 | - return $this->get_first_related('Datetime_Ticket'); |
|
| 1047 | - } |
|
| 1048 | - |
|
| 1049 | - |
|
| 1050 | - /** |
|
| 1051 | - * Sets the registration's datetime_ticket. |
|
| 1052 | - * |
|
| 1053 | - * @param EE_Datetime_Ticket $datetime_ticket |
|
| 1054 | - * @return EE_Datetime_Ticket |
|
| 1055 | - */ |
|
| 1056 | - public function set_datetime_ticket($datetime_ticket) |
|
| 1057 | - { |
|
| 1058 | - return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
| 1059 | - } |
|
| 1060 | - |
|
| 1061 | - /** |
|
| 1062 | - * Gets deleted |
|
| 1063 | - * |
|
| 1064 | - * @return boolean |
|
| 1065 | - */ |
|
| 1066 | - public function deleted() |
|
| 1067 | - { |
|
| 1068 | - return $this->get('REG_deleted'); |
|
| 1069 | - } |
|
| 1070 | - |
|
| 1071 | - /** |
|
| 1072 | - * Sets deleted |
|
| 1073 | - * |
|
| 1074 | - * @param boolean $deleted |
|
| 1075 | - * @return boolean |
|
| 1076 | - */ |
|
| 1077 | - public function set_deleted($deleted) |
|
| 1078 | - { |
|
| 1079 | - if ($deleted) { |
|
| 1080 | - $this->delete(); |
|
| 1081 | - } else { |
|
| 1082 | - $this->restore(); |
|
| 1083 | - } |
|
| 1084 | - } |
|
| 1085 | - |
|
| 1086 | - |
|
| 1087 | - /** |
|
| 1088 | - * Get the status object of this object |
|
| 1089 | - * |
|
| 1090 | - * @return EE_Status |
|
| 1091 | - */ |
|
| 1092 | - public function status_obj() |
|
| 1093 | - { |
|
| 1094 | - return $this->get_first_related('Status'); |
|
| 1095 | - } |
|
| 1096 | - |
|
| 1097 | - |
|
| 1098 | - /** |
|
| 1099 | - * Returns the number of times this registration has checked into any of the datetimes |
|
| 1100 | - * its available for |
|
| 1101 | - * |
|
| 1102 | - * @return int |
|
| 1103 | - */ |
|
| 1104 | - public function count_checkins() |
|
| 1105 | - { |
|
| 1106 | - return $this->get_model()->count_related($this, 'Checkin'); |
|
| 1107 | - } |
|
| 1108 | - |
|
| 1109 | - |
|
| 1110 | - /** |
|
| 1111 | - * Returns the number of current Check-ins this registration is checked into for any of the datetimes the |
|
| 1112 | - * registration is for. Note, this is ONLY checked in (does not include checkedout) |
|
| 1113 | - * |
|
| 1114 | - * @return int |
|
| 1115 | - */ |
|
| 1116 | - public function count_checkins_not_checkedout() |
|
| 1117 | - { |
|
| 1118 | - return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
| 1119 | - } |
|
| 1120 | - |
|
| 1121 | - |
|
| 1122 | - /** |
|
| 1123 | - * The purpose of this method is simply to check whether this registration can checkin to the given datetime. |
|
| 1124 | - * |
|
| 1125 | - * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
| 1126 | - * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also |
|
| 1127 | - * consider registration status as well as datetime access. |
|
| 1128 | - * @return bool |
|
| 1129 | - */ |
|
| 1130 | - public function can_checkin($DTT_OR_ID, $check_approved = true) |
|
| 1131 | - { |
|
| 1132 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
| 1133 | - |
|
| 1134 | - //first check registration status |
|
| 1135 | - if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
| 1136 | - return false; |
|
| 1137 | - } |
|
| 1138 | - //is there a datetime ticket that matches this dtt_ID? |
|
| 1139 | - if (! (EEM_Datetime_Ticket::instance()->exists(array( |
|
| 1140 | - array( |
|
| 1141 | - 'TKT_ID' => $this->get('TKT_ID'), |
|
| 1142 | - 'DTT_ID' => $DTT_ID, |
|
| 1143 | - ), |
|
| 1144 | - ))) |
|
| 1145 | - ) { |
|
| 1146 | - return false; |
|
| 1147 | - } |
|
| 1148 | - |
|
| 1149 | - //final check is against TKT_uses |
|
| 1150 | - return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
| 1151 | - } |
|
| 1152 | - |
|
| 1153 | - |
|
| 1154 | - /** |
|
| 1155 | - * This method verifies whether the user can checkin for the given datetime considering the max uses value set on |
|
| 1156 | - * the ticket. To do this, a query is done to get the count of the datetime records already checked into. If the |
|
| 1157 | - * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses, |
|
| 1158 | - * then return false. Otherwise return true. |
|
| 1159 | - * |
|
| 1160 | - * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
| 1161 | - * @return bool true means can checkin. false means cannot checkin. |
|
| 1162 | - */ |
|
| 1163 | - public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) |
|
| 1164 | - { |
|
| 1165 | - $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
| 1166 | - |
|
| 1167 | - if (! $DTT_ID) { |
|
| 1168 | - return false; |
|
| 1169 | - } |
|
| 1170 | - |
|
| 1171 | - $max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF; |
|
| 1172 | - |
|
| 1173 | - // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
|
| 1174 | - // or not. |
|
| 1175 | - if (! $max_uses || $max_uses === EE_INF) { |
|
| 1176 | - return true; |
|
| 1177 | - } |
|
| 1178 | - |
|
| 1179 | - //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
|
| 1180 | - //go ahead and toggle. |
|
| 1181 | - if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
| 1182 | - return true; |
|
| 1183 | - } |
|
| 1184 | - |
|
| 1185 | - //made it here so the last check is whether the number of checkins per unique datetime on this registration |
|
| 1186 | - //disallows further check-ins. |
|
| 1187 | - $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array( |
|
| 1188 | - array( |
|
| 1189 | - 'REG_ID' => $this->ID(), |
|
| 1190 | - 'CHK_in' => true, |
|
| 1191 | - ), |
|
| 1192 | - ), 'DTT_ID', true); |
|
| 1193 | - // checkins have already reached their max number of uses |
|
| 1194 | - // so registrant can NOT checkin |
|
| 1195 | - if ($count_unique_dtt_checkins >= $max_uses) { |
|
| 1196 | - EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', |
|
| 1197 | - 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1198 | - return false; |
|
| 1199 | - } |
|
| 1200 | - return true; |
|
| 1201 | - } |
|
| 1202 | - |
|
| 1203 | - |
|
| 1204 | - /** |
|
| 1205 | - * toggle Check-in status for this registration |
|
| 1206 | - * Check-ins are toggled in the following order: |
|
| 1207 | - * never checked in -> checked in |
|
| 1208 | - * checked in -> checked out |
|
| 1209 | - * checked out -> checked in |
|
| 1210 | - * |
|
| 1211 | - * @param int $DTT_ID include specific datetime to toggle Check-in for. |
|
| 1212 | - * If not included or null, then it is assumed latest datetime is being toggled. |
|
| 1213 | - * @param bool $verify If true then can_checkin() is used to verify whether the person |
|
| 1214 | - * can be checked in or not. Otherwise this forces change in checkin status. |
|
| 1215 | - * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
|
| 1216 | - * @throws EE_Error |
|
| 1217 | - */ |
|
| 1218 | - public function toggle_checkin_status($DTT_ID = null, $verify = false) |
|
| 1219 | - { |
|
| 1220 | - if (empty($DTT_ID)) { |
|
| 1221 | - $datetime = $this->get_latest_related_datetime(); |
|
| 1222 | - $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
| 1223 | - // verify the registration can checkin for the given DTT_ID |
|
| 1224 | - } elseif (! $this->can_checkin($DTT_ID, $verify)) { |
|
| 1225 | - EE_Error::add_error( |
|
| 1226 | - sprintf( |
|
| 1227 | - __('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', |
|
| 1228 | - 'event_espresso'), |
|
| 1229 | - $this->ID(), |
|
| 1230 | - $DTT_ID |
|
| 1231 | - ), |
|
| 1232 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 1233 | - ); |
|
| 1234 | - return false; |
|
| 1235 | - } |
|
| 1236 | - $status_paths = array( |
|
| 1237 | - EE_Registration::checkin_status_never => EE_Registration::checkin_status_in, |
|
| 1238 | - EE_Registration::checkin_status_in => EE_Registration::checkin_status_out, |
|
| 1239 | - EE_Registration::checkin_status_out => EE_Registration::checkin_status_in, |
|
| 1240 | - ); |
|
| 1241 | - //start by getting the current status so we know what status we'll be changing to. |
|
| 1242 | - $cur_status = $this->check_in_status_for_datetime($DTT_ID, null); |
|
| 1243 | - $status_to = $status_paths[$cur_status]; |
|
| 1244 | - // database only records true for checked IN or false for checked OUT |
|
| 1245 | - // no record ( null ) means checked in NEVER, but we obviously don't save that |
|
| 1246 | - $new_status = $status_to === EE_Registration::checkin_status_in ? true : false; |
|
| 1247 | - // add relation - note Check-ins are always creating new rows |
|
| 1248 | - // because we are keeping track of Check-ins over time. |
|
| 1249 | - // Eventually we'll probably want to show a list table |
|
| 1250 | - // for the individual Check-ins so that they can be managed. |
|
| 1251 | - $checkin = EE_Checkin::new_instance(array( |
|
| 1252 | - 'REG_ID' => $this->ID(), |
|
| 1253 | - 'DTT_ID' => $DTT_ID, |
|
| 1254 | - 'CHK_in' => $new_status, |
|
| 1255 | - )); |
|
| 1256 | - // if the record could not be saved then return false |
|
| 1257 | - if ($checkin->save() === 0) { |
|
| 1258 | - if (WP_DEBUG) { |
|
| 1259 | - global $wpdb; |
|
| 1260 | - $error = sprintf( |
|
| 1261 | - __('Registration check in update failed because of the following database error: %1$s%2$s', |
|
| 1262 | - 'event_espresso'), |
|
| 1263 | - '<br />', |
|
| 1264 | - $wpdb->last_error |
|
| 1265 | - ); |
|
| 1266 | - } else { |
|
| 1267 | - $error = __('Registration check in update failed because of an unknown database error', |
|
| 1268 | - 'event_espresso'); |
|
| 1269 | - } |
|
| 1270 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
| 1271 | - return false; |
|
| 1272 | - } |
|
| 1273 | - return $status_to; |
|
| 1274 | - } |
|
| 1275 | - |
|
| 1276 | - |
|
| 1277 | - /** |
|
| 1278 | - * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
|
| 1279 | - * "Latest" is defined by the `DTT_EVT_start` column. |
|
| 1280 | - * |
|
| 1281 | - * @return EE_Datetime|null |
|
| 1282 | - * @throws \EE_Error |
|
| 1283 | - */ |
|
| 1284 | - public function get_latest_related_datetime() |
|
| 1285 | - { |
|
| 1286 | - return EEM_Datetime::instance()->get_one( |
|
| 1287 | - array( |
|
| 1288 | - array( |
|
| 1289 | - 'Ticket.Registration.REG_ID' => $this->ID(), |
|
| 1290 | - ), |
|
| 1291 | - 'order_by' => array('DTT_EVT_start' => 'DESC'), |
|
| 1292 | - ) |
|
| 1293 | - ); |
|
| 1294 | - } |
|
| 1295 | - |
|
| 1296 | - |
|
| 1297 | - /** |
|
| 1298 | - * Returns the earliest datetime related to this registration (via the ticket attached to the registration). |
|
| 1299 | - * "Earliest" is defined by the `DTT_EVT_start` column. |
|
| 1300 | - * |
|
| 1301 | - * @throws \EE_Error |
|
| 1302 | - */ |
|
| 1303 | - public function get_earliest_related_datetime() |
|
| 1304 | - { |
|
| 1305 | - return EEM_Datetime::instance()->get_one( |
|
| 1306 | - array( |
|
| 1307 | - array( |
|
| 1308 | - 'Ticket.Registration.REG_ID' => $this->ID(), |
|
| 1309 | - ), |
|
| 1310 | - 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
| 1311 | - ) |
|
| 1312 | - ); |
|
| 1313 | - } |
|
| 1314 | - |
|
| 1315 | - |
|
| 1316 | - /** |
|
| 1317 | - * This method simply returns the check-in status for this registration and the given datetime. |
|
| 1318 | - * If neither the datetime nor the checkin values are provided as arguments, |
|
| 1319 | - * then this will return the LATEST check-in status for the registration across all datetimes it belongs to. |
|
| 1320 | - * |
|
| 1321 | - * @param int $DTT_ID The ID of the datetime we're checking against |
|
| 1322 | - * (if empty we'll get the primary datetime for |
|
| 1323 | - * this registration (via event) and use it's ID); |
|
| 1324 | - * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
|
| 1325 | - * @return int Integer representing Check-in status. |
|
| 1326 | - * @throws \EE_Error |
|
| 1327 | - */ |
|
| 1328 | - public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null) |
|
| 1329 | - { |
|
| 1330 | - $checkin_query_params = array( |
|
| 1331 | - 'order_by' => array('CHK_timestamp' => 'DESC'), |
|
| 1332 | - ); |
|
| 1333 | - |
|
| 1334 | - if ($DTT_ID > 0) { |
|
| 1335 | - $checkin_query_params[0] = array('DTT_ID' => $DTT_ID); |
|
| 1336 | - } |
|
| 1337 | - |
|
| 1338 | - //get checkin object (if exists) |
|
| 1339 | - $checkin = $checkin instanceof EE_Checkin |
|
| 1340 | - ? $checkin |
|
| 1341 | - : $this->get_first_related('Checkin', $checkin_query_params); |
|
| 1342 | - if ($checkin instanceof EE_Checkin) { |
|
| 1343 | - if ($checkin->get('CHK_in')) { |
|
| 1344 | - return EE_Registration::checkin_status_in; //checked in |
|
| 1345 | - } |
|
| 1346 | - return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
|
| 1347 | - } |
|
| 1348 | - return EE_Registration::checkin_status_never; //never been checked in |
|
| 1349 | - } |
|
| 1350 | - |
|
| 1351 | - |
|
| 1352 | - /** |
|
| 1353 | - * This method returns a localized message for the toggled Check-in message. |
|
| 1354 | - * |
|
| 1355 | - * @param int $DTT_ID include specific datetime to get the correct Check-in message. If not included or null, |
|
| 1356 | - * then it is assumed Check-in for primary datetime was toggled. |
|
| 1357 | - * @param bool $error This just flags that you want an error message returned. This is put in so that the error |
|
| 1358 | - * message can be customized with the attendee name. |
|
| 1359 | - * @return string internationalized message |
|
| 1360 | - */ |
|
| 1361 | - public function get_checkin_msg($DTT_ID, $error = false) |
|
| 1362 | - { |
|
| 1363 | - //let's get the attendee first so we can include the name of the attendee |
|
| 1364 | - $attendee = $this->get_first_related('Attendee'); |
|
| 1365 | - if ($attendee instanceof EE_Attendee) { |
|
| 1366 | - if ($error) { |
|
| 1367 | - return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
| 1368 | - } |
|
| 1369 | - $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
| 1370 | - //what is the status message going to be? |
|
| 1371 | - switch ($cur_status) { |
|
| 1372 | - case EE_Registration::checkin_status_never : |
|
| 1373 | - return sprintf(__("%s has been removed from Check-in records", "event_espresso"), |
|
| 1374 | - $attendee->full_name()); |
|
| 1375 | - break; |
|
| 1376 | - case EE_Registration::checkin_status_in : |
|
| 1377 | - return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
| 1378 | - break; |
|
| 1379 | - case EE_Registration::checkin_status_out : |
|
| 1380 | - return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
| 1381 | - break; |
|
| 1382 | - } |
|
| 1383 | - } |
|
| 1384 | - return __("The check-in status could not be determined.", "event_espresso"); |
|
| 1385 | - } |
|
| 1386 | - |
|
| 1387 | - |
|
| 1388 | - /** |
|
| 1389 | - * Returns the related EE_Transaction to this registration |
|
| 1390 | - * |
|
| 1391 | - * @return EE_Transaction |
|
| 1392 | - */ |
|
| 1393 | - public function transaction() |
|
| 1394 | - { |
|
| 1395 | - $transaction = $this->get_first_related('Transaction'); |
|
| 1396 | - if (! $transaction instanceof \EE_Transaction) { |
|
| 1397 | - throw new EntityNotFoundException('Transaction ID', $this->transaction_ID()); |
|
| 1398 | - } |
|
| 1399 | - return $transaction; |
|
| 1400 | - } |
|
| 1401 | - |
|
| 1402 | - |
|
| 1403 | - /** |
|
| 1404 | - * get Registration Code |
|
| 1405 | - */ |
|
| 1406 | - public function reg_code() |
|
| 1407 | - { |
|
| 1408 | - return $this->get('REG_code'); |
|
| 1409 | - } |
|
| 1410 | - |
|
| 1411 | - |
|
| 1412 | - /** |
|
| 1413 | - * get Transaction ID |
|
| 1414 | - */ |
|
| 1415 | - public function transaction_ID() |
|
| 1416 | - { |
|
| 1417 | - return $this->get('TXN_ID'); |
|
| 1418 | - } |
|
| 1419 | - |
|
| 1420 | - |
|
| 1421 | - /** |
|
| 1422 | - * @return int |
|
| 1423 | - */ |
|
| 1424 | - public function ticket_ID() |
|
| 1425 | - { |
|
| 1426 | - return $this->get('TKT_ID'); |
|
| 1427 | - } |
|
| 1428 | - |
|
| 1429 | - |
|
| 1430 | - /** |
|
| 1431 | - * Set Registration Code |
|
| 1432 | - * |
|
| 1433 | - * @access public |
|
| 1434 | - * @param string $REG_code Registration Code |
|
| 1435 | - * @param boolean $use_default |
|
| 1436 | - */ |
|
| 1437 | - public function set_reg_code($REG_code, $use_default = false) |
|
| 1438 | - { |
|
| 1439 | - if (empty($REG_code)) { |
|
| 1440 | - EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1441 | - return; |
|
| 1442 | - } |
|
| 1443 | - if (! $this->reg_code()) { |
|
| 1444 | - parent::set('REG_code', $REG_code, $use_default); |
|
| 1445 | - } else { |
|
| 1446 | - EE_Error::doing_it_wrong( |
|
| 1447 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 1448 | - __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
| 1449 | - '4.6.0' |
|
| 1450 | - ); |
|
| 1451 | - } |
|
| 1452 | - } |
|
| 1453 | - |
|
| 1454 | - |
|
| 1455 | - /** |
|
| 1456 | - * Returns all other registrations in the same group as this registrant who have the same ticket option. |
|
| 1457 | - * Note, if you want to just get all registrations in the same transaction (group), use: |
|
| 1458 | - * $registration->transaction()->registrations(); |
|
| 1459 | - * |
|
| 1460 | - * @since 4.5.0 |
|
| 1461 | - * @return EE_Registration[] or empty array if this isn't a group registration. |
|
| 1462 | - */ |
|
| 1463 | - public function get_all_other_registrations_in_group() |
|
| 1464 | - { |
|
| 1465 | - if ($this->group_size() < 2) { |
|
| 1466 | - return array(); |
|
| 1467 | - } |
|
| 1468 | - |
|
| 1469 | - $query[0] = array( |
|
| 1470 | - 'TXN_ID' => $this->transaction_ID(), |
|
| 1471 | - 'REG_ID' => array('!=', $this->ID()), |
|
| 1472 | - 'TKT_ID' => $this->ticket_ID(), |
|
| 1473 | - ); |
|
| 1474 | - |
|
| 1475 | - $registrations = $this->get_model()->get_all($query); |
|
| 1476 | - return $registrations; |
|
| 1477 | - } |
|
| 1478 | - |
|
| 1479 | - /** |
|
| 1480 | - * Return the link to the admin details for the object. |
|
| 1481 | - * |
|
| 1482 | - * @return string |
|
| 1483 | - */ |
|
| 1484 | - public function get_admin_details_link() |
|
| 1485 | - { |
|
| 1486 | - EE_Registry::instance()->load_helper('URL'); |
|
| 1487 | - return EEH_URL::add_query_args_and_nonce( |
|
| 1488 | - array( |
|
| 1489 | - 'page' => 'espresso_registrations', |
|
| 1490 | - 'action' => 'view_registration', |
|
| 1491 | - '_REG_ID' => $this->ID(), |
|
| 1492 | - ), |
|
| 1493 | - admin_url('admin.php') |
|
| 1494 | - ); |
|
| 1495 | - } |
|
| 1496 | - |
|
| 1497 | - /** |
|
| 1498 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 1499 | - * |
|
| 1500 | - * @return string |
|
| 1501 | - */ |
|
| 1502 | - public function get_admin_edit_link() |
|
| 1503 | - { |
|
| 1504 | - return $this->get_admin_details_link(); |
|
| 1505 | - } |
|
| 1506 | - |
|
| 1507 | - /** |
|
| 1508 | - * Returns the link to a settings page for the object. |
|
| 1509 | - * |
|
| 1510 | - * @return string |
|
| 1511 | - */ |
|
| 1512 | - public function get_admin_settings_link() |
|
| 1513 | - { |
|
| 1514 | - return $this->get_admin_details_link(); |
|
| 1515 | - } |
|
| 1516 | - |
|
| 1517 | - /** |
|
| 1518 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 1519 | - * |
|
| 1520 | - * @return string |
|
| 1521 | - */ |
|
| 1522 | - public function get_admin_overview_link() |
|
| 1523 | - { |
|
| 1524 | - EE_Registry::instance()->load_helper('URL'); |
|
| 1525 | - return EEH_URL::add_query_args_and_nonce( |
|
| 1526 | - array( |
|
| 1527 | - 'page' => 'espresso_registrations', |
|
| 1528 | - ), |
|
| 1529 | - admin_url('admin.php') |
|
| 1530 | - ); |
|
| 1531 | - } |
|
| 1532 | - |
|
| 1533 | - |
|
| 1534 | - /** |
|
| 1535 | - * @param array $query_params |
|
| 1536 | - * @return \EE_Registration[] |
|
| 1537 | - * @throws \EE_Error |
|
| 1538 | - */ |
|
| 1539 | - public function payments($query_params = array()) |
|
| 1540 | - { |
|
| 1541 | - return $this->get_many_related('Payment', $query_params); |
|
| 1542 | - } |
|
| 1543 | - |
|
| 1544 | - |
|
| 1545 | - /** |
|
| 1546 | - * @param array $query_params |
|
| 1547 | - * @return \EE_Registration_Payment[] |
|
| 1548 | - * @throws \EE_Error |
|
| 1549 | - */ |
|
| 1550 | - public function registration_payments($query_params = array()) |
|
| 1551 | - { |
|
| 1552 | - return $this->get_many_related('Registration_Payment', $query_params); |
|
| 1553 | - } |
|
| 1554 | - |
|
| 1555 | - |
|
| 1556 | - /** |
|
| 1557 | - * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
|
| 1558 | - * Note: if there are no payments on the registration there will be no payment method returned. |
|
| 1559 | - * |
|
| 1560 | - * @return EE_Payment_Method|null |
|
| 1561 | - */ |
|
| 1562 | - public function payment_method() |
|
| 1563 | - { |
|
| 1564 | - return EEM_Payment_Method::instance()->get_last_used_for_registration($this); |
|
| 1565 | - } |
|
| 1566 | - |
|
| 1567 | - |
|
| 1568 | - /** |
|
| 1569 | - * @return \EE_Line_Item |
|
| 1570 | - * @throws EntityNotFoundException |
|
| 1571 | - * @throws \EE_Error |
|
| 1572 | - */ |
|
| 1573 | - public function ticket_line_item() |
|
| 1574 | - { |
|
| 1575 | - $ticket = $this->ticket(); |
|
| 1576 | - $transaction = $this->transaction(); |
|
| 1577 | - $line_item = null; |
|
| 1578 | - $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
| 1579 | - $transaction->total_line_item(), |
|
| 1580 | - 'Ticket', |
|
| 1581 | - array($ticket->ID()) |
|
| 1582 | - ); |
|
| 1583 | - foreach ($ticket_line_items as $ticket_line_item) { |
|
| 1584 | - if ( |
|
| 1585 | - $ticket_line_item instanceof \EE_Line_Item |
|
| 1586 | - && $ticket_line_item->OBJ_type() === 'Ticket' |
|
| 1587 | - && $ticket_line_item->OBJ_ID() === $ticket->ID() |
|
| 1588 | - ) { |
|
| 1589 | - $line_item = $ticket_line_item; |
|
| 1590 | - break; |
|
| 1591 | - } |
|
| 1592 | - } |
|
| 1593 | - if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
| 1594 | - throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
|
| 1595 | - } |
|
| 1596 | - return $line_item; |
|
| 1597 | - } |
|
| 1598 | - |
|
| 1599 | - |
|
| 1600 | - /** |
|
| 1601 | - * Soft Deletes this model object. |
|
| 1602 | - * |
|
| 1603 | - * @return boolean | int |
|
| 1604 | - * @throws \RuntimeException |
|
| 1605 | - * @throws \EE_Error |
|
| 1606 | - */ |
|
| 1607 | - public function delete() |
|
| 1608 | - { |
|
| 1609 | - if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) { |
|
| 1610 | - $this->set_status(EEM_Registration::status_id_cancelled); |
|
| 1611 | - } |
|
| 1612 | - return parent::delete(); |
|
| 1613 | - } |
|
| 1614 | - |
|
| 1615 | - |
|
| 1616 | - /** |
|
| 1617 | - * Restores whatever the previous status was on a registration before it was trashed (if possible) |
|
| 1618 | - * |
|
| 1619 | - * @throws \EE_Error |
|
| 1620 | - * @throws \RuntimeException |
|
| 1621 | - */ |
|
| 1622 | - public function restore() |
|
| 1623 | - { |
|
| 1624 | - $previous_status = $this->get_extra_meta( |
|
| 1625 | - EE_Registration::PRE_TRASH_REG_STATUS_KEY, |
|
| 1626 | - true, |
|
| 1627 | - EEM_Registration::status_id_cancelled |
|
| 1628 | - ); |
|
| 1629 | - if ($previous_status) { |
|
| 1630 | - $this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY); |
|
| 1631 | - $this->set_status($previous_status); |
|
| 1632 | - } |
|
| 1633 | - return parent::restore(); |
|
| 1634 | - } |
|
| 1635 | - |
|
| 1636 | - |
|
| 1637 | - |
|
| 1638 | - /*************************** DEPRECATED ***************************/ |
|
| 1639 | - |
|
| 1640 | - |
|
| 1641 | - /** |
|
| 1642 | - * @deprecated |
|
| 1643 | - * @since 4.7.0 |
|
| 1644 | - * @access public |
|
| 1645 | - */ |
|
| 1646 | - public function price_paid() |
|
| 1647 | - { |
|
| 1648 | - EE_Error::doing_it_wrong('EE_Registration::price_paid()', |
|
| 1649 | - __('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'), |
|
| 1650 | - '4.7.0'); |
|
| 1651 | - return $this->final_price(); |
|
| 1652 | - } |
|
| 1653 | - |
|
| 1654 | - |
|
| 1655 | - /** |
|
| 1656 | - * @deprecated |
|
| 1657 | - * @since 4.7.0 |
|
| 1658 | - * @access public |
|
| 1659 | - * @param float $REG_final_price |
|
| 1660 | - */ |
|
| 1661 | - public function set_price_paid($REG_final_price = 0.00) |
|
| 1662 | - { |
|
| 1663 | - EE_Error::doing_it_wrong('EE_Registration::set_price_paid()', |
|
| 1664 | - __('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'), |
|
| 1665 | - '4.7.0'); |
|
| 1666 | - $this->set_final_price($REG_final_price); |
|
| 1667 | - } |
|
| 1668 | - |
|
| 1669 | - |
|
| 1670 | - /** |
|
| 1671 | - * @deprecated |
|
| 1672 | - * @since 4.7.0 |
|
| 1673 | - * @return string |
|
| 1674 | - */ |
|
| 1675 | - public function pretty_price_paid() |
|
| 1676 | - { |
|
| 1677 | - EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', |
|
| 1678 | - __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', |
|
| 1679 | - 'event_espresso'), '4.7.0'); |
|
| 1680 | - return $this->pretty_final_price(); |
|
| 1681 | - } |
|
| 1682 | - |
|
| 1683 | - |
|
| 1684 | - /** |
|
| 1685 | - * Gets the primary datetime related to this registration via the related Event to this registration |
|
| 1686 | - * |
|
| 1687 | - * @deprecated 4.9.17 |
|
| 1688 | - * @return EE_Datetime |
|
| 1689 | - */ |
|
| 1690 | - public function get_related_primary_datetime() |
|
| 1691 | - { |
|
| 1692 | - EE_Error::doing_it_wrong( |
|
| 1693 | - __METHOD__, |
|
| 1694 | - esc_html__( |
|
| 1695 | - 'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()', |
|
| 1696 | - 'event_espresso' |
|
| 1697 | - ), |
|
| 1698 | - '4.9.17', |
|
| 1699 | - '5.0.0' |
|
| 1700 | - ); |
|
| 1701 | - return $this->event()->primary_datetime(); |
|
| 1702 | - } |
|
| 18 | + /** |
|
| 19 | + * Used to reference when a registration has never been checked in. |
|
| 20 | + * |
|
| 21 | + * @type int |
|
| 22 | + */ |
|
| 23 | + const checkin_status_never = 2; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Used to reference when a registration has been checked in. |
|
| 27 | + * |
|
| 28 | + * @type int |
|
| 29 | + */ |
|
| 30 | + const checkin_status_in = 1; |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * Used to reference when a registration has been checked out. |
|
| 35 | + * |
|
| 36 | + * @type int |
|
| 37 | + */ |
|
| 38 | + const checkin_status_out = 0; |
|
| 39 | + |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * extra meta key for tracking reg status os trashed registrations |
|
| 43 | + * |
|
| 44 | + * @type string |
|
| 45 | + */ |
|
| 46 | + const PRE_TRASH_REG_STATUS_KEY = 'pre_trash_registration_status'; |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * extra meta key for tracking if registration has reserved ticket |
|
| 51 | + * |
|
| 52 | + * @type string |
|
| 53 | + */ |
|
| 54 | + const HAS_RESERVED_TICKET_KEY = 'has_reserved_ticket'; |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * @param array $props_n_values incoming values |
|
| 59 | + * @param string $timezone incoming timezone (if not set the timezone set for the website will be |
|
| 60 | + * used.) |
|
| 61 | + * @param array $date_formats incoming date_formats in an array where the first value is the |
|
| 62 | + * date_format and the second value is the time format |
|
| 63 | + * @return EE_Registration |
|
| 64 | + */ |
|
| 65 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) |
|
| 66 | + { |
|
| 67 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 68 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @param array $props_n_values incoming values from the database |
|
| 74 | + * @param string $timezone incoming timezone as set by the model. If not set the timezone for |
|
| 75 | + * the website will be used. |
|
| 76 | + * @return EE_Registration |
|
| 77 | + */ |
|
| 78 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) |
|
| 79 | + { |
|
| 80 | + return new self($props_n_values, true, $timezone); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * Set Event ID |
|
| 86 | + * |
|
| 87 | + * @param int $EVT_ID Event ID |
|
| 88 | + */ |
|
| 89 | + public function set_event($EVT_ID = 0) |
|
| 90 | + { |
|
| 91 | + $this->set('EVT_ID', $EVT_ID); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Overrides parent set() method so that all calls to set( 'REG_code', $REG_code ) OR set( 'STS_ID', $STS_ID ) can |
|
| 97 | + * be routed to internal methods |
|
| 98 | + * |
|
| 99 | + * @param string $field_name |
|
| 100 | + * @param mixed $field_value |
|
| 101 | + * @param bool $use_default |
|
| 102 | + * @throws \EE_Error |
|
| 103 | + * @throws \RuntimeException |
|
| 104 | + */ |
|
| 105 | + public function set($field_name, $field_value, $use_default = false) |
|
| 106 | + { |
|
| 107 | + switch ($field_name) { |
|
| 108 | + case 'REG_code' : |
|
| 109 | + if (! empty($field_value) && $this->reg_code() === null) { |
|
| 110 | + $this->set_reg_code($field_value, $use_default); |
|
| 111 | + } |
|
| 112 | + break; |
|
| 113 | + case 'STS_ID' : |
|
| 114 | + $this->set_status($field_value, $use_default); |
|
| 115 | + break; |
|
| 116 | + default : |
|
| 117 | + parent::set($field_name, $field_value, $use_default); |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Set Status ID |
|
| 124 | + * updates the registration status and ALSO... |
|
| 125 | + * calls reserve_registration_space() if the reg status changes TO approved from any other reg status |
|
| 126 | + * calls release_registration_space() if the reg status changes FROM approved to any other reg status |
|
| 127 | + * |
|
| 128 | + * @param string $new_STS_ID |
|
| 129 | + * @param boolean $use_default |
|
| 130 | + * @return bool |
|
| 131 | + * @throws \RuntimeException |
|
| 132 | + * @throws \EE_Error |
|
| 133 | + */ |
|
| 134 | + public function set_status($new_STS_ID = null, $use_default = false) |
|
| 135 | + { |
|
| 136 | + // get current REG_Status |
|
| 137 | + $old_STS_ID = $this->status_ID(); |
|
| 138 | + // if status has changed |
|
| 139 | + if ( |
|
| 140 | + $old_STS_ID !== $new_STS_ID // and that status has actually changed |
|
| 141 | + && ! empty($old_STS_ID) // and that old status is actually set |
|
| 142 | + && ! empty($new_STS_ID) // as well as the new status |
|
| 143 | + && $this->ID() // ensure registration is in the db |
|
| 144 | + ) { |
|
| 145 | + // TO approved |
|
| 146 | + if ($new_STS_ID === EEM_Registration::status_id_approved) { |
|
| 147 | + // reserve a space by incrementing ticket and datetime sold values |
|
| 148 | + $this->_reserve_registration_space(); |
|
| 149 | + do_action('AHEE__EE_Registration__set_status__to_approved', $this, $old_STS_ID, $new_STS_ID); |
|
| 150 | + // OR FROM approved |
|
| 151 | + } else if ($old_STS_ID === EEM_Registration::status_id_approved) { |
|
| 152 | + // release a space by decrementing ticket and datetime sold values |
|
| 153 | + $this->_release_registration_space(); |
|
| 154 | + do_action('AHEE__EE_Registration__set_status__from_approved', $this, $old_STS_ID, $new_STS_ID); |
|
| 155 | + } |
|
| 156 | + // update status |
|
| 157 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
| 158 | + $this->_update_if_canceled_or_declined($new_STS_ID, $old_STS_ID); |
|
| 159 | + /** @type EE_Transaction_Payments $transaction_payments */ |
|
| 160 | + $transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments'); |
|
| 161 | + $transaction_payments->recalculate_transaction_total($this->transaction(), false); |
|
| 162 | + $this->transaction()->update_status_based_on_total_paid(true); |
|
| 163 | + do_action('AHEE__EE_Registration__set_status__after_update', $this); |
|
| 164 | + return true; |
|
| 165 | + } else { |
|
| 166 | + //even though the old value matches the new value, it's still good to |
|
| 167 | + //allow the parent set method to have a say |
|
| 168 | + parent::set('STS_ID', $new_STS_ID, $use_default); |
|
| 169 | + return true; |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * update REGs and TXN when cancelled or declined registrations involved |
|
| 176 | + * |
|
| 177 | + * @param string $new_STS_ID |
|
| 178 | + * @param string $old_STS_ID |
|
| 179 | + * @throws \EE_Error |
|
| 180 | + */ |
|
| 181 | + private function _update_if_canceled_or_declined($new_STS_ID, $old_STS_ID) |
|
| 182 | + { |
|
| 183 | + // these reg statuses should not be considered in any calculations involving monies owing |
|
| 184 | + $closed_reg_statuses = EEM_Registration::closed_reg_statuses(); |
|
| 185 | + // true if registration has been cancelled or declined |
|
| 186 | + if ( |
|
| 187 | + in_array($new_STS_ID, $closed_reg_statuses, true) |
|
| 188 | + && ! in_array($old_STS_ID, $closed_reg_statuses, true) |
|
| 189 | + ) { |
|
| 190 | + /** @type EE_Registration_Processor $registration_processor */ |
|
| 191 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 192 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 193 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 194 | + // cancelled or declined registration |
|
| 195 | + $registration_processor->update_registration_after_being_canceled_or_declined( |
|
| 196 | + $this, |
|
| 197 | + $closed_reg_statuses |
|
| 198 | + ); |
|
| 199 | + $transaction_processor->update_transaction_after_canceled_or_declined_registration( |
|
| 200 | + $this, |
|
| 201 | + $closed_reg_statuses, |
|
| 202 | + false |
|
| 203 | + ); |
|
| 204 | + do_action('AHEE__EE_Registration__set_status__canceled_or_declined', $this, $old_STS_ID, $new_STS_ID); |
|
| 205 | + return; |
|
| 206 | + } |
|
| 207 | + // true if reinstating cancelled or declined registration |
|
| 208 | + if ( |
|
| 209 | + in_array($old_STS_ID, $closed_reg_statuses, true) |
|
| 210 | + && ! in_array($new_STS_ID, $closed_reg_statuses, true) |
|
| 211 | + ) { |
|
| 212 | + /** @type EE_Registration_Processor $registration_processor */ |
|
| 213 | + $registration_processor = EE_Registry::instance()->load_class('Registration_Processor'); |
|
| 214 | + /** @type EE_Transaction_Processor $transaction_processor */ |
|
| 215 | + $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor'); |
|
| 216 | + // reinstating cancelled or declined registration |
|
| 217 | + $registration_processor->update_canceled_or_declined_registration_after_being_reinstated( |
|
| 218 | + $this, |
|
| 219 | + $closed_reg_statuses |
|
| 220 | + ); |
|
| 221 | + $transaction_processor->update_transaction_after_reinstating_canceled_registration( |
|
| 222 | + $this, |
|
| 223 | + $closed_reg_statuses, |
|
| 224 | + false |
|
| 225 | + ); |
|
| 226 | + do_action('AHEE__EE_Registration__set_status__after_reinstated', $this, $old_STS_ID, $new_STS_ID); |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * get Status ID |
|
| 233 | + */ |
|
| 234 | + public function status_ID() |
|
| 235 | + { |
|
| 236 | + return $this->get('STS_ID'); |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * increments this registration's related ticket sold and corresponding datetime sold values |
|
| 242 | + * |
|
| 243 | + * @return void |
|
| 244 | + * @throws \EE_Error |
|
| 245 | + */ |
|
| 246 | + private function _reserve_registration_space() |
|
| 247 | + { |
|
| 248 | + // reserved ticket and datetime counts will be decremented as sold counts are incremented |
|
| 249 | + // so stop tracking that this reg has a ticket reserved |
|
| 250 | + $this->release_reserved_ticket(); |
|
| 251 | + $ticket = $this->ticket(); |
|
| 252 | + $ticket->increase_sold(); |
|
| 253 | + $ticket->save(); |
|
| 254 | + // possibly set event status to sold out |
|
| 255 | + $this->event()->perform_sold_out_status_check(); |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * Gets the ticket this registration is for |
|
| 261 | + * |
|
| 262 | + * @param boolean $include_archived whether to include archived tickets or not. |
|
| 263 | + * @return EE_Ticket|EE_Base_Class |
|
| 264 | + * @throws \EE_Error |
|
| 265 | + */ |
|
| 266 | + public function ticket($include_archived = true) |
|
| 267 | + { |
|
| 268 | + $query_params = array(); |
|
| 269 | + if ($include_archived) { |
|
| 270 | + $query_params['default_where_conditions'] = 'none'; |
|
| 271 | + } |
|
| 272 | + return $this->get_first_related('Ticket', $query_params); |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * Gets the event this registration is for |
|
| 278 | + * |
|
| 279 | + * @return EE_Event |
|
| 280 | + */ |
|
| 281 | + public function event() |
|
| 282 | + { |
|
| 283 | + $event = $this->get_first_related('Event'); |
|
| 284 | + if (! $event instanceof \EE_Event) { |
|
| 285 | + throw new EntityNotFoundException('Event ID', $this->event_ID()); |
|
| 286 | + } |
|
| 287 | + return $event; |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Gets the "author" of the registration. Note that for the purposes of registrations, the author will correspond |
|
| 293 | + * with the author of the event this registration is for. |
|
| 294 | + * |
|
| 295 | + * @since 4.5.0 |
|
| 296 | + * @return int |
|
| 297 | + */ |
|
| 298 | + public function wp_user() |
|
| 299 | + { |
|
| 300 | + $event = $this->event(); |
|
| 301 | + if ($event instanceof EE_Event) { |
|
| 302 | + return $event->wp_user(); |
|
| 303 | + } |
|
| 304 | + return 0; |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * decrements (subtracts) this registration's related ticket sold and corresponding datetime sold values |
|
| 310 | + * |
|
| 311 | + * @return void |
|
| 312 | + * @throws \EE_Error |
|
| 313 | + */ |
|
| 314 | + private function _release_registration_space() |
|
| 315 | + { |
|
| 316 | + $ticket = $this->ticket(); |
|
| 317 | + $ticket->decrease_sold(); |
|
| 318 | + $ticket->save(); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * tracks this registration's ticket reservation in extra meta |
|
| 324 | + * and can increment related ticket reserved and corresponding datetime reserved values |
|
| 325 | + * |
|
| 326 | + * @param bool $update_ticket if true, will increment ticket and datetime reserved count |
|
| 327 | + * @return void |
|
| 328 | + * @throws \EE_Error |
|
| 329 | + */ |
|
| 330 | + public function reserve_ticket($update_ticket = false) |
|
| 331 | + { |
|
| 332 | + if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) === false) { |
|
| 333 | + // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
| 334 | + // we NEED to ALWAYS call update_extra_meta(), which is why that is done first |
|
| 335 | + if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) && $update_ticket) { |
|
| 336 | + $ticket = $this->ticket(); |
|
| 337 | + $ticket->increase_reserved(); |
|
| 338 | + $ticket->save(); |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * stops tracking this registration's ticket reservation in extra meta |
|
| 346 | + * decrements (subtracts) related ticket reserved and corresponding datetime reserved values |
|
| 347 | + * |
|
| 348 | + * @param bool $update_ticket if true, will decrement ticket and datetime reserved count |
|
| 349 | + * @return void |
|
| 350 | + * @throws \EE_Error |
|
| 351 | + */ |
|
| 352 | + public function release_reserved_ticket($update_ticket = false) |
|
| 353 | + { |
|
| 354 | + if ($this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true, false) !== false) { |
|
| 355 | + // PLZ NOTE: although checking $update_ticket first would be more efficient, |
|
| 356 | + // we NEED to ALWAYS call delete_extra_meta(), which is why that is done first |
|
| 357 | + if ($this->delete_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY) && $update_ticket) { |
|
| 358 | + $ticket = $this->ticket(); |
|
| 359 | + $ticket->decrease_reserved(); |
|
| 360 | + $ticket->save(); |
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + |
|
| 366 | + /** |
|
| 367 | + * Set Attendee ID |
|
| 368 | + * |
|
| 369 | + * @param int $ATT_ID Attendee ID |
|
| 370 | + */ |
|
| 371 | + public function set_attendee_id($ATT_ID = 0) |
|
| 372 | + { |
|
| 373 | + $this->set('ATT_ID', $ATT_ID); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * Set Transaction ID |
|
| 379 | + * |
|
| 380 | + * @param int $TXN_ID Transaction ID |
|
| 381 | + */ |
|
| 382 | + public function set_transaction_id($TXN_ID = 0) |
|
| 383 | + { |
|
| 384 | + $this->set('TXN_ID', $TXN_ID); |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * Set Session |
|
| 390 | + * |
|
| 391 | + * @param string $REG_session PHP Session ID |
|
| 392 | + */ |
|
| 393 | + public function set_session($REG_session = '') |
|
| 394 | + { |
|
| 395 | + $this->set('REG_session', $REG_session); |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + |
|
| 399 | + /** |
|
| 400 | + * Set Registration URL Link |
|
| 401 | + * |
|
| 402 | + * @param string $REG_url_link Registration URL Link |
|
| 403 | + */ |
|
| 404 | + public function set_reg_url_link($REG_url_link = '') |
|
| 405 | + { |
|
| 406 | + $this->set('REG_url_link', $REG_url_link); |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + |
|
| 410 | + /** |
|
| 411 | + * Set Attendee Counter |
|
| 412 | + * |
|
| 413 | + * @param int $REG_count Primary Attendee |
|
| 414 | + */ |
|
| 415 | + public function set_count($REG_count = 1) |
|
| 416 | + { |
|
| 417 | + $this->set('REG_count', $REG_count); |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + |
|
| 421 | + /** |
|
| 422 | + * Set Group Size |
|
| 423 | + * |
|
| 424 | + * @param boolean $REG_group_size Group Registration |
|
| 425 | + */ |
|
| 426 | + public function set_group_size($REG_group_size = false) |
|
| 427 | + { |
|
| 428 | + $this->set('REG_group_size', $REG_group_size); |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + |
|
| 432 | + /** |
|
| 433 | + * is_not_approved - convenience method that returns TRUE if REG status ID == |
|
| 434 | + * EEM_Registration::status_id_not_approved |
|
| 435 | + * |
|
| 436 | + * @return boolean |
|
| 437 | + */ |
|
| 438 | + public function is_not_approved() |
|
| 439 | + { |
|
| 440 | + return $this->status_ID() == EEM_Registration::status_id_not_approved ? true : false; |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + |
|
| 444 | + /** |
|
| 445 | + * is_pending_payment - convenience method that returns TRUE if REG status ID == |
|
| 446 | + * EEM_Registration::status_id_pending_payment |
|
| 447 | + * |
|
| 448 | + * @return boolean |
|
| 449 | + */ |
|
| 450 | + public function is_pending_payment() |
|
| 451 | + { |
|
| 452 | + return $this->status_ID() == EEM_Registration::status_id_pending_payment ? true : false; |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * is_approved - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_approved |
|
| 458 | + * |
|
| 459 | + * @return boolean |
|
| 460 | + */ |
|
| 461 | + public function is_approved() |
|
| 462 | + { |
|
| 463 | + return $this->status_ID() == EEM_Registration::status_id_approved ? true : false; |
|
| 464 | + } |
|
| 465 | + |
|
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * is_cancelled - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_cancelled |
|
| 469 | + * |
|
| 470 | + * @return boolean |
|
| 471 | + */ |
|
| 472 | + public function is_cancelled() |
|
| 473 | + { |
|
| 474 | + return $this->status_ID() == EEM_Registration::status_id_cancelled ? true : false; |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + |
|
| 478 | + /** |
|
| 479 | + * is_declined - convenience method that returns TRUE if REG status ID == EEM_Registration::status_id_declined |
|
| 480 | + * |
|
| 481 | + * @return boolean |
|
| 482 | + */ |
|
| 483 | + public function is_declined() |
|
| 484 | + { |
|
| 485 | + return $this->status_ID() == EEM_Registration::status_id_declined ? true : false; |
|
| 486 | + } |
|
| 487 | + |
|
| 488 | + |
|
| 489 | + /** |
|
| 490 | + * is_incomplete - convenience method that returns TRUE if REG status ID == |
|
| 491 | + * EEM_Registration::status_id_incomplete |
|
| 492 | + * |
|
| 493 | + * @return boolean |
|
| 494 | + */ |
|
| 495 | + public function is_incomplete() |
|
| 496 | + { |
|
| 497 | + return $this->status_ID() == EEM_Registration::status_id_incomplete ? true : false; |
|
| 498 | + } |
|
| 499 | + |
|
| 500 | + |
|
| 501 | + /** |
|
| 502 | + * Set Registration Date |
|
| 503 | + * |
|
| 504 | + * @param mixed ( int or string ) $REG_date Registration Date - Unix timestamp or string representation of |
|
| 505 | + * Date |
|
| 506 | + */ |
|
| 507 | + public function set_reg_date($REG_date = false) |
|
| 508 | + { |
|
| 509 | + $this->set('REG_date', $REG_date); |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + |
|
| 513 | + /** |
|
| 514 | + * Set final price owing for this registration after all ticket/price modifications |
|
| 515 | + * |
|
| 516 | + * @access public |
|
| 517 | + * @param float $REG_final_price |
|
| 518 | + */ |
|
| 519 | + public function set_final_price($REG_final_price = 0.00) |
|
| 520 | + { |
|
| 521 | + $this->set('REG_final_price', $REG_final_price); |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + |
|
| 525 | + /** |
|
| 526 | + * Set amount paid towards this registration's final price |
|
| 527 | + * |
|
| 528 | + * @access public |
|
| 529 | + * @param float $REG_paid |
|
| 530 | + */ |
|
| 531 | + public function set_paid($REG_paid = 0.00) |
|
| 532 | + { |
|
| 533 | + $this->set('REG_paid', $REG_paid); |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + |
|
| 537 | + /** |
|
| 538 | + * Attendee Is Going |
|
| 539 | + * |
|
| 540 | + * @param boolean $REG_att_is_going Attendee Is Going |
|
| 541 | + */ |
|
| 542 | + public function set_att_is_going($REG_att_is_going = false) |
|
| 543 | + { |
|
| 544 | + $this->set('REG_att_is_going', $REG_att_is_going); |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + |
|
| 548 | + /** |
|
| 549 | + * Gets the related attendee |
|
| 550 | + * |
|
| 551 | + * @return EE_Attendee |
|
| 552 | + */ |
|
| 553 | + public function attendee() |
|
| 554 | + { |
|
| 555 | + return $this->get_first_related('Attendee'); |
|
| 556 | + } |
|
| 557 | + |
|
| 558 | + |
|
| 559 | + /** |
|
| 560 | + * get Event ID |
|
| 561 | + */ |
|
| 562 | + public function event_ID() |
|
| 563 | + { |
|
| 564 | + return $this->get('EVT_ID'); |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + |
|
| 568 | + /** |
|
| 569 | + * get Event ID |
|
| 570 | + */ |
|
| 571 | + public function event_name() |
|
| 572 | + { |
|
| 573 | + $event = $this->event_obj(); |
|
| 574 | + if ($event) { |
|
| 575 | + return $event->name(); |
|
| 576 | + } else { |
|
| 577 | + return null; |
|
| 578 | + } |
|
| 579 | + } |
|
| 580 | + |
|
| 581 | + |
|
| 582 | + /** |
|
| 583 | + * Fetches the event this registration is for |
|
| 584 | + * |
|
| 585 | + * @return EE_Event |
|
| 586 | + */ |
|
| 587 | + public function event_obj() |
|
| 588 | + { |
|
| 589 | + return $this->get_first_related('Event'); |
|
| 590 | + } |
|
| 591 | + |
|
| 592 | + |
|
| 593 | + /** |
|
| 594 | + * get Attendee ID |
|
| 595 | + */ |
|
| 596 | + public function attendee_ID() |
|
| 597 | + { |
|
| 598 | + return $this->get('ATT_ID'); |
|
| 599 | + } |
|
| 600 | + |
|
| 601 | + |
|
| 602 | + /** |
|
| 603 | + * get PHP Session ID |
|
| 604 | + */ |
|
| 605 | + public function session_ID() |
|
| 606 | + { |
|
| 607 | + return $this->get('REG_session'); |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + |
|
| 611 | + /** |
|
| 612 | + * Gets the string which represents the URL trigger for the receipt template in the message template system. |
|
| 613 | + * |
|
| 614 | + * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
| 615 | + * @return string |
|
| 616 | + */ |
|
| 617 | + public function receipt_url($messenger = 'html') |
|
| 618 | + { |
|
| 619 | + |
|
| 620 | + /** |
|
| 621 | + * 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. |
|
| 622 | + * |
|
| 623 | + * @since 4.5.0 |
|
| 624 | + */ |
|
| 625 | + $template_relative_path = 'modules/gateways/Invoice/lib/templates/receipt_body.template.php'; |
|
| 626 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
| 627 | + |
|
| 628 | + if ($has_custom) { |
|
| 629 | + return add_query_arg(array('receipt' => 'true'), $this->invoice_url('launch')); |
|
| 630 | + } |
|
| 631 | + return apply_filters('FHEE__EE_Registration__receipt_url__receipt_url', '', $this, $messenger, 'receipt'); |
|
| 632 | + } |
|
| 633 | + |
|
| 634 | + |
|
| 635 | + /** |
|
| 636 | + * Gets the string which represents the URL trigger for the invoice template in the message template system. |
|
| 637 | + * |
|
| 638 | + * @param string $messenger 'pdf' or 'html'. Default 'html'. |
|
| 639 | + * @return string |
|
| 640 | + */ |
|
| 641 | + public function invoice_url($messenger = 'html') |
|
| 642 | + { |
|
| 643 | + /** |
|
| 644 | + * 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. |
|
| 645 | + * |
|
| 646 | + * @since 4.5.0 |
|
| 647 | + */ |
|
| 648 | + $template_relative_path = 'modules/gateways/Invoice/lib/templates/invoice_body.template.php'; |
|
| 649 | + $has_custom = EEH_Template::locate_template($template_relative_path, array(), true, true, true); |
|
| 650 | + |
|
| 651 | + if ($has_custom) { |
|
| 652 | + if ($messenger == 'html') { |
|
| 653 | + return $this->invoice_url('launch'); |
|
| 654 | + } |
|
| 655 | + $route = $messenger == 'download' || $messenger == 'pdf' ? 'download_invoice' : 'launch_invoice'; |
|
| 656 | + |
|
| 657 | + $query_args = array('ee' => $route, 'id' => $this->reg_url_link()); |
|
| 658 | + if ($messenger == 'html') { |
|
| 659 | + $query_args['html'] = true; |
|
| 660 | + } |
|
| 661 | + return add_query_arg($query_args, get_permalink(EE_Registry::instance()->CFG->core->thank_you_page_id)); |
|
| 662 | + } |
|
| 663 | + return apply_filters('FHEE__EE_Registration__invoice_url__invoice_url', '', $this, $messenger, 'invoice'); |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + |
|
| 667 | + /** |
|
| 668 | + * get Registration URL Link |
|
| 669 | + * |
|
| 670 | + * @access public |
|
| 671 | + * @return string |
|
| 672 | + * @throws \EE_Error |
|
| 673 | + */ |
|
| 674 | + public function reg_url_link() |
|
| 675 | + { |
|
| 676 | + return (string)$this->get('REG_url_link'); |
|
| 677 | + } |
|
| 678 | + |
|
| 679 | + |
|
| 680 | + /** |
|
| 681 | + * Echoes out invoice_url() |
|
| 682 | + * |
|
| 683 | + * @param string $type 'download','launch', or 'html' (default is 'launch') |
|
| 684 | + * @return void |
|
| 685 | + */ |
|
| 686 | + public function e_invoice_url($type = 'launch') |
|
| 687 | + { |
|
| 688 | + echo $this->invoice_url($type); |
|
| 689 | + } |
|
| 690 | + |
|
| 691 | + |
|
| 692 | + /** |
|
| 693 | + * Echoes out payment_overview_url |
|
| 694 | + */ |
|
| 695 | + public function e_payment_overview_url() |
|
| 696 | + { |
|
| 697 | + echo $this->payment_overview_url(); |
|
| 698 | + } |
|
| 699 | + |
|
| 700 | + |
|
| 701 | + /** |
|
| 702 | + * Gets the URL of the thank you page with this registration REG_url_link added as |
|
| 703 | + * a query parameter |
|
| 704 | + * |
|
| 705 | + * @return string |
|
| 706 | + */ |
|
| 707 | + public function payment_overview_url() |
|
| 708 | + { |
|
| 709 | + return add_query_arg(array( |
|
| 710 | + 'e_reg_url_link' => $this->reg_url_link(), |
|
| 711 | + 'step' => 'payment_options', |
|
| 712 | + 'revisit' => true, |
|
| 713 | + ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
| 714 | + } |
|
| 715 | + |
|
| 716 | + |
|
| 717 | + /** |
|
| 718 | + * Gets the URL of the thank you page with this registration REG_url_link added as |
|
| 719 | + * a query parameter |
|
| 720 | + * |
|
| 721 | + * @return string |
|
| 722 | + */ |
|
| 723 | + public function edit_attendee_information_url() |
|
| 724 | + { |
|
| 725 | + return add_query_arg(array( |
|
| 726 | + 'e_reg_url_link' => $this->reg_url_link(), |
|
| 727 | + 'step' => 'attendee_information', |
|
| 728 | + 'revisit' => true, |
|
| 729 | + ), EE_Registry::instance()->CFG->core->reg_page_url()); |
|
| 730 | + } |
|
| 731 | + |
|
| 732 | + |
|
| 733 | + /** |
|
| 734 | + * Simply generates and returns the appropriate admin_url link to edit this registration |
|
| 735 | + * |
|
| 736 | + * @return string |
|
| 737 | + */ |
|
| 738 | + public function get_admin_edit_url() |
|
| 739 | + { |
|
| 740 | + return EEH_URL::add_query_args_and_nonce(array( |
|
| 741 | + 'page' => 'espresso_registrations', |
|
| 742 | + 'action' => 'view_registration', |
|
| 743 | + '_REG_ID' => $this->ID(), |
|
| 744 | + ), admin_url('admin.php')); |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + |
|
| 748 | + /** |
|
| 749 | + * is_primary_registrant? |
|
| 750 | + */ |
|
| 751 | + public function is_primary_registrant() |
|
| 752 | + { |
|
| 753 | + return $this->get('REG_count') == 1 ? true : false; |
|
| 754 | + } |
|
| 755 | + |
|
| 756 | + |
|
| 757 | + /** |
|
| 758 | + * This returns the primary registration object for this registration group (which may be this object). |
|
| 759 | + * |
|
| 760 | + * @return EE_Registration |
|
| 761 | + */ |
|
| 762 | + public function get_primary_registration() |
|
| 763 | + { |
|
| 764 | + if ($this->is_primary_registrant()) { |
|
| 765 | + return $this; |
|
| 766 | + } |
|
| 767 | + |
|
| 768 | + //k reg_count !== 1 so let's get the EE_Registration object matching this txn_id and reg_count == 1 |
|
| 769 | + $primary_registrant = EEM_Registration::instance()->get_one(array( |
|
| 770 | + array( |
|
| 771 | + 'TXN_ID' => $this->transaction_ID(), |
|
| 772 | + 'REG_count' => 1, |
|
| 773 | + ), |
|
| 774 | + )); |
|
| 775 | + return $primary_registrant; |
|
| 776 | + } |
|
| 777 | + |
|
| 778 | + |
|
| 779 | + /** |
|
| 780 | + * get Attendee Number |
|
| 781 | + * |
|
| 782 | + * @access public |
|
| 783 | + */ |
|
| 784 | + public function count() |
|
| 785 | + { |
|
| 786 | + return $this->get('REG_count'); |
|
| 787 | + } |
|
| 788 | + |
|
| 789 | + |
|
| 790 | + /** |
|
| 791 | + * get Group Size |
|
| 792 | + */ |
|
| 793 | + public function group_size() |
|
| 794 | + { |
|
| 795 | + return $this->get('REG_group_size'); |
|
| 796 | + } |
|
| 797 | + |
|
| 798 | + |
|
| 799 | + /** |
|
| 800 | + * get Registration Date |
|
| 801 | + */ |
|
| 802 | + public function date() |
|
| 803 | + { |
|
| 804 | + return $this->get('REG_date'); |
|
| 805 | + } |
|
| 806 | + |
|
| 807 | + |
|
| 808 | + /** |
|
| 809 | + * gets a pretty date |
|
| 810 | + * |
|
| 811 | + * @param string $date_format |
|
| 812 | + * @param string $time_format |
|
| 813 | + * @return string |
|
| 814 | + */ |
|
| 815 | + public function pretty_date($date_format = null, $time_format = null) |
|
| 816 | + { |
|
| 817 | + return $this->get_datetime('REG_date', $date_format, $time_format); |
|
| 818 | + } |
|
| 819 | + |
|
| 820 | + |
|
| 821 | + /** |
|
| 822 | + * final_price |
|
| 823 | + * the registration's share of the transaction total, so that the |
|
| 824 | + * sum of all the transaction's REG_final_prices equal the transaction's total |
|
| 825 | + * |
|
| 826 | + * @return float |
|
| 827 | + */ |
|
| 828 | + public function final_price() |
|
| 829 | + { |
|
| 830 | + return $this->get('REG_final_price'); |
|
| 831 | + } |
|
| 832 | + |
|
| 833 | + |
|
| 834 | + /** |
|
| 835 | + * pretty_final_price |
|
| 836 | + * final price as formatted string, with correct decimal places and currency symbol |
|
| 837 | + * |
|
| 838 | + * @return string |
|
| 839 | + */ |
|
| 840 | + public function pretty_final_price() |
|
| 841 | + { |
|
| 842 | + return $this->get_pretty('REG_final_price'); |
|
| 843 | + } |
|
| 844 | + |
|
| 845 | + |
|
| 846 | + /** |
|
| 847 | + * get paid (yeah) |
|
| 848 | + * |
|
| 849 | + * @return float |
|
| 850 | + */ |
|
| 851 | + public function paid() |
|
| 852 | + { |
|
| 853 | + return $this->get('REG_paid'); |
|
| 854 | + } |
|
| 855 | + |
|
| 856 | + |
|
| 857 | + /** |
|
| 858 | + * pretty_paid |
|
| 859 | + * |
|
| 860 | + * @return float |
|
| 861 | + */ |
|
| 862 | + public function pretty_paid() |
|
| 863 | + { |
|
| 864 | + return $this->get_pretty('REG_paid'); |
|
| 865 | + } |
|
| 866 | + |
|
| 867 | + |
|
| 868 | + /** |
|
| 869 | + * owes_monies_and_can_pay |
|
| 870 | + * whether or not this registration has monies owing and it's' status allows payment |
|
| 871 | + * |
|
| 872 | + * @param array $requires_payment |
|
| 873 | + * @return bool |
|
| 874 | + */ |
|
| 875 | + public function owes_monies_and_can_pay($requires_payment = array()) |
|
| 876 | + { |
|
| 877 | + // these reg statuses require payment (if event is not free) |
|
| 878 | + $requires_payment = ! empty($requires_payment) ? $requires_payment : EEM_Registration::reg_statuses_that_allow_payment(); |
|
| 879 | + if ( |
|
| 880 | + in_array($this->status_ID(), $requires_payment) && |
|
| 881 | + $this->final_price() != 0 && |
|
| 882 | + $this->final_price() != $this->paid() |
|
| 883 | + ) { |
|
| 884 | + return true; |
|
| 885 | + } else { |
|
| 886 | + return false; |
|
| 887 | + } |
|
| 888 | + } |
|
| 889 | + |
|
| 890 | + |
|
| 891 | + /** |
|
| 892 | + * Prints out the return value of $this->pretty_status() |
|
| 893 | + * |
|
| 894 | + * @param bool $show_icons |
|
| 895 | + * @return void |
|
| 896 | + */ |
|
| 897 | + public function e_pretty_status($show_icons = false) |
|
| 898 | + { |
|
| 899 | + echo $this->pretty_status($show_icons); |
|
| 900 | + } |
|
| 901 | + |
|
| 902 | + |
|
| 903 | + /** |
|
| 904 | + * Returns a nice version of the status for displaying to customers |
|
| 905 | + * |
|
| 906 | + * @param bool $show_icons |
|
| 907 | + * @return string |
|
| 908 | + */ |
|
| 909 | + public function pretty_status($show_icons = false) |
|
| 910 | + { |
|
| 911 | + $status = EEM_Status::instance()->localized_status(array($this->status_ID() => __('unknown', 'event_espresso')), |
|
| 912 | + false, 'sentence'); |
|
| 913 | + $icon = ''; |
|
| 914 | + switch ($this->status_ID()) { |
|
| 915 | + case EEM_Registration::status_id_approved: |
|
| 916 | + $icon = $show_icons ? '<span class="dashicons dashicons-star-filled ee-icon-size-16 green-text"></span>' : ''; |
|
| 917 | + break; |
|
| 918 | + case EEM_Registration::status_id_pending_payment: |
|
| 919 | + $icon = $show_icons ? '<span class="dashicons dashicons-star-half ee-icon-size-16 orange-text"></span>' : ''; |
|
| 920 | + break; |
|
| 921 | + case EEM_Registration::status_id_not_approved: |
|
| 922 | + $icon = $show_icons ? '<span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>' : ''; |
|
| 923 | + break; |
|
| 924 | + case EEM_Registration::status_id_cancelled: |
|
| 925 | + $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-grey-text"></span>' : ''; |
|
| 926 | + break; |
|
| 927 | + case EEM_Registration::status_id_incomplete: |
|
| 928 | + $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 lt-orange-text"></span>' : ''; |
|
| 929 | + break; |
|
| 930 | + case EEM_Registration::status_id_declined: |
|
| 931 | + $icon = $show_icons ? '<span class="dashicons dashicons-no ee-icon-size-16 red-text"></span>' : ''; |
|
| 932 | + break; |
|
| 933 | + case EEM_Registration::status_id_wait_list: |
|
| 934 | + $icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : ''; |
|
| 935 | + break; |
|
| 936 | + } |
|
| 937 | + return $icon . $status[$this->status_ID()]; |
|
| 938 | + } |
|
| 939 | + |
|
| 940 | + |
|
| 941 | + /** |
|
| 942 | + * get Attendee Is Going |
|
| 943 | + */ |
|
| 944 | + public function att_is_going() |
|
| 945 | + { |
|
| 946 | + return $this->get('REG_att_is_going'); |
|
| 947 | + } |
|
| 948 | + |
|
| 949 | + |
|
| 950 | + /** |
|
| 951 | + * Gets related answers |
|
| 952 | + * |
|
| 953 | + * @param array $query_params like EEM_Base::get_all |
|
| 954 | + * @return EE_Answer[] |
|
| 955 | + */ |
|
| 956 | + public function answers($query_params = null) |
|
| 957 | + { |
|
| 958 | + return $this->get_many_related('Answer', $query_params); |
|
| 959 | + } |
|
| 960 | + |
|
| 961 | + |
|
| 962 | + /** |
|
| 963 | + * Gets the registration's answer value to the specified question |
|
| 964 | + * (either the question's ID or a question object) |
|
| 965 | + * |
|
| 966 | + * @param EE_Question|int $question |
|
| 967 | + * @param bool $pretty_value |
|
| 968 | + * @return array|string if pretty_value= true, the result will always be a string |
|
| 969 | + * (because the answer might be an array of answer values, so passing pretty_value=true |
|
| 970 | + * will convert it into some kind of string) |
|
| 971 | + */ |
|
| 972 | + public function answer_value_to_question($question, $pretty_value = true) |
|
| 973 | + { |
|
| 974 | + $question_id = EEM_Question::instance()->ensure_is_ID($question); |
|
| 975 | + return EEM_Answer::instance()->get_answer_value_to_question($this, $question_id, $pretty_value); |
|
| 976 | + } |
|
| 977 | + |
|
| 978 | + |
|
| 979 | + /** |
|
| 980 | + * question_groups |
|
| 981 | + * returns an array of EE_Question_Group objects for this registration |
|
| 982 | + * |
|
| 983 | + * @return EE_Question_Group[] |
|
| 984 | + */ |
|
| 985 | + public function question_groups() |
|
| 986 | + { |
|
| 987 | + $question_groups = array(); |
|
| 988 | + if ($this->event() instanceof EE_Event) { |
|
| 989 | + $question_groups = $this->event()->question_groups( |
|
| 990 | + array( |
|
| 991 | + array( |
|
| 992 | + 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
| 993 | + ), |
|
| 994 | + 'order_by' => array('QSG_order' => 'ASC'), |
|
| 995 | + ) |
|
| 996 | + ); |
|
| 997 | + } |
|
| 998 | + return $question_groups; |
|
| 999 | + } |
|
| 1000 | + |
|
| 1001 | + |
|
| 1002 | + /** |
|
| 1003 | + * count_question_groups |
|
| 1004 | + * returns a count of the number of EE_Question_Group objects for this registration |
|
| 1005 | + * |
|
| 1006 | + * @return int |
|
| 1007 | + */ |
|
| 1008 | + public function count_question_groups() |
|
| 1009 | + { |
|
| 1010 | + $qg_count = 0; |
|
| 1011 | + if ($this->event() instanceof EE_Event) { |
|
| 1012 | + $qg_count = $this->event()->count_related( |
|
| 1013 | + 'Question_Group', |
|
| 1014 | + array( |
|
| 1015 | + array( |
|
| 1016 | + 'Event_Question_Group.EQG_primary' => $this->count() == 1 ? true : false, |
|
| 1017 | + ), |
|
| 1018 | + ) |
|
| 1019 | + ); |
|
| 1020 | + } |
|
| 1021 | + return $qg_count; |
|
| 1022 | + } |
|
| 1023 | + |
|
| 1024 | + |
|
| 1025 | + /** |
|
| 1026 | + * Returns the registration date in the 'standard' string format |
|
| 1027 | + * (function may be improved in the future to allow for different formats and timezones) |
|
| 1028 | + * |
|
| 1029 | + * @return string |
|
| 1030 | + */ |
|
| 1031 | + public function reg_date() |
|
| 1032 | + { |
|
| 1033 | + return $this->get_datetime('REG_date'); |
|
| 1034 | + } |
|
| 1035 | + |
|
| 1036 | + |
|
| 1037 | + /** |
|
| 1038 | + * Gets the datetime-ticket for this registration (ie, it can be used to isolate |
|
| 1039 | + * the ticket this registration purchased, or the datetime they have registered |
|
| 1040 | + * to attend) |
|
| 1041 | + * |
|
| 1042 | + * @return EE_Datetime_Ticket |
|
| 1043 | + */ |
|
| 1044 | + public function datetime_ticket() |
|
| 1045 | + { |
|
| 1046 | + return $this->get_first_related('Datetime_Ticket'); |
|
| 1047 | + } |
|
| 1048 | + |
|
| 1049 | + |
|
| 1050 | + /** |
|
| 1051 | + * Sets the registration's datetime_ticket. |
|
| 1052 | + * |
|
| 1053 | + * @param EE_Datetime_Ticket $datetime_ticket |
|
| 1054 | + * @return EE_Datetime_Ticket |
|
| 1055 | + */ |
|
| 1056 | + public function set_datetime_ticket($datetime_ticket) |
|
| 1057 | + { |
|
| 1058 | + return $this->_add_relation_to($datetime_ticket, 'Datetime_Ticket'); |
|
| 1059 | + } |
|
| 1060 | + |
|
| 1061 | + /** |
|
| 1062 | + * Gets deleted |
|
| 1063 | + * |
|
| 1064 | + * @return boolean |
|
| 1065 | + */ |
|
| 1066 | + public function deleted() |
|
| 1067 | + { |
|
| 1068 | + return $this->get('REG_deleted'); |
|
| 1069 | + } |
|
| 1070 | + |
|
| 1071 | + /** |
|
| 1072 | + * Sets deleted |
|
| 1073 | + * |
|
| 1074 | + * @param boolean $deleted |
|
| 1075 | + * @return boolean |
|
| 1076 | + */ |
|
| 1077 | + public function set_deleted($deleted) |
|
| 1078 | + { |
|
| 1079 | + if ($deleted) { |
|
| 1080 | + $this->delete(); |
|
| 1081 | + } else { |
|
| 1082 | + $this->restore(); |
|
| 1083 | + } |
|
| 1084 | + } |
|
| 1085 | + |
|
| 1086 | + |
|
| 1087 | + /** |
|
| 1088 | + * Get the status object of this object |
|
| 1089 | + * |
|
| 1090 | + * @return EE_Status |
|
| 1091 | + */ |
|
| 1092 | + public function status_obj() |
|
| 1093 | + { |
|
| 1094 | + return $this->get_first_related('Status'); |
|
| 1095 | + } |
|
| 1096 | + |
|
| 1097 | + |
|
| 1098 | + /** |
|
| 1099 | + * Returns the number of times this registration has checked into any of the datetimes |
|
| 1100 | + * its available for |
|
| 1101 | + * |
|
| 1102 | + * @return int |
|
| 1103 | + */ |
|
| 1104 | + public function count_checkins() |
|
| 1105 | + { |
|
| 1106 | + return $this->get_model()->count_related($this, 'Checkin'); |
|
| 1107 | + } |
|
| 1108 | + |
|
| 1109 | + |
|
| 1110 | + /** |
|
| 1111 | + * Returns the number of current Check-ins this registration is checked into for any of the datetimes the |
|
| 1112 | + * registration is for. Note, this is ONLY checked in (does not include checkedout) |
|
| 1113 | + * |
|
| 1114 | + * @return int |
|
| 1115 | + */ |
|
| 1116 | + public function count_checkins_not_checkedout() |
|
| 1117 | + { |
|
| 1118 | + return $this->get_model()->count_related($this, 'Checkin', array(array('CHK_in' => 1))); |
|
| 1119 | + } |
|
| 1120 | + |
|
| 1121 | + |
|
| 1122 | + /** |
|
| 1123 | + * The purpose of this method is simply to check whether this registration can checkin to the given datetime. |
|
| 1124 | + * |
|
| 1125 | + * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
| 1126 | + * @param bool $check_approved This is used to indicate whether the caller wants can_checkin to also |
|
| 1127 | + * consider registration status as well as datetime access. |
|
| 1128 | + * @return bool |
|
| 1129 | + */ |
|
| 1130 | + public function can_checkin($DTT_OR_ID, $check_approved = true) |
|
| 1131 | + { |
|
| 1132 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
| 1133 | + |
|
| 1134 | + //first check registration status |
|
| 1135 | + if (($check_approved && ! $this->is_approved()) || ! $DTT_ID) { |
|
| 1136 | + return false; |
|
| 1137 | + } |
|
| 1138 | + //is there a datetime ticket that matches this dtt_ID? |
|
| 1139 | + if (! (EEM_Datetime_Ticket::instance()->exists(array( |
|
| 1140 | + array( |
|
| 1141 | + 'TKT_ID' => $this->get('TKT_ID'), |
|
| 1142 | + 'DTT_ID' => $DTT_ID, |
|
| 1143 | + ), |
|
| 1144 | + ))) |
|
| 1145 | + ) { |
|
| 1146 | + return false; |
|
| 1147 | + } |
|
| 1148 | + |
|
| 1149 | + //final check is against TKT_uses |
|
| 1150 | + return $this->verify_can_checkin_against_TKT_uses($DTT_ID); |
|
| 1151 | + } |
|
| 1152 | + |
|
| 1153 | + |
|
| 1154 | + /** |
|
| 1155 | + * This method verifies whether the user can checkin for the given datetime considering the max uses value set on |
|
| 1156 | + * the ticket. To do this, a query is done to get the count of the datetime records already checked into. If the |
|
| 1157 | + * datetime given does not have a check-in record and checking in for that datetime will exceed the allowed uses, |
|
| 1158 | + * then return false. Otherwise return true. |
|
| 1159 | + * |
|
| 1160 | + * @param int | EE_Datetime $DTT_OR_ID The datetime the registration is being checked against |
|
| 1161 | + * @return bool true means can checkin. false means cannot checkin. |
|
| 1162 | + */ |
|
| 1163 | + public function verify_can_checkin_against_TKT_uses($DTT_OR_ID) |
|
| 1164 | + { |
|
| 1165 | + $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
|
| 1166 | + |
|
| 1167 | + if (! $DTT_ID) { |
|
| 1168 | + return false; |
|
| 1169 | + } |
|
| 1170 | + |
|
| 1171 | + $max_uses = $this->ticket() instanceof EE_Ticket ? $this->ticket()->uses() : EE_INF; |
|
| 1172 | + |
|
| 1173 | + // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
|
| 1174 | + // or not. |
|
| 1175 | + if (! $max_uses || $max_uses === EE_INF) { |
|
| 1176 | + return true; |
|
| 1177 | + } |
|
| 1178 | + |
|
| 1179 | + //does this datetime have a checkin record? If so, then the dtt count has already been verified so we can just |
|
| 1180 | + //go ahead and toggle. |
|
| 1181 | + if (EEM_Checkin::instance()->exists(array(array('REG_ID' => $this->ID(), 'DTT_ID' => $DTT_ID)))) { |
|
| 1182 | + return true; |
|
| 1183 | + } |
|
| 1184 | + |
|
| 1185 | + //made it here so the last check is whether the number of checkins per unique datetime on this registration |
|
| 1186 | + //disallows further check-ins. |
|
| 1187 | + $count_unique_dtt_checkins = EEM_Checkin::instance()->count(array( |
|
| 1188 | + array( |
|
| 1189 | + 'REG_ID' => $this->ID(), |
|
| 1190 | + 'CHK_in' => true, |
|
| 1191 | + ), |
|
| 1192 | + ), 'DTT_ID', true); |
|
| 1193 | + // checkins have already reached their max number of uses |
|
| 1194 | + // so registrant can NOT checkin |
|
| 1195 | + if ($count_unique_dtt_checkins >= $max_uses) { |
|
| 1196 | + EE_Error::add_error(__('Check-in denied because number of datetime uses for the ticket has been reached or exceeded.', |
|
| 1197 | + 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1198 | + return false; |
|
| 1199 | + } |
|
| 1200 | + return true; |
|
| 1201 | + } |
|
| 1202 | + |
|
| 1203 | + |
|
| 1204 | + /** |
|
| 1205 | + * toggle Check-in status for this registration |
|
| 1206 | + * Check-ins are toggled in the following order: |
|
| 1207 | + * never checked in -> checked in |
|
| 1208 | + * checked in -> checked out |
|
| 1209 | + * checked out -> checked in |
|
| 1210 | + * |
|
| 1211 | + * @param int $DTT_ID include specific datetime to toggle Check-in for. |
|
| 1212 | + * If not included or null, then it is assumed latest datetime is being toggled. |
|
| 1213 | + * @param bool $verify If true then can_checkin() is used to verify whether the person |
|
| 1214 | + * can be checked in or not. Otherwise this forces change in checkin status. |
|
| 1215 | + * @return bool|int the chk_in status toggled to OR false if nothing got changed. |
|
| 1216 | + * @throws EE_Error |
|
| 1217 | + */ |
|
| 1218 | + public function toggle_checkin_status($DTT_ID = null, $verify = false) |
|
| 1219 | + { |
|
| 1220 | + if (empty($DTT_ID)) { |
|
| 1221 | + $datetime = $this->get_latest_related_datetime(); |
|
| 1222 | + $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
|
| 1223 | + // verify the registration can checkin for the given DTT_ID |
|
| 1224 | + } elseif (! $this->can_checkin($DTT_ID, $verify)) { |
|
| 1225 | + EE_Error::add_error( |
|
| 1226 | + sprintf( |
|
| 1227 | + __('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', |
|
| 1228 | + 'event_espresso'), |
|
| 1229 | + $this->ID(), |
|
| 1230 | + $DTT_ID |
|
| 1231 | + ), |
|
| 1232 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 1233 | + ); |
|
| 1234 | + return false; |
|
| 1235 | + } |
|
| 1236 | + $status_paths = array( |
|
| 1237 | + EE_Registration::checkin_status_never => EE_Registration::checkin_status_in, |
|
| 1238 | + EE_Registration::checkin_status_in => EE_Registration::checkin_status_out, |
|
| 1239 | + EE_Registration::checkin_status_out => EE_Registration::checkin_status_in, |
|
| 1240 | + ); |
|
| 1241 | + //start by getting the current status so we know what status we'll be changing to. |
|
| 1242 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID, null); |
|
| 1243 | + $status_to = $status_paths[$cur_status]; |
|
| 1244 | + // database only records true for checked IN or false for checked OUT |
|
| 1245 | + // no record ( null ) means checked in NEVER, but we obviously don't save that |
|
| 1246 | + $new_status = $status_to === EE_Registration::checkin_status_in ? true : false; |
|
| 1247 | + // add relation - note Check-ins are always creating new rows |
|
| 1248 | + // because we are keeping track of Check-ins over time. |
|
| 1249 | + // Eventually we'll probably want to show a list table |
|
| 1250 | + // for the individual Check-ins so that they can be managed. |
|
| 1251 | + $checkin = EE_Checkin::new_instance(array( |
|
| 1252 | + 'REG_ID' => $this->ID(), |
|
| 1253 | + 'DTT_ID' => $DTT_ID, |
|
| 1254 | + 'CHK_in' => $new_status, |
|
| 1255 | + )); |
|
| 1256 | + // if the record could not be saved then return false |
|
| 1257 | + if ($checkin->save() === 0) { |
|
| 1258 | + if (WP_DEBUG) { |
|
| 1259 | + global $wpdb; |
|
| 1260 | + $error = sprintf( |
|
| 1261 | + __('Registration check in update failed because of the following database error: %1$s%2$s', |
|
| 1262 | + 'event_espresso'), |
|
| 1263 | + '<br />', |
|
| 1264 | + $wpdb->last_error |
|
| 1265 | + ); |
|
| 1266 | + } else { |
|
| 1267 | + $error = __('Registration check in update failed because of an unknown database error', |
|
| 1268 | + 'event_espresso'); |
|
| 1269 | + } |
|
| 1270 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
| 1271 | + return false; |
|
| 1272 | + } |
|
| 1273 | + return $status_to; |
|
| 1274 | + } |
|
| 1275 | + |
|
| 1276 | + |
|
| 1277 | + /** |
|
| 1278 | + * Returns the latest datetime related to this registration (via the ticket attached to the registration). |
|
| 1279 | + * "Latest" is defined by the `DTT_EVT_start` column. |
|
| 1280 | + * |
|
| 1281 | + * @return EE_Datetime|null |
|
| 1282 | + * @throws \EE_Error |
|
| 1283 | + */ |
|
| 1284 | + public function get_latest_related_datetime() |
|
| 1285 | + { |
|
| 1286 | + return EEM_Datetime::instance()->get_one( |
|
| 1287 | + array( |
|
| 1288 | + array( |
|
| 1289 | + 'Ticket.Registration.REG_ID' => $this->ID(), |
|
| 1290 | + ), |
|
| 1291 | + 'order_by' => array('DTT_EVT_start' => 'DESC'), |
|
| 1292 | + ) |
|
| 1293 | + ); |
|
| 1294 | + } |
|
| 1295 | + |
|
| 1296 | + |
|
| 1297 | + /** |
|
| 1298 | + * Returns the earliest datetime related to this registration (via the ticket attached to the registration). |
|
| 1299 | + * "Earliest" is defined by the `DTT_EVT_start` column. |
|
| 1300 | + * |
|
| 1301 | + * @throws \EE_Error |
|
| 1302 | + */ |
|
| 1303 | + public function get_earliest_related_datetime() |
|
| 1304 | + { |
|
| 1305 | + return EEM_Datetime::instance()->get_one( |
|
| 1306 | + array( |
|
| 1307 | + array( |
|
| 1308 | + 'Ticket.Registration.REG_ID' => $this->ID(), |
|
| 1309 | + ), |
|
| 1310 | + 'order_by' => array('DTT_EVT_start' => 'ASC'), |
|
| 1311 | + ) |
|
| 1312 | + ); |
|
| 1313 | + } |
|
| 1314 | + |
|
| 1315 | + |
|
| 1316 | + /** |
|
| 1317 | + * This method simply returns the check-in status for this registration and the given datetime. |
|
| 1318 | + * If neither the datetime nor the checkin values are provided as arguments, |
|
| 1319 | + * then this will return the LATEST check-in status for the registration across all datetimes it belongs to. |
|
| 1320 | + * |
|
| 1321 | + * @param int $DTT_ID The ID of the datetime we're checking against |
|
| 1322 | + * (if empty we'll get the primary datetime for |
|
| 1323 | + * this registration (via event) and use it's ID); |
|
| 1324 | + * @param EE_Checkin $checkin If present, we use the given checkin object rather than the dtt_id. |
|
| 1325 | + * @return int Integer representing Check-in status. |
|
| 1326 | + * @throws \EE_Error |
|
| 1327 | + */ |
|
| 1328 | + public function check_in_status_for_datetime($DTT_ID = 0, $checkin = null) |
|
| 1329 | + { |
|
| 1330 | + $checkin_query_params = array( |
|
| 1331 | + 'order_by' => array('CHK_timestamp' => 'DESC'), |
|
| 1332 | + ); |
|
| 1333 | + |
|
| 1334 | + if ($DTT_ID > 0) { |
|
| 1335 | + $checkin_query_params[0] = array('DTT_ID' => $DTT_ID); |
|
| 1336 | + } |
|
| 1337 | + |
|
| 1338 | + //get checkin object (if exists) |
|
| 1339 | + $checkin = $checkin instanceof EE_Checkin |
|
| 1340 | + ? $checkin |
|
| 1341 | + : $this->get_first_related('Checkin', $checkin_query_params); |
|
| 1342 | + if ($checkin instanceof EE_Checkin) { |
|
| 1343 | + if ($checkin->get('CHK_in')) { |
|
| 1344 | + return EE_Registration::checkin_status_in; //checked in |
|
| 1345 | + } |
|
| 1346 | + return EE_Registration::checkin_status_out; //had checked in but is now checked out. |
|
| 1347 | + } |
|
| 1348 | + return EE_Registration::checkin_status_never; //never been checked in |
|
| 1349 | + } |
|
| 1350 | + |
|
| 1351 | + |
|
| 1352 | + /** |
|
| 1353 | + * This method returns a localized message for the toggled Check-in message. |
|
| 1354 | + * |
|
| 1355 | + * @param int $DTT_ID include specific datetime to get the correct Check-in message. If not included or null, |
|
| 1356 | + * then it is assumed Check-in for primary datetime was toggled. |
|
| 1357 | + * @param bool $error This just flags that you want an error message returned. This is put in so that the error |
|
| 1358 | + * message can be customized with the attendee name. |
|
| 1359 | + * @return string internationalized message |
|
| 1360 | + */ |
|
| 1361 | + public function get_checkin_msg($DTT_ID, $error = false) |
|
| 1362 | + { |
|
| 1363 | + //let's get the attendee first so we can include the name of the attendee |
|
| 1364 | + $attendee = $this->get_first_related('Attendee'); |
|
| 1365 | + if ($attendee instanceof EE_Attendee) { |
|
| 1366 | + if ($error) { |
|
| 1367 | + return sprintf(__("%s's check-in status was not changed.", "event_espresso"), $attendee->full_name()); |
|
| 1368 | + } |
|
| 1369 | + $cur_status = $this->check_in_status_for_datetime($DTT_ID); |
|
| 1370 | + //what is the status message going to be? |
|
| 1371 | + switch ($cur_status) { |
|
| 1372 | + case EE_Registration::checkin_status_never : |
|
| 1373 | + return sprintf(__("%s has been removed from Check-in records", "event_espresso"), |
|
| 1374 | + $attendee->full_name()); |
|
| 1375 | + break; |
|
| 1376 | + case EE_Registration::checkin_status_in : |
|
| 1377 | + return sprintf(__('%s has been checked in', 'event_espresso'), $attendee->full_name()); |
|
| 1378 | + break; |
|
| 1379 | + case EE_Registration::checkin_status_out : |
|
| 1380 | + return sprintf(__('%s has been checked out', 'event_espresso'), $attendee->full_name()); |
|
| 1381 | + break; |
|
| 1382 | + } |
|
| 1383 | + } |
|
| 1384 | + return __("The check-in status could not be determined.", "event_espresso"); |
|
| 1385 | + } |
|
| 1386 | + |
|
| 1387 | + |
|
| 1388 | + /** |
|
| 1389 | + * Returns the related EE_Transaction to this registration |
|
| 1390 | + * |
|
| 1391 | + * @return EE_Transaction |
|
| 1392 | + */ |
|
| 1393 | + public function transaction() |
|
| 1394 | + { |
|
| 1395 | + $transaction = $this->get_first_related('Transaction'); |
|
| 1396 | + if (! $transaction instanceof \EE_Transaction) { |
|
| 1397 | + throw new EntityNotFoundException('Transaction ID', $this->transaction_ID()); |
|
| 1398 | + } |
|
| 1399 | + return $transaction; |
|
| 1400 | + } |
|
| 1401 | + |
|
| 1402 | + |
|
| 1403 | + /** |
|
| 1404 | + * get Registration Code |
|
| 1405 | + */ |
|
| 1406 | + public function reg_code() |
|
| 1407 | + { |
|
| 1408 | + return $this->get('REG_code'); |
|
| 1409 | + } |
|
| 1410 | + |
|
| 1411 | + |
|
| 1412 | + /** |
|
| 1413 | + * get Transaction ID |
|
| 1414 | + */ |
|
| 1415 | + public function transaction_ID() |
|
| 1416 | + { |
|
| 1417 | + return $this->get('TXN_ID'); |
|
| 1418 | + } |
|
| 1419 | + |
|
| 1420 | + |
|
| 1421 | + /** |
|
| 1422 | + * @return int |
|
| 1423 | + */ |
|
| 1424 | + public function ticket_ID() |
|
| 1425 | + { |
|
| 1426 | + return $this->get('TKT_ID'); |
|
| 1427 | + } |
|
| 1428 | + |
|
| 1429 | + |
|
| 1430 | + /** |
|
| 1431 | + * Set Registration Code |
|
| 1432 | + * |
|
| 1433 | + * @access public |
|
| 1434 | + * @param string $REG_code Registration Code |
|
| 1435 | + * @param boolean $use_default |
|
| 1436 | + */ |
|
| 1437 | + public function set_reg_code($REG_code, $use_default = false) |
|
| 1438 | + { |
|
| 1439 | + if (empty($REG_code)) { |
|
| 1440 | + EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 1441 | + return; |
|
| 1442 | + } |
|
| 1443 | + if (! $this->reg_code()) { |
|
| 1444 | + parent::set('REG_code', $REG_code, $use_default); |
|
| 1445 | + } else { |
|
| 1446 | + EE_Error::doing_it_wrong( |
|
| 1447 | + __CLASS__ . '::' . __FUNCTION__, |
|
| 1448 | + __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
|
| 1449 | + '4.6.0' |
|
| 1450 | + ); |
|
| 1451 | + } |
|
| 1452 | + } |
|
| 1453 | + |
|
| 1454 | + |
|
| 1455 | + /** |
|
| 1456 | + * Returns all other registrations in the same group as this registrant who have the same ticket option. |
|
| 1457 | + * Note, if you want to just get all registrations in the same transaction (group), use: |
|
| 1458 | + * $registration->transaction()->registrations(); |
|
| 1459 | + * |
|
| 1460 | + * @since 4.5.0 |
|
| 1461 | + * @return EE_Registration[] or empty array if this isn't a group registration. |
|
| 1462 | + */ |
|
| 1463 | + public function get_all_other_registrations_in_group() |
|
| 1464 | + { |
|
| 1465 | + if ($this->group_size() < 2) { |
|
| 1466 | + return array(); |
|
| 1467 | + } |
|
| 1468 | + |
|
| 1469 | + $query[0] = array( |
|
| 1470 | + 'TXN_ID' => $this->transaction_ID(), |
|
| 1471 | + 'REG_ID' => array('!=', $this->ID()), |
|
| 1472 | + 'TKT_ID' => $this->ticket_ID(), |
|
| 1473 | + ); |
|
| 1474 | + |
|
| 1475 | + $registrations = $this->get_model()->get_all($query); |
|
| 1476 | + return $registrations; |
|
| 1477 | + } |
|
| 1478 | + |
|
| 1479 | + /** |
|
| 1480 | + * Return the link to the admin details for the object. |
|
| 1481 | + * |
|
| 1482 | + * @return string |
|
| 1483 | + */ |
|
| 1484 | + public function get_admin_details_link() |
|
| 1485 | + { |
|
| 1486 | + EE_Registry::instance()->load_helper('URL'); |
|
| 1487 | + return EEH_URL::add_query_args_and_nonce( |
|
| 1488 | + array( |
|
| 1489 | + 'page' => 'espresso_registrations', |
|
| 1490 | + 'action' => 'view_registration', |
|
| 1491 | + '_REG_ID' => $this->ID(), |
|
| 1492 | + ), |
|
| 1493 | + admin_url('admin.php') |
|
| 1494 | + ); |
|
| 1495 | + } |
|
| 1496 | + |
|
| 1497 | + /** |
|
| 1498 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 1499 | + * |
|
| 1500 | + * @return string |
|
| 1501 | + */ |
|
| 1502 | + public function get_admin_edit_link() |
|
| 1503 | + { |
|
| 1504 | + return $this->get_admin_details_link(); |
|
| 1505 | + } |
|
| 1506 | + |
|
| 1507 | + /** |
|
| 1508 | + * Returns the link to a settings page for the object. |
|
| 1509 | + * |
|
| 1510 | + * @return string |
|
| 1511 | + */ |
|
| 1512 | + public function get_admin_settings_link() |
|
| 1513 | + { |
|
| 1514 | + return $this->get_admin_details_link(); |
|
| 1515 | + } |
|
| 1516 | + |
|
| 1517 | + /** |
|
| 1518 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 1519 | + * |
|
| 1520 | + * @return string |
|
| 1521 | + */ |
|
| 1522 | + public function get_admin_overview_link() |
|
| 1523 | + { |
|
| 1524 | + EE_Registry::instance()->load_helper('URL'); |
|
| 1525 | + return EEH_URL::add_query_args_and_nonce( |
|
| 1526 | + array( |
|
| 1527 | + 'page' => 'espresso_registrations', |
|
| 1528 | + ), |
|
| 1529 | + admin_url('admin.php') |
|
| 1530 | + ); |
|
| 1531 | + } |
|
| 1532 | + |
|
| 1533 | + |
|
| 1534 | + /** |
|
| 1535 | + * @param array $query_params |
|
| 1536 | + * @return \EE_Registration[] |
|
| 1537 | + * @throws \EE_Error |
|
| 1538 | + */ |
|
| 1539 | + public function payments($query_params = array()) |
|
| 1540 | + { |
|
| 1541 | + return $this->get_many_related('Payment', $query_params); |
|
| 1542 | + } |
|
| 1543 | + |
|
| 1544 | + |
|
| 1545 | + /** |
|
| 1546 | + * @param array $query_params |
|
| 1547 | + * @return \EE_Registration_Payment[] |
|
| 1548 | + * @throws \EE_Error |
|
| 1549 | + */ |
|
| 1550 | + public function registration_payments($query_params = array()) |
|
| 1551 | + { |
|
| 1552 | + return $this->get_many_related('Registration_Payment', $query_params); |
|
| 1553 | + } |
|
| 1554 | + |
|
| 1555 | + |
|
| 1556 | + /** |
|
| 1557 | + * This grabs the payment method corresponding to the last payment made for the amount owing on the registration. |
|
| 1558 | + * Note: if there are no payments on the registration there will be no payment method returned. |
|
| 1559 | + * |
|
| 1560 | + * @return EE_Payment_Method|null |
|
| 1561 | + */ |
|
| 1562 | + public function payment_method() |
|
| 1563 | + { |
|
| 1564 | + return EEM_Payment_Method::instance()->get_last_used_for_registration($this); |
|
| 1565 | + } |
|
| 1566 | + |
|
| 1567 | + |
|
| 1568 | + /** |
|
| 1569 | + * @return \EE_Line_Item |
|
| 1570 | + * @throws EntityNotFoundException |
|
| 1571 | + * @throws \EE_Error |
|
| 1572 | + */ |
|
| 1573 | + public function ticket_line_item() |
|
| 1574 | + { |
|
| 1575 | + $ticket = $this->ticket(); |
|
| 1576 | + $transaction = $this->transaction(); |
|
| 1577 | + $line_item = null; |
|
| 1578 | + $ticket_line_items = \EEH_Line_Item::get_line_items_by_object_type_and_IDs( |
|
| 1579 | + $transaction->total_line_item(), |
|
| 1580 | + 'Ticket', |
|
| 1581 | + array($ticket->ID()) |
|
| 1582 | + ); |
|
| 1583 | + foreach ($ticket_line_items as $ticket_line_item) { |
|
| 1584 | + if ( |
|
| 1585 | + $ticket_line_item instanceof \EE_Line_Item |
|
| 1586 | + && $ticket_line_item->OBJ_type() === 'Ticket' |
|
| 1587 | + && $ticket_line_item->OBJ_ID() === $ticket->ID() |
|
| 1588 | + ) { |
|
| 1589 | + $line_item = $ticket_line_item; |
|
| 1590 | + break; |
|
| 1591 | + } |
|
| 1592 | + } |
|
| 1593 | + if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
| 1594 | + throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
|
| 1595 | + } |
|
| 1596 | + return $line_item; |
|
| 1597 | + } |
|
| 1598 | + |
|
| 1599 | + |
|
| 1600 | + /** |
|
| 1601 | + * Soft Deletes this model object. |
|
| 1602 | + * |
|
| 1603 | + * @return boolean | int |
|
| 1604 | + * @throws \RuntimeException |
|
| 1605 | + * @throws \EE_Error |
|
| 1606 | + */ |
|
| 1607 | + public function delete() |
|
| 1608 | + { |
|
| 1609 | + if ($this->update_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY, $this->status_ID()) === true) { |
|
| 1610 | + $this->set_status(EEM_Registration::status_id_cancelled); |
|
| 1611 | + } |
|
| 1612 | + return parent::delete(); |
|
| 1613 | + } |
|
| 1614 | + |
|
| 1615 | + |
|
| 1616 | + /** |
|
| 1617 | + * Restores whatever the previous status was on a registration before it was trashed (if possible) |
|
| 1618 | + * |
|
| 1619 | + * @throws \EE_Error |
|
| 1620 | + * @throws \RuntimeException |
|
| 1621 | + */ |
|
| 1622 | + public function restore() |
|
| 1623 | + { |
|
| 1624 | + $previous_status = $this->get_extra_meta( |
|
| 1625 | + EE_Registration::PRE_TRASH_REG_STATUS_KEY, |
|
| 1626 | + true, |
|
| 1627 | + EEM_Registration::status_id_cancelled |
|
| 1628 | + ); |
|
| 1629 | + if ($previous_status) { |
|
| 1630 | + $this->delete_extra_meta(EE_Registration::PRE_TRASH_REG_STATUS_KEY); |
|
| 1631 | + $this->set_status($previous_status); |
|
| 1632 | + } |
|
| 1633 | + return parent::restore(); |
|
| 1634 | + } |
|
| 1635 | + |
|
| 1636 | + |
|
| 1637 | + |
|
| 1638 | + /*************************** DEPRECATED ***************************/ |
|
| 1639 | + |
|
| 1640 | + |
|
| 1641 | + /** |
|
| 1642 | + * @deprecated |
|
| 1643 | + * @since 4.7.0 |
|
| 1644 | + * @access public |
|
| 1645 | + */ |
|
| 1646 | + public function price_paid() |
|
| 1647 | + { |
|
| 1648 | + EE_Error::doing_it_wrong('EE_Registration::price_paid()', |
|
| 1649 | + __('This method is deprecated, please use EE_Registration::final_price() instead.', 'event_espresso'), |
|
| 1650 | + '4.7.0'); |
|
| 1651 | + return $this->final_price(); |
|
| 1652 | + } |
|
| 1653 | + |
|
| 1654 | + |
|
| 1655 | + /** |
|
| 1656 | + * @deprecated |
|
| 1657 | + * @since 4.7.0 |
|
| 1658 | + * @access public |
|
| 1659 | + * @param float $REG_final_price |
|
| 1660 | + */ |
|
| 1661 | + public function set_price_paid($REG_final_price = 0.00) |
|
| 1662 | + { |
|
| 1663 | + EE_Error::doing_it_wrong('EE_Registration::set_price_paid()', |
|
| 1664 | + __('This method is deprecated, please use EE_Registration::set_final_price() instead.', 'event_espresso'), |
|
| 1665 | + '4.7.0'); |
|
| 1666 | + $this->set_final_price($REG_final_price); |
|
| 1667 | + } |
|
| 1668 | + |
|
| 1669 | + |
|
| 1670 | + /** |
|
| 1671 | + * @deprecated |
|
| 1672 | + * @since 4.7.0 |
|
| 1673 | + * @return string |
|
| 1674 | + */ |
|
| 1675 | + public function pretty_price_paid() |
|
| 1676 | + { |
|
| 1677 | + EE_Error::doing_it_wrong('EE_Registration::pretty_price_paid()', |
|
| 1678 | + __('This method is deprecated, please use EE_Registration::pretty_final_price() instead.', |
|
| 1679 | + 'event_espresso'), '4.7.0'); |
|
| 1680 | + return $this->pretty_final_price(); |
|
| 1681 | + } |
|
| 1682 | + |
|
| 1683 | + |
|
| 1684 | + /** |
|
| 1685 | + * Gets the primary datetime related to this registration via the related Event to this registration |
|
| 1686 | + * |
|
| 1687 | + * @deprecated 4.9.17 |
|
| 1688 | + * @return EE_Datetime |
|
| 1689 | + */ |
|
| 1690 | + public function get_related_primary_datetime() |
|
| 1691 | + { |
|
| 1692 | + EE_Error::doing_it_wrong( |
|
| 1693 | + __METHOD__, |
|
| 1694 | + esc_html__( |
|
| 1695 | + 'Use EE_Registration::get_latest_related_datetime() or EE_Registration::get_earliest_related_datetime()', |
|
| 1696 | + 'event_espresso' |
|
| 1697 | + ), |
|
| 1698 | + '4.9.17', |
|
| 1699 | + '5.0.0' |
|
| 1700 | + ); |
|
| 1701 | + return $this->event()->primary_datetime(); |
|
| 1702 | + } |
|
| 1703 | 1703 | |
| 1704 | 1704 | |
| 1705 | 1705 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php use EventEspresso\core\exceptions\EntityNotFoundException; |
| 2 | 2 | |
| 3 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | 4 | exit('No direct script access allowed'); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | { |
| 107 | 107 | switch ($field_name) { |
| 108 | 108 | case 'REG_code' : |
| 109 | - if (! empty($field_value) && $this->reg_code() === null) { |
|
| 109 | + if ( ! empty($field_value) && $this->reg_code() === null) { |
|
| 110 | 110 | $this->set_reg_code($field_value, $use_default); |
| 111 | 111 | } |
| 112 | 112 | break; |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | public function event() |
| 282 | 282 | { |
| 283 | 283 | $event = $this->get_first_related('Event'); |
| 284 | - if (! $event instanceof \EE_Event) { |
|
| 284 | + if ( ! $event instanceof \EE_Event) { |
|
| 285 | 285 | throw new EntityNotFoundException('Event ID', $this->event_ID()); |
| 286 | 286 | } |
| 287 | 287 | return $event; |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | */ |
| 674 | 674 | public function reg_url_link() |
| 675 | 675 | { |
| 676 | - return (string)$this->get('REG_url_link'); |
|
| 676 | + return (string) $this->get('REG_url_link'); |
|
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | $icon = $show_icons ? '<span class="dashicons dashicons-clipboard ee-icon-size-16 purple-text"></span>' : ''; |
| 935 | 935 | break; |
| 936 | 936 | } |
| 937 | - return $icon . $status[$this->status_ID()]; |
|
| 937 | + return $icon.$status[$this->status_ID()]; |
|
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | return false; |
| 1137 | 1137 | } |
| 1138 | 1138 | //is there a datetime ticket that matches this dtt_ID? |
| 1139 | - if (! (EEM_Datetime_Ticket::instance()->exists(array( |
|
| 1139 | + if ( ! (EEM_Datetime_Ticket::instance()->exists(array( |
|
| 1140 | 1140 | array( |
| 1141 | 1141 | 'TKT_ID' => $this->get('TKT_ID'), |
| 1142 | 1142 | 'DTT_ID' => $DTT_ID, |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | { |
| 1165 | 1165 | $DTT_ID = EEM_Datetime::instance()->ensure_is_ID($DTT_OR_ID); |
| 1166 | 1166 | |
| 1167 | - if (! $DTT_ID) { |
|
| 1167 | + if ( ! $DTT_ID) { |
|
| 1168 | 1168 | return false; |
| 1169 | 1169 | } |
| 1170 | 1170 | |
@@ -1172,7 +1172,7 @@ discard block |
||
| 1172 | 1172 | |
| 1173 | 1173 | // if max uses is not set or equals infinity then return true cause its not a factor for whether user can check-in |
| 1174 | 1174 | // or not. |
| 1175 | - if (! $max_uses || $max_uses === EE_INF) { |
|
| 1175 | + if ( ! $max_uses || $max_uses === EE_INF) { |
|
| 1176 | 1176 | return true; |
| 1177 | 1177 | } |
| 1178 | 1178 | |
@@ -1221,7 +1221,7 @@ discard block |
||
| 1221 | 1221 | $datetime = $this->get_latest_related_datetime(); |
| 1222 | 1222 | $DTT_ID = $datetime instanceof EE_Datetime ? $datetime->ID() : 0; |
| 1223 | 1223 | // verify the registration can checkin for the given DTT_ID |
| 1224 | - } elseif (! $this->can_checkin($DTT_ID, $verify)) { |
|
| 1224 | + } elseif ( ! $this->can_checkin($DTT_ID, $verify)) { |
|
| 1225 | 1225 | EE_Error::add_error( |
| 1226 | 1226 | sprintf( |
| 1227 | 1227 | __('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', |
@@ -1393,7 +1393,7 @@ discard block |
||
| 1393 | 1393 | public function transaction() |
| 1394 | 1394 | { |
| 1395 | 1395 | $transaction = $this->get_first_related('Transaction'); |
| 1396 | - if (! $transaction instanceof \EE_Transaction) { |
|
| 1396 | + if ( ! $transaction instanceof \EE_Transaction) { |
|
| 1397 | 1397 | throw new EntityNotFoundException('Transaction ID', $this->transaction_ID()); |
| 1398 | 1398 | } |
| 1399 | 1399 | return $transaction; |
@@ -1440,11 +1440,11 @@ discard block |
||
| 1440 | 1440 | EE_Error::add_error(__('REG_code can not be empty.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
| 1441 | 1441 | return; |
| 1442 | 1442 | } |
| 1443 | - if (! $this->reg_code()) { |
|
| 1443 | + if ( ! $this->reg_code()) { |
|
| 1444 | 1444 | parent::set('REG_code', $REG_code, $use_default); |
| 1445 | 1445 | } else { |
| 1446 | 1446 | EE_Error::doing_it_wrong( |
| 1447 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 1447 | + __CLASS__.'::'.__FUNCTION__, |
|
| 1448 | 1448 | __('Can not change a registration REG_code once it has been set.', 'event_espresso'), |
| 1449 | 1449 | '4.6.0' |
| 1450 | 1450 | ); |
@@ -1590,7 +1590,7 @@ discard block |
||
| 1590 | 1590 | break; |
| 1591 | 1591 | } |
| 1592 | 1592 | } |
| 1593 | - if (! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
| 1593 | + if ( ! ($line_item instanceof \EE_Line_Item && $line_item->OBJ_type() === 'Ticket')) { |
|
| 1594 | 1594 | throw new EntityNotFoundException('Line Item Ticket ID', $ticket->ID()); |
| 1595 | 1595 | } |
| 1596 | 1596 | return $line_item; |
@@ -14,248 +14,248 @@ |
||
| 14 | 14 | abstract class EE_Form_Section_Layout_Base |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Form form section to lay out |
|
| 19 | - * |
|
| 20 | - * @var EE_Form_Section_Proper |
|
| 21 | - */ |
|
| 22 | - protected $_form_section; |
|
| 23 | - |
|
| 24 | - |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * __construct |
|
| 28 | - */ |
|
| 29 | - function __construct() |
|
| 30 | - { |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * The form section on which this strategy is to perform |
|
| 37 | - * |
|
| 38 | - * @param EE_Form_Section_Proper $form |
|
| 39 | - */ |
|
| 40 | - public function _construct_finalize(EE_Form_Section_Proper $form) |
|
| 41 | - { |
|
| 42 | - $this->_form_section = $form; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @return \EE_Form_Section_Proper |
|
| 49 | - */ |
|
| 50 | - public function form_section() |
|
| 51 | - { |
|
| 52 | - return $this->_form_section; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Also has teh side effect of enqueuing any needed JS and CSS for |
|
| 59 | - * this form. |
|
| 60 | - * Creates all the HTML necessary for displaying this form, its inputs, and |
|
| 61 | - * proper subsections. |
|
| 62 | - * Returns the HTML |
|
| 63 | - * |
|
| 64 | - * @return string HTML for displaying |
|
| 65 | - */ |
|
| 66 | - public function layout_form() |
|
| 67 | - { |
|
| 68 | - $html = ''; |
|
| 69 | - // layout_form_begin |
|
| 70 | - $html .= apply_filters( |
|
| 71 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(), |
|
| 72 | - $this->layout_form_begin(), |
|
| 73 | - $this->_form_section |
|
| 74 | - ); |
|
| 75 | - // layout_form_loop |
|
| 76 | - $html .= apply_filters( |
|
| 77 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(), |
|
| 78 | - $this->layout_form_loop(), |
|
| 79 | - $this->_form_section |
|
| 80 | - ); |
|
| 81 | - // layout_form_end |
|
| 82 | - $html .= apply_filters( |
|
| 83 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(), |
|
| 84 | - $this->layout_form_end(), |
|
| 85 | - $this->_form_section |
|
| 86 | - ); |
|
| 87 | - $html = $this->add_form_section_hooks_and_filters($html); |
|
| 88 | - return $html; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @return string |
|
| 95 | - */ |
|
| 96 | - public function layout_form_loop() |
|
| 97 | - { |
|
| 98 | - $html = ''; |
|
| 99 | - foreach ($this->_form_section->subsections() as $name => $subsection) { |
|
| 100 | - if ($subsection instanceof EE_Form_Input_Base) { |
|
| 101 | - $html .= apply_filters( |
|
| 102 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_' . $name . '__in_' . $this->_form_section->name(), |
|
| 103 | - $this->layout_input($subsection), |
|
| 104 | - $this->_form_section, |
|
| 105 | - $subsection |
|
| 106 | - ); |
|
| 107 | - } elseif ($subsection instanceof EE_Form_Section_Base) { |
|
| 108 | - $html .= apply_filters( |
|
| 109 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_' . $name . '__in_' . $this->_form_section->name(), |
|
| 110 | - $this->layout_subsection($subsection), |
|
| 111 | - $this->_form_section, |
|
| 112 | - $subsection |
|
| 113 | - ); |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - return $html; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
| 123 | - * |
|
| 124 | - * @return string |
|
| 125 | - */ |
|
| 126 | - abstract public function layout_form_begin(); |
|
| 127 | - |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
| 132 | - * |
|
| 133 | - * @return string |
|
| 134 | - */ |
|
| 135 | - abstract public function layout_form_end(); |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * Should be used internally by layout_form() to layout each input (eg, if this layout |
|
| 141 | - * is putting each input in a row of its own, this should probably be called by a |
|
| 142 | - * foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop. |
|
| 143 | - * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely |
|
| 144 | - * customize the form's layout, but would like to make use of it for laying out |
|
| 145 | - * 'easy-to-layout' inputs |
|
| 146 | - * |
|
| 147 | - * @param EE_Form_Input_Base $input |
|
| 148 | - * @return string html |
|
| 149 | - */ |
|
| 150 | - abstract public function layout_input($input); |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Similar to layout_input(), should be used internally by layout_form() within a |
|
| 156 | - * loop to layout each proper subsection. Unlike layout_input(), however, it is assumed |
|
| 157 | - * that the proper subsection will layout its container, label, etc on its own. |
|
| 158 | - * |
|
| 159 | - * @param EE_Form_Section_Base $subsection |
|
| 160 | - * @return string html |
|
| 161 | - */ |
|
| 162 | - abstract public function layout_subsection($subsection); |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * Gets the HTML for the label tag and its contents for the input |
|
| 168 | - * |
|
| 169 | - * @param EE_Form_Input_Base $input |
|
| 170 | - * @return string |
|
| 171 | - */ |
|
| 172 | - public function display_label($input) |
|
| 173 | - { |
|
| 174 | - $class = $input->required() ? 'ee-required-label ' . $input->html_label_class() : $input->html_label_class(); |
|
| 175 | - $label_text = $input->required() |
|
| 176 | - ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
| 177 | - : $input->html_label_text(); |
|
| 178 | - return '<label id="' |
|
| 179 | - . $input->html_label_id() |
|
| 180 | - . '" class="' |
|
| 181 | - . $class |
|
| 182 | - . '" style="' |
|
| 183 | - . $input->html_label_style() |
|
| 184 | - . '" for="' . $input->html_name() |
|
| 185 | - . '">' |
|
| 186 | - . $label_text |
|
| 187 | - . '</label>'; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * returns the HTML for the server-side validation errors for the specified input |
|
| 194 | - * Note that if JS is enabled, it should remove these and instead |
|
| 195 | - * populate the form's errors in the jquery validate fashion |
|
| 196 | - * using the localized data provided to the JS |
|
| 197 | - * |
|
| 198 | - * @param EE_Form_Input_Base $input |
|
| 199 | - * @return string |
|
| 200 | - */ |
|
| 201 | - public function display_errors($input) |
|
| 202 | - { |
|
| 203 | - if ($input->get_validation_errors()) { |
|
| 204 | - return "<label id='" |
|
| 205 | - . $input->html_id() |
|
| 206 | - . "-error' class='error' for='{$input->html_name()}'>" |
|
| 207 | - . $input->get_validation_error_string() |
|
| 208 | - . "</label>"; |
|
| 209 | - } else { |
|
| 210 | - return ''; |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * Displays the help span for the specified input |
|
| 218 | - * |
|
| 219 | - * @param EE_Form_Input_Base $input |
|
| 220 | - * @return string |
|
| 221 | - */ |
|
| 222 | - public function display_help_text($input) |
|
| 223 | - { |
|
| 224 | - if ($input->html_help_text() != '') { |
|
| 225 | - $tag = is_admin() ? 'p' : 'span'; |
|
| 226 | - return '<' |
|
| 227 | - . $tag |
|
| 228 | - . ' id="' |
|
| 229 | - . $input->html_id() |
|
| 230 | - . '-help" class="' |
|
| 231 | - . $input->html_help_class() |
|
| 232 | - . '" style="' |
|
| 233 | - . $input->html_help_style() |
|
| 234 | - . '">' |
|
| 235 | - . $input->html_help_text() |
|
| 236 | - . '</' |
|
| 237 | - . $tag |
|
| 238 | - . '>'; |
|
| 239 | - } |
|
| 240 | - return ''; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * Does an action and hook onto the end of teh form |
|
| 247 | - * |
|
| 248 | - * @param string $html |
|
| 249 | - * @return string |
|
| 250 | - */ |
|
| 251 | - public function add_form_section_hooks_and_filters($html) |
|
| 252 | - { |
|
| 253 | - // replace dashes and spaces with underscores |
|
| 254 | - $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id()); |
|
| 255 | - do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section); |
|
| 256 | - $html = apply_filters('AFEE__Form_Section_Layout__' . $hook_name . '__html', $html, $this->_form_section); |
|
| 257 | - $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->'; |
|
| 258 | - $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->'; |
|
| 259 | - return $html; |
|
| 260 | - } |
|
| 17 | + /** |
|
| 18 | + * Form form section to lay out |
|
| 19 | + * |
|
| 20 | + * @var EE_Form_Section_Proper |
|
| 21 | + */ |
|
| 22 | + protected $_form_section; |
|
| 23 | + |
|
| 24 | + |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * __construct |
|
| 28 | + */ |
|
| 29 | + function __construct() |
|
| 30 | + { |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * The form section on which this strategy is to perform |
|
| 37 | + * |
|
| 38 | + * @param EE_Form_Section_Proper $form |
|
| 39 | + */ |
|
| 40 | + public function _construct_finalize(EE_Form_Section_Proper $form) |
|
| 41 | + { |
|
| 42 | + $this->_form_section = $form; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @return \EE_Form_Section_Proper |
|
| 49 | + */ |
|
| 50 | + public function form_section() |
|
| 51 | + { |
|
| 52 | + return $this->_form_section; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Also has teh side effect of enqueuing any needed JS and CSS for |
|
| 59 | + * this form. |
|
| 60 | + * Creates all the HTML necessary for displaying this form, its inputs, and |
|
| 61 | + * proper subsections. |
|
| 62 | + * Returns the HTML |
|
| 63 | + * |
|
| 64 | + * @return string HTML for displaying |
|
| 65 | + */ |
|
| 66 | + public function layout_form() |
|
| 67 | + { |
|
| 68 | + $html = ''; |
|
| 69 | + // layout_form_begin |
|
| 70 | + $html .= apply_filters( |
|
| 71 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(), |
|
| 72 | + $this->layout_form_begin(), |
|
| 73 | + $this->_form_section |
|
| 74 | + ); |
|
| 75 | + // layout_form_loop |
|
| 76 | + $html .= apply_filters( |
|
| 77 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(), |
|
| 78 | + $this->layout_form_loop(), |
|
| 79 | + $this->_form_section |
|
| 80 | + ); |
|
| 81 | + // layout_form_end |
|
| 82 | + $html .= apply_filters( |
|
| 83 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(), |
|
| 84 | + $this->layout_form_end(), |
|
| 85 | + $this->_form_section |
|
| 86 | + ); |
|
| 87 | + $html = $this->add_form_section_hooks_and_filters($html); |
|
| 88 | + return $html; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @return string |
|
| 95 | + */ |
|
| 96 | + public function layout_form_loop() |
|
| 97 | + { |
|
| 98 | + $html = ''; |
|
| 99 | + foreach ($this->_form_section->subsections() as $name => $subsection) { |
|
| 100 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 101 | + $html .= apply_filters( |
|
| 102 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_' . $name . '__in_' . $this->_form_section->name(), |
|
| 103 | + $this->layout_input($subsection), |
|
| 104 | + $this->_form_section, |
|
| 105 | + $subsection |
|
| 106 | + ); |
|
| 107 | + } elseif ($subsection instanceof EE_Form_Section_Base) { |
|
| 108 | + $html .= apply_filters( |
|
| 109 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_' . $name . '__in_' . $this->_form_section->name(), |
|
| 110 | + $this->layout_subsection($subsection), |
|
| 111 | + $this->_form_section, |
|
| 112 | + $subsection |
|
| 113 | + ); |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + return $html; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
| 123 | + * |
|
| 124 | + * @return string |
|
| 125 | + */ |
|
| 126 | + abstract public function layout_form_begin(); |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
| 132 | + * |
|
| 133 | + * @return string |
|
| 134 | + */ |
|
| 135 | + abstract public function layout_form_end(); |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * Should be used internally by layout_form() to layout each input (eg, if this layout |
|
| 141 | + * is putting each input in a row of its own, this should probably be called by a |
|
| 142 | + * foreach loop in layout_form() (WITHOUT adding any content directly within layout_form()'s foreach loop. |
|
| 143 | + * Eg, this method should add the tr and td tags). This method is exposed in case you want to completely |
|
| 144 | + * customize the form's layout, but would like to make use of it for laying out |
|
| 145 | + * 'easy-to-layout' inputs |
|
| 146 | + * |
|
| 147 | + * @param EE_Form_Input_Base $input |
|
| 148 | + * @return string html |
|
| 149 | + */ |
|
| 150 | + abstract public function layout_input($input); |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Similar to layout_input(), should be used internally by layout_form() within a |
|
| 156 | + * loop to layout each proper subsection. Unlike layout_input(), however, it is assumed |
|
| 157 | + * that the proper subsection will layout its container, label, etc on its own. |
|
| 158 | + * |
|
| 159 | + * @param EE_Form_Section_Base $subsection |
|
| 160 | + * @return string html |
|
| 161 | + */ |
|
| 162 | + abstract public function layout_subsection($subsection); |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * Gets the HTML for the label tag and its contents for the input |
|
| 168 | + * |
|
| 169 | + * @param EE_Form_Input_Base $input |
|
| 170 | + * @return string |
|
| 171 | + */ |
|
| 172 | + public function display_label($input) |
|
| 173 | + { |
|
| 174 | + $class = $input->required() ? 'ee-required-label ' . $input->html_label_class() : $input->html_label_class(); |
|
| 175 | + $label_text = $input->required() |
|
| 176 | + ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
| 177 | + : $input->html_label_text(); |
|
| 178 | + return '<label id="' |
|
| 179 | + . $input->html_label_id() |
|
| 180 | + . '" class="' |
|
| 181 | + . $class |
|
| 182 | + . '" style="' |
|
| 183 | + . $input->html_label_style() |
|
| 184 | + . '" for="' . $input->html_name() |
|
| 185 | + . '">' |
|
| 186 | + . $label_text |
|
| 187 | + . '</label>'; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * returns the HTML for the server-side validation errors for the specified input |
|
| 194 | + * Note that if JS is enabled, it should remove these and instead |
|
| 195 | + * populate the form's errors in the jquery validate fashion |
|
| 196 | + * using the localized data provided to the JS |
|
| 197 | + * |
|
| 198 | + * @param EE_Form_Input_Base $input |
|
| 199 | + * @return string |
|
| 200 | + */ |
|
| 201 | + public function display_errors($input) |
|
| 202 | + { |
|
| 203 | + if ($input->get_validation_errors()) { |
|
| 204 | + return "<label id='" |
|
| 205 | + . $input->html_id() |
|
| 206 | + . "-error' class='error' for='{$input->html_name()}'>" |
|
| 207 | + . $input->get_validation_error_string() |
|
| 208 | + . "</label>"; |
|
| 209 | + } else { |
|
| 210 | + return ''; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * Displays the help span for the specified input |
|
| 218 | + * |
|
| 219 | + * @param EE_Form_Input_Base $input |
|
| 220 | + * @return string |
|
| 221 | + */ |
|
| 222 | + public function display_help_text($input) |
|
| 223 | + { |
|
| 224 | + if ($input->html_help_text() != '') { |
|
| 225 | + $tag = is_admin() ? 'p' : 'span'; |
|
| 226 | + return '<' |
|
| 227 | + . $tag |
|
| 228 | + . ' id="' |
|
| 229 | + . $input->html_id() |
|
| 230 | + . '-help" class="' |
|
| 231 | + . $input->html_help_class() |
|
| 232 | + . '" style="' |
|
| 233 | + . $input->html_help_style() |
|
| 234 | + . '">' |
|
| 235 | + . $input->html_help_text() |
|
| 236 | + . '</' |
|
| 237 | + . $tag |
|
| 238 | + . '>'; |
|
| 239 | + } |
|
| 240 | + return ''; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * Does an action and hook onto the end of teh form |
|
| 247 | + * |
|
| 248 | + * @param string $html |
|
| 249 | + * @return string |
|
| 250 | + */ |
|
| 251 | + public function add_form_section_hooks_and_filters($html) |
|
| 252 | + { |
|
| 253 | + // replace dashes and spaces with underscores |
|
| 254 | + $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id()); |
|
| 255 | + do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section); |
|
| 256 | + $html = apply_filters('AFEE__Form_Section_Layout__' . $hook_name . '__html', $html, $this->_form_section); |
|
| 257 | + $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->'; |
|
| 258 | + $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->'; |
|
| 259 | + return $html; |
|
| 260 | + } |
|
| 261 | 261 | } |
@@ -68,19 +68,19 @@ discard block |
||
| 68 | 68 | $html = ''; |
| 69 | 69 | // layout_form_begin |
| 70 | 70 | $html .= apply_filters( |
| 71 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_' . $this->_form_section->name(), |
|
| 71 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__start__for_'.$this->_form_section->name(), |
|
| 72 | 72 | $this->layout_form_begin(), |
| 73 | 73 | $this->_form_section |
| 74 | 74 | ); |
| 75 | 75 | // layout_form_loop |
| 76 | 76 | $html .= apply_filters( |
| 77 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_' . $this->_form_section->name(), |
|
| 77 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop__for_'.$this->_form_section->name(), |
|
| 78 | 78 | $this->layout_form_loop(), |
| 79 | 79 | $this->_form_section |
| 80 | 80 | ); |
| 81 | 81 | // layout_form_end |
| 82 | 82 | $html .= apply_filters( |
| 83 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_' . $this->_form_section->name(), |
|
| 83 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__end__for_'.$this->_form_section->name(), |
|
| 84 | 84 | $this->layout_form_end(), |
| 85 | 85 | $this->_form_section |
| 86 | 86 | ); |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | foreach ($this->_form_section->subsections() as $name => $subsection) { |
| 100 | 100 | if ($subsection instanceof EE_Form_Input_Base) { |
| 101 | 101 | $html .= apply_filters( |
| 102 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_' . $name . '__in_' . $this->_form_section->name(), |
|
| 102 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_input_'.$name.'__in_'.$this->_form_section->name(), |
|
| 103 | 103 | $this->layout_input($subsection), |
| 104 | 104 | $this->_form_section, |
| 105 | 105 | $subsection |
| 106 | 106 | ); |
| 107 | 107 | } elseif ($subsection instanceof EE_Form_Section_Base) { |
| 108 | 108 | $html .= apply_filters( |
| 109 | - 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_' . $name . '__in_' . $this->_form_section->name(), |
|
| 109 | + 'FHEE__EE_Form_Section_Layout_Base__layout_form__loop_for_non_input_'.$name.'__in_'.$this->_form_section->name(), |
|
| 110 | 110 | $this->layout_subsection($subsection), |
| 111 | 111 | $this->_form_section, |
| 112 | 112 | $subsection |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | public function display_label($input) |
| 173 | 173 | { |
| 174 | - $class = $input->required() ? 'ee-required-label ' . $input->html_label_class() : $input->html_label_class(); |
|
| 174 | + $class = $input->required() ? 'ee-required-label '.$input->html_label_class() : $input->html_label_class(); |
|
| 175 | 175 | $label_text = $input->required() |
| 176 | - ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
| 176 | + ? $input->html_label_text().'<span class="ee-asterisk">*</span>' |
|
| 177 | 177 | : $input->html_label_text(); |
| 178 | 178 | return '<label id="' |
| 179 | 179 | . $input->html_label_id() |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | . $class |
| 182 | 182 | . '" style="' |
| 183 | 183 | . $input->html_label_style() |
| 184 | - . '" for="' . $input->html_name() |
|
| 184 | + . '" for="'.$input->html_name() |
|
| 185 | 185 | . '">' |
| 186 | 186 | . $label_text |
| 187 | 187 | . '</label>'; |
@@ -252,10 +252,10 @@ discard block |
||
| 252 | 252 | { |
| 253 | 253 | // replace dashes and spaces with underscores |
| 254 | 254 | $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id()); |
| 255 | - do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section); |
|
| 256 | - $html = apply_filters('AFEE__Form_Section_Layout__' . $hook_name . '__html', $html, $this->_form_section); |
|
| 257 | - $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->'; |
|
| 258 | - $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->'; |
|
| 255 | + do_action('AHEE__Form_Section_Layout__'.$hook_name, $this->_form_section); |
|
| 256 | + $html = apply_filters('AFEE__Form_Section_Layout__'.$hook_name.'__html', $html, $this->_form_section); |
|
| 257 | + $html .= EEH_HTML::nl().'<!-- AHEE__Form_Section_Layout__'.$hook_name.'__html -->'; |
|
| 258 | + $html .= EEH_HTML::nl().'<!-- AFEE__Form_Section_Layout__'.$hook_name.' -->'; |
|
| 259 | 259 | return $html; |
| 260 | 260 | } |
| 261 | 261 | } |
@@ -9,69 +9,69 @@ |
||
| 9 | 9 | class EE_Admin_Two_Column_Layout extends EE_Two_Column_Layout |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Overriding the parent table layout to include <tbody> tags |
|
| 14 | - * |
|
| 15 | - * @param array $additional_args |
|
| 16 | - * @return string |
|
| 17 | - */ |
|
| 18 | - public function layout_form_begin($additional_args = array()) |
|
| 19 | - { |
|
| 20 | - $this->_form_section->set_html_class('form-table'); |
|
| 21 | - return parent::layout_form_begin($additional_args); |
|
| 22 | - } |
|
| 12 | + /** |
|
| 13 | + * Overriding the parent table layout to include <tbody> tags |
|
| 14 | + * |
|
| 15 | + * @param array $additional_args |
|
| 16 | + * @return string |
|
| 17 | + */ |
|
| 18 | + public function layout_form_begin($additional_args = array()) |
|
| 19 | + { |
|
| 20 | + $this->_form_section->set_html_class('form-table'); |
|
| 21 | + return parent::layout_form_begin($additional_args); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Lays out a row for the subsection |
|
| 28 | - * |
|
| 29 | - * @param EE_Form_Section_Proper $form_section |
|
| 30 | - * @return string |
|
| 31 | - */ |
|
| 32 | - public function layout_subsection($form_section) |
|
| 33 | - { |
|
| 34 | - if ($form_section instanceof EE_Form_Section_Proper) { |
|
| 35 | - return EEH_HTML::no_row($form_section->get_html(), 2); |
|
| 36 | - } elseif ($form_section instanceof EE_Form_Section_HTML) { |
|
| 37 | - return EEH_HTML::no_row($form_section->get_html(), 2); |
|
| 38 | - } |
|
| 39 | - return ''; |
|
| 40 | - } |
|
| 26 | + /** |
|
| 27 | + * Lays out a row for the subsection |
|
| 28 | + * |
|
| 29 | + * @param EE_Form_Section_Proper $form_section |
|
| 30 | + * @return string |
|
| 31 | + */ |
|
| 32 | + public function layout_subsection($form_section) |
|
| 33 | + { |
|
| 34 | + if ($form_section instanceof EE_Form_Section_Proper) { |
|
| 35 | + return EEH_HTML::no_row($form_section->get_html(), 2); |
|
| 36 | + } elseif ($form_section instanceof EE_Form_Section_HTML) { |
|
| 37 | + return EEH_HTML::no_row($form_section->get_html(), 2); |
|
| 38 | + } |
|
| 39 | + return ''; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Lays out the row for the input, including label and errors |
|
| 46 | - * |
|
| 47 | - * @param EE_Form_Input_Base $input |
|
| 48 | - * @return string |
|
| 49 | - */ |
|
| 50 | - public function layout_input($input) |
|
| 51 | - { |
|
| 52 | - if ($input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy |
|
| 53 | - || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
|
| 54 | - || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
|
| 55 | - ) { |
|
| 56 | - $input->set_html_class($input->html_class() . ' large-text'); |
|
| 57 | - } |
|
| 58 | - if ($input instanceof EE_Text_Area_Input) { |
|
| 59 | - $input->set_rows(4); |
|
| 60 | - $input->set_cols(60); |
|
| 61 | - } |
|
| 62 | - $input_html = $input->get_html_for_input(); |
|
| 63 | - // maybe add errors and help text ? |
|
| 64 | - $input_html .= $input->get_html_for_errors() != '' ? EEH_HTML::nl() . $input->get_html_for_errors() : ''; |
|
| 65 | - $input_html .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
| 66 | - //overriding parent to add wp admin specific things. |
|
| 67 | - $html = ''; |
|
| 68 | - if ($input instanceof EE_Hidden_Input) { |
|
| 69 | - $html .= EEH_HTML::no_row($input->get_html_for_input(), 2); |
|
| 70 | - } else { |
|
| 71 | - $html .= EEH_HTML::tr( |
|
| 72 | - EEH_HTML::th($input->get_html_for_label(), '', '', '', 'scope="row"') . EEH_HTML::td($input_html) |
|
| 73 | - ); |
|
| 74 | - } |
|
| 75 | - return $html; |
|
| 76 | - } |
|
| 44 | + /** |
|
| 45 | + * Lays out the row for the input, including label and errors |
|
| 46 | + * |
|
| 47 | + * @param EE_Form_Input_Base $input |
|
| 48 | + * @return string |
|
| 49 | + */ |
|
| 50 | + public function layout_input($input) |
|
| 51 | + { |
|
| 52 | + if ($input->get_display_strategy() instanceof EE_Text_Area_Display_Strategy |
|
| 53 | + || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
|
| 54 | + || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
|
| 55 | + ) { |
|
| 56 | + $input->set_html_class($input->html_class() . ' large-text'); |
|
| 57 | + } |
|
| 58 | + if ($input instanceof EE_Text_Area_Input) { |
|
| 59 | + $input->set_rows(4); |
|
| 60 | + $input->set_cols(60); |
|
| 61 | + } |
|
| 62 | + $input_html = $input->get_html_for_input(); |
|
| 63 | + // maybe add errors and help text ? |
|
| 64 | + $input_html .= $input->get_html_for_errors() != '' ? EEH_HTML::nl() . $input->get_html_for_errors() : ''; |
|
| 65 | + $input_html .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
| 66 | + //overriding parent to add wp admin specific things. |
|
| 67 | + $html = ''; |
|
| 68 | + if ($input instanceof EE_Hidden_Input) { |
|
| 69 | + $html .= EEH_HTML::no_row($input->get_html_for_input(), 2); |
|
| 70 | + } else { |
|
| 71 | + $html .= EEH_HTML::tr( |
|
| 72 | + EEH_HTML::th($input->get_html_for_label(), '', '', '', 'scope="row"') . EEH_HTML::td($input_html) |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | + return $html; |
|
| 76 | + } |
|
| 77 | 77 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | || $input->get_display_strategy() instanceof EE_Text_Input_Display_Strategy |
| 54 | 54 | || $input->get_display_strategy() instanceof EE_Admin_File_Uploader_Display_Strategy |
| 55 | 55 | ) { |
| 56 | - $input->set_html_class($input->html_class() . ' large-text'); |
|
| 56 | + $input->set_html_class($input->html_class().' large-text'); |
|
| 57 | 57 | } |
| 58 | 58 | if ($input instanceof EE_Text_Area_Input) { |
| 59 | 59 | $input->set_rows(4); |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | $input_html = $input->get_html_for_input(); |
| 63 | 63 | // maybe add errors and help text ? |
| 64 | - $input_html .= $input->get_html_for_errors() != '' ? EEH_HTML::nl() . $input->get_html_for_errors() : ''; |
|
| 65 | - $input_html .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
| 64 | + $input_html .= $input->get_html_for_errors() != '' ? EEH_HTML::nl().$input->get_html_for_errors() : ''; |
|
| 65 | + $input_html .= $input->get_html_for_help() != '' ? EEH_HTML::nl().$input->get_html_for_help() : ''; |
|
| 66 | 66 | //overriding parent to add wp admin specific things. |
| 67 | 67 | $html = ''; |
| 68 | 68 | if ($input instanceof EE_Hidden_Input) { |
| 69 | 69 | $html .= EEH_HTML::no_row($input->get_html_for_input(), 2); |
| 70 | 70 | } else { |
| 71 | 71 | $html .= EEH_HTML::tr( |
| 72 | - EEH_HTML::th($input->get_html_for_label(), '', '', '', 'scope="row"') . EEH_HTML::td($input_html) |
|
| 72 | + EEH_HTML::th($input->get_html_for_label(), '', '', '', 'scope="row"').EEH_HTML::td($input_html) |
|
| 73 | 73 | ); |
| 74 | 74 | } |
| 75 | 75 | return $html; |
@@ -14,123 +14,123 @@ |
||
| 14 | 14 | class EE_Div_Per_Section_Layout extends EE_Form_Section_Layout_Base |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * opening div tag for a form |
|
| 19 | - * |
|
| 20 | - * @return string |
|
| 21 | - */ |
|
| 22 | - public function layout_form_begin() |
|
| 23 | - { |
|
| 24 | - return EEH_HTML::div( |
|
| 25 | - '', |
|
| 26 | - $this->_form_section->html_id(), |
|
| 27 | - $this->_form_section->html_class(), |
|
| 28 | - $this->_form_section->html_style() |
|
| 29 | - ); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Lays out the row for the input, including label and errors |
|
| 36 | - * |
|
| 37 | - * @param EE_Form_Input_Base $input |
|
| 38 | - * @return string |
|
| 39 | - */ |
|
| 40 | - public function layout_input($input) |
|
| 41 | - { |
|
| 42 | - $html = ''; |
|
| 43 | - if ($input instanceof EE_Hidden_Input) { |
|
| 44 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
| 45 | - } elseif ($input instanceof EE_Submit_Input) { |
|
| 46 | - $html .= EEH_HTML::div( |
|
| 47 | - $input->get_html_for_input(), |
|
| 48 | - $input->html_id() . '-submit-dv', |
|
| 49 | - $input->html_class() . '-submit-dv' |
|
| 50 | - ); |
|
| 51 | - } elseif ($input instanceof EE_Select_Input) { |
|
| 52 | - $html .= EEH_HTML::div( |
|
| 53 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
| 54 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 55 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 56 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 57 | - $input->html_id() . '-input-dv', |
|
| 58 | - $input->html_class() . '-input-dv' |
|
| 59 | - ); |
|
| 60 | - } elseif ($input instanceof EE_Form_Input_With_Options_Base) { |
|
| 61 | - $html .= EEH_HTML::div( |
|
| 62 | - EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
| 63 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 64 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 65 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 66 | - $input->html_id() . '-input-dv', |
|
| 67 | - $input->html_class() . '-input-dv' |
|
| 68 | - ); |
|
| 69 | - } else { |
|
| 70 | - $html .= EEH_HTML::div( |
|
| 71 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
| 72 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 73 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 74 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 75 | - $input->html_id() . '-input-dv', |
|
| 76 | - $input->html_class() . '-input-dv' |
|
| 77 | - ); |
|
| 78 | - } |
|
| 79 | - return $html; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * _display_label_for_option_type_question |
|
| 86 | - * Gets the HTML for the 'label', which is just text for this (because labels |
|
| 87 | - * should be for each input) |
|
| 88 | - * |
|
| 89 | - * @param EE_Form_Input_With_Options_Base $input |
|
| 90 | - * @return string |
|
| 91 | - */ |
|
| 92 | - protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input) |
|
| 93 | - { |
|
| 94 | - if ($input->display_html_label_text() != '') { |
|
| 95 | - $class = $input->required() |
|
| 96 | - ? 'ee-required-label ' . $input->html_label_class() |
|
| 97 | - : $input->html_label_class(); |
|
| 98 | - $label_text = $input->required() |
|
| 99 | - ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
| 100 | - : $input->html_label_text(); |
|
| 101 | - $html = '<div id="' . $input->html_label_id() . '"'; |
|
| 102 | - $html .= ' class="' . $class . '"'; |
|
| 103 | - $html .= ' style="' . $input->html_label_style() . '">'; |
|
| 104 | - $html .= $label_text . '</div>'; |
|
| 105 | - return $html; |
|
| 106 | - } else { |
|
| 107 | - return ''; |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Lays out a row for the subsection |
|
| 115 | - * |
|
| 116 | - * @param EE_Form_Section_Proper $form_section |
|
| 117 | - * @return string |
|
| 118 | - */ |
|
| 119 | - public function layout_subsection($form_section) |
|
| 120 | - { |
|
| 121 | - // d( $form_section ); |
|
| 122 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * closing div tag for a form |
|
| 129 | - * |
|
| 130 | - * @return string |
|
| 131 | - */ |
|
| 132 | - public function layout_form_end() |
|
| 133 | - { |
|
| 134 | - return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class()); |
|
| 135 | - } |
|
| 17 | + /** |
|
| 18 | + * opening div tag for a form |
|
| 19 | + * |
|
| 20 | + * @return string |
|
| 21 | + */ |
|
| 22 | + public function layout_form_begin() |
|
| 23 | + { |
|
| 24 | + return EEH_HTML::div( |
|
| 25 | + '', |
|
| 26 | + $this->_form_section->html_id(), |
|
| 27 | + $this->_form_section->html_class(), |
|
| 28 | + $this->_form_section->html_style() |
|
| 29 | + ); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Lays out the row for the input, including label and errors |
|
| 36 | + * |
|
| 37 | + * @param EE_Form_Input_Base $input |
|
| 38 | + * @return string |
|
| 39 | + */ |
|
| 40 | + public function layout_input($input) |
|
| 41 | + { |
|
| 42 | + $html = ''; |
|
| 43 | + if ($input instanceof EE_Hidden_Input) { |
|
| 44 | + $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
| 45 | + } elseif ($input instanceof EE_Submit_Input) { |
|
| 46 | + $html .= EEH_HTML::div( |
|
| 47 | + $input->get_html_for_input(), |
|
| 48 | + $input->html_id() . '-submit-dv', |
|
| 49 | + $input->html_class() . '-submit-dv' |
|
| 50 | + ); |
|
| 51 | + } elseif ($input instanceof EE_Select_Input) { |
|
| 52 | + $html .= EEH_HTML::div( |
|
| 53 | + EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
| 54 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 55 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 56 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 57 | + $input->html_id() . '-input-dv', |
|
| 58 | + $input->html_class() . '-input-dv' |
|
| 59 | + ); |
|
| 60 | + } elseif ($input instanceof EE_Form_Input_With_Options_Base) { |
|
| 61 | + $html .= EEH_HTML::div( |
|
| 62 | + EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
| 63 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 64 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 65 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 66 | + $input->html_id() . '-input-dv', |
|
| 67 | + $input->html_class() . '-input-dv' |
|
| 68 | + ); |
|
| 69 | + } else { |
|
| 70 | + $html .= EEH_HTML::div( |
|
| 71 | + EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
| 72 | + EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 73 | + EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 74 | + EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 75 | + $input->html_id() . '-input-dv', |
|
| 76 | + $input->html_class() . '-input-dv' |
|
| 77 | + ); |
|
| 78 | + } |
|
| 79 | + return $html; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * _display_label_for_option_type_question |
|
| 86 | + * Gets the HTML for the 'label', which is just text for this (because labels |
|
| 87 | + * should be for each input) |
|
| 88 | + * |
|
| 89 | + * @param EE_Form_Input_With_Options_Base $input |
|
| 90 | + * @return string |
|
| 91 | + */ |
|
| 92 | + protected function _display_label_for_option_type_question(EE_Form_Input_With_Options_Base $input) |
|
| 93 | + { |
|
| 94 | + if ($input->display_html_label_text() != '') { |
|
| 95 | + $class = $input->required() |
|
| 96 | + ? 'ee-required-label ' . $input->html_label_class() |
|
| 97 | + : $input->html_label_class(); |
|
| 98 | + $label_text = $input->required() |
|
| 99 | + ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
| 100 | + : $input->html_label_text(); |
|
| 101 | + $html = '<div id="' . $input->html_label_id() . '"'; |
|
| 102 | + $html .= ' class="' . $class . '"'; |
|
| 103 | + $html .= ' style="' . $input->html_label_style() . '">'; |
|
| 104 | + $html .= $label_text . '</div>'; |
|
| 105 | + return $html; |
|
| 106 | + } else { |
|
| 107 | + return ''; |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Lays out a row for the subsection |
|
| 115 | + * |
|
| 116 | + * @param EE_Form_Section_Proper $form_section |
|
| 117 | + * @return string |
|
| 118 | + */ |
|
| 119 | + public function layout_subsection($form_section) |
|
| 120 | + { |
|
| 121 | + // d( $form_section ); |
|
| 122 | + return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * closing div tag for a form |
|
| 129 | + * |
|
| 130 | + * @return string |
|
| 131 | + */ |
|
| 132 | + public function layout_form_end() |
|
| 133 | + { |
|
| 134 | + return EEH_HTML::divx($this->_form_section->html_id(), $this->_form_section->html_class()); |
|
| 135 | + } |
|
| 136 | 136 | } |
| 137 | 137 | \ No newline at end of file |
@@ -41,39 +41,39 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | $html = ''; |
| 43 | 43 | if ($input instanceof EE_Hidden_Input) { |
| 44 | - $html .= EEH_HTML::nl() . $input->get_html_for_input(); |
|
| 44 | + $html .= EEH_HTML::nl().$input->get_html_for_input(); |
|
| 45 | 45 | } elseif ($input instanceof EE_Submit_Input) { |
| 46 | 46 | $html .= EEH_HTML::div( |
| 47 | 47 | $input->get_html_for_input(), |
| 48 | - $input->html_id() . '-submit-dv', |
|
| 49 | - $input->html_class() . '-submit-dv' |
|
| 48 | + $input->html_id().'-submit-dv', |
|
| 49 | + $input->html_class().'-submit-dv' |
|
| 50 | 50 | ); |
| 51 | 51 | } elseif ($input instanceof EE_Select_Input) { |
| 52 | 52 | $html .= EEH_HTML::div( |
| 53 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
| 54 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 55 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 56 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 57 | - $input->html_id() . '-input-dv', |
|
| 58 | - $input->html_class() . '-input-dv' |
|
| 53 | + EEH_HTML::nl(1).$input->get_html_for_label(). |
|
| 54 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
| 55 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
| 56 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
| 57 | + $input->html_id().'-input-dv', |
|
| 58 | + $input->html_class().'-input-dv' |
|
| 59 | 59 | ); |
| 60 | 60 | } elseif ($input instanceof EE_Form_Input_With_Options_Base) { |
| 61 | 61 | $html .= EEH_HTML::div( |
| 62 | - EEH_HTML::nl() . $this->_display_label_for_option_type_question($input) . |
|
| 63 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 64 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 65 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 66 | - $input->html_id() . '-input-dv', |
|
| 67 | - $input->html_class() . '-input-dv' |
|
| 62 | + EEH_HTML::nl().$this->_display_label_for_option_type_question($input). |
|
| 63 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
| 64 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
| 65 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
| 66 | + $input->html_id().'-input-dv', |
|
| 67 | + $input->html_class().'-input-dv' |
|
| 68 | 68 | ); |
| 69 | 69 | } else { |
| 70 | 70 | $html .= EEH_HTML::div( |
| 71 | - EEH_HTML::nl(1) . $input->get_html_for_label() . |
|
| 72 | - EEH_HTML::nl() . $input->get_html_for_errors() . |
|
| 73 | - EEH_HTML::nl() . $input->get_html_for_input() . |
|
| 74 | - EEH_HTML::nl() . $input->get_html_for_help(), |
|
| 75 | - $input->html_id() . '-input-dv', |
|
| 76 | - $input->html_class() . '-input-dv' |
|
| 71 | + EEH_HTML::nl(1).$input->get_html_for_label(). |
|
| 72 | + EEH_HTML::nl().$input->get_html_for_errors(). |
|
| 73 | + EEH_HTML::nl().$input->get_html_for_input(). |
|
| 74 | + EEH_HTML::nl().$input->get_html_for_help(), |
|
| 75 | + $input->html_id().'-input-dv', |
|
| 76 | + $input->html_class().'-input-dv' |
|
| 77 | 77 | ); |
| 78 | 78 | } |
| 79 | 79 | return $html; |
@@ -93,15 +93,15 @@ discard block |
||
| 93 | 93 | { |
| 94 | 94 | if ($input->display_html_label_text() != '') { |
| 95 | 95 | $class = $input->required() |
| 96 | - ? 'ee-required-label ' . $input->html_label_class() |
|
| 96 | + ? 'ee-required-label '.$input->html_label_class() |
|
| 97 | 97 | : $input->html_label_class(); |
| 98 | 98 | $label_text = $input->required() |
| 99 | - ? $input->html_label_text() . '<span class="ee-asterisk">*</span>' |
|
| 99 | + ? $input->html_label_text().'<span class="ee-asterisk">*</span>' |
|
| 100 | 100 | : $input->html_label_text(); |
| 101 | - $html = '<div id="' . $input->html_label_id() . '"'; |
|
| 102 | - $html .= ' class="' . $class . '"'; |
|
| 103 | - $html .= ' style="' . $input->html_label_style() . '">'; |
|
| 104 | - $html .= $label_text . '</div>'; |
|
| 101 | + $html = '<div id="'.$input->html_label_id().'"'; |
|
| 102 | + $html .= ' class="'.$class.'"'; |
|
| 103 | + $html .= ' style="'.$input->html_label_style().'">'; |
|
| 104 | + $html .= $label_text.'</div>'; |
|
| 105 | 105 | return $html; |
| 106 | 106 | } else { |
| 107 | 107 | return ''; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | public function layout_subsection($form_section) |
| 120 | 120 | { |
| 121 | 121 | // d( $form_section ); |
| 122 | - return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1); |
|
| 122 | + return EEH_HTML::nl(1).$form_section->get_html().EEH_HTML::nl(-1); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -16,109 +16,109 @@ discard block |
||
| 16 | 16 | class EE_Fieldset_Section_Layout extends EE_Div_Per_Section_Layout |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * legend_class |
|
| 21 | - * |
|
| 22 | - * @var string |
|
| 23 | - */ |
|
| 24 | - protected $_legend_class; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * legend_text |
|
| 28 | - * |
|
| 29 | - * @var string |
|
| 30 | - */ |
|
| 31 | - protected $_legend_text; |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * construct |
|
| 37 | - * |
|
| 38 | - * @param array $options |
|
| 39 | - */ |
|
| 40 | - public function __construct($options = array()) |
|
| 41 | - { |
|
| 42 | - foreach ($options as $key => $value) { |
|
| 43 | - $key = '_' . $key; |
|
| 44 | - if (property_exists($this, $key)) { |
|
| 45 | - $this->{$key} = $value; |
|
| 46 | - } |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * opening div tag for a form |
|
| 54 | - * |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 57 | - public function layout_form_begin() |
|
| 58 | - { |
|
| 59 | - $html = EEH_HTML::nl(1) |
|
| 60 | - . '<fieldset id="' |
|
| 61 | - . $this->_form_section->html_id() |
|
| 62 | - . '" class="' |
|
| 63 | - . $this->_form_section->html_class() |
|
| 64 | - . '" style="' |
|
| 65 | - . $this->_form_section->html_style() |
|
| 66 | - . '">'; |
|
| 67 | - $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
| 68 | - return $html; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * closing div tag for a form |
|
| 75 | - * |
|
| 76 | - * @return string |
|
| 77 | - */ |
|
| 78 | - public function layout_form_end() |
|
| 79 | - { |
|
| 80 | - return EEH_HTML::nl(-1) . '</fieldset>'; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @param string $legend_class |
|
| 87 | - */ |
|
| 88 | - public function set_legend_class($legend_class) |
|
| 89 | - { |
|
| 90 | - $this->_legend_class = $legend_class; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * @return string |
|
| 97 | - */ |
|
| 98 | - public function legend_class() |
|
| 99 | - { |
|
| 100 | - return $this->_legend_class; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @param string $legend_text |
|
| 107 | - */ |
|
| 108 | - public function set_legend_text($legend_text) |
|
| 109 | - { |
|
| 110 | - $this->_legend_text = $legend_text; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @return string |
|
| 117 | - */ |
|
| 118 | - public function legend_text() |
|
| 119 | - { |
|
| 120 | - return $this->_legend_text; |
|
| 121 | - } |
|
| 19 | + /** |
|
| 20 | + * legend_class |
|
| 21 | + * |
|
| 22 | + * @var string |
|
| 23 | + */ |
|
| 24 | + protected $_legend_class; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * legend_text |
|
| 28 | + * |
|
| 29 | + * @var string |
|
| 30 | + */ |
|
| 31 | + protected $_legend_text; |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * construct |
|
| 37 | + * |
|
| 38 | + * @param array $options |
|
| 39 | + */ |
|
| 40 | + public function __construct($options = array()) |
|
| 41 | + { |
|
| 42 | + foreach ($options as $key => $value) { |
|
| 43 | + $key = '_' . $key; |
|
| 44 | + if (property_exists($this, $key)) { |
|
| 45 | + $this->{$key} = $value; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * opening div tag for a form |
|
| 54 | + * |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | + public function layout_form_begin() |
|
| 58 | + { |
|
| 59 | + $html = EEH_HTML::nl(1) |
|
| 60 | + . '<fieldset id="' |
|
| 61 | + . $this->_form_section->html_id() |
|
| 62 | + . '" class="' |
|
| 63 | + . $this->_form_section->html_class() |
|
| 64 | + . '" style="' |
|
| 65 | + . $this->_form_section->html_style() |
|
| 66 | + . '">'; |
|
| 67 | + $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
| 68 | + return $html; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * closing div tag for a form |
|
| 75 | + * |
|
| 76 | + * @return string |
|
| 77 | + */ |
|
| 78 | + public function layout_form_end() |
|
| 79 | + { |
|
| 80 | + return EEH_HTML::nl(-1) . '</fieldset>'; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @param string $legend_class |
|
| 87 | + */ |
|
| 88 | + public function set_legend_class($legend_class) |
|
| 89 | + { |
|
| 90 | + $this->_legend_class = $legend_class; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * @return string |
|
| 97 | + */ |
|
| 98 | + public function legend_class() |
|
| 99 | + { |
|
| 100 | + return $this->_legend_class; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @param string $legend_text |
|
| 107 | + */ |
|
| 108 | + public function set_legend_text($legend_text) |
|
| 109 | + { |
|
| 110 | + $this->_legend_text = $legend_text; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @return string |
|
| 117 | + */ |
|
| 118 | + public function legend_text() |
|
| 119 | + { |
|
| 120 | + return $this->_legend_text; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | 123 | |
| 124 | 124 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | 4 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public function __construct($options = array()) |
| 41 | 41 | { |
| 42 | 42 | foreach ($options as $key => $value) { |
| 43 | - $key = '_' . $key; |
|
| 43 | + $key = '_'.$key; |
|
| 44 | 44 | if (property_exists($this, $key)) { |
| 45 | 45 | $this->{$key} = $value; |
| 46 | 46 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | . '" style="' |
| 65 | 65 | . $this->_form_section->html_style() |
| 66 | 66 | . '">'; |
| 67 | - $html .= '<legend class="' . $this->legend_class() . '">' . $this->legend_text() . '</legend>'; |
|
| 67 | + $html .= '<legend class="'.$this->legend_class().'">'.$this->legend_text().'</legend>'; |
|
| 68 | 68 | return $html; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function layout_form_end() |
| 79 | 79 | { |
| 80 | - return EEH_HTML::nl(-1) . '</fieldset>'; |
|
| 80 | + return EEH_HTML::nl(-1).'</fieldset>'; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |